Skip to content

Commit d44db61

Browse files
committed
Playwright tests adjusted
1 parent c757d86 commit d44db61

File tree

6 files changed

+52
-43
lines changed

6 files changed

+52
-43
lines changed

.github/workflows/playwright.yml

+2
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ jobs:
1616
- name: Install playwright browsers
1717
run: npx playwright install --with-deps
1818
- name: Run tests
19+
env:
20+
WP_BASE_URL: ${{ secrets.WP_BASE_URL }}
1921
run: npx playwright test

playwright.config.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import { defineConfig, devices } from '@playwright/test';
2-
import * as dotenv from "dotenv";
3-
4-
dotenv.config({ path: __dirname + '/tests/playwright/.env.local' });
52

63
export default defineConfig({
74
testDir: './tests/playwright/',

tests/playwright/.env.local.example

-3
This file was deleted.

tests/playwright/admin-dashboard.spec.ts

-24
This file was deleted.

tests/playwright/homepage.spec.ts

-13
This file was deleted.

tests/playwright/testpage.spec.ts

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test.beforeEach(async ({ page }) => {
4+
await page.goto('/testpage');
5+
});
6+
7+
[
8+
{ selector: '.widget_mslswidget', firstLink: {name: 'de_DE Deutsch'}, secondLink: {name: 'en_GB English'} },
9+
{ selector: '.msls-menu', firstLink: { name: 'de_DE', exact: true }, secondLink: { name: 'en_GB', exact: true } },
10+
].forEach(({ selector, firstLink, secondLink }) => {
11+
test.describe(() => {
12+
test(`testing with ${selector} ${firstLink.name} ${secondLink.name}`, async ({page}) => {
13+
const section = page.locator(selector);
14+
15+
let element = section.getByRole('link', firstLink).first();
16+
await element.click();
17+
await expect(element).toHaveClass(['current_language']);
18+
19+
element = section.getByRole('link', secondLink).first();
20+
await element.click();
21+
await expect(element).toHaveClass(['current_language']);
22+
})
23+
})
24+
});
25+
26+
[0, 1, 2].forEach((index) => {
27+
test.describe(() => {
28+
test(`testing with link nth(${index})`, async ({ page }) => {
29+
let section = page.locator('.entry-content');
30+
31+
let element = section.getByRole('link', { name: 'de_DE Deutsch' }).nth(index) ;
32+
await element.click();
33+
await expect(element).toHaveClass(['current_language']);
34+
35+
element = section.getByRole('link', { name: 'en_GB English' }).nth(index);
36+
await element.click();
37+
await expect(element).toHaveClass(['current_language']);
38+
})
39+
})
40+
});
41+
42+
test(`testing translation hint`, async ({ page }) => {
43+
let section = page.locator('.entry-content');
44+
45+
await section.getByRole('link', { name: 'Deutsch', exact: true }).click();
46+
await expect(section.getByRole('link', { name: 'English', exact: true })).toHaveCount(0);
47+
48+
await section.getByRole('link', { name: 'English', exact: true }).click();
49+
await expect(section.getByRole('link', { name: 'English', exact: true })).toHaveCount(0);
50+
});

0 commit comments

Comments
 (0)