Skip to content

Commit

Permalink
Add spinner step for flaky tests (#3956)
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-HMCTS authored Oct 21, 2024
1 parent c26b9a7 commit 6fb3261
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions playwright_tests/E2E/global-search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { test, expect } from '@playwright/test';
import { signIn } from './steps/login-steps';
import { clickOnMainMenu } from './steps/steps-functions';
import { retryAction } from './steps/retry-steps';
import { waitForSpinner } from './steps/spinner-steps';
import axeTest from "./helpers/accessibilityTestHelper";

test('Search from menu 16-digit find control', async ({ page }) => {
await signIn(page, 'IAC_CaseOfficer_R2');

console.log('Search from menu 16-digit find control');
const caseId = findCaseId(page)
await waitForSpinner(page);
await expect(page.getByText('-digit case reference:')).toBeVisible();
await page.getByLabel('-digit case reference:').click();
await page.getByLabel('-digit case reference:').fill(caseId);
Expand Down
4 changes: 4 additions & 0 deletions playwright_tests/E2E/staff-search.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { test, expect } from '@playwright/test';
import { signIn, signOut } from "./steps/login-steps";
import { clickToStaffPage, fillSearchBox } from "./steps/staff-steps";
import { waitForSpinner } from './steps/spinner-steps';
import axeTest from "./helpers/accessibilityTestHelper";

test('Simplified search results', async ({ page }) => {
await signIn(page, "STAFF_ADMIN");
await expect(page.getByLabel('Manage Cases')).toBeVisible();

await waitForSpinner(page);
await clickToStaffPage(page);

console.log("Using simple search");
Expand Down
10 changes: 10 additions & 0 deletions playwright_tests/E2E/steps/spinner-steps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Page } from '@playwright/test';

export async function waitForSpinner(page: Page) {
try {
await page.waitForSelector('xuilib-loading-spinner', { state: 'attached', timeout: 5000 });
await page.waitForSelector('xuilib-loading-spinner', { state: 'detached' });
} catch (error) {
console.log('Spinner did not appear within the timeout period.');
}
}

0 comments on commit 6fb3261

Please sign in to comment.