Skip to content

Commit c5e66d5

Browse files
committed
fix: e2e tests
1 parent fae76cc commit c5e66d5

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

tests/e2e/specs/admin.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ test.describe( 'Chart Library', () => {
198198
expect( titleValue ).toBe( backendName );
199199

200200
await page.frameLocator('iframe').getByRole('link', { name: 'Settings' }).click();
201-
await page.frameLocator('iframe').getByRole('heading', { name: 'General Settings' }).click();
201+
await page.frameLocator('iframe').getByRole('button', { name: 'General Settings' }).click();
202202
await page.frameLocator('iframe').getByText('Title', { exact: true }).click();
203203

204204
await page.frameLocator('iframe').locator('input[name="title"]').fill(chartName);

tests/e2e/specs/upsell.spec.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ test.describe( 'Upsell', () => {
2222
await page.getByRole('button', { name: 'Classic Builder Step-by-step' }).click();
2323
await page.waitForSelector('h1:text("Visualizer")');
2424

25-
expect( await page.frameLocator('iframe').locator('.pro-upsell').count() ).toBe( 11 );
25+
const frame = page.frameLocator('iframe');
26+
await expect( frame.locator('#type-picker') ).toBeVisible({ timeout: 10000 });
27+
await expect( frame.locator('.pro-upsell') ).toHaveCount( 11 );
2628

27-
const proUpsellElements = await page.frameLocator('iframe').locator('a.pro-upsell').all();
29+
const proUpsellElements = await frame.getByRole('link', { name: 'Upgrade Now' }).all();
2830

2931
for (const element of proUpsellElements) {
3032
const href = await element.getAttribute('href');
3133
const searchParams = new URLSearchParams(href);
32-
expect( searchParams.get('utm_campaign') ).toBe('charttypes');
34+
expect( searchParams.get('utm_campaign') ).toBe('procharts');
3335
}
3436
} );
3537

@@ -65,15 +67,15 @@ test.describe( 'Upsell', () => {
6567
href = await wpImportUpsell.getAttribute('href');
6668
searchParams = new URLSearchParams(href);
6769
expect( searchParams.get('utm_campaign') ).toBe('import-wp');
68-
await page.frameLocator('iframe').getByRole('heading', { name: /Import from WordPress/ }).click();
70+
await page.frameLocator('iframe').getByRole('button', { name: /Import from WordPress/ }).click();
6971
await expect(page.frameLocator('iframe').locator('#vz-chart-source')).toContainText('Upgrade to PRO to activate this feature!');
7072

7173
const dbImportUpsell = page.frameLocator('iframe').locator('#vz-chart-source .visualizer_source_query .only-pro-inner a').last();
7274
href = await dbImportUpsell.getAttribute('href');
7375
searchParams = new URLSearchParams(href);
7476
expect( searchParams.get('utm_campaign') ).toBe('db-query');
7577

76-
await page.frameLocator('iframe').getByRole('heading', { name: /Import from database/ }).click();
78+
await page.frameLocator('iframe').getByRole('button', { name: /Import from database/ }).click();
7779
await expect(page.frameLocator('iframe').locator('#vz-db-wizard')).toContainText('Upgrade to Plus plan to activate this feature!');
7880
await expect(page.frameLocator('iframe').locator('#vz-db-wizard')).toContainText('Upgrade Now');
7981

@@ -93,7 +95,7 @@ test.describe( 'Upsell', () => {
9395
href = await chartPermissionsUpsell.getAttribute('href');
9496
searchParams = new URLSearchParams(href);
9597
expect( searchParams.get('utm_campaign') ).toBe('chart-permissions');
96-
await page.frameLocator('iframe').getByRole('heading', { name: /Permissions/ }).click();
98+
await page.frameLocator('iframe').getByRole('button', { name: /Permissions/ }).click();
9799
await expect(page.frameLocator('iframe').locator('#vz-db-wizard')).toContainText('Upgrade to Plus plan to activate this feature!');
98100
await expect(page.frameLocator('iframe').locator('#vz-db-wizard')).toContainText('Upgrade Now');
99101
});

tests/e2e/utils/common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export async function createChartWithAdmin( admin, page, chart_label = CHART_JS_
5757
await selectChartAdmin( page.frameLocator('iframe'), chart_label );
5858

5959
// Wait a little for the request to be processed.
60-
await expect( page.frameLocator('iframe').getByRole('heading', { name: 'Import data from URL' })).toBeVisible({ timeout: 5000 });
60+
await expect( page.frameLocator('iframe').getByRole('button', { name: 'Import data from URL' })).toBeVisible({ timeout: 5000 });
6161

6262
const chartId = await page.frameLocator('iframe').locator('#visualizer-chart-id').getAttribute('data-id');
6363

0 commit comments

Comments
 (0)