forked from marmelab/react-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsales.js
81 lines (69 loc) · 2.98 KB
/
sales.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
const scenario = async page => {
const raNotificationAutoHideDuration = 4000;
const isRaSettled = () => !document.querySelector('.app-loader');
const waitForRaSettled = async () =>
await page.waitForFunction(isRaSettled, undefined, {
polling: 500,
timeout: 5000,
});
const waitForUndoableNotification = async () =>
await page.waitForTimeout(raNotificationAutoHideDuration + 300);
const addMonths = (date, count) => {
if (date && count) {
const day = (date = new Date(+date)).getDate();
date.setMonth(date.getMonth() + count, 1);
const month = date.getMonth();
date.setDate(day);
if (date.getMonth() !== month) date.setDate(0); // 0 gives the last day of the previous month
}
return date;
};
await page.goto('', {
waitUntil: 'networkidle',
});
await page.addMilestone('Log in');
await page.getByLabel('Username *').click();
await page.getByLabel('Username *').fill('demo');
await page.getByLabel('Username *').press('Tab');
await page.getByLabel('Password *').fill('demo');
await page.getByLabel('Password *').press('Enter');
await page.getByText('Welcome to the react-admin e-commerce demo');
await page.addMilestone('Go to Invoices list');
await page.getByRole('menuitem', { name: 'Invoices' }).click();
await waitForRaSettled();
await page.addMilestone('Delete first invoice');
await page.check(
'[aria-label="Select\\ this\\ row"] input[type="checkbox"]'
);
await page.getByRole('button', { name: 'Delete' }).click();
await page.getByText('Element deleted');
await waitForUndoableNotification();
await waitForRaSettled();
await page.addMilestone('Edit first remaining invoice');
await page.locator('td').first().click();
await waitForRaSettled();
await page.addMilestone('Go to related Order');
await page.getByRole('link').nth(1).click();
await waitForRaSettled();
await page.addMilestone('Edit the status');
await page.getByLabel('Status').click();
await page.getByRole('option', { name: 'delivered' }).click();
await page.addMilestone('Click the Save button');
await page.getByRole('button', { name: 'Save' }).click();
await page.getByText('Element updated');
await waitForUndoableNotification();
await waitForRaSettled();
await page.addMilestone('List all delivered orders');
await page.getByRole('tab', { name: /delivered/ }).click();
await waitForRaSettled();
await page.addMilestone('Filter all orders passed since one month');
await page.getByRole('button', { name: 'Add filter' }).click();
await page.getByText('Passed Since').click();
const oneMonthAgo = addMonths(new Date(), -1)
.toISOString()
.substring(0, 10);
await page.getByLabel('Passed Since').fill(oneMonthAgo);
await page.waitForNavigation();
await waitForRaSettled();
};
module.exports = scenario;