Skip to content

Commit ed5b114

Browse files
committed
chore: added onboarding e2e test
Closes: Codeinwp/dev-internals#72
1 parent a8a5feb commit ed5b114

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

tests/e2e/specs/onboarding.spec.ts

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/**
2+
* WordPress dependencies
3+
*/
4+
import {test, expect} from '@wordpress/e2e-test-utils-playwright';
5+
6+
const { deleteAllCharts } = require('../utils/common');
7+
8+
async function setOption( page, optionName, optionValue ) {
9+
await page.waitForSelector( `#${ optionName }` );
10+
const previousValue = await page.$eval(
11+
`#${ optionName }`,
12+
( element ) => element.value
13+
);
14+
15+
await page.focus( `#${ optionName }` );
16+
await page.type( `#${ optionName }`, optionValue );
17+
18+
await Promise.all( [
19+
page.click( '#Update' ),
20+
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
21+
] );
22+
}
23+
24+
test.describe( 'Onboarding', () => {
25+
26+
test.beforeEach( async ( { page, admin, requestUtils } ) => {
27+
await deleteAllCharts( requestUtils );
28+
await admin.visitAdminPage( 'options.php' );
29+
await setOption( page,'visualizer_fresh_install', '1' );
30+
} );
31+
32+
test( 'Check the setup wizard', async ( { page, admin} ) => {
33+
await admin.visitAdminPage( 'admin.php?page=visualizer-setup-wizard#step-1' );
34+
35+
// Step 1
36+
await expect(page.getByLabel('Pie/Donut chart', { exact: true })).toBeVisible();
37+
await page.getByLabel('Bar chart', { exact: true }).check();
38+
await expect(page.getByLabel('Line chart', { exact: true })).toBeVisible();
39+
await expect(page.getByLabel('Bar chart', { exact: true })).toBeVisible();
40+
await page.getByLabel('Next', { exact: true }).click();
41+
await page.getByLabel('Next', { exact: true }).click();
42+
await page.getByLabel('Next', { exact: true }).click();
43+
await page.getByLabel('Next', { exact: true }).click();
44+
await expect(page.getByText('Discover the power of PRO! 11')).toBeVisible();
45+
await expect(page.getByRole('button', { name: 'Save And Continue ' })).toBeVisible();
46+
await expect(page.getByRole('link', { name: ' Go to dashboard' })).toBeVisible();
47+
await page.getByRole('button', { name: 'Save And Continue ' }).click();
48+
49+
// Step 2
50+
await expect(page.getByLabel('You\'re almost done! We use').locator('h2')).toContainText('You\'re almost done!');
51+
await expect(page.getByRole('heading', { name: 'Importing demo data' })).toBeVisible();
52+
await expect(page.getByText('Done! Demo data imported')).toBeVisible();
53+
await expect(page.getByLabel('You\'re almost done! We use')).toContainText('Import data from other Charts, WordPress, DataBase, or Manual Data with Visualizer Premium version');
54+
await page.getByRole('button', { name: 'Continue ' }).click();
55+
56+
// Step 3
57+
await expect(page.getByRole('heading')).toContainText('Insert chart into the draft page');
58+
await expect(page.getByRole('button', { name: 'Create a draft page We will' })).toBeVisible();
59+
await page.getByRole('button', { name: 'Create a draft page We will' }).click();
60+
await expect(page.getByRole('heading', { name: 'Chart preview' })).toBeVisible();
61+
await page.getByRole('button', { name: 'Create a draft page We will' }).click();
62+
await page.getByRole('button', { name: 'Save And Continue ' }).click();
63+
64+
// Step 4
65+
await expect(page.getByRole('heading')).toContainText('Extra Features');
66+
await expect(page.getByRole('button', { name: 'Enable perfomance features' })).toBeVisible();
67+
await page.getByRole('button', { name: 'Enable perfomance features' }).click();
68+
await expect(page.getByLabel('Extra Features We\'re').getByRole('listitem')).toContainText('Improve your website speed and images by 80% with Optimole');
69+
await expect(page.getByRole('button', { name: 'Improve now' })).toBeVisible();
70+
await page.getByRole('checkbox').uncheck();
71+
await expect(page.getByLabel('Extra Features We\'re')).toContainText('Skip Improvement');
72+
await page.getByRole('button', { name: 'Skip Improvement' }).click();
73+
74+
// Step 5
75+
await expect(page.getByRole('heading')).toContainText('Updates, tutorials, special offers & more');
76+
await expect(page.getByLabel('Updates, tutorials, special')).toContainText('Get exclusive access of Visualizer newsletter');
77+
await expect(page.getByLabel('Updates, tutorials, special').locator('img')).toBeVisible();
78+
await expect(page.getByPlaceholder('[email protected]')).toBeVisible();
79+
await page.getByPlaceholder('[email protected]').click();
80+
await page.getByPlaceholder('[email protected]').fill('[email protected]');
81+
await expect(page.getByLabel('Updates, tutorials, special')).toContainText('Send Me Access');
82+
await expect(page.getByLabel('Updates, tutorials, special')).toContainText('Skip, Don’t give me access');
83+
await page.getByRole('button', { name: 'Skip, Don’t give me access' }).click();
84+
} );
85+
86+
} );

0 commit comments

Comments
 (0)