Skip to content

Commit

Permalink
fix(e2e): account for a recurring MFA reminder when singing in to clo…
Browse files Browse the repository at this point in the history
…ud ui (#6429)
  • Loading branch information
gribnoysup authored Nov 1, 2024
1 parent 3e48138 commit 649c208
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion packages/compass-e2e-tests/helpers/compass-web-sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,44 @@ export async function spawnCompassWebSandboxAndSignInToAtlas(

debug('Waiting for the auth to finish ...');

const res = await authenticatePromise;
let authenticatedPromiseSettled = false;

// Atlas Cloud will periodically remind user to enable MFA (which we can't
// enable in e2e CI environment), so to account for that, in parallel to
// waiting for auth to finish, we'll wait for the MFA screen to show up and
// skip it if it appears
const [, settledRes] = await Promise.allSettled([
(async () => {
const remindMeLaterButton = 'button*=Remind me later';

await electronProxyRemote.waitUntil(
async () => {
return (
authenticatedPromiseSettled ||
(await electronProxyRemote.$(remindMeLaterButton).isDisplayed())
);
},
// Takes awhile for the redirect to land on this reminder page when it
// happens, so no need to bombard the browser with displayed checks
{ interval: 2000 }
);

if (authenticatedPromiseSettled) {
return;
}

await electronProxyRemote.$(remindMeLaterButton).click();
})(),
authenticatePromise.finally(() => {
authenticatedPromiseSettled = true;
}),
]);

if (settledRes.status === 'rejected') {
throw settledRes.reason;
}

const res = settledRes.value;

if (res.ok === false || !(await res.json()).projectId) {
throw new Error(
Expand Down

0 comments on commit 649c208

Please sign in to comment.