Skip to content

Commit

Permalink
Add afterAll cleanup step
Browse files Browse the repository at this point in the history
  • Loading branch information
allie500 committed Feb 5, 2025
1 parent cb15c01 commit 4340ca0
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,29 @@ test.describe(
await emptyCart( page );
} );

/**
* This afterAll step is to ensure that there is no coupon stored in the customer session.
* This is done in cases where a test may be interrupted causing the coupon state to persist
* in the next Atomic workflow run.
*/
test.afterAll( async ( { browser } ) => {
const cleanupPage = await browser.newPage();
await addToCartFromShopPage( cleanupPage );
await goToCart( cleanupPage );
const couponRemovalLink = cleanupPage.getByRole( 'link', {
name: '[Remove]',
} );

if ( await couponRemovalLink.isVisible() ) {
await couponRemovalLink.click();
await expect(
cleanupPage.getByText( 'Coupon has been removed.' )
).toBeVisible();
}

await emptyCart( cleanupPage );
} );

test( 'Checkout with a free coupon', async ( { page } ) => {
await goToCheckout( page );
await fillBillingAddress( page, config.addresses.customer.billing );
Expand Down

0 comments on commit 4340ca0

Please sign in to comment.