@guidepup/playwright 0.16.2 → 0.16.3

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.
Files changed (2) hide show
  1. package/lib/nvdaTest.js +16 -3
  2. package/package.json +1 -1
package/lib/nvdaTest.js CHANGED
@@ -14,9 +14,19 @@ const MOVE_TO_TOP = {
14
14
  keyCode: [guidepup_1.WindowsKeyCodes.Home],
15
15
  modifiers: [guidepup_1.WindowsModifiers.Control],
16
16
  };
17
+ const cleanString = (str) => str
18
+ .toLowerCase()
19
+ // REF: https://github.com/nvaccess/nvda/blob/master/source/locale/en/symbols.dic
20
+ .replace(/[|¦:;'"`\-‐–—·_()[\]{}\\^~]/g, " ")
21
+ .replace(/\s+/g, " ")
22
+ .trim();
17
23
  const hasFocus = ({ applicationName, pageTitle, windowTitle, }) => {
18
- return ((pageTitle.length && windowTitle.startsWith(pageTitle)) ||
19
- windowTitle.includes(applicationName));
24
+ const cleanedApplicationName = cleanString(applicationName);
25
+ const cleanedPageTitle = cleanString(pageTitle);
26
+ const cleanedWindowTitle = cleanString(windowTitle);
27
+ return ((cleanedPageTitle.length &&
28
+ cleanedWindowTitle.startsWith(cleanedPageTitle)) ||
29
+ cleanedWindowTitle.includes(cleanedApplicationName));
20
30
  };
21
31
  const focusBrowser = async ({ applicationName, pageTitle, }) => {
22
32
  await nvdaPlaywright.perform(nvdaPlaywright.keyboardCommands.reportTitle);
@@ -56,7 +66,10 @@ exports.nvdaTest = test_1.test.extend({
56
66
  await nvdaPlaywright.perform(nvdaPlaywright.keyboardCommands.exitFocusMode);
57
67
  const pageTitle = await page.title();
58
68
  // Ensure application is brought to front and focused.
59
- await focusBrowser({ applicationName, pageTitle });
69
+ await focusBrowser({
70
+ applicationName,
71
+ pageTitle,
72
+ });
60
73
  // Ensure the document is ready and focused.
61
74
  await page.bringToFront();
62
75
  await page.locator("body").waitFor();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guidepup/playwright",
3
- "version": "0.16.2",
3
+ "version": "0.16.3",
4
4
  "description": "Screen reader automation library for Playwright testing. ",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",