Skip to content

Commit 436d8a6

Browse files
fix: lint issue
1 parent 07372de commit 436d8a6

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

test/source/tests/page-recipe/oauth-page-recipe.ts

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,6 @@ import { Url } from '../../core/common';
99
export class OauthPageRecipe extends PageRecipe {
1010
private static longTimeout = 40;
1111

12-
/**
13-
* Check if an error is a "Navigating frame was detached" error.
14-
* This can happen when the OAuth page closes during navigation (e.g., successful auth).
15-
* @param e - The error to check
16-
* @returns true if this is a frame detached error that can be safely ignored
17-
*/
18-
private static isFrameDetachedError(e: unknown): boolean {
19-
if (!e) {
20-
return false;
21-
}
22-
// Check if it's an Error object with a message property
23-
if (e instanceof Error) {
24-
return e.message.includes('Navigating frame was detached') || e.message.includes('frame was detached');
25-
}
26-
// Check if it's already a string
27-
if (typeof e === 'string') {
28-
return e.includes('Navigating frame was detached') || e.includes('frame was detached');
29-
}
30-
// For other types, we can't reliably check - return false to be safe
31-
return false;
32-
}
33-
34-
/**
35-
* Safely navigate to a URL, ignoring "frame was detached" errors.
36-
* The OAuth page may close during navigation on successful auth.
37-
* @param oauthPage - The OAuth page to navigate
38-
* @param url - The URL to navigate to
39-
*/
40-
private static async safeGoto(oauthPage: ControllablePage, url: string): Promise<void> {
41-
try {
42-
await oauthPage.target.goto(url);
43-
} catch (e: unknown) {
44-
if (!OauthPageRecipe.isFrameDetachedError(e)) {
45-
throw e;
46-
}
47-
// Ignore frame detached errors - page closed successfully
48-
}
49-
}
50-
5112
public static mock = async (
5213
t: AvaContext,
5314
oauthPage: ControllablePage,
@@ -204,4 +165,43 @@ export class OauthPageRecipe extends PageRecipe {
204165
return await OauthPageRecipe.google(t, oauthPage, acctEmail, action); // retry, it should pick up where it left off
205166
}
206167
};
168+
169+
/**
170+
* Check if an error is a "Navigating frame was detached" error.
171+
* This can happen when the OAuth page closes during navigation (e.g., successful auth).
172+
* @param e - The error to check
173+
* @returns true if this is a frame detached error that can be safely ignored
174+
*/
175+
private static isFrameDetachedError(e: unknown): boolean {
176+
if (!e) {
177+
return false;
178+
}
179+
// Check if it's an Error object with a message property
180+
if (e instanceof Error) {
181+
return e.message.includes('Navigating frame was detached') || e.message.includes('frame was detached');
182+
}
183+
// Check if it's already a string
184+
if (typeof e === 'string') {
185+
return e.includes('Navigating frame was detached') || e.includes('frame was detached');
186+
}
187+
// For other types, we can't reliably check - return false to be safe
188+
return false;
189+
}
190+
191+
/**
192+
* Safely navigate to a URL, ignoring "frame was detached" errors.
193+
* The OAuth page may close during navigation on successful auth.
194+
* @param oauthPage - The OAuth page to navigate
195+
* @param url - The URL to navigate to
196+
*/
197+
private static async safeGoto(oauthPage: ControllablePage, url: string): Promise<void> {
198+
try {
199+
await oauthPage.target.goto(url);
200+
} catch (e: unknown) {
201+
if (!OauthPageRecipe.isFrameDetachedError(e)) {
202+
throw e;
203+
}
204+
// Ignore frame detached errors - page closed successfully
205+
}
206+
}
207207
}

0 commit comments

Comments
 (0)