Skip to content

Commit 4b96b53

Browse files
Jinksihaszari
andcommitted
Add e2e test for dispute flow: viewing dispute details via the order notice (#7976)
Co-authored-by: Rua Haszard <[email protected]>
1 parent c9aeb19 commit 4b96b53

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: dev
3+
Comment: Not user-facing: add e2e test for viewing the dispute details via the disputed order notice
4+
5+
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* External dependencies
3+
*/
4+
import config from 'config';
5+
6+
/**
7+
* Internal dependencies
8+
*/
9+
import { fillCardDetails, setupProductCheckout } from '../../../utils/payments';
10+
11+
const { merchant, shopper } = require( '@woocommerce/e2e-utils' );
12+
13+
describe( 'Disputes > View dispute details via disputed order notice', () => {
14+
beforeAll( async () => {
15+
await page.goto( config.get( 'url' ), { waitUntil: 'networkidle0' } );
16+
17+
// Place an order to dispute later
18+
await setupProductCheckout(
19+
config.get( 'addresses.customer.billing' )
20+
);
21+
const card = config.get( 'cards.disputed-fraudulent' );
22+
await fillCardDetails( page, card );
23+
await shopper.placeOrder();
24+
await expect( page ).toMatch( 'Order received' );
25+
26+
// Get the order ID
27+
const orderIdField = await page.$(
28+
'.woocommerce-order-overview__order.order > strong'
29+
);
30+
const orderId = await orderIdField.evaluate( ( el ) => el.innerText );
31+
32+
await merchant.login();
33+
await merchant.goToOrder( orderId );
34+
} );
35+
36+
afterAll( async () => {
37+
await merchant.logout();
38+
} );
39+
40+
it( 'should navigate to dispute details when disputed order notice button clicked', async () => {
41+
// If WC < 7.9, return early since the order dispute notice is not present.
42+
const orderPaymentDetailsContainer = await page.$(
43+
'#wcpay-order-payment-details-container'
44+
);
45+
if ( ! orderPaymentDetailsContainer ) {
46+
// eslint-disable-next-line no-console
47+
console.log(
48+
'Skipping test since the order dispute notice is not present in WC < 7.9'
49+
);
50+
return;
51+
}
52+
53+
// Click the order dispute notice.
54+
await expect( page ).toClick( '[type="button"]', {
55+
text: 'Respond now',
56+
} );
57+
58+
await page.waitForNavigation( {
59+
waitUntil: 'networkidle0',
60+
} );
61+
62+
// Verify we see the dispute details on the transaction details page.
63+
await expect( page ).toMatchElement( '.dispute-notice', {
64+
text: 'The cardholder claims this is an unauthorized transaction',
65+
} );
66+
} );
67+
} );

0 commit comments

Comments
 (0)