Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(e2e): account for a recurring MFA reminder when singing in to cloud ui #6429

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading