File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,14 +62,27 @@ type FocusBrowserParams = {
6262 pageTitle : string ;
6363} ;
6464
65+ const cleanString = ( str : string ) : string =>
66+ str
67+ . toLowerCase ( )
68+ // REF: https://github.com/nvaccess/nvda/blob/master/source/locale/en/symbols.dic
69+ . replace ( / [ | ¦ : ; ' " ` \- ‐ – — · _ ( ) [ \] { } \\ ^ ~ ] / g, " " )
70+ . replace ( / \s + / g, " " )
71+ . trim ( ) ;
72+
6573const hasFocus = ( {
6674 applicationName,
6775 pageTitle,
6876 windowTitle,
6977} : FocusBrowserParams & { windowTitle : string } ) => {
78+ const cleanedApplicationName = cleanString ( applicationName ) ;
79+ const cleanedPageTitle = cleanString ( pageTitle ) ;
80+ const cleanedWindowTitle = cleanString ( windowTitle ) ;
81+
7082 return (
71- ( pageTitle . length && windowTitle . startsWith ( pageTitle ) ) ||
72- windowTitle . includes ( applicationName )
83+ ( cleanedPageTitle . length &&
84+ cleanedWindowTitle . startsWith ( cleanedPageTitle ) ) ||
85+ cleanedWindowTitle . includes ( cleanedApplicationName )
7386 ) ;
7487} ;
7588
@@ -161,7 +174,10 @@ export const nvdaTest = test.extend<{
161174
162175 const pageTitle = await page . title ( ) ;
163176 // Ensure application is brought to front and focused.
164- await focusBrowser ( { applicationName, pageTitle } ) ;
177+ await focusBrowser ( {
178+ applicationName,
179+ pageTitle,
180+ } ) ;
165181
166182 // Ensure the document is ready and focused.
167183 await page . bringToFront ( ) ;
You can’t perform that action at this time.
0 commit comments