Skip to content

Commit 6a49b99

Browse files
committed
fix: e2e tests
1 parent 4a33c7a commit 6a49b99

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

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

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ test.afterEach("Cleanup session", async ({ page }) => {
77

88
test.beforeEach(async ({ page }) => {
99
await page.goto("/");
10+
await page.waitForLoadState("networkidle");
1011
});
1112

1213
test.describe("SkipLink:", function () {
@@ -17,30 +18,22 @@ test.describe("SkipLink:", function () {
1718

1819
// Check initial styling (hidden)
1920
const transform = await skipLink.evaluate(el => getComputedStyle(el).transform);
20-
expect(transform).toContain("translateY(-120%)") || expect(transform).toContain("matrix");
21+
expect(transform).toContain("matrix(1, 0, 0, 1, 0, -48)");
2122
});
2223

2324
test("skip link becomes visible when focused via keyboard", async ({ page }) => {
2425
// Tab to focus the skip link (should be first focusable element)
26+
const skipLink = page.locator(".skip-link").first();
2527
await page.keyboard.press("Tab");
2628

27-
const skipLink = page.locator(".skip-link").first();
2829
await expect(skipLink).toBeFocused();
29-
30+
await page.waitForTimeout(1000);
3031
// Check that it becomes visible when focused
3132
const transform = await skipLink.evaluate(el => getComputedStyle(el).transform);
32-
expect(transform).toContain("translateY(0px)") || expect(transform).toBe("none");
33+
expect(transform).toContain("matrix(1, 0, 0, 1, 0, 0)")
3334
});
3435

3536
test("skip link navigates to main content when activated", async ({ page }) => {
36-
// Create a main content element to test focus behavior
37-
await page.evaluate(() => {
38-
const main = document.createElement("main");
39-
main.id = "main-content";
40-
main.textContent = "Main content area";
41-
document.body.appendChild(main);
42-
});
43-
4437
// Tab to focus the skip link
4538
await page.keyboard.press("Tab");
4639

@@ -51,7 +44,7 @@ test.describe("SkipLink:", function () {
5144
await page.keyboard.press("Enter");
5245

5346
// Check that main content is now focused
54-
const mainContent = page.locator("#main-content");
47+
const mainContent = page.locator("main");
5548
await expect(mainContent).toBeFocused();
5649
});
5750

@@ -62,7 +55,7 @@ test.describe("SkipLink:", function () {
6255
await expect(skipLink).toHaveText("Skip to main content");
6356

6457
// Check href attribute
65-
await expect(skipLink).toHaveAttribute("href", "#main-content");
58+
await expect(skipLink).toHaveAttribute("href", "#");
6659

6760
// Check tabindex
6861
await expect(skipLink).toHaveAttribute("tabindex", "0");

packages/pluggableWidgets/skiplink-web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"create-translation": "rui-create-translation",
3333
"dev": "pluggable-widgets-tools start:web",
3434
"e2e": "MENDIX_VERSION=11.1.0.75979 run-e2e ci --no-update-project",
35-
"e2edev": "run-e2e dev --with-preps",
35+
"e2edev": "MENDIX_VERSION=11.1.0.75979 run-e2e dev --with-preps --no-update-project",
3636
"format": "prettier --ignore-path ./node_modules/@mendix/prettier-config-web-widgets/global-prettierignore --write .",
3737
"lint": "eslint src/ package.json",
3838
"publish-marketplace": "rui-publish-marketplace",

0 commit comments

Comments
 (0)