Files
logic-puzzle/test/halloween_widget_test.dart
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

110 lines
4.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:lumen/domain/book.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() {
testWidgets(
'all Halloween leaves fit larger text and keep navigation reachable in both orientations',
(tester) async {
addTearDown(tester.view.reset);
tester.platformDispatcher.textScaleFactorTestValue = 1.5;
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
final library = (await tester.runAsync(StoryLibrary.load))!;
final book = (await tester.runAsync(
() => library.open('midnight-invitation'),
))!;
await tester.runAsync(() async {
final font = FontLoader('MaraHand')
..addFont(rootBundle.load('assets/fonts/DancingScript.ttf'));
await font.load();
});
for (final size in [const Size(360, 640), const Size(960, 600)]) {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
final g = Game(book, Progress.memory(), library: library);
await tester.pumpWidget(LumenApp(game: g, adsEnabled: false));
await tester.pumpAndSettle();
for (var i = 0; i < book.pages.length; i++) {
g.showStory(i);
await tester.pumpAndSettle();
final page = book.pages[i];
expect(find.image(AssetImage(book.paperAsset!)), findsOneWidget);
expect(find.text('Undo a mark'), findsNothing);
expect(find.text(page.title), findsOneWidget, reason: page.id);
final next = i == book.pages.length - 1
? 'Back to contents'
: 'Next leaf →';
expect(
find.text(next).hitTestable(),
findsOneWidget,
reason: page.id,
);
if (page.type == StoryPageType.puzzle) {
for (final cell in [0, g.cells.length - 1]) {
final target = find.byKey(ValueKey('cell-$cell'));
expect(target.hitTestable(), findsOneWidget, reason: page.id);
final rect = tester.getRect(target);
expect(rect.top, greaterThanOrEqualTo(0), reason: page.id);
expect(
rect.bottom,
lessThan(tester.getRect(find.text(next)).top),
reason: page.id,
);
}
final hint = find.text('Hint · rewarded ad');
await tester.ensureVisible(hint);
await tester.pumpAndSettle();
expect(hint.hitTestable(), findsOneWidget, reason: page.id);
if (page.text.isNotEmpty) {
expect(find.text(page.text), findsOneWidget);
}
}
expect(tester.takeException(), isNull, reason: page.id);
}
await tester.pumpWidget(const SizedBox());
}
},
);
testWidgets(
'Halloween discovery artwork stays hidden until its own puzzle is restored',
(tester) async {
tester.view.physicalSize = const Size(600, 960);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final library = (await tester.runAsync(StoryLibrary.load))!;
final book = (await tester.runAsync(
() => library.open('midnight-invitation'),
))!;
final g = Game(book, Progress.memory());
await tester.pumpWidget(LumenApp(game: g, adsEnabled: false));
await tester.pumpAndSettle();
for (var i = 0; i < 12; i++) {
final page = book.pageFor(i, StoryPageType.memory);
final asset = AssetImage(book.levels[i].illustrationAsset!);
g.showStory(page);
await tester.pumpAndSettle();
expect(find.image(asset), findsNothing);
await g.progress.set('done_${book.puzzleKey(i)}', true);
g.showStory(page);
await tester.pumpAndSettle();
expect(find.image(asset), findsOneWidget, reason: book.levels[i].id);
expect(tester.takeException(), isNull);
g.showStory(book.pageFor(i, StoryPageType.entry));
await tester.pumpAndSettle();
expect(find.image(asset), findsNothing);
}
await g.progress.set('notebook_manual_bookmark', 'midnight.ending');
g.contents(2);
await tester.pumpAndSettle();
expect(find.text('Return to my ribbon bookmark'), findsOneWidget);
await tester.pumpWidget(const SizedBox());
},
);
}