halkyon_app reads where the device's person stands with SimpleLogin (nothing to show, linked, or missing) and shows it in SimpleLoginSection, which each app places above the password part: Add SimpleLogin, once added one more way in. GitHub is added to nobody where SimpleLogin is offered, and Learn's Profile offers an anonymous person SimpleLogin alone there (D23). No cut-off day, reminder or banner (D24): with the developer the only person on learn.halkyon.eu, the cut-off is the operator taking GitHub's OAuth app out of the deploy's settings once that account has SimpleLogin. ADR 0020 records it and drops step 5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
117 lines
3.5 KiB
Dart
117 lines
3.5 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:halkyon_app/halkyon_app.dart';
|
|
import 'package:halkyon_app/testing.dart';
|
|
import 'package:material_ui/material_ui.dart';
|
|
|
|
const password = 'correct horse battery';
|
|
|
|
void main() {
|
|
late FakeAuthGateway gateway;
|
|
late TestAppDependencies dependencies;
|
|
|
|
setUp(() {
|
|
gateway = FakeAuthGateway();
|
|
dependencies = TestAppDependencies(gateway: gateway);
|
|
dependencies.simpleLoginGateway.isOffered = true;
|
|
});
|
|
tearDown(() => dependencies.dispose());
|
|
|
|
/// An app's account section.
|
|
Future<void> show(WidgetTester tester) async {
|
|
tester.view.physicalSize = const Size(412, 1200);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
await tester.pumpWidget(
|
|
testApp(
|
|
const Scaffold(
|
|
body: Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 16),
|
|
child: SimpleLoginSection(gapAbove: 16),
|
|
),
|
|
),
|
|
dependencies: dependencies,
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
}
|
|
|
|
Future<void> signInAccount() =>
|
|
gateway.useSession(const SessionGrant('person-9', 'session-9'));
|
|
|
|
testWidgets('an account without SimpleLogin is offered to add it', (
|
|
tester,
|
|
) async {
|
|
await signInAccount();
|
|
await show(tester);
|
|
|
|
expect(find.text('SimpleLogin'), findsOneWidget);
|
|
expect(find.widgetWithText(ListTile, 'Add SimpleLogin'), findsOneWidget);
|
|
expect(
|
|
find.text('Sign in with SimpleLogin, or with your Proton account.'),
|
|
findsOneWidget,
|
|
);
|
|
});
|
|
|
|
testWidgets('nothing where the instance offers no SimpleLogin', (
|
|
tester,
|
|
) async {
|
|
dependencies.simpleLoginGateway.isOffered = false;
|
|
await signInAccount();
|
|
await show(tester);
|
|
|
|
expect(find.textContaining('SimpleLogin'), findsNothing);
|
|
});
|
|
|
|
testWidgets('an account that has it: one more way in', (tester) async {
|
|
dependencies.simpleLoginGateway.addAccount(
|
|
'person-9',
|
|
subject: 'simplelogin-ben',
|
|
);
|
|
await signInAccount();
|
|
await show(tester);
|
|
|
|
expect(find.widgetWithText(ListTile, 'SimpleLogin'), findsOneWidget);
|
|
expect(find.text('Signs you in'), findsOneWidget);
|
|
expect(find.text('Add SimpleLogin'), findsNothing);
|
|
});
|
|
|
|
testWidgets('adding it: an account with its keys is done once the browser '
|
|
'is back, says so, and shows it as a way in', (tester) async {
|
|
final material = await dependencies.crypto.newKeys(password);
|
|
dependencies.simpleLoginGateway.accounts['person-9'] =
|
|
FakeSimpleLoginAccount(handle: 'ben', keys: material.setup);
|
|
await signInAccount();
|
|
await show(tester);
|
|
|
|
await tester.tap(find.widgetWithText(ListTile, 'Add SimpleLogin'));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('SimpleLogin added.'), findsOneWidget);
|
|
expect(dependencies.simpleLoginGateway.linked, {
|
|
'simplelogin-anna': 'person-9',
|
|
});
|
|
expect(find.text('Signs you in'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets("a SimpleLogin account that is another account's is refused", (
|
|
tester,
|
|
) async {
|
|
dependencies.simpleLoginGateway.addAccount(
|
|
'person-7',
|
|
subject: 'simplelogin-anna',
|
|
);
|
|
await signInAccount();
|
|
await show(tester);
|
|
|
|
await tester.tap(find.widgetWithText(ListTile, 'Add SimpleLogin'));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(
|
|
find.text('This SimpleLogin account belongs to another account here.'),
|
|
findsOneWidget,
|
|
);
|
|
expect(dependencies.simpleLoginGateway.linked, {
|
|
'simplelogin-anna': 'person-7',
|
|
});
|
|
});
|
|
}
|