halkyon/packages/halkyon_app/test/simplelogin/widget/simplelogin_section_test.dart
Tizian 「ティツィアーン」 830aea10fe
feat(learn,app): explanations wait behind a question mark beside their title
What explains a setting or a section, rather than what is the person's
own, moves behind halkyon_ui's HelpButton, beside its title through the
new ExplainedTitle (the developer's review of 3 Nov 2026): in Learn's
settings (citations, the Pomodoro timer, grammar, the web search,
Jellyfin, the device's dictionaries, counting one's learning), the study
settings, export's progress, the Jellyfin tags and the study button's
back first; in halkyon_app, setting up a password, adding SimpleLogin,
own keys not allowed, the profile page's link back and the operator's
grant sheet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-11-04 09:32:05 +01:00

119 lines
3.7 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:halkyon_app/halkyon_app.dart';
import 'package:halkyon_app/testing.dart';
import 'package:halkyon_ui/halkyon_ui.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);
const hint = 'Sign in with SimpleLogin, or with your Proton account.';
expect(find.text(hint), findsNothing, reason: 'behind its question mark');
await tester.tap(find.byType(HelpButton));
await tester.pumpAndSettle();
expect(find.text(hint), 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',
});
});
}