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

Tests for a content page - Day-use pass #13

Merged
merged 2 commits into from
Oct 21, 2024
Merged
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
49 changes: 49 additions & 0 deletions tests/dayUsePasses_contentPage.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//@ts-check

// Import the test and expect functions from Playwright
import { test, expect } from '@playwright/test';

//base URL for the tests
const baseURL = 'https://bcparks.ca/';

//wait for the page to load before running the tests
test.beforeEach(async ({page})=>{
await page.goto(baseURL);
});

// Test navigation to the Day-use passes page via the mega menu
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 expect(page).toHaveURL(baseURL + 'reservations/day-use-passes/');
await expect(page).toHaveTitle('Day-use passes - Province of British Columbia | BC Parks');

});


test('Verify the page content', async ({ page }) => {
await page.goto(baseURL + 'reservations/day-use-passes/');
test.setTimeout(60000);
await expect(page.getByText('Home›Reservations›Day-use')).toBeVisible();
await expect(page.getByLabel('breadcrumb').locator('div')).toContainText('Day-use passes');
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('Joffre LakesGaribaldiGolden EarsMount SeymourWhy 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.getByRole('link', { name: 'Why day-use passes?', exact: true })).toBeVisible();
await expect(page.locator('#section-navbar')).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();
});