Skip to content

Commit acfd39a

Browse files
chore: add upsell check e2e test
1 parent 59566bf commit acfd39a

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

tests/e2e/specs/upsell.spec.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/**
2+
* WordPress dependencies
3+
*/
4+
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );
5+
6+
/**
7+
* Internal dependencies
8+
*/
9+
const { deleteAllCharts, getAssetFilePath, CHART_JS_LABELS, selectChartAdmin } = require('../utils/common');
10+
11+
test.describe( 'Upsell', () => {
12+
test.beforeEach( async ( { admin, requestUtils, page } ) => {
13+
await deleteAllCharts( requestUtils );
14+
await admin.visitAdminPage( 'admin.php?page=visualizer' );
15+
page.setDefaultTimeout( 5000 );
16+
} );
17+
18+
test( 'chart selection on admin', async ( { admin, page } ) => {
19+
await admin.visitAdminPage( 'admin.php?page=visualizer&vaction=addnew' );
20+
await page.waitForURL( '**/admin.php?page=visualizer&vaction=addnew' );
21+
await page.waitForSelector('h1:text("Visualizer")');
22+
23+
expect( await page.frameLocator('iframe').locator('.pro-upsell').count() ).toBe( 11 );
24+
25+
const proUpsellElements = await page.frameLocator('iframe').locator('a.pro-upsell').all();
26+
27+
for (const element of proUpsellElements) {
28+
const href = await element.getAttribute('href');
29+
const searchParams = new URLSearchParams(href);
30+
expect( searchParams.get('utm_campaign') ).toBe('charttypes');
31+
}
32+
} );
33+
34+
test( 'chart settings on admin', async ( { admin, page } ) => {
35+
await admin.visitAdminPage( 'admin.php?page=visualizer&vaction=addnew' );
36+
await page.waitForURL( '**/admin.php?page=visualizer&vaction=addnew' );
37+
await page.waitForSelector('h1:text("Visualizer")');
38+
await selectChartAdmin( page.frameLocator('iframe'), CHART_JS_LABELS.pie );
39+
40+
await expect( page.frameLocator('iframe').locator( '#viz-tabs' ) ).toBeVisible();
41+
42+
expect( await page.frameLocator('iframe').locator('#vz-chart-source .viz-group-title .dashicons-lock').count() ).toBe( 4 );
43+
44+
const otherChartUpsell = page.frameLocator('iframe').locator('#vz-chart-source .viz-import-from-other .only-pro-inner a');
45+
let href = await otherChartUpsell.getAttribute('href');
46+
let searchParams = new URLSearchParams(href);
47+
expect( searchParams.get('utm_campaign') ).toBe('import-chart');
48+
49+
const wpImportUpsell = page.frameLocator('iframe').locator('#vz-chart-source .visualizer_source_query_wp .only-pro-inner a');
50+
href = await wpImportUpsell.getAttribute('href');
51+
searchParams = new URLSearchParams(href);
52+
expect( searchParams.get('utm_campaign') ).toBe('import-wp');
53+
54+
const dbImportUpsell = page.frameLocator('iframe').locator('#vz-chart-source .visualizer_source_query .only-pro-inner a');
55+
href = await dbImportUpsell.getAttribute('href');
56+
searchParams = new URLSearchParams(href);
57+
expect( searchParams.get('utm_campaign') ).toBe('db-query');
58+
59+
const manualDataUpsell = page.frameLocator('iframe').locator('#vz-chart-source .visualizer_source_manual .only-pro-inner a');
60+
href = await manualDataUpsell.getAttribute('href');
61+
searchParams = new URLSearchParams(href);
62+
expect( searchParams.get('utm_campaign') ).toBe('manual-data');
63+
64+
await page.frameLocator('iframe').getByRole('link', { name: 'Settings' }).click();
65+
66+
const dataFilterConfigurationUpsell = page.frameLocator('iframe').locator('#vz-data-controls .only-pro-inner a');
67+
href = await dataFilterConfigurationUpsell.getAttribute('href');
68+
searchParams = new URLSearchParams(href);
69+
expect( searchParams.get('utm_campaign') ).toBe('data-filter-configuration');
70+
71+
const frontendActionsUpsell = page.frameLocator('iframe').locator('#vz-frontend-actions .only-pro-inner a');
72+
href = await frontendActionsUpsell.getAttribute('href');
73+
searchParams = new URLSearchParams(href);
74+
expect( searchParams.get('utm_campaign') ).toBe('frontend-actions');
75+
76+
const chartPermissionsUpsell = page.frameLocator('iframe').locator('#vz-permissions .only-pro-inner a');
77+
href = await chartPermissionsUpsell.getAttribute('href');
78+
searchParams = new URLSearchParams(href);
79+
expect( searchParams.get('utm_campaign') ).toBe('chart-permissions');
80+
});
81+
} );

0 commit comments

Comments
 (0)