@guidepup/playwright 0.19.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.voiceOverTest = void 0;
4
- const test_1 = require("@playwright/test");
5
4
  const guidepup_1 = require("@guidepup/guidepup");
6
- const applicationNameMap_1 = require("./applicationNameMap");
7
- const delay_1 = require("./delay");
5
+ const applicationIdMap_1 = require("./applicationIdMap");
6
+ const navigateVoiceOverToWebContent_1 = require("./navigateVoiceOverToWebContent");
7
+ const test_1 = require("@playwright/test");
8
8
  const voiceOverPlaywright = guidepup_1.voiceOver;
9
9
  /**
10
10
  * These tests extend the default Playwright environment that launches the
11
- * browser with a running instance of the VoiceOver screen reader for MacOS.
11
+ * browser with a running instance of the VoiceOver screen reader for macOS.
12
12
  *
13
13
  * A fresh started VoiceOver instance `voiceOver` is provided to each test.
14
14
  */
@@ -16,82 +16,16 @@ exports.voiceOverTest = test_1.test.extend({
16
16
  voiceOverStartOptions: { capture: "initial" },
17
17
  voiceOver: async ({ browserName, page, voiceOverStartOptions }, use) => {
18
18
  try {
19
- const applicationName = applicationNameMap_1.applicationNameMap[browserName];
20
- if (!applicationName) {
21
- throw new Error(`Browser ${browserName} is not installed.`);
19
+ const applicationId = applicationIdMap_1.applicationIdMap[browserName];
20
+ if (!applicationId) {
21
+ throw new Error(`Browser ${browserName} is not recognised.`);
22
22
  }
23
- voiceOverPlaywright.navigateToWebContent = async ({ capture } = {}) => {
24
- // Ensure application is brought to front and focused.
25
- await (0, guidepup_1.macOSActivate)(applicationName);
26
- // Cancel auto navigation.
27
- await voiceOverPlaywright.perform({ keyCode: guidepup_1.MacOSKeyCodes.Control }, { capture: false });
28
- await (0, delay_1.delay)(100);
29
- // Ensure the document is ready and focused.
30
- await page.bringToFront();
31
- await page.locator("body").waitFor();
32
- try {
33
- // Add an interactive marker to the page that will force VoiceOver
34
- // to listen to events emitted by Playwright interactions when
35
- // navigated to.
36
- await page.evaluate(() => {
37
- const marker = document.createElement("input");
38
- marker.id = "__guidepup_marker__";
39
- marker.type = "text";
40
- marker.value = "Guidepup Marker";
41
- marker.readOnly = true;
42
- marker.tabIndex = -1;
43
- marker.autocomplete = "off";
44
- marker.setAttribute("aria-label", "Guidepup Marker");
45
- marker.style.cssText = `
46
- position: absolute;
47
- width: 1px;
48
- height: 1px;
49
- overflow: hidden;
50
- clip: rect(0 0 0 0);
51
- white-space: nowrap;
52
- `;
53
- document.body.prepend(marker);
54
- });
55
- // Open the web item chooser.
56
- await voiceOverPlaywright.perform(voiceOverPlaywright.keyboardCommands.openItemChooser, { capture: false });
57
- await (0, delay_1.delay)(500);
58
- // Filter by "web content" - currently web content items for all browsers
59
- // are suffixed by "web content".
60
- for (const character of "web content") {
61
- await voiceOverPlaywright.type(character, { capture: false });
62
- await (0, delay_1.delay)(100);
63
- }
64
- // Select the web content window spot.
65
- await voiceOverPlaywright.perform({ keyCode: guidepup_1.MacOSKeyCodes.Enter }, { capture: false });
66
- await (0, delay_1.delay)(100);
67
- // Navigate into web content.
68
- await voiceOverPlaywright.interact({ capture: false });
69
- await (0, delay_1.delay)(100);
70
- // Navigate to the beginning of the web content.
71
- await voiceOverPlaywright.perform(voiceOverPlaywright.keyboardCommands.moveToBeginningOfText, { capture: false });
72
- await (0, delay_1.delay)(100);
73
- // Cancel auto navigation
74
- await voiceOverPlaywright.perform({ keyCode: guidepup_1.MacOSKeyCodes.Control }, { capture: false });
75
- await (0, delay_1.delay)(100);
76
- // Navigate to the Guidepup marker element at beginning of the web
77
- // content.
78
- await voiceOverPlaywright.perform(voiceOverPlaywright.keyboardCommands.moveToBeginningOfText, { capture: false });
79
- await (0, delay_1.delay)(100);
80
- // Navigate to the first element of the page using the provided
81
- // capture settings.
82
- await voiceOverPlaywright.next({ capture });
83
- }
84
- finally {
85
- // Remove the temporary Guidepup marker element to restore original
86
- // page structure.
87
- await page.evaluate(() => {
88
- const marker = document.querySelector("#__guidepup_marker__");
89
- if (marker) {
90
- document.body.removeChild(marker);
91
- }
92
- });
93
- }
94
- };
23
+ voiceOverPlaywright.navigateToWebContent = ({ capture } = {}) => (0, navigateVoiceOverToWebContent_1.navigateVoiceOverToWebContent)({
24
+ voiceOver: voiceOverPlaywright,
25
+ page,
26
+ applicationId,
27
+ capture,
28
+ });
95
29
  await voiceOverPlaywright.start(voiceOverStartOptions);
96
30
  await use(voiceOverPlaywright);
97
31
  }
@@ -0,0 +1,2 @@
1
+ import type { PlaywrightTestConfig } from "@playwright/test";
2
+ export declare const withGuidepup: (config: PlaywrightTestConfig) => PlaywrightTestConfig;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withGuidepup = void 0;
4
+ const screenReaderConfig_1 = require("./screenReaderConfig");
5
+ const withGuidepup = (config) => ({
6
+ ...config,
7
+ workers: screenReaderConfig_1.screenReaderConfig.workers,
8
+ fullyParallel: screenReaderConfig_1.screenReaderConfig.fullyParallel,
9
+ use: {
10
+ ...config.use,
11
+ ...screenReaderConfig_1.screenReaderConfig.use,
12
+ },
13
+ projects: config.projects?.map((project) => ({
14
+ ...project,
15
+ use: {
16
+ ...project.use,
17
+ ...screenReaderConfig_1.screenReaderConfig.use,
18
+ },
19
+ })),
20
+ });
21
+ exports.withGuidepup = withGuidepup;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guidepup/playwright",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "description": "Screen reader automation library for Playwright testing. ",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -34,19 +34,22 @@
34
34
  "prepublish": "yarn build",
35
35
  "pretest": "npx playwright install chromium firefox webkit",
36
36
  "test:nvda": "yarn test:nvda:chromium && yarn test:nvda:firefox",
37
- "test:screenreader": "yarn test:screenreader:chromium",
37
+ "test:orca": "yarn test:orca:firefox",
38
+ "test:screenreader": "yarn test:screenreader:chromium && yarn test:screenreader:firefox",
38
39
  "test:voiceover": "yarn test:voiceover:chromium && yarn test:voiceover:firefox && yarn test:voiceover:webkit",
39
40
  "test:nvda:chromium": "playwright test --config ./examples/playwright-nvda/chromium.config.ts ./examples/playwright-nvda/tests/chromium/",
40
41
  "test:nvda:firefox": "playwright test --config ./examples/playwright-nvda/firefox.config.ts ./examples/playwright-nvda/tests/firefox/",
42
+ "test:orca:firefox": "playwright test --config ./examples/playwright-orca/firefox.config.ts ./examples/playwright-orca/tests/firefox/",
41
43
  "test:screenreader:chromium": "playwright test --config ./examples/playwright-screenreader/chromium.config.ts ./examples/playwright-screenreader/tests/chromium/",
44
+ "test:screenreader:firefox": "playwright test --config ./examples/playwright-screenreader/firefox.config.ts ./examples/playwright-screenreader/tests/firefox/",
42
45
  "test:voiceover:chromium": "playwright test --config ./examples/playwright-voiceover/chromium.config.ts ./examples/playwright-voiceover/tests/chromium/",
43
46
  "test:voiceover:firefox": "playwright test --config ./examples/playwright-voiceover/firefox.config.ts ./examples/playwright-voiceover/tests/firefox/",
44
47
  "test:voiceover:webkit": "playwright test --config ./examples/playwright-voiceover/webkit.config.ts ./examples/playwright-voiceover/tests/webkit/"
45
48
  },
46
49
  "devDependencies": {
47
- "@guidepup/guidepup": "^0.33.0",
48
- "@guidepup/record": "^0.1.0",
49
- "@playwright/test": "^1.60.0",
50
+ "@guidepup/guidepup": "^0.36.1",
51
+ "@guidepup/record": "^0.3.0",
52
+ "@playwright/test": "^1.62.1",
50
53
  "@types/node": "^24.10.1",
51
54
  "@typescript-eslint/eslint-plugin": "^8.48.1",
52
55
  "@typescript-eslint/parser": "^8.48.1",
@@ -58,8 +61,8 @@
58
61
  "typescript": "^5.9.3"
59
62
  },
60
63
  "peerDependencies": {
61
- "@guidepup/guidepup": ">=0.33.0",
62
- "@playwright/test": "^1.57.0"
64
+ "@guidepup/guidepup": ">=0.36.1",
65
+ "@playwright/test": ">=1.62.1"
63
66
  },
64
67
  "resolutions": {
65
68
  "strip-ansi": "6.0.1",