Skip to content

Commit

Permalink
fix: Use a different approach to serving static files in tests that _…
Browse files Browse the repository at this point in the history
…does_ work with symbolic links, in Edge. Kudos ruifigueira for the suggestion, in microsoft/playwright#13968 (comment).
  • Loading branch information
smockle committed Oct 22, 2024
1 parent 11df7c6 commit 0f87504
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 11 deletions.
3 changes: 0 additions & 3 deletions playwright.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ const config = {
use: {
...devices["Desktop Edge"],
channel: "msedge",
baseURL: `file://${url.fileURLToPath(
new URL("./examples/", import.meta.url)
)}`,
},
},
],
Expand Down
28 changes: 24 additions & 4 deletions tests/nvda.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// @ts-check
import { test, expect } from "@playwright/test";

import { test as baseTest, expect } from "@playwright/test";
import { nvda, WindowsKeyCodes, WindowsModifiers } from "@guidepup/guidepup";
import path from "node:path";

// Pre-requisites:
// - Install NVDA
Expand All @@ -21,12 +23,30 @@ import { nvda, WindowsKeyCodes, WindowsModifiers } from "@guidepup/guidepup";
// - Run `REG ADD HKCU\Software\Guidepup\Nvda /v guidepup_nvda_0.1.1-2021.3.1 /t REG_SZ /d "C:\Program Files (x86)\NVDA\\"`
// (version is from https://github.com/guidepup/setup/blob/82179ec8915680344d0db320422dd18e29593eb9/package.json#L60C27-L60C41)

const test = baseTest.extend({
context: async ({ context }, run) => {
await context.route("**/*", (route, request) =>
route.fulfill({
path: path.join(
import.meta.dirname,
"..",
new URL(request.url()).pathname
),
})
);
await run(context);
},
});

if (process.platform === "win32") {
test.beforeEach(async ({ page }) => {
// Navigate to suggested test example page
await page.goto("suggested-text/index.html", {
waitUntil: "load",
});
await page.goto(
"http://localhost:3333/examples/suggested-text/index.html",
{
waitUntil: "load",
}
);

// Start NVDA
await nvda.start();
Expand Down
27 changes: 23 additions & 4 deletions tests/voiceover.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
// @ts-check

import { test, expect } from "@playwright/test";
import { test as baseTest, expect } from "@playwright/test";
import { voiceOver } from "@guidepup/guidepup";
import path from "node:path";

// Pre-requisites:
// - Run `defaults write com.apple.VoiceOver4/default SCREnableAppleScript 1`

const test = baseTest.extend({
context: async ({ context }, run) => {
await context.route("**/*", (route, request) =>
route.fulfill({
path: path.join(
import.meta.dirname,
"..",
new URL(request.url()).pathname
),
})
);
await run(context);
},
});

if (process.platform === "darwin") {
test.beforeAll(async () => {
// Start VoiceOver
Expand All @@ -14,9 +30,12 @@ if (process.platform === "darwin") {

test.beforeEach(async ({ page }) => {
// Navigate to suggested text example page
await page.goto("suggested-text/index.html", {
waitUntil: "load",
});
await page.goto(
"http://localhost:3333/examples/suggested-text/index.html",
{
waitUntil: "load",
}
);

// From https://github.com/guidepup/guidepup-playwright/blob/34c3973dd98e19c81f468352e13bac5b8434b28f/src/voiceOverTest.ts#L97-L110:

Expand Down

0 comments on commit 0f87504

Please sign in to comment.