Skip to content

Commit d2c71d6

Browse files
committed
fix(e2e): account for a recurring MFA reminder when singing in to cloud ui
1 parent 3e48138 commit d2c71d6

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

packages/compass-e2e-tests/helpers/compass-web-sandbox.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,44 @@ export async function spawnCompassWebSandboxAndSignInToAtlas(
132132

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

135-
const res = await authenticatePromise;
135+
let authenticatedPromiseSettled = false;
136+
137+
// Atlas Cloud will periodically remind user to enable MFA (which we can't
138+
// enable in e2e CI environment), so to account for that, in parallel to
139+
// waiting for auth to finish, we'll wait for the MFA screen to show up and
140+
// skip it if it appears
141+
const [, settledRes] = await Promise.allSettled([
142+
(async () => {
143+
const remindMeLaterButton = 'button*=Remind me later';
144+
145+
await electronProxyRemote.waitUntil(
146+
async () => {
147+
return (
148+
authenticatedPromiseSettled ||
149+
(await electronProxyRemote.$(remindMeLaterButton).isDisplayed())
150+
);
151+
},
152+
// Takes awhile for the redirect to land on this reminder page when it
153+
// happens, so no need to bombard the browser with displayed checks
154+
{ interval: 2000 }
155+
);
156+
157+
if (authenticatedPromiseSettled) {
158+
return;
159+
}
160+
161+
await electronProxyRemote.$(remindMeLaterButton).click();
162+
})(),
163+
authenticatePromise.finally(() => {
164+
authenticatedPromiseSettled = true;
165+
}),
166+
]);
167+
168+
if (settledRes.status === 'rejected') {
169+
throw settledRes.reason;
170+
}
171+
172+
const res = settledRes.value;
136173

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

0 commit comments

Comments
 (0)