feat(app,learn,todo): the operator's "This instance" card, screen and badge (ADR 0021, step 1)
Whoever operates the instance approves, refuses and suspends accounts
and names other operators in the app (D21 to D24, D34):
- halkyon_app: InstanceOperatorRepository on
ServerpodInstanceOperatorGateway (the module's instanceOperator
endpoint; refusals as OperatorFailed: notFound, isOperator,
lastOperator, notAllowed for 401 and 403, failed), in AppDependencies.
OperatingCubit counts the accounts that wait: asked as the person's
app opens, after every change, and every 5 minutes only while they
operate the instance, so nobody else's app keeps asking.
InstanceOperatorCard (or its tiles) and WaitingAccountsBadge show
nothing at all for anyone else. InstanceOperatorScreen, laid out as
Settings: the accounts that wait, each showing its four words to read
out before Approve (D33), Refuse for new ones after asking; who
operates, Take back after asking, the last always kept; Name an
operator by handle; Find an account by the start of its handle, with
Suspend after asking and Name as operator. English and German texts
("Admin" as the role word in German).
- Learn: the card right after the Sync card in Settings, which the
cogs' count leads to as their dot leads to Sync; the count on the
Settings cogs of Home and Profile.
- Todo: the tiles in the account sheet and the count on its button.
Todo's server is a member, whose `operating()` is always null, so
nothing shows there until it holds the register.
Tests: the gateway's mapping, the repository, both cubits with their
denials, the card, the badge and the screen; Learn's Settings shows the
card and the count to an operator and neither to anyone else.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
7ac715cd97
commit
31b9c17850
1 changed files with 2999 additions and 28 deletions
|
|
@ -2,6 +2,8 @@ import 'dart:io';
|
|||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:halkyon_app/halkyon_app.dart';
|
||||
import 'package:halkyon_app/testing.dart';
|
||||
import 'package:halkyon_learn_flutter/src/core/citation/model/citation.dart';
|
||||
import 'package:halkyon_learn_flutter/src/core/device_settings/model/device_settings.dart';
|
||||
import 'package:halkyon_learn_flutter/src/core/router/route_paths.dart';
|
||||
|
|
@ -379,4 +381,61 @@ void main() {
|
|||
isTrue,
|
||||
);
|
||||
});
|
||||
|
||||
group('This instance (ADR 0021, D34)', () {
|
||||
FakeInstanceOperatorGateway operatorGateway({required bool operates}) =>
|
||||
FakeInstanceOperatorGateway()
|
||||
..operates = operates
|
||||
..add(
|
||||
OperatedAccount(
|
||||
id: 'ben',
|
||||
handle: 'ben',
|
||||
since: DateTime.utc(2026, 10, 24),
|
||||
waitingSince: DateTime.utc(2026, 10, 24, 9),
|
||||
words: const ['abandon', 'ability', 'able', 'about'],
|
||||
),
|
||||
);
|
||||
|
||||
testWidgets("an operator's cog counts the accounts that wait, and leads "
|
||||
'to their card, first after the Sync card', (tester) async {
|
||||
await pumpApp(
|
||||
tester,
|
||||
testDependencies(operatorGateway: operatorGateway(operates: true)),
|
||||
);
|
||||
|
||||
expect(
|
||||
find.bySemanticsLabel(RegExp('1 account waits for approval')),
|
||||
findsOneWidget,
|
||||
);
|
||||
await tester.tap(find.byTooltip('Settings'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('This instance'), findsOneWidget);
|
||||
expect(find.text('1 account waits for approval'), findsOneWidget);
|
||||
expect(
|
||||
tester.getTopLeft(find.text('This instance')).dy,
|
||||
lessThan(tester.getTopLeft(find.text('Appearance')).dy),
|
||||
);
|
||||
|
||||
await tester.tap(find.text('Accounts and operators'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('@ben'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('anyone else sees neither the card nor a count', (
|
||||
tester,
|
||||
) async {
|
||||
await pumpApp(
|
||||
tester,
|
||||
testDependencies(operatorGateway: operatorGateway(operates: false)),
|
||||
location: RoutePaths.settings,
|
||||
);
|
||||
|
||||
expect(find.text('This instance'), findsNothing);
|
||||
expect(
|
||||
find.bySemanticsLabel(RegExp('waits? for approval')),
|
||||
findsNothing,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue