fix(welcome): structured doc-load error + Forgejo fallback link
Some checks failed
Security / Security check (push) Failing after 2s
Some checks failed
Security / Security check (push) Failing after 2s
The doc-reader bottom-sheet in welcome.dart hits rootBundle
to load assets/docs/<slug>[_de].md. When the asset isn't in
the bundle (e.g. the binary on disk predates the
flutter_markdown_plus migration in 69b54629 or an in-progress
asset reorganisation), the FutureBuilder's error branch dumps
the raw PlatformException text into FaiErrorBox with no
hint at what the operator should do.
Switch the throw to a structured `_DocReaderError` that
carries:
- the slug, locale, and both attempted asset paths
- the underlying error message
- a precomputed `forgejoUrl` pointing at the same doc on
the platform repo's main branch
The error UI gains a TextButton.icon below FaiErrorBox that
opens the Forgejo copy in the OS browser via the existing
SystemActions.openInOs path — operators always have a
working out, even when the local bundle is broken.
The error toString() also surfaces "rebuild Studio" as the
top suggestion, since the most common cause for asset
mismatches is a stale binary running against a newer source
tree.
New regression test (test/load_docs_test.dart) pumps the
exact code path the sheet uses (rootBundle.loadString +
Markdown with FaiTheme.markdownStyle) against all eight asset
paths (architecture/security/audit/flows × en/de). Catches a
future bundle drift before an operator notices.
No behavioural change on the happy path. Both the rendered
markdown widget and the closed-sheet animation are unchanged.
Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
This commit is contained in:
parent
1c306916aa
commit
570c38b238
2 changed files with 107 additions and 7 deletions
52
test/load_docs_test.dart
Normal file
52
test/load_docs_test.dart
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart' show rootBundle;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter_markdown_plus/flutter_markdown_plus.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:fai_studio/l10n/app_localizations.dart';
|
||||
import 'package:fai_studio/theme/theme.dart';
|
||||
|
||||
/// Recreates the exact DocReaderSheet code path that
|
||||
/// welcome.dart uses, including FaiTheme.markdownStyle, so a
|
||||
/// regression in either rootBundle, the markdown parser, or
|
||||
/// the style sheet surfaces here instead of only at runtime
|
||||
/// when an operator clicks a doc card.
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
testWidgets('DocReaderSheet renders all four german + english docs',
|
||||
(tester) async {
|
||||
final theme = FaiTheme.light();
|
||||
for (final slug in ['architecture', 'security', 'audit', 'flows']) {
|
||||
for (final locale in ['de', 'en']) {
|
||||
final path = locale == 'de'
|
||||
? 'assets/docs/${slug}_de.md'
|
||||
: 'assets/docs/$slug.md';
|
||||
final text = await rootBundle.loadString(path);
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
locale: Locale(locale),
|
||||
supportedLocales: const [Locale('en'), Locale('de')],
|
||||
localizationsDelegates: const [
|
||||
AppLocalizations.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
theme: theme,
|
||||
home: Scaffold(
|
||||
body: Markdown(
|
||||
data: text,
|
||||
padding: const EdgeInsets.all(8),
|
||||
selectable: true,
|
||||
styleSheet: FaiTheme.markdownStyle(theme),
|
||||
),
|
||||
),
|
||||
));
|
||||
await tester.pump();
|
||||
// ignore: avoid_print
|
||||
print('rendered $path');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue