Skip to content

Commit ac9ac9b

Browse files
wesbillmanBrain
andcommitted
test(mobile): cover consent for saved browser-binding identities
Extend the browser journey through a persisted unconfirmed account key, cancellation, restart and explicit binding approval. Co-authored-by: Brain <1a02c72794dcd0f07058a353bc3a81f4028b8c77c92c87fce6d5c8b85970a20b@buzz.block.builderlab.xyz> Signed-off-by: Wes <[email protected]>
1 parent dfb29fe commit ac9ac9b

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

‎mobile/test/features/onboarding/hosted_backup_consent_test.dart‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,46 @@ void main() {
318318
isNull,
319319
); // Web binding has never promised mobile backup.
320320
expect(f.flow.stage, HostedFlowStage.browserReturned);
321+
322+
// A returning account may already have a saved key from an interrupted
323+
// setup. No adoption occurs, so the bind-only gate must ask for consent.
324+
await f.flow.signOutAccount();
325+
f.subject = 'returning-owner';
326+
f.bound = null;
327+
await f.store.create(f.secondKeys.nsec);
328+
await f.flow.account.exchange(
329+
code: 'synthetic-code',
330+
verifier: 'v' * 43,
331+
);
332+
debugDefaultTargetPlatformOverride = null;
333+
await f.restart(tester);
334+
f.requests.clear();
335+
openBindLink();
336+
await f.settle(tester);
337+
expect(find.text('Link your identity?'), findsOneWidget);
338+
expect(find.textContaining('No backup is uploaded'), findsOneWidget);
339+
expect(find.text(fullNpub(f.secondKeys.public)!), findsOneWidget);
340+
expect((await f.store.read())!.backup, isNull);
341+
expect(f.bound, isNull);
342+
expect(f.sent('/verify'), isEmpty);
343+
await f.tap(tester, 'Cancel setup');
344+
expect((await f.store.read())!.pubkey, f.secondKeys.public);
345+
expect(f.bound, isNull);
346+
expect(f.sent('/verify'), isEmpty);
347+
348+
// Cancellation and restart retain the key, but never retain approval.
349+
await f.restart(tester);
350+
openBindLink();
351+
await f.settle(tester);
352+
expect(find.text('Link your identity?'), findsOneWidget);
353+
expect(f.sent('/verify'), isEmpty);
354+
await f.tap(tester, 'Link and continue');
355+
expect(f.bound, f.secondKeys.public);
356+
expect(f.sent('/verify'), hasLength(1));
357+
expect(f.sent('/enrollment'), isEmpty);
358+
expect(f.sent('/nsec-backups'), isEmpty);
359+
expect((await f.store.read())!.backup, isNull);
360+
expect(f.flow.stage, HostedFlowStage.browserReturned);
321361
} finally {
322362
await tester.pumpWidget(const SizedBox.shrink());
323363
await tester.pump();

0 commit comments

Comments
 (0)