Skip to content

Commit

Permalink
feat: Basic Map View feature, Header refactor, and testing upgrades (#…
Browse files Browse the repository at this point in the history
…163)

Co-authored-by: Om Mishra <[email protected]>
  • Loading branch information
ccallendar and mishraomp authored Jul 9, 2024
1 parent e558882 commit 643c758
Show file tree
Hide file tree
Showing 34 changed files with 1,387 additions and 993 deletions.
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,43 @@ Pre-requisites:
- Access to OpenShift namespace for Organics Info (ORI) project
- OC CLI installed.(https://console.apps.silver.devops.gov.bc.ca/command-line-tools)
- .env file is created in the backend folder based on the .env.sample file, the values can be retrieved from secrets in
OpenShift namespace.
OpenShift namespace:
- `NR_ORACLE_SERVICE_URL=http://localhost:9080`
- `NR_ORACLE_SERVICE_KEY` value is the `apiKey` value in the [nr-oracle-service dev project](https://console.apps.silver.devops.gov.bc.ca/k8s/ns/d37bb7-dev/secrets/nr-oracle-service)
- The `OS_` values can be found in the [nr-epd-organics-info-prod project](https://console.apps.silver.devops.gov.bc.ca/k8s/ns/d37bb7-prod/secrets/nr-epd-organics-info-prod)

Steps:

1. Open terminal, do oc login and switch to the namespace where the application is deployed.
1. Open a terminal, run the oc login command and switch to the namespace where the application is deployed.
- The oc login command can be found by logging into [OpenShift](https://console.apps.silver.devops.gov.bc.ca/)
- Clicking on your name in the top right corner and choose `Copy login command`
- Then choose `Developer Log In` and click `Display Token`
- Then copy the `oc login ...` command
2. Run the following command in terminal `oc port-forward service/nr-oracle-service 9080:80`, this enables access to nr
oracle service on port 9080 of local machine.
3. Run the following command in terminal `cd backend && npm install && npm run start:debug`, this will start the backend
application on port 3000.
4. Run the following command in terminal `cd frontend && npm install && npm run dev`, this will start the frontend
application on port 3001.

## Running Frontend Tests

**End to end** tests are run using [Playwright](https://playwright.dev/).
Here are the steps to follow to run the end to end tests:
1. First install Playwright: `npx playwright install`
2. Then run start the server and frontend as shown above in steps 1-4.
3. Run Playwright with this command: `npx playwright test` or `npm run test:e2e`

To configure playwright edit the `playwright.config.ts` file.
End to end tests are located in the `/e2e` folder.

**Unit tests** do not require the server or frontend to be running.
You can run the unit tests with this command: `npm run test:unit`
To generate a coverage report, use this command: `npm run test:cov`
The coverage report can be viewed in the `coverage` folder.
Unit tests use [MSW](https://mswjs.io/) to mock API responses, see the
`src/test-setup.ts` file where it is set up.

# Contribution Guidelines

Follow the steps outlined in this repository to contribute: [CONTRIBUTING.md](./CONTRIBUTING.md).
Expand Down
17 changes: 17 additions & 0 deletions frontend/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,22 @@
"experimentalObjectRestSpread": true,
"spread": true
}
},
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"unused-imports"
],
"rules": {
"unused-imports/no-unused-imports": "warn",
"unused-imports/no-unused-vars": [
"warn",
{
"vars": "all",
"varsIgnorePattern": "^_",
"args": "after-used",
"argsIgnorePattern": "^_"
}
]
}
}
26 changes: 15 additions & 11 deletions frontend/e2e/omrr.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { test } from '@playwright/test';
import { dashboard_page } from './pages/dashboard';
import { authorization_list_page } from './pages/auth.list';
import { authorization_details_page } from './pages/auth.details';
import { test } from '@playwright/test'
import { dashboard_page } from './pages/dashboard'
import { authorization_list_page } from './pages/auth.list'
import { authorization_details_page } from './pages/auth.details'
import { map_page } from './pages/map'

test.describe.parallel('Organics Info', () => {
test('Dashboard Page', async ({ page }) => {
await dashboard_page(page);
});
await dashboard_page(page)
})
test('Authorization List', async ({ page }) => {
await authorization_list_page(page);
});
await authorization_list_page(page)
})
test('Authorization Details', async ({ page }) => {
await authorization_details_page(page);
});
});
await authorization_details_page(page)
})
test('Map View', async ({ page }) => {
await map_page(page)
})
})
57 changes: 39 additions & 18 deletions frontend/e2e/pages/dashboard.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,41 @@
import { test, expect } from '@playwright/test';
import { baseURL } from '../utils';
import { Page } from 'playwright';
import { expect } from '@playwright/test'
import { baseURL } from '../utils'
import { Page } from 'playwright'

export const dashboard_page = async (page: Page) => {
await page.goto(baseURL);
await expect(page.getByText('Organics Info')).toBeVisible();
await expect(page.getByRole('link', { name: 'Logo' })).toBeVisible();
await expect(page.getByRole('button', { name: 'Text Search' })).toBeVisible();
await expect(page.getByRole('button', { name: 'Contact Us' })).toBeVisible();
await expect(page.getByRole('heading', { name: 'Compost and Biosolids' })).toBeVisible();
await expect(page.getByRole('heading', { name: 'Find an authorized compost' })).toBeVisible();
await expect(page.getByRole('button', { name: 'List all authorizations' })).toBeVisible();
await expect(page.getByRole('link', { name: 'Legislation' })).toBeVisible();
await expect(page.getByRole('link', { name: 'Process and procedures' })).toBeVisible();
await expect(page.getByRole('link', { name: 'Compliance and enforcement' })).toBeVisible();
await expect(page.locator('.MuiCardContent-root > .MuiCardMedia-root').first()).toBeVisible();
await expect(page.locator('div:nth-child(2) > .MuiPaper-root > .MuiCardContent-root > .MuiCardMedia-root')).toBeVisible();
await expect(page.locator('div:nth-child(3) > .MuiPaper-root > .MuiCardContent-root > .MuiCardMedia-root')).toBeVisible();
};
await page.goto(baseURL)
await expect(page.getByText('Organics Info')).toBeVisible()
await expect(page.getByAltText('Logo')).toBeVisible()
await expect(page.getByRole('button', { name: 'Map Search' })).toBeVisible()
await expect(page.getByRole('button', { name: 'Text Search' })).toBeVisible()
await expect(page.getByRole('button', { name: 'Contact Us' })).toBeVisible()
await expect(
page.getByRole('heading', { name: 'Compost and Biosolids' }),
).toBeVisible()
await expect(
page.getByRole('heading', { name: 'Find an authorized compost' }),
).toBeVisible()
await expect(
page.getByRole('button', { name: 'List all authorizations' }),
).toBeVisible()
await expect(page.getByRole('link', { name: 'Legislation' })).toBeVisible()
await expect(
page.getByRole('link', { name: 'Process and procedures' }),
).toBeVisible()
await expect(
page.getByRole('link', { name: 'Compliance and enforcement' }),
).toBeVisible()
await expect(
page.locator('.MuiCardContent-root > .MuiCardMedia-root').first(),
).toBeVisible()
await expect(
page.locator(
'div:nth-child(2) > .MuiPaper-root > .MuiCardContent-root > .MuiCardMedia-root',
),
).toBeVisible()
await expect(
page.locator(
'div:nth-child(3) > .MuiPaper-root > .MuiCardContent-root > .MuiCardMedia-root',
),
).toBeVisible()
}
20 changes: 20 additions & 0 deletions frontend/e2e/pages/map.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { expect } from '@playwright/test'
import { baseURL } from '../utils'
import { Page } from 'playwright'

export const map_page = async (page: Page) => {
await page.goto(baseURL)

await page.getByRole('button', { name: 'Map Search' }).click()

await expect(page).toHaveTitle('Organics Info')
await expect(page.getByRole('button', { name: 'Map Search' })).toBeVisible()
await expect(page.getByRole('button', { name: 'Text Search' })).toBeVisible()

await page.getByTestId('map-view')

// Find map markers - expect there to be some
// TODO not sure why this fails on CI (chromium/Chrome)
// const markers = await page.getByAltText('Authorization marker').all()
// expect(markers.length > 0).toBe(true)
}
Loading

0 comments on commit 643c758

Please sign in to comment.