Skip to content

Commit

Permalink
Update fallback assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoumpierre committed Feb 5, 2025
1 parent bd523f0 commit 7e65e1c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions tests/e2e-pw/utils/shopper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,17 +300,16 @@ export const addToCartFromShopPage = async (
`Add\\s+(?:to\\s+cart:\\s*)?\u201C${ product.name }\u201D(?:\\s+to\\s+your\\s+cart)?`
);

await page.getByLabel( addToCartRegex ).click();
const addToCartButton = page.getByLabel( addToCartRegex );
await addToCartButton.click();

try {
await expect(
page.getByLabel( addToCartRegex )
).toHaveAttribute( 'class', /added/, { timeout: 5000 } );
await expect( addToCartButton ).toHaveAttribute( 'class', /added/, {
timeout: 5000,
} );
} catch ( error ) {
// fallback for a different theme.
await expect(
page.getByLabel( addToCartRegex ).getByText( 'in cart' )
).toBeVisible();
await expect( addToCartButton ).toHaveText( /in cart/ );
}
};

Expand Down

0 comments on commit 7e65e1c

Please sign in to comment.