feat(library): offer once to make every studyset from before private (ADR 0019, D4)
New studysets are private; those from before stay readable until the person chooses. The library offers once, on this device, where it can encrypt and some top-level studyset isn't private: Make all private, or Not now; either answer is remembered (`private_offer` in the person's folder) and the offer goes. Each studyset's menu changes it later. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
0e10afcc68
commit
9cdd4859d1
1 changed files with 262 additions and 1 deletions
|
|
@ -0,0 +1,92 @@
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:halkyon_learn_flutter/src/core/router/route_paths.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/studyset/data/studyset_payload.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/studyset/model/studyset_content.dart';
|
||||
import 'package:material_ui/material_ui.dart';
|
||||
|
||||
import '../../../support/fake_studyset_gateway.dart';
|
||||
import '../../../support/memory_private_offer_store.dart';
|
||||
import '../../../support/pump_app.dart';
|
||||
import '../../../support/test_dependencies.dart';
|
||||
|
||||
/// The library's one offer to make the studysets from before private (ADR
|
||||
/// 0019, D4).
|
||||
void main() {
|
||||
late FakeStudysetGateway gateway;
|
||||
late MemoryPrivateOfferStore offer;
|
||||
|
||||
setUp(() {
|
||||
gateway = FakeStudysetGateway()..canMakePrivate = true;
|
||||
offer = MemoryPrivateOfferStore();
|
||||
gateway
|
||||
..receiveRemoteChange(
|
||||
'japanese',
|
||||
encodeStudysetPayload(StudysetContent.titled('Japanese')),
|
||||
)
|
||||
..receiveRemoteChange(
|
||||
'kanji',
|
||||
encodeStudysetPayload(StudysetContent.titled('Kanji')),
|
||||
parentId: 'japanese',
|
||||
)
|
||||
..receiveRemoteChange(
|
||||
'diary',
|
||||
encodeStudysetPayload(StudysetContent.titled('Diary')),
|
||||
isPrivate: true,
|
||||
);
|
||||
});
|
||||
|
||||
Future<void> showLibrary(WidgetTester tester) async {
|
||||
tester.view.physicalSize = const Size(1200, 1600);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
await pumpApp(
|
||||
tester,
|
||||
testDependencies(studysetGateway: gateway, privateOffer: offer),
|
||||
location: RoutePaths.library,
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
}
|
||||
|
||||
testWidgets('makes every top-level studyset that is not private private '
|
||||
'at once, then never asks again', (tester) async {
|
||||
await showLibrary(tester);
|
||||
|
||||
expect(find.text('Make your studysets private?'), findsOneWidget);
|
||||
await tester.tap(find.text('Make all private'));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
expect(gateway.privacyChanges, [('japanese', true)]);
|
||||
expect(offer.isAnswered, isTrue);
|
||||
expect(find.text('Make your studysets private?'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('not now leaves them as they are, and asks no more', (
|
||||
tester,
|
||||
) async {
|
||||
await showLibrary(tester);
|
||||
|
||||
await tester.tap(find.text('Not now'));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
expect(gateway.privacyChanges, isEmpty);
|
||||
expect(offer.isAnswered, isTrue);
|
||||
expect(find.text('Make your studysets private?'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('is never shown once answered', (tester) async {
|
||||
offer.isAnswered = true;
|
||||
await showLibrary(tester);
|
||||
expect(find.text('Make your studysets private?'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets("is never shown on a device without the account's keys", (
|
||||
tester,
|
||||
) async {
|
||||
gateway.canMakePrivate = false;
|
||||
await showLibrary(tester);
|
||||
expect(find.text('Make your studysets private?'), findsNothing);
|
||||
});
|
||||
}
|
||||
Loading…
Reference in a new issue