Skip to content

Commit e769b0b

Browse files
mgascamclaudeMrJnrmanfrosso
authored
[E2E][QIT] Add remaining merchant E2E test specs to QIT test-package (#11221)
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: MrJnrman <jnoelreid@gmai.com> Co-authored-by: Francesco <frosso@users.noreply.github.com>
1 parent 8d92a34 commit e769b0b

18 files changed

+2128
-63
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: Migration of E2E merchant tests to QIT.
4+
5+
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/**
2+
* Internal dependencies
3+
*/
4+
import { test, expect } from '../../../fixtures/auth';
5+
import {
6+
activateMulticurrency,
7+
ensureOrderIsProcessed,
8+
isMulticurrencyEnabled,
9+
tableDataHasLoaded,
10+
waitAndSkipTourComponent,
11+
goToOrderAnalytics,
12+
} from '../../../utils/merchant';
13+
import { placeOrderWithCurrency } from '../../../utils/shopper';
14+
15+
test.describe( 'Admin order analytics', { tag: '@merchant' }, () => {
16+
// Extend timeout for the entire test suite to allow order processing
17+
test.setTimeout( 120000 );
18+
19+
test.beforeAll( async ( { adminPage, customerPage } ) => {
20+
// Set explicit timeout for this beforeAll hook
21+
test.setTimeout( 120000 );
22+
23+
// Ensure multi-currency is enabled for the analytics tests
24+
if ( false === ( await isMulticurrencyEnabled( adminPage ) ) ) {
25+
await activateMulticurrency( adminPage );
26+
}
27+
28+
// Place an order to ensure the analytics data is correct
29+
await placeOrderWithCurrency( customerPage, 'USD' );
30+
await ensureOrderIsProcessed( adminPage );
31+
32+
// Give analytics more time to process the order data
33+
await adminPage.waitForTimeout( 2000 );
34+
} );
35+
36+
test( 'should load without any errors', async ( { adminPage } ) => {
37+
await goToOrderAnalytics( adminPage );
38+
await tableDataHasLoaded( adminPage );
39+
await waitAndSkipTourComponent(
40+
adminPage,
41+
'.woocommerce-revenue-report-date-tour'
42+
);
43+
44+
const ordersTitle = adminPage.getByRole( 'heading', {
45+
name: 'Orders',
46+
level: 1,
47+
exact: true,
48+
} );
49+
await expect( ordersTitle ).toBeVisible();
50+
51+
// Check for analytics data with retry mechanism
52+
let attempts = 0;
53+
const maxAttempts = 3;
54+
55+
while ( attempts < maxAttempts ) {
56+
const noDataText = adminPage.getByText( 'No data to display' );
57+
const noDataCount = await noDataText.count();
58+
59+
if ( noDataCount === 0 ) {
60+
break; // Data is present, exit retry loop
61+
}
62+
63+
// If no data on first check, try refreshing
64+
if ( attempts < maxAttempts - 1 ) {
65+
await adminPage.reload();
66+
await tableDataHasLoaded( adminPage );
67+
await waitAndSkipTourComponent(
68+
adminPage,
69+
'.woocommerce-revenue-report-date-tour'
70+
);
71+
// Wait a bit more for data to load after refresh
72+
await adminPage.waitForTimeout( 2000 );
73+
}
74+
75+
attempts++;
76+
}
77+
78+
// Verify that we have analytics data from the order created in beforeAll
79+
const finalNoDataText = adminPage.getByText( 'No data to display' );
80+
await expect( finalNoDataText ).toHaveCount( 0 );
81+
82+
// TODO: This visual regression test is flaky, we should revisit the approach.
83+
// await expect( adminPage ).toHaveScreenshot();
84+
} );
85+
86+
test( 'orders table should have the customer currency column', async ( {
87+
adminPage,
88+
} ) => {
89+
await goToOrderAnalytics( adminPage );
90+
await tableDataHasLoaded( adminPage );
91+
await waitAndSkipTourComponent(
92+
adminPage,
93+
'.woocommerce-revenue-report-date-tour'
94+
);
95+
96+
const columnToggle = adminPage.getByTitle(
97+
'Choose which values to display'
98+
);
99+
await columnToggle.click();
100+
const customerCurrencyToggle = adminPage.getByRole(
101+
'menuitemcheckbox',
102+
{
103+
name: 'Customer Currency',
104+
}
105+
);
106+
await expect( customerCurrencyToggle ).toBeVisible();
107+
await customerCurrencyToggle.click();
108+
const customerCurrencyColumn = adminPage.getByRole( 'columnheader', {
109+
name: 'Customer Currency',
110+
} );
111+
await expect( customerCurrencyColumn ).toBeVisible();
112+
} );
113+
} );
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* Internal dependencies
3+
*/
4+
import { test, expect } from '../../../fixtures/auth';
5+
6+
test.describe( 'Merchant deposits', { tag: '@merchant' }, () => {
7+
test( 'Load the deposits list page', async ( { adminPage } ) => {
8+
await adminPage.goto(
9+
'/wp-admin/admin.php?page=wc-admin&path=/payments/payouts'
10+
);
11+
12+
// Wait for the deposits table to load.
13+
await adminPage
14+
.locator( '.woocommerce-table__table.is-loading' )
15+
.waitFor( { state: 'hidden' } );
16+
17+
await expect(
18+
adminPage.getByRole( 'heading', {
19+
name: 'Payout history',
20+
} )
21+
).toBeVisible();
22+
} );
23+
24+
test( 'Select deposits list advanced filters', async ( { adminPage } ) => {
25+
await adminPage.goto(
26+
'/wp-admin/admin.php?page=wc-admin&path=/payments/payouts'
27+
);
28+
29+
// Wait for the deposits table to load.
30+
await adminPage
31+
.locator( '.woocommerce-table__table.is-loading' )
32+
.waitFor( { state: 'hidden' } );
33+
34+
// Open the advanced filters.
35+
await adminPage.getByRole( 'button', { name: 'All payouts' } ).click();
36+
await adminPage
37+
.getByRole( 'button', { name: 'Advanced filters' } )
38+
.click();
39+
40+
// Select a filter
41+
await adminPage.getByRole( 'button', { name: 'Add a Filter' } ).click();
42+
await adminPage.getByRole( 'button', { name: 'Status' } ).click();
43+
44+
// Select a filter option
45+
await adminPage
46+
.getByLabel( 'Select a payout status', {
47+
exact: true,
48+
} )
49+
.selectOption( 'Pending' );
50+
51+
// Scroll to the top to ensure the sticky header doesn't cover the filters.
52+
await adminPage.evaluate( () => {
53+
window.scrollTo( 0, 0 );
54+
} );
55+
// TODO: This visual regression test is not flaky, but we should revisit the approach.
56+
// await expect(
57+
// adminPage.locator( '.woocommerce-filters' ).last()
58+
// ).toHaveScreenshot();
59+
} );
60+
} );
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Internal dependencies
3+
*/
4+
import { test, expect } from '../../../fixtures/auth';
5+
import { goToDisputes, tableDataHasLoaded } from '../../../utils/merchant';
6+
7+
test.describe( 'Merchant disputes', { tag: '@merchant' }, () => {
8+
test( 'Load the disputes list page', async ( { adminPage } ) => {
9+
await goToDisputes( adminPage );
10+
await tableDataHasLoaded( adminPage );
11+
12+
// .nth( 1 ) defines the second instance of the Disputes heading, which is in the table.
13+
await expect(
14+
adminPage.getByRole( 'heading', { name: 'Disputes' } ).nth( 1 )
15+
).toBeVisible();
16+
} );
17+
} );
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Internal dependencies
3+
*/
4+
import { test, expect } from '../../../fixtures/auth';
5+
import { goToTransactions } from '../../../utils/merchant';
6+
7+
// Preserve the legacy subscriptions test guard since QIT utils don't export this constant yet
8+
const shouldRunSubscriptionsTests =
9+
process.env.SKIP_WC_SUBSCRIPTIONS_TESTS !== '1';
10+
11+
test.describe( 'Admin transactions', { tag: '@merchant' }, () => {
12+
test( 'page should load without errors', async ( { adminPage } ) => {
13+
await goToTransactions( adminPage );
14+
await expect(
15+
adminPage
16+
.getByLabel( 'Transactions', { exact: true } )
17+
.getByRole( 'heading', { name: 'Transactions' } )
18+
).toBeVisible();
19+
20+
if ( shouldRunSubscriptionsTests ) {
21+
// Check if the subscription column exists - it may not be present in all QIT environments
22+
const subscriptionColumn = adminPage.getByRole( 'columnheader', {
23+
name: 'Subscription number',
24+
} );
25+
26+
// Only assert visibility if the element exists in the DOM
27+
const columnCount = await subscriptionColumn.count();
28+
if ( columnCount > 0 ) {
29+
await expect( subscriptionColumn ).toBeVisible();
30+
}
31+
}
32+
33+
// TODO: Uncomment this line after fixing the screenshot issue.
34+
// await expect( adminPage ).toHaveScreenshot();
35+
} );
36+
} );

0 commit comments

Comments
 (0)