Files
Hadrian Burkhardt 0718e3f252 Open Lumen on a responsive bookshelf and land pending story work
- Start the app on a shelf of every installed book instead of the last
  book's home. Cards show the cover, translated metadata, available
  languages, restored patterns and either "Continue reading" or a way in.
- Keep each book's saved route: the shelf is never written to
  flutter_screen, so choosing a book resumes its own leaf.
- Lay the shelf out responsively: dense single-column cards on phones,
  a two-column grid from 720 logical pixels, a centred 860 px column on
  tablets and a chevron that exists in the bundled handwriting font.
- Keep Settings reachable from the shelf and let the home page's story
  library button open the shelf instead of a dialog.
- Add tool/shelf_screenshots_test.dart, which renders the shelf at phone
  and tablet metrics, checks that every card and Settings stay reachable
  without overflow, and writes artifacts/library/shelf-*.png.
- Commit the pending Midnight Invitation package (campaign, notebook,
  narration and artwork), cast drama and ambience tooling, region
  selection, phone/tablet integration coverage and related docs.

flutter analyze is clean and all 74 widget/domain tests pass.
2026-11-05 14:29:50 +01:00

97 lines
3.5 KiB
Dart

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,
)..showLibrary();
await tester.pumpWidget(LumenApp(game: g, adsEnabled: false));
await tester.pumpAndSettle();
await binding.convertFlutterSurfaceToImage();
// The shelf loads every installed book asynchronously.
Future<void> waitFor(String text) async {
for (var i = 0; i < 100 && find.text(text).evaluate().isEmpty; i++) {
await tester.pump(const Duration(milliseconds: 100));
}
await tester.ensureVisible(find.text(text));
await tester.pumpAndSettle();
}
Future<void> tap(String text) async {
await waitFor(text);
await tester.tap(find.text(text));
await tester.pumpAndSettle();
}
expect(g.screen, Screen.library);
await waitFor('The paper boat');
await binding.takeScreenshot('library-shelf');
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 tester.binding.handlePopRoute();
await tester.pumpAndSettle();
expect(g.screen, Screen.home);
await tap('Settings');
await tap('Language');
await tap('Deutsch');
expect(g.book.language, 'de');
g.openNotebook();
await tester.pumpAndSettle();
expect(g.cells, marks);
expect(g.canUndo, true);
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([]);
});
}