Skip to content

Commit eb29cbf

Browse files
Test/improve playwright (#2158)
2 parents 12eb0df + 6fe97ce commit eb29cbf

9 files changed

Lines changed: 40 additions & 21 deletions

File tree

automation/run-e2e/docker/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ services:
2929
# Starts after mxbuild completes; "docker compose up --wait" blocks until healthy.
3030
mxruntime:
3131
image: mxruntime:${MENDIX_VERSION:?MENDIX_VERSION is required}
32+
shm_size: "2gb"
3233
depends_on:
3334
mxbuild:
3435
condition: service_completed_successfully

automation/run-e2e/playwright.config.cjs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,28 @@ module.exports = defineConfig({
4141
baseURL: process.env.URL ? process.env.URL : "http://127.0.0.1:8080",
4242

4343
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
44-
trace: "on-first-retry"
44+
trace: "on-first-retry",
45+
46+
launchOptions: {
47+
args: [
48+
"--disable-dev-shm-usage",
49+
"--disable-extensions",
50+
"--disable-background-networking",
51+
"--disable-background-timer-throttling",
52+
"--disable-renderer-backgrounding",
53+
"--disable-sync",
54+
"--disable-translate",
55+
"--disable-default-apps",
56+
"--disable-hang-monitor",
57+
"--metrics-recording-only",
58+
"--no-first-run",
59+
"--font-render-hinting=none"
60+
]
61+
},
62+
63+
contextOptions: {
64+
reducedMotion: "reduce"
65+
}
4566
},
4667

4768
/* Configure projects for major browsers */
Loading
-2.79 KB
Loading
-3.03 KB
Loading
-2.7 KB
Loading

packages/pluggableWidgets/skiplink-web/e2e/SkipLink.spec.js

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,63 +12,60 @@ test.beforeEach(async ({ page }) => {
1212

1313
test.describe("SkipLink:", function () {
1414
test("skip link is present in DOM but initially hidden", async ({ page }) => {
15-
// Skip link should be in the DOM but not visible
1615
const skipLink = page.locator(".widget-skip-link").first();
1716
await expect(skipLink).toBeAttached();
18-
19-
// Check initial styling (hidden)
20-
const transform = await skipLink.evaluate(el => getComputedStyle(el).transform);
21-
expect(transform).toContain("matrix(1, 0, 0, 1, 0, -48)");
17+
18+
// Element is translated above the viewport — its bottom edge should be at or above y=0
19+
const rect = await skipLink.evaluate(el => el.getBoundingClientRect().toJSON());
20+
expect(rect.bottom).toBeLessThanOrEqual(0);
2221
});
2322

2423
test("skip link becomes visible when focused via keyboard", async ({ page }) => {
25-
// Tab to focus the skip link (should be first focusable element)
2624
const skipLink = page.locator(".widget-skip-link").first();
2725
await page.keyboard.press("Tab");
28-
26+
2927
await expect(skipLink).toBeFocused();
30-
await page.waitForTimeout(1000);
31-
// Check that it becomes visible when focused
32-
const transform = await skipLink.evaluate(el => getComputedStyle(el).transform);
33-
expect(transform).toContain("matrix(1, 0, 0, 1, 0, 0)")
28+
// Element should now be within the viewport
29+
const rect = await skipLink.evaluate(el => el.getBoundingClientRect().toJSON());
30+
expect(rect.top).toBeGreaterThanOrEqual(0);
3431
});
3532

3633
test("skip link navigates to main content when activated", async ({ page }) => {
3734
// Tab to focus the skip link
3835
await page.keyboard.press("Tab");
39-
36+
4037
const skipLink = page.locator(".widget-skip-link").first();
4138
await expect(skipLink).toBeFocused();
42-
39+
4340
// Activate the skip link
4441
await page.keyboard.press("Enter");
45-
42+
4643
// Check that main content is now focused
4744
const mainContent = page.locator("main");
4845
await expect(mainContent).toBeFocused();
4946
});
5047

5148
test("skip link has correct attributes and text", async ({ page }) => {
5249
const skipLink = page.locator(".widget-skip-link").first();
53-
50+
5451
// Check default text
5552
await expect(skipLink).toHaveText("Skip to main content");
56-
53+
5754
// Check href attribute
5855
await expect(skipLink).toHaveAttribute("href", "#");
59-
56+
6057
// Check CSS class
6158
await expect(skipLink).toHaveClass("widget-skip-link mx-name-skipLink1");
6259
});
6360

6461
test("visual comparison", async ({ page }) => {
6562
// Tab to make skip link visible for screenshot
6663
await page.keyboard.press("Tab");
67-
64+
6865
const skipLink = page.locator(".widget-skip-link").first();
6966
await expect(skipLink).toBeFocused();
70-
67+
7168
// Visual comparison of focused skip link
7269
await expect(skipLink).toHaveScreenshot("skiplink-focused.png");
7370
});
74-
});
71+
});
-390 Bytes
Loading
638 Bytes
Loading

0 commit comments

Comments
 (0)