Skip to content

Commit 84f3708

Browse files
author
Anush
committed
playwright tests for rtl mode
1 parent 05cee1f commit 84f3708

File tree

2 files changed

+40
-34
lines changed

2 files changed

+40
-34
lines changed

.github/workflows/plotlyTestCoverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: "Plotly Test coverage"
22
on:
33
schedule:
4-
- cron: "0 */8 * * *"
4+
- cron: "30 8 * * *" # Runs every day at 2:00 PM IST (08:30 AM UTC)
55
workflow_dispatch:
66
inputs:
77
repo:

apps/plotly_examples/tests/DeclarativeChart.spec.ts

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,45 @@ import * as dotenv from 'dotenv';
44
const chartsListWithErrors = [];
55
var totalChartExamplesCount = 302;
66
const themes = ["Light", "Dark"];
7+
const modes = ["LTR", "RTL"];
8+
test.beforeEach(async ({ page }) => {
9+
//Pass base URL as part of playwright command
10+
//ex: npx cross-env BASE_URL='https://fluentchartstest-stage.azurewebsites.net/' npx playwright test
11+
await page.goto(process.env.BASE_URL!);
12+
});
713

8-
for (const theme of themes){
9-
test.describe(`Declarative chart examples in ${theme} mode`, () => {
10-
test.beforeEach( async ({ page }) => {
11-
//Pass base URL as part of playwright command
12-
//ex: npx cross-env BASE_URL='https://fluentchartstest-stage.azurewebsites.net/' npx playwright test
13-
await page.goto(process.env.BASE_URL);
14-
});
15-
16-
for (let index = 0; index < totalChartExamplesCount; index++) {
17-
test(`Declarative chart example ${ index + 1 }`, async ({ page }) => {
18-
const iframe = page.locator('#webpack-dev-server-client-overlay');
19-
if (await iframe.count() > 0) {
20-
await iframe.evaluate((el) => el.remove()).catch(() => {
21-
console.warn("Failed to remove overlay iframe.");
22-
});
14+
for (const theme of themes) {
15+
for (const mode of modes) {
16+
//test.describe(`Declarative chart examples in ${theme} mode and ${mode} layout`, () => {
17+
for (let index = 0; index < totalChartExamplesCount; index++) {
18+
test(`Declarative chart example ${index + 1}-${theme}-${mode} mode` , async ({ page }) => {
19+
const iframe = page.locator('#webpack-dev-server-client-overlay');
20+
if (await iframe.count() > 0) {
21+
await iframe.evaluate((el) => el.remove()).catch(() => {
22+
console.warn("Failed to remove overlay iframe.");
23+
});
24+
}
25+
await page.getByRole('combobox').first().click();
26+
const listbox = page.getByRole('listbox');
27+
await listbox.getByRole('option').locator(`text=${theme}`).click();
28+
const rtlSwitch = page.getByRole('switch');
29+
const isCurrentlyRTL = await rtlSwitch.isChecked();
30+
if ((mode === 'RTL' && !isCurrentlyRTL) || (mode === 'LTR' && isCurrentlyRTL)) {
31+
await rtlSwitch.click();
32+
}
33+
const combobox = page.getByRole('combobox');
34+
await combobox.nth(1).click();
35+
const listitems = listbox.last().getByRole('option');
36+
if (!chartsListWithErrors.includes(index)) {
37+
await listitems.nth(index).scrollIntoViewIfNeeded();
38+
await listitems.nth(index).click();
39+
const chart = page.getByTestId('chart-container');
40+
await expect(chart).toHaveScreenshot();
41+
await combobox.last().click();
42+
} else {
43+
test.fail();
44+
}
45+
});
46+
};
2347
}
24-
await page.getByRole('combobox').first().click();
25-
const listbox = page.getByRole('listbox');
26-
await listbox.getByRole('option').locator(`text=${theme}`).click();
27-
const combobox = page.getByRole('combobox');
28-
await combobox.nth(1).click();
29-
const listitems = listbox.last().getByRole('option');
30-
if (!chartsListWithErrors.includes(index)) {
31-
await listitems.nth(index).scrollIntoViewIfNeeded();
32-
await listitems.nth(index).click();
33-
const chart = page.getByTestId('chart-container');
34-
await expect(chart).toHaveScreenshot();
35-
await combobox.last().click();
36-
} else {
37-
test.fail();
38-
}
39-
});
40-
};
41-
});
4248
}

0 commit comments

Comments
 (0)