-
Notifications
You must be signed in to change notification settings - Fork 10.7k
/
onboarding-tasklist.test.js
108 lines (94 loc) · 2.97 KB
/
onboarding-tasklist.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/**
* Internal dependencies
*/
const {
merchant,
completeOnboardingWizard,
withRestApi,
addShippingZoneAndMethod,
IS_RETEST_MODE,
} = require( '@woocommerce/e2e-utils' );
/**
* External dependencies
*/
const config = require( 'config' );
import deprecated from '@wordpress/deprecated';
const { it, describe } = require( '@jest/globals' );
const shippingZoneNameUS = config.get( 'addresses.customer.shipping.country' );
const runOnboardingFlowTest = () => {
describe( 'Store owner can go through store Onboarding', () => {
beforeAll( async () => {
await merchant.login();
} );
if ( IS_RETEST_MODE ) {
it( 'can reset onboarding to default settings', async () => {
await withRestApi.resetOnboarding();
} );
it( 'can reset shipping zones to default settings', async () => {
await withRestApi.deleteAllShippingZones();
} );
it( 'can reset shipping classes', async () => {
await withRestApi.deleteAllShippingClasses();
} );
it( 'can reset to default settings', async () => {
await withRestApi.resetSettingsGroupToDefault( 'general' );
await withRestApi.resetSettingsGroupToDefault( 'products' );
await withRestApi.resetSettingsGroupToDefault( 'tax' );
} );
}
it( 'can start and complete onboarding when visiting the site for the first time.', async () => {
deprecated( 'runOnboardingFlowTest', {
alternative:
'@woocommerce/admin-e2e-tests `testAdminOnboardingWizard()`',
} );
await completeOnboardingWizard();
} );
} );
};
const runTaskListTest = () => {
describe( 'Store owner can go through setup Task List', () => {
beforeAll( async () => {
await merchant.login();
} );
it( 'can setup shipping', async () => {
deprecated( 'runTaskListTest', {
alternative:
'@woocommerce/admin-e2e-tests `testAdminHomescreenTasklist()`',
} );
await page.evaluate( () => {
document
.querySelector( '.woocommerce-list__item-title' )
.scrollIntoView();
} );
// Query for all tasks on the list
const taskListItems = await page.$$(
'.woocommerce-list__item-title'
);
expect( taskListItems.length ).toBeInRange( 5, 6 );
// Work around for https://github.com/woocommerce/woocommerce-admin/issues/6761
if ( taskListItems.length === 6 ) {
// Click on "Get your products shipped" task to move to the next step
const [ setupTaskListItem ] = await page.$x(
'//div[contains(text(),"Get your products shipped")]'
);
await setupTaskListItem.click();
// Wait for "Proceed" button to become active
await page.waitForSelector(
'button.is-primary:not(:disabled)'
);
await page.waitFor( 3000 );
// Click on "Proceed" button to save shipping settings
await page.click( 'button.is-primary' );
await page.waitFor( 3000 );
} else {
await merchant.openNewShipping();
await addShippingZoneAndMethod( shippingZoneNameUS );
}
} );
} );
};
// eslint-disable-next-line jest/no-export
module.exports = {
runOnboardingFlowTest,
runTaskListTest,
};