App: dark-aware HTML views, run cards, changed/missing file notes, one card width, dense diff rows

show_html documents that declare dark support follow the app theme; others
stay light. Tool description and skill docs say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-02 19:54:58 +00:00
parent d204ce3187
commit f02ff56dfe
27 changed files with 1086 additions and 61 deletions
@@ -0,0 +1,83 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/artifacts/domain/artifact_html_theme.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_html_view.dart';
const _aware = '''<!doctype html><html><head><style>
body{background:#fff;color:#111}
@media (prefers-color-scheme: dark){body{background:#111;color:#eee}}
@media (prefers-color-scheme:light){.hint{display:block}}
</style></head><body>Hi</body></html>''';
const _plain = '<!DOCTYPE html><body style="color:#222">No dark styles</body>';
void main() {
test('only a document that supports dark mode is shown dark', () {
expect(artifactHtmlSupportsDark(_aware), isTrue);
expect(artifactHtmlSupportsDark(_plain), isFalse);
expect(
artifactHtmlSupportsDark('<p style="color: light-dark(#000, #fff)">'),
isTrue,
);
expect(artifactHtmlScheme(_aware, dark: true), 'dark');
expect(artifactHtmlScheme(_aware, dark: false), 'light');
expect(artifactHtmlScheme(_plain, dark: true), 'light');
});
test('a dark-aware document gets the app scheme and fixed queries', () {
final dark = artifactHtmlForScheme(_aware, dark: true);
expect(
dark,
contains('<head><meta name="color-scheme" content="dark"><style>'),
);
expect(dark, contains('@media (min-width: 0px){body{background:#111'));
expect(dark, contains('@media (max-width: -1px){.hint'));
expect(dark, isNot(contains('prefers-color-scheme')));
final light = artifactHtmlForScheme(_aware, dark: false);
expect(light, contains('<meta name="color-scheme" content="light">'));
expect(light, contains('@media (max-width: -1px){body{background:#111'));
expect(light, contains('@media (min-width: 0px){.hint'));
});
test('a document without dark styles stays light, after its doctype', () {
final shown = artifactHtmlForScheme(_plain, dark: true);
expect(
shown,
'<!DOCTYPE html><meta name="color-scheme" content="light">'
'<body style="color:#222">No dark styles</body>',
);
expect(
artifactHtmlForScheme('<svg viewBox="0 0 1 1"></svg>', dark: true),
startsWith('<meta name="color-scheme" content="light"><svg'),
);
});
testWidgets('the HTML view follows the app theme, not the system', (
tester,
) async {
bool? seen;
Future<void> pump(ThemeMode mode) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(brightness: Brightness.light),
darkTheme: ThemeData(brightness: Brightness.dark),
themeMode: mode,
home: Builder(
builder: (context) {
seen = artifactHtmlDark(context);
return const SizedBox();
},
),
),
);
// The theme change animates; read it once settled.
await tester.pumpAndSettle();
}
await pump(ThemeMode.dark);
expect(seen, isTrue);
await pump(ThemeMode.light);
expect(seen, isFalse);
});
}