Skip to content

Commit

Permalink
Adding wait for load state for these tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianneOXD committed Jul 27, 2024
1 parent 60024c0 commit 704bb32
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions tests/all_advisories_page.spec.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,63 @@
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 = {timeout: 60000};

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

test('Navigate to active advisories page', async ({page})=>{
await page.waitForLoadState('domcontentloaded');
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.waitForLoadState('domcontentloaded');
await page.goto(activeAdvisoriesURL);
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.waitForLoadState('domcontentloaded');
await page.goto(activeAdvisoriesURL);
await expect(page.locator('h1', {name : 'Active advisories'})).toBeVisible();
});
/*
test('Verify the Event search is working', async ({page}) =>{
await page.waitForLoadState('domcontentloaded');
await page.goto(activeAdvisoriesURL);
await page.getByLabel('Select an event').fill('Avalanche');
await page.waitForLoadState();
await expect(page.getByLabel('menu-options'), customTimeout).toBeVisible();
await expect(page.getByLabel('menu-options')).toBeVisible();
await page.getByLabel('Avalanche', { exact: true }).click();
await page.getByRole('button', {name : 'Search'}).click();
await expect(page.locator('h1', {name : 'Active advisories | Avalanche'}), customTimeout).toBeVisible();
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'}), customTimeout).toBeVisible();
await expect(page.locator('h1', {name : 'Active advisories | Fire'})).toBeVisible();
});

test('Verify the search filters are working', async ({page})=>{
await page.waitForLoadState('domcontentloaded');
await page.goto(activeAdvisoriesURL)
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.waitForLoadState('domcontentloaded');
await page.goto(activeAdvisoriesURL)
const highAdvisoryLegendItem = page.locator('.advisory-legend-item').first();
const mediumAdvisoryLegendItem = page.locator('.advisory-legend-item').nth(1);
Expand All @@ -77,6 +79,7 @@ test.describe('All advisories page tests', ()=>{
});

test('Check that all links redirect to the correct pages', async ({page}) =>{
await page.waitForLoadState('domcontentloaded');
await page.goto(activeAdvisoriesURL);
await page.getByText('BC Wildfire Service').click();
await expect(page).toHaveURL('https://www2.gov.bc.ca/gov/content/safety/wildfire-status');
Expand All @@ -88,4 +91,4 @@ test.describe('All advisories page tests', ()=>{
await expect(page).toHaveURL('https://drivebc.ca/');
});
});
*/

0 comments on commit 704bb32

Please sign in to comment.