Skip to content

Commit 5dca86d

Browse files
committed
Attempt to fix disputes flaky test
1 parent f50963e commit 5dca86d

File tree

1 file changed

+24
-35
lines changed

1 file changed

+24
-35
lines changed

tests/e2e/specs/wcpay/merchant/merchant-disputes-respond.spec.ts

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -570,37 +570,19 @@ test.describe( 'Disputes > Respond to a dispute', () => {
570570
}
571571
);
572572

573-
await test.step(
574-
'Fill in the product type and product description',
575-
async () => {
576-
await merchantPage
577-
.getByTestId( 'dispute-challenge-product-type-selector' )
578-
.selectOption( 'offline_service' );
579-
await merchantPage
580-
.getByLabel( 'PRODUCT DESCRIPTION' )
581-
.fill( 'my product description' );
582-
583-
// Verify the values were set correctly immediately after filling
584-
await expect(
585-
merchantPage.getByTestId(
586-
'dispute-challenge-product-type-selector'
587-
)
588-
).toHaveValue( 'offline_service' );
589-
590-
await expect(
591-
merchantPage.getByLabel( 'PRODUCT DESCRIPTION' )
592-
).toHaveValue( 'my product description' );
593-
}
594-
);
573+
await test.step( 'Fill in the product description', async () => {
574+
await merchantPage
575+
.getByLabel( 'PRODUCT DESCRIPTION' )
576+
.fill( 'my product description' );
595577

596-
await test.step( 'Verify form values before saving', async () => {
597-
// Double-check that the form values are still correct before saving
578+
// Verify the value was set correctly immediately after filling
598579
await expect(
599-
merchantPage.getByTestId(
600-
'dispute-challenge-product-type-selector'
601-
)
602-
).toHaveValue( 'offline_service' );
580+
merchantPage.getByLabel( 'PRODUCT DESCRIPTION' )
581+
).toHaveValue( 'my product description' );
582+
} );
603583

584+
await test.step( 'Verify form values before saving', async () => {
585+
// Double-check that the form value is still correct before saving
604586
await expect(
605587
merchantPage.getByLabel( 'PRODUCT DESCRIPTION' )
606588
).toHaveValue( 'my product description' );
@@ -612,6 +594,13 @@ test.describe( 'Disputes > Respond to a dispute', () => {
612594
name: 'Save for later',
613595
} )
614596
.click();
597+
598+
// Wait for the success snackbar to confirm UI acknowledged the save.
599+
await expect(
600+
merchantPage.locator( '.components-snackbar__content', {
601+
hasText: 'Evidence saved!',
602+
} )
603+
).toBeVisible( { timeout: 10000 } );
615604
} );
616605

617606
await test.step( 'Go back to the payment details page', async () => {
@@ -628,7 +617,7 @@ test.describe( 'Disputes > Respond to a dispute', () => {
628617
);
629618

630619
await test.step(
631-
'Verify the previously selected challenge product type is saved',
620+
'Verify previously saved values are restored',
632621
async () => {
633622
await test.step(
634623
'Confirm we are on the challenge dispute page',
@@ -641,15 +630,15 @@ test.describe( 'Disputes > Respond to a dispute', () => {
641630
}
642631
);
643632

633+
// Wait for description control to be visible
644634
await merchantPage
645-
.getByTestId( 'dispute-challenge-product-type-selector' )
646-
.waitFor( { timeout: 5000, state: 'visible' } );
635+
.getByLabel( 'PRODUCT DESCRIPTION' )
636+
.waitFor( { timeout: 10000, state: 'visible' } );
647637

638+
// Assert the product description persisted (server stores this under evidence)
648639
await expect(
649-
merchantPage.getByTestId(
650-
'dispute-challenge-product-type-selector'
651-
)
652-
).toHaveValue( 'offline_service' );
640+
merchantPage.getByLabel( 'PRODUCT DESCRIPTION' )
641+
).toHaveValue( 'my product description', { timeout: 10000 } );
653642
}
654643
);
655644
} );

0 commit comments

Comments
 (0)