Skip to content

Commit b5d4fae

Browse files
test(mosaic): consolidate reverification overlay coverage
1 parent 6f2c70b commit b5d4fae

2 files changed

Lines changed: 10 additions & 66 deletions

File tree

‎packages/mosaic/src/features/reverification/__tests__/reverification.controller.test.ts‎

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -158,68 +158,3 @@ describe('reverification interrupted requests', () => {
158158
actor.stop();
159159
});
160160
});
161-
162-
describe('reverification preparation overlays', () => {
163-
it('blocks leaving a pending picker and preserves help opened over the factor', async () => {
164-
const effects = deps();
165-
const pending = deferred<ReverificationPreparation>();
166-
effects.prepare = vi.fn(() => pending.promise);
167-
const actor = createActor(reverificationMachine, { context: { deps: effects } }).start();
168-
actor.send({ type: 'START', scope: { runId: Symbol(), sessionId: 'session' } });
169-
await tick();
170-
actor.send({ type: 'SHOW_HELP' });
171-
expect(actor.getSnapshot().context.overlay).toEqual(['help']);
172-
expect(actor.can({ type: 'BACK' })).toBe(true);
173-
actor.send({ type: 'BACK' });
174-
actor.send({ type: 'SHOW_METHODS' });
175-
actor.send({ type: 'SELECT_METHOD', id: work.id });
176-
expect(actor.can({ type: 'BACK' })).toBe(false);
177-
expect(actor.can({ type: 'SHOW_HELP' })).toBe(false);
178-
actor.send({ type: 'BACK' });
179-
actor.send({ type: 'SHOW_HELP' });
180-
expect(actor.getSnapshot().context.overlay).toEqual(['method-picker']);
181-
actor.stop();
182-
});
183-
184-
it('keeps help visible when the send behind it settles', async () => {
185-
const effects = deps();
186-
const pending = deferred<ReverificationPreparation>();
187-
effects.prepare = vi.fn(() => pending.promise);
188-
const actor = createActor(reverificationMachine, { context: { deps: effects } }).start();
189-
actor.send({ type: 'START', scope: { runId: Symbol(), sessionId: 'session' } });
190-
await tick();
191-
actor.send({ type: 'SHOW_HELP' });
192-
pending.resolve({ reusableUntil: Date.now() + 60_000 });
193-
await tick();
194-
expect(actor.getSnapshot().context.overlay).toEqual(['help']);
195-
expect(actor.getSnapshot().context.operation).toBeNull();
196-
actor.send({ type: 'BACK' });
197-
expect(actor.getSnapshot().context.overlay).toEqual([]);
198-
actor.stop();
199-
});
200-
});
201-
202-
it.each([false, true])(
203-
'keeps a picker opened over the original pending factor when the send settles (failure %s)',
204-
async fails => {
205-
const effects = deps();
206-
const pending = deferred<ReverificationPreparation>();
207-
effects.prepare = vi.fn(() => pending.promise);
208-
const actor = createActor(reverificationMachine, { context: { deps: effects } }).start();
209-
actor.send({ type: 'START', scope: { runId: Symbol(), sessionId: 'session' } });
210-
await tick();
211-
actor.send({ type: 'SHOW_METHODS' });
212-
expect(actor.can({ type: 'BACK' })).toBe(true);
213-
expect(actor.can({ type: 'SHOW_HELP' })).toBe(true);
214-
if (fails) {
215-
pending.reject({ code: 'form_identifier_not_found', message: 'Unknown identifier' });
216-
} else {
217-
pending.resolve({ reusableUntil: Date.now() + 60_000 });
218-
}
219-
await tick();
220-
expect(actor.getSnapshot().context.overlay).toEqual(['method-picker']);
221-
actor.send({ type: 'BACK' });
222-
expect(actor.getSnapshot().context.overlay).toEqual([]);
223-
actor.stop();
224-
},
225-
);

‎packages/mosaic/src/features/reverification/__tests__/reverification.feature.test.tsx‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,12 +677,20 @@ describe('Reverification', () => {
677677
},
678678
);
679679

680-
it('keeps the cooldown of a code sent while the picker is open', async () => {
680+
it.each(['picker', 'help'] as const)('keeps the cooldown of a code sent while the %s is open', async step => {
681681
const { prepare, user } = await startSendingCode();
682682
await useAnotherMethod(user);
683+
if (step === 'help') {
684+
await user.click(await screen.findByRole('button', { name: 'Get help' }));
685+
expect(await screen.findByText(/If you have trouble verifying your account/)).toBeVisible();
686+
}
683687

684688
prepare.release();
685689
await settle();
690+
if (step === 'help') {
691+
expect(screen.getByText(/If you have trouble verifying your account/)).toBeVisible();
692+
await back(user);
693+
}
686694
expect(screen.getByRole('button', { name: 'Continue with your password' })).toBeVisible();
687695
await back(user);
688696

@@ -1196,6 +1204,7 @@ describe('Reverification', () => {
11961204
await waitFor(() => expect(secondPrepare.requests).toHaveLength(1));
11971205
expect(method('Continue with your password')).toBeDisabled();
11981206
expect(method('Back')).toBeDisabled();
1207+
expect(method('Get help')).toBeDisabled();
11991208
secondPrepare.release();
12001209
expect(await screen.findByText(STEP.phoneCode)).toBeVisible();
12011210
expect(fapi.verification.firstFactorVerification?.strategy).toBe('phone_code');

0 commit comments

Comments
 (0)