Skip to content

Commit

Permalink
Remove Discouraged 'networkidle' Calls (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSwigerAtBentley authored Oct 29, 2024
1 parent 56e8cf2 commit 181937a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Remove discouraged 'networkidle'",
"packageName": "@itwin/oidc-signin-tool",
"email": "[email protected]",
"dependentChangeType": "patch"
}
9 changes: 5 additions & 4 deletions packages/oidc-signin-tool/src/SignInAutomation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ export async function automatedSignOut<T>(
}

async function handleErrorPage<T>({ page }: AutomatedContextBase<T>): Promise<void> {
await page.waitForLoadState("networkidle");
const pageTitle = await page.title();
let errMsgText;

Expand Down Expand Up @@ -166,7 +165,6 @@ async function handlePingLoginPage<T>(context: AutomatedSignInContext<T>): Promi
allow = page.locator(testSelectors.pingAllowSubmit);
await allow.click();

await page.waitForLoadState("networkidle");
const error = page.getByText(
"We didn't recognize the email address or password you entered. Please try again.",
);
Expand All @@ -187,10 +185,14 @@ async function handlePingLoginPage<T>(context: AutomatedSignInContext<T>): Promi
async function handleFederatedSignin<T>(context: AutomatedSignInContext<T>): Promise<void> {
const { page } = context;

await page.waitForLoadState("networkidle");
if (-1 === page.url().indexOf("microsoftonline"))
return;

// Wait for either msUserNameField or fedPassword to be visible
const msUserNameFieldPromise = page.waitForSelector(testSelectors.msUserNameField, { state: "visible" });
const fedPasswordPromise = page.waitForSelector(testSelectors.fedPassword, { state: "visible" });
await Promise.race([msUserNameFieldPromise, fedPasswordPromise]);

if (await checkSelectorExists(page, testSelectors.msUserNameField)) {
await page.locator(testSelectors.msUserNameField).fill(context.user.email);
const msSubmit = await page.waitForSelector(testSelectors.msSubmit);
Expand Down Expand Up @@ -270,7 +272,6 @@ async function checkSelectorExists(
}

async function checkErrorOnPage(page: Page, selector: string): Promise<void> {
await page.waitForLoadState("networkidle");
const errMsgElement = await page.$(selector);
if (errMsgElement) {
const errMsgText = await errMsgElement.textContent();
Expand Down

0 comments on commit 181937a

Please sign in to comment.