Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Approved Management Plan and Park Operating Date pages #5

Merged
merged 45 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
bebe2be
Adding tests for the Park Operating Date page
adrianneOXD Jul 12, 2024
8ec084e
Adding tests for Approved Management Plan page
adrianneOXD Jul 12, 2024
5a42dc3
Merge branch 'manuji:Automated-tests' into Automated-tests
adrianneOXD Jul 17, 2024
dde6228
Updated the number of workers on playwright.config file
adrianneOXD Jul 18, 2024
91c5d27
Putting tests in a describe block
adrianneOXD Jul 24, 2024
20b7430
Fix the social media test for the footer
adrianneOXD Jul 25, 2024
ee0b9d2
Adding a line to trigger a job
adrianneOXD Jul 26, 2024
3473f11
Update playwright.yml
adrianneOXD Jul 26, 2024
f8c1a1f
Put the beforeEach loop within the describe block
adrianneOXD Jul 26, 2024
86ee0b2
Reverted change back for social media link test
adrianneOXD Jul 26, 2024
b2792d9
Commiting changes to git ignore, package-lock and package.sjon
adrianneOXD Jul 26, 2024
29d131c
Commented out tests in all files except for home page
adrianneOXD Jul 26, 2024
5fb1b29
Fixed test to be less flaky
adrianneOXD Jul 26, 2024
a9ac736
Fixed url in assertion
adrianneOXD Jul 26, 2024
c56a34c
Updating test and playwright config page
adrianneOXD Jul 26, 2024
7e180a2
Added timeout for beforeeach
adrianneOXD Jul 26, 2024
5e542da
Added timeout to URL assertions
adrianneOXD Jul 26, 2024
fd11255
Adding tests for all advisories page
adrianneOXD Jul 26, 2024
7e3f6a8
adding custom timeout
adrianneOXD Jul 26, 2024
6da2466
Fix customTimeout
adrianneOXD Jul 26, 2024
92ceea6
Updated custom timeout
adrianneOXD Jul 26, 2024
b7a803f
Fixing customTimeout
adrianneOXD Jul 26, 2024
a5537f1
Adding wait for load state
adrianneOXD Jul 27, 2024
60024c0
Commenting out the tests for this file
adrianneOXD Jul 27, 2024
704bb32
Adding wait for load state for these tests
adrianneOXD Jul 27, 2024
9b4f957
Refactor test to add step in beforeeach
adrianneOXD Jul 29, 2024
6ab456e
Adding timeout
adrianneOXD Jul 29, 2024
65b6532
Adding waitForLoadState to each test and remove from beforeEach
adrianneOXD Jul 29, 2024
d28cfc5
Updated all advisories page
adrianneOXD Jul 29, 2024
99d62f5
Updated locators on BC Parks links redirect
adrianneOXD Jul 29, 2024
17c8aee
Adding home page test fixes
adrianneOXD Jul 29, 2024
904cf55
All advisories page test
adrianneOXD Jul 29, 2024
1968c71
Remove custom timeout
adrianneOXD Jul 31, 2024
929a7c7
Fixed home page tests
adrianneOXD Jul 31, 2024
fda2721
Remove customTimeout
adrianneOXD Jul 31, 2024
2eaf66c
Added networkidle
adrianneOXD Jul 31, 2024
6b40d7c
Adding changes to find a park page
adrianneOXD Jul 31, 2024
a5b97bd
Adding changes to config file
adrianneOXD Jul 31, 2024
3e91294
Adding firefox
adrianneOXD Jul 31, 2024
7984aca
Making changes to package.json and homepage
adrianneOXD Jul 31, 2024
0fe3ccf
Adding tests for approved management plan
adrianneOXD Jul 31, 2024
dab4c68
Adding tests for footer and park operating date back
adrianneOXD Jul 31, 2024
914ba4b
Fixed locator for park operating date
adrianneOXD Jul 31, 2024
a580061
Adding a test to mimic real browsers
adrianneOXD Jul 31, 2024
2153c66
Fix the instagram redirect test
adrianneOXD Jul 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
name: Playwright Tests
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to run the workflow on'
required: true
default: 'Automated-tests'
environment:
description: 'Which environment to deploy to'
required: true
default: 'staging'
version:
description: 'Version to deploy'
required: false
push:
branches: [ main, master ]
branches: [ Automated-tests ]
pull_request:
branches: [ main, master ]
branches: [ Automated-tests ]
jobs:
test:
timeout-minutes: 60
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,7 @@ bcparks.ca-scrape.laccdb
/playwright-report/
/blob-report/
/playwright/.cache/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
"directories": {
"doc": "docs"
},
"scripts": {},
"scripts": {
"test": "playwright test"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@playwright/test": "^1.44.1",
"@playwright/test": "^1.45.0",
"@types/node": "^20.14.1"
}
}
9 changes: 5 additions & 4 deletions playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const { defineConfig, devices } = require('@playwright/test');
* @see https://playwright.dev/docs/test-configuration
*/
module.exports = defineConfig({
timeout: 100000,
testDir: './tests',
/* Run tests in files in parallel */
fullyParallel: true,
Expand All @@ -19,7 +20,7 @@ module.exports = defineConfig({
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
workers: process.env.CI ? 4 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
Expand All @@ -41,13 +42,13 @@ module.exports = defineConfig({
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

}
/*
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},

*/
/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
Expand Down
95 changes: 95 additions & 0 deletions tests/all_advisories_page.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { test, expect } from '@playwright/test';

test.describe('All advisories page tests', ()=>{

const baseURL = 'https://bcparks.ca/';
const activeAdvisoriesURL = 'https://bcparks.ca/active-advisories/';
// const { chromium } = require('@playwright/test');
const customTimeout = 90000;

test.beforeEach(async ({page})=>{
await page.goto(baseURL);
});

test('Navigate to active advisories page', async ({page})=>{
await page.waitForLoadState('networkidle');
await page.getByText('See all advisories').click();
await expect(page).toHaveURL(baseURL + 'active-advisories/');
await expect(page).toHaveTitle('Active advisories | BC Parks');
});

test('Verify the breadcrumbs are visible and working', async ({page})=>{
await page.goto(activeAdvisoriesURL);
await page.waitForLoadState('networkidle');
await expect(page.getByRole('link', { name: 'Home'})).toBeVisible();
await page.getByRole('link', {name: 'Home'}).click();
await expect(page).toHaveURL(baseURL);
});

test('Verify the h1 is visible', async ({page}) =>{
await page.goto(activeAdvisoriesURL);
await page.waitForLoadState('networkidle');
await expect(page.locator('h1', {name : 'Active advisories'})).toBeVisible();
});

test('Verify the Event search is working', async ({page}) =>{
await page.goto(activeAdvisoriesURL);
await page.waitForLoadState('networkidle');
await page.getByLabel('Select an event').click();
await page.getByLabel('Select an event').fill('Avalanche', { customTimeout });
await page.getByLabel('Avalanche', { exact: true }).click();
await page.getByRole('button', { name: 'Search' }).click();
await expect(page.locator('h1', {name : 'Active advisories | Avalanche'})).toBeVisible();
await page.getByLabel('Clear').click();
await expect(page.getByLabel('Select an event')).toBeEmpty();
await page.getByLabel('Select an event').fill('Fire');
await page.getByLabel('Wildfire', { exact: true }).click();
await page.getByRole('button', {name : 'Search'}).click();
await expect(page.locator('h1', {name : 'Active advisories | Fire'})).toBeVisible();
});

test('Verify the search filters are working', async ({page})=>{
await page.goto(activeAdvisoriesURL);
await page.waitForLoadState('networkidle');
await page.getByRole('checkbox').nth(1).check();
await page.getByRole('textbox', {name : 'Search'}).fill('Babine');
await page.getByRole('button', {name : 'Search'}).click();
});

test('Verify the park safety advisories legend is visible', async ({page}) =>{
await page.goto(activeAdvisoriesURL);
await page.waitForLoadState('networkidle');
const highAdvisoryLegendItem = page.locator('.advisory-legend-item').first();
const mediumAdvisoryLegendItem = page.locator('.advisory-legend-item').nth(1);
const lowAdvisoryLegendItem = page.locator('.advisory-legend-item').nth(2);

await page.goto(activeAdvisoriesURL);
await page.waitForLoadState('networkidle');
await expect(highAdvisoryLegendItem).toBeVisible();
await expect(highAdvisoryLegendItem).toHaveText('HighImmediate danger and closures');
await expect(highAdvisoryLegendItem.locator('.legend-icon').first()).toBeVisible();
await expect(highAdvisoryLegendItem.locator('.legend-icon').first()).toHaveCSS('background-color', 'rgb(216, 41, 47)');
await expect(mediumAdvisoryLegendItem).toBeVisible();
await expect(mediumAdvisoryLegendItem).toHaveText('MediumSafety and health related');
await expect(mediumAdvisoryLegendItem.locator('.legend-icon').first()).toBeVisible();
await expect(mediumAdvisoryLegendItem.locator('.legend-icon').first()).toHaveCSS('background-color', 'rgb(252, 186, 25)');
await expect(lowAdvisoryLegendItem).toBeVisible();
await expect(lowAdvisoryLegendItem).toHaveText('LowDiscretion and warnings');
await expect(lowAdvisoryLegendItem.locator('.legend-icon').first()).toBeVisible();
await expect(lowAdvisoryLegendItem.locator('.legend-icon').first()).toHaveCSS('background-color', 'rgb(36, 100, 164)');
});

test('Check that all links redirect to the correct pages', async ({page}) =>{
await page.goto(activeAdvisoriesURL);
await page.waitForLoadState('networkidle');
await page.getByRole('link', { name: 'BC Wildfire Service', exact: true }).click();
await expect(page).toHaveURL('https://www2.gov.bc.ca/gov/content/safety/wildfire-status');
await page.goBack();
await page.getByRole('link', { name: 'BC River Forecast Centre' }).click();
await expect(page).toHaveURL('https://www2.gov.bc.ca/gov/content/environment/air-land-water/water/drought-flooding-dikes-dams/river-forecast-centre');
await page.goBack();
await page.locator('a:nth-child(5)').click();
await expect(page).toHaveURL('https://drivebc.ca/');
});
});

100 changes: 100 additions & 0 deletions tests/approved_management_plan.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import { test, expect } from '@playwright/test';

test.describe('Approved management plan tests', ()=>{

const baseURL = 'https://bcparks.ca/';
const approvedManagementPlanURL = 'https://bcparks.ca/about/management-plans/approved/';

test.beforeEach(async ({page})=>{
await page.goto(baseURL);
});

test('Check that we can get to the page from homepage', async ({page})=>{
await page.waitForLoadState('networkidle');
await page.getByRole('menuitem', { name: 'About' }).click();
await expect(page.locator('#home div').filter({ hasText: 'Main Menu BackAboutOur' }).nth(4)).toBeVisible();
await expect(page.getByRole('menuitem', { name: 'About', exact: true })).toBeVisible();
await page.getByRole('menuitem', { name: 'Management plans' }).click();
await expect(page.getByRole('menuitem', { name: 'Management plans', exact: true })).toBeVisible();
await page.getByRole('menuitem', { name: 'Approved management plans' }).click();
await expect(page).toHaveURL(baseURL + 'about/management-plans/approved/');
await expect(page).toHaveTitle('Approved management plans | BC Parks');
await expect(page.locator('h1', { name: 'Approved management plans'})).toBeVisible();
});

test('Check the breadcrumbs displayed', async ({page})=>{
await page.waitForLoadState('networkidle');
await expect (page.locator('#main-content')).toBeVisible();
await page.goto(approvedManagementPlanURL);
await page.getByRole('link', { name: 'Home' }).click();
await expect(page).toHaveURL(baseURL);
await page.goBack();
await page.waitForLoadState('networkidle');
await page.getByRole('link', { name: 'About' }).click();
await expect(page).toHaveURL(baseURL + 'about/');
await page.goBack();
await page.waitForLoadState('networkidle');
await page.getByRole('link', { name: 'Management plans', exact: true }).click();
await expect(page).toHaveURL(baseURL + 'about/management-plans/');
await page.goBack();
await page.waitForLoadState('networkidle');
await expect(page.getByLabel('breadcrumb').getByText('Approved management plans')).toBeVisible();
});

test('Check the filter menu is present and in default setting', async ({page})=>{
await page.waitForLoadState('networkidle');
await page.getByRole('menuitem', { name: 'About' }).click();
await page.getByRole('menuitem', { name: 'Management plans' }).click();
await page.getByRole('menuitem', { name: 'Approved management plans' }).click();
await expect(page.getByRole('heading', { name: 'Filter' })).toBeVisible();

const allButton = page.getByRole('button', { name: 'All'});
await expect(allButton).toBeVisible();
await expect(allButton).toHaveClass('btn btn-selected--true');

const letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U','V', 'W', 'X', 'Y', 'Z']

for(const letter of letters){
const button = page.getByLabel(letter, { exact: true});
await expect(button).toBeVisible();
await expect(button).toHaveClass('btn btn-selected--false');
};

// Check the letter headings are visible
for (const letter of letters){
const heading = page.getByRole('heading', { name: letter, exact: true});
await expect(heading).toBeVisible();
};
});

test('Check the filters work and list updates', async ({page})=>{
await page.waitForLoadState('networkidle');
await page.getByRole('menuitem', { name: 'About' }).click();
await page.getByRole('menuitem', { name: 'Management plans' }).click();
await page.getByRole('menuitem', { name: 'Approved management plans' }).click();
// Check the default state
const allButton = page.getByRole('button', { name: 'All'});
await expect(allButton).toBeVisible();
await expect(allButton).toHaveClass('btn btn-selected--true');

const letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U','V', 'W', 'X', 'Y', 'Z']

// For every letter click on the filter, state of the filter should change
for(const letter of letters){
const button = page.getByLabel(letter, { exact: true});
const heading = page.getByRole('heading', { name: letter, exact: true});
await button.click();
await expect(heading).toBeVisible();
await expect(allButton).toHaveClass('btn btn-selected--false');
await expect(button).toHaveClass('btn btn-selected--true');

// Check that if the letter is not selected, then the headings should not be displayed
for (const otherLetter of letters){
if(otherLetter !== letter){
const otherHeading = page.getByRole('heading', { name: otherLetter, exact: true });
await expect(otherHeading).not.toBeVisible();
}
}
}
});
});
40 changes: 40 additions & 0 deletions tests/find_a_park_page.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { test, expect } from '@playwright/test';

test.describe('Find a park page tests', async ()=>{
const baseURL = 'https://bcparks.ca/';
const customTimeout = { timeout: 90000 };

test.beforeEach(async ({page})=>{
page.goto(baseURL);
});

test('Go to the find a park page', async ({page})=>{
await page.waitForLoadState('networkidle');
await page.getByRole('menuitem', { name: 'Find a park' }, customTimeout).click();
await expect(page).toHaveURL(baseURL + 'find-a-park/');
await expect(page).toHaveTitle('Find a park | BC Parks');
});

test('Search for a park and redirect to the park page', async ({page})=>{
await page.waitForLoadState('networkidle');
await page.getByLabel('By park name').click();
await page.getByLabel('By park name').fill('joffres');
await page.getByLabel('Search').click();
await page.getByRole('link', { name: 'Joffre Lakes Park' }, customTimeout).click();
await expect(page).toHaveURL(baseURL + 'joffre-lakes-park/');
await expect(page).toHaveTitle('Joffre Lakes Park | BC Parks');
});

test('Check the filter headings are present', async ({page})=>{
await page.getByRole('menuitem', { name: 'Find a park' }).click();
await page.waitForLoadState('networkidle');
await expect(page.getByRole('heading', { name: 'Filter' })).toBeVisible();
await expect(page.getByText('Popular')).toBeVisible();
await expect(page.getByText('Area', { exact: true })).toBeVisible();
await expect(page.getByRole('group', { name: 'Camping' }).locator('legend')).toBeVisible();
await expect(page.getByText('Activities', { exact: true })).toBeVisible();
await expect(page.getByText('Facilities')).toBeVisible();
await expect(page.getByRole('heading', { name: 'More ways to find a park' })).toBeVisible();
});
});

Loading
Loading