Add modular story library and shared-progress translations

This commit is contained in:
Hadrian Burkhardt
2026-11-03 17:15:15 +01:00
parent 5b9a76fb53
commit d45cd0698a
30 changed files with 2694 additions and 495 deletions
+82
View File
@@ -0,0 +1,82 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:lumen/domain/game.dart';
import 'package:lumen/domain/library.dart';
import 'package:lumen/main.dart';
import 'package:lumen/services/progress.dart';
void main() {
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
testWidgets('library switching and translation share progress on a device', (
tester,
) async {
expect(const bool.fromEnvironment('QA_TEST'), true);
final library = await StoryLibrary.load();
final g = Game(
await library.open('mara-island'),
Progress.memory({'language': 'en'}),
library: library,
);
await tester.pumpWidget(LumenApp(game: g, adsEnabled: false));
await tester.pumpAndSettle();
await binding.convertFlutterSurfaceToImage();
Future<void> tap(String text) async {
await tester.ensureVisible(find.text(text));
await tester.pumpAndSettle();
await tester.tap(find.text(text));
await tester.pumpAndSettle();
}
await tap('Story library');
await tap('The paper boat');
expect(g.book.id, 'paper-boat');
await tap('Open The paper boat · 0 / 1');
await tap('Next leaf →');
await tester.ensureVisible(find.byKey(const ValueKey('cell-0')));
await tester.tap(find.byKey(const ValueKey('cell-0')));
await tester.pumpAndSettle();
final marks = List<int>.of(g.cells);
await tap('Bookmark');
await tap('Language');
await tap('Deutsch');
expect(g.book.language, 'de');
expect(g.cells, marks);
expect(g.canUndo, true);
expect(g.progress.text('notebook_manual_bookmark'), 'boat.puzzle');
expect(find.text('Eine kleine Überfahrt'), findsOneWidget);
await binding.takeScreenshot('library-german-puzzle');
await tap('Nächste Seite →');
await tap('Weiterlesen');
expect(g.recoveredCount, 0);
expect(g.storyPage.id, 'boat.memory');
await binding.takeScreenshot('library-german-memory');
await g.selectStory('mara-island');
expect(g.book.language, 'en');
expect(g.progress.text('notebook_manual_bookmark'), isEmpty);
expect(g.recoveredCount, 0);
await g.selectStory('paper-boat');
g.startCampaign(0);
await tester.pumpAndSettle();
expect(g.cells, marks);
final puzzle = g.puzzle!;
for (var i = 0; i < g.cells.length; i++) {
while (g.cells[i] != (puzzle.solution[i] == 1 ? 1 : 2)) {
g.mark(i);
}
}
await tester.pumpAndSettle();
expect(g.recoveredCount, 1);
expect(g.solved, 1);
await binding.takeScreenshot('library-german-discovery');
await SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeLeft,
]);
await tester.pumpAndSettle();
await binding.takeScreenshot('library-german-landscape');
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox());
await SystemChrome.setPreferredOrientations([]);
});
}