Skip to content

Commit 0fb09c6

Browse files
committed
update test
1 parent 513a26a commit 0fb09c6

2 files changed

Lines changed: 22 additions & 9 deletions

File tree

tests/e2e/auth.setup.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ async function cleanup() {
1212
}
1313
}
1414

15+
// Handle async cleanup properly
16+
async function handleCleanup() {
17+
await cleanup();
18+
process.exit( 0 );
19+
}
20+
1521
// Register cleanup on process exit
16-
// process.on( 'exit', cleanup ); // it gets triggered between sequential & parallel tests
17-
process.on( 'SIGINT', cleanup );
18-
process.on( 'SIGTERM', cleanup );
22+
process.on( 'exit', () => cleanup() ); // exit event doesn't support async, it gets triggered between sequential & parallel tests
23+
process.on( 'SIGINT', () => handleCleanup() );
24+
process.on( 'SIGTERM', () => handleCleanup() );
1925

2026
async function globalSetup() {
2127
const authFile = path.join( process.cwd(), 'auth.json' );

tests/e2e/tour.spec.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,29 @@ test.describe( 'PRPL Tour', () => {
1313
await tourButton.click();
1414

1515
// Wait for and verify the tour popover is visible
16-
const tourPopover = page.locator( '.driver-popover' );
16+
let tourPopover = page.locator( '.driver-popover' );
1717
await expect( tourPopover ).toBeVisible();
1818

1919
// Get the number of steps from the window object
2020
const numberOfSteps = await page.evaluate(
2121
() => window.progressPlannerTour.steps.length
2222
);
2323

24-
// Click the next button for each step
25-
const nextButton = page.locator( '.driver-popover-next-btn' );
26-
for ( let i = 0; i < numberOfSteps; i++ ) {
27-
await nextButton.click();
28-
// Verify the tour popover remains visible for each step
24+
for ( let i = 0; i < numberOfSteps - 1; i++ ) {
25+
tourPopover = page.locator( '.driver-popover' );
26+
27+
// Wait for the popover to be visible before interacting
2928
await expect( tourPopover ).toBeVisible();
29+
30+
// Click the "Next" button if it's not the last step
31+
if ( i < numberOfSteps - 1 ) {
32+
const nextButton = page.locator( '.driver-popover-next-btn' );
33+
await nextButton.click();
34+
}
3035
}
3136

37+
const nextButton = page.locator( '.driver-popover-next-btn' );
38+
3239
// Verify the button text changes to "Finish" on the last step
3340
await expect( nextButton ).toHaveText( 'Finish' );
3441

0 commit comments

Comments
 (0)