Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E: Fix the dispute save draft challenge failing due to redirect race condition #9284

Merged
merged 3 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/fix-9281-e2e-dispute-save-challenge
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Not a user-facing change: fix e2e test save draft dispute challenge failing due to disputes list redirect race condition


Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ const { merchant, shopper, evalAndClick } = require( '@woocommerce/e2e-utils' );
import { fillCardDetails, setupProductCheckout } from '../../../utils/payments';
import { uiLoaded } from '../../../utils';

let orderId;

describe( 'Disputes > Merchant can save and resume draft dispute challenge', () => {
let orderId;
let paymentDetailsLink;

beforeAll( async () => {
await page.goto( config.get( 'url' ), { waitUntil: 'networkidle0' } );

Expand All @@ -36,7 +37,7 @@ describe( 'Disputes > Merchant can save and resume draft dispute challenge', ()
await merchant.goToOrder( orderId );

// Get the payment details link from the order page.
const paymentDetailsLink = await page.$eval(
paymentDetailsLink = await page.$eval(
'p.order_number > a',
( anchor ) => anchor.getAttribute( 'href' )
);
Expand Down Expand Up @@ -107,11 +108,24 @@ describe( 'Disputes > Merchant can save and resume draft dispute challenge', ()
}
);

// Reload the page
await page.reload();

// The merchant will be redirected to the dispute list page here, wait for it to load.
await uiLoaded();

// Open the payment details page again and wait for it to load.
await Promise.all( [
page.goto( paymentDetailsLink, {
waitUntil: 'networkidle0',
} ),
uiLoaded(),
] );

// Click the challenge dispute button.
await evalAndClick( '[data-testid="challenge-dispute-button"]' );
await Promise.all( [
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
uiLoaded(),
] );

// Verify the previously selected Product type was saved
await expect( page ).toMatchElement(
'[data-testid="dispute-challenge-product-type-selector"]',
Expand Down
Loading