Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 0 additions & 13 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
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: [ Automated-tests ]
pull_request:
Expand Down
14 changes: 14 additions & 0 deletions package-lock.json

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

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
"devDependencies": {
"@playwright/test": "^1.47.1",
"@types/node": "^20.14.1"
},
"dependencies": {
"dotenv": "^16.4.5"
}
}
11 changes: 11 additions & 0 deletions playwright.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import dotenv from 'dotenv'
require ('dotenv').config();


dotenv.config({
path: `./.env/.env.${process.env.ENV}`,
})

// @ts-check
const { defineConfig, devices } = require('@playwright/test');



/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
Expand All @@ -27,6 +37,7 @@ module.exports = defineConfig({
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',
baseURL: process.env.BASE_URL,

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
Expand Down
25 changes: 25 additions & 0 deletions tests/all_advisories_page.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,30 @@ test.describe('All advisories page tests', ()=>{
await page.locator('a:nth-child(5)').click();
await expect(page).toHaveURL('https://drivebc.ca/');
});

test('Check the land acknowledgment message is visible', async ({page})=>{
await page.waitForLoadState('networkidle');
await page.evaluate(() =>{
window.scrollBy(0, 5000);
});
await expect(page.locator('#home div').filter({ hasText: 'We acknowledge all First' }).nth(1)).toBeVisible();
await expect(page.locator('#home div').filter({ hasText: 'We acknowledge all First' }).nth(1)).toContainText('We acknowledge all First Nations on whose territories BC Parks were established. We honour their connection to the land and respect the importance of their diverse teachings, traditions, and practices within these territories.')
await expect(page.getByText('We acknowledge all First')).toBeVisible();
});

test('Check the back to top button is working', async ({ page }) => {
await page.waitForLoadState('networkidle');
await page.getByText('See all advisories').click();
await page.waitForTimeout(5000);
await page.evaluate(() => {
window.scrollBy(0, 5000);
});
await expect(page.getByLabel('scroll to top')).toBeVisible();
await page.getByLabel('scroll to top').click();
await page.waitForTimeout(5000)
const updatedScrollPosition = await page.evaluate(() => window.scrollY);
expect(updatedScrollPosition).toBe(0);
await expect(page.getByLabel('scroll to top')).toBeHidden();
});
});

33 changes: 33 additions & 0 deletions tests/approved_management_plan.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,37 @@ test.describe('Approved management plan tests', ()=>{
}
}
});

test('Check the land acknowledgment message is visible', async ({page})=>{
await page.waitForLoadState('networkidle');
await page.getByRole('menuitem', { name: 'About' }).click();
await expect(page.getByRole('menuitem', { name: 'About', exact: true })).toBeVisible();
await page.getByRole('menuitem', { name: 'Management plans' }).click();
await page.getByRole('menuitem', { name: 'Management plans' }).nth(1).click();
await page.waitForLoadState('networkidle');
await page.evaluate(() =>{
window.scrollBy(0, 5000);
});
await expect(page.locator('div').filter({ hasText: 'We acknowledge all First' }).nth(3)).toBeVisible();
await expect(page.locator('div').filter({ hasText: 'We acknowledge all First' }).nth(3)).toContainText('We acknowledge all First Nations on whose territories BC Parks were established. We honour their connection to the land and respect the importance of their diverse teachings, traditions, and practices within these territories.')
await expect(page.getByText('We acknowledge all First')).toBeVisible();
});

test('Check the back to top button is working', async ({ page }) => {
await page.waitForLoadState('networkidle');
await page.getByRole('menuitem', { name: 'About' }).click();
await expect(page.getByRole('menuitem', { name: 'About', exact: true })).toBeVisible();
await page.getByRole('menuitem', { name: 'Management plans' }).click();
await page.getByRole('menuitem', { name: 'Management plans' }).nth(1).click();
await page.waitForTimeout(5000);
await page.evaluate(() => {
window.scrollBy(0, 5000);
});
await expect(page.getByLabel('scroll to top')).toBeVisible();
await page.getByLabel('scroll to top').click();
await page.waitForTimeout(5000)
const updatedScrollPosition = await page.evaluate(() => window.scrollY);
expect(updatedScrollPosition).toBe(0);
await expect(page.getByLabel('scroll to top')).toBeHidden();
});
});
58 changes: 45 additions & 13 deletions tests/dayUsePasses_contentPage.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ test('Verify the navigation to the Day-use passes page', async ({ page }) => {
await page.waitForLoadState('networkidle');
await page.getByRole('menuitem', { name: 'Reservations' }).click();
await page.getByRole('menuitem', { name: 'Day-use passes' }).click();
await page.getByRole('menuitem', { name: 'Day-use passes' }).nth(1).click()
await expect(page).toHaveURL(baseURL + 'reservations/day-use-passes/');
await expect(page).toHaveTitle('Day-use passes - Province of British Columbia | BC Parks');

await expect(page).toHaveTitle('Day-use passes | BC Parks');
});


Expand All @@ -30,20 +30,52 @@ test('Verify the page content', async ({ page }) => {
await expect(page.getByRole('heading', { name: 'Day-use passes', exact: true })).toBeVisible();
await expect(page.locator('h1')).toContainText('Day-use passes');
await expect(page.getByRole('img', { name: 'Day-use passes' })).toBeVisible();
await expect(page.getByText('Mount SeymourJoffre LakesGaribaldiGolden EarsWhy day-use passes?', { exact: true })).toBeVisible();
await expect(page.locator('#section-navbar').getByRole('link', { name: 'Joffre Lakes' })).toBeVisible();
await expect(page.locator('#section-navbar')).toContainText('Joffre Lakes');
await expect(page.locator('#section-navbar').getByRole('link', { name: 'Garibaldi' })).toBeVisible();
await expect(page.locator('#section-navbar')).toContainText('Garibaldi');
await expect(page.locator('#section-navbar').getByRole('link', { name: 'Golden Ears' })).toBeVisible();
await expect(page.locator('#section-navbar')).toContainText('Golden Ears');
await expect(page.locator('#section-navbar').getByRole('link', { name: 'Mount Seymour' })).toBeVisible();
await expect(page.locator('#section-navbar')).toContainText('Mount Seymour');
await expect(page.getByText('On this pageJoffre')).toBeVisible();
await expect(page.getByRole('link', { name: 'Joffre Lakes' }).first()).toBeVisible();
await expect(page.getByRole('link', { name: 'Joffre Lakes' }).first()).toContainText('Joffre Lakes');
await expect(page.getByRole('link', { name: 'Garibaldi' }).first()).toBeVisible();
await expect(page.getByRole('link', { name: 'Garibaldi' }).first()).toContainText('Garibaldi');
await expect(page.getByRole('link', { name: 'Golden Ears' }).first()).toBeVisible();
await expect(page.getByRole('link', { name: 'Golden Ears' }).first()).toContainText('Golden Ears');
await expect(page.getByRole('link', { name: 'Mount Seymour' }).first()).toBeVisible();
await expect(page.getByRole('link', { name: 'Mount Seymour' }).first()).toContainText('Mount Seymour');
await expect(page.getByRole('link', { name: 'Day-use pass exemptions', exact: true })).toBeVisible();
await expect(page.getByRole('link', { name: 'Day-use pass exemptions', exact: true })).toContainText('Day-use pass exemptions');
await expect(page.getByRole('link', { name: 'Why day-use passes?', exact: true })).toBeVisible();
await expect(page.locator('#section-navbar')).toContainText('Why day-use passes?');
await expect(page.getByRole('link', { name: 'Why day-use passes?', exact: true })).toContainText('Why day-use passes?');
await expect(page.locator('.page-content')).toBeVisible();
await expect(page.getByRole('link', { name: 'Book a pass' }).first()).toBeVisible();
await expect(page.getByRole('link', { name: 'Book a pass' }).first()).toHaveAttribute('href', 'https://reserve.bcparks.ca/dayuse/');
await expect(page.locator('#gatsby-focus-wrapper')).toContainText('Day-use passes are required to visit some of the most popular BC Parks during their busiest times. Passes are free, and you can get them online. This page has everything you need to know about getting a pass, and it explains why these passes are important.');
await expect(page.locator('#home-footer')).toBeVisible();
});
});

test('Check the land acknowledgment message is visible', async ({page})=>{
await page.goto(baseURL + 'reservations/day-use-passes/');
await page.waitForLoadState('networkidle');
await page.evaluate(() =>{
window.scrollBy(0, 5000);
});
await expect(page.locator('div').filter({ hasText: 'We acknowledge all First' }).nth(3)).toBeVisible();
await expect(page.locator('div').filter({ hasText: 'We acknowledge all First' }).nth(3)).toContainText('We acknowledge all First Nations on whose territories BC Parks were established. We honour their connection to the land and respect the importance of their diverse teachings, traditions, and practices within these territories.')
await expect(page.getByText('We acknowledge all First')).toBeVisible();
});

test('Check the back to top button is working', async ({ page }) => {
await page.waitForLoadState('networkidle');
await page.getByRole('menuitem', { name: 'Reservations' }).click();
await page.getByRole('menuitem', { name: 'Day-use passes' }).click();
await page.getByRole('menuitem', { name: 'Day-use passes' }).nth(1).click()
await page.waitForTimeout(5000);
await page.evaluate(() => {
window.scrollBy(0, 5000);
});
await expect(page.getByLabel('scroll to top')).toBeVisible();
await page.getByLabel('scroll to top').click();
await page.waitForTimeout(5000)
const updatedScrollPosition = await page.evaluate(() => window.scrollY);
expect(updatedScrollPosition).toBe(0);
await expect(page.getByLabel('scroll to top')).toBeHidden();
});


Loading