113063b040
Adds the Notebook design (TranscriptStyle.cells, ComposerStyle.cell), a white/charcoal IDE theme with light grey cells, hairlines and 5px corners. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
129 lines
4.6 KiB
Dart
129 lines
4.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/chat/conversation/chat_draft_store.dart';
|
|
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
|
import 'package:pipelines_app/features/chat/ui/transcript/notebook/notebook_cell_frame.dart';
|
|
import 'package:pipelines_app/ui/theme/app_design.dart';
|
|
import 'package:pipelines_app/ui/theme/app_design_tokens.dart';
|
|
|
|
import '../../features/chat/conversation/chat_composer_bar_fixtures.dart';
|
|
|
|
ThemeData _theme(Brightness brightness, {String? font}) =>
|
|
brightness == Brightness.dark
|
|
? AppDesign.notebook.dark(fontFamily: font)
|
|
: AppDesign.notebook.light(fontFamily: font);
|
|
|
|
Widget _thread(ComposerBarGateway gateway, AppDesign design) => MaterialApp(
|
|
theme: design.light(),
|
|
home: Scaffold(
|
|
body: ChatThreadView(
|
|
gateway: gateway,
|
|
sessionId: 's',
|
|
session: const {'id': 's', 'directory': '/Users/ada/repos/tank'},
|
|
syncToken: 0,
|
|
onBack: () {},
|
|
drafts: MemoryChatDraftStore(),
|
|
),
|
|
),
|
|
);
|
|
|
|
void main() {
|
|
test('Notebook is listed with a stable id, a label and one line', () {
|
|
expect(AppDesign.fromId('notebook'), AppDesign.notebook);
|
|
expect(AppDesign.notebook.label, 'Notebook');
|
|
expect(AppDesign.notebook.description, isNot(contains('\n')));
|
|
expect(AppDesign.notebook.usesInterfaceFont, isTrue);
|
|
});
|
|
|
|
test('Notebook tokens: cells transcript, cell composer, washed row, '
|
|
'4-6px corners, hairlines, flat', () {
|
|
for (final brightness in Brightness.values) {
|
|
final theme = _theme(brightness);
|
|
final tokens = theme.extension<AppDesignTokens>()!;
|
|
expect(tokens.design, AppDesign.notebook);
|
|
expect(tokens.transcript, TranscriptStyle.cells);
|
|
expect(tokens.terminal, isFalse);
|
|
expect(tokens.composer, ComposerStyle.cell);
|
|
expect(tokens.selectedRow, SelectedRowStyle.washed);
|
|
expect(tokens.radius, inInclusiveRange(4, 6));
|
|
expect(tokens.flat, isTrue);
|
|
expect(tokens.frame, theme.colorScheme.outlineVariant);
|
|
expect(tokens.ansi, isNotNull);
|
|
// Reading text keeps the interface sans.
|
|
expect(tokens.reading.family, isNull);
|
|
}
|
|
});
|
|
|
|
test('Notebook pages: white by day, neutral charcoal by night, cells a '
|
|
'step off the page', () {
|
|
final light = _theme(Brightness.light);
|
|
expect(light.scaffoldBackgroundColor, const Color(0xFFFFFFFF));
|
|
final dark = _theme(Brightness.dark);
|
|
expect(
|
|
dark.scaffoldBackgroundColor.computeLuminance(),
|
|
inExclusiveRange(0.005, 0.03),
|
|
);
|
|
for (final theme in [light, dark]) {
|
|
final scheme = theme.colorScheme;
|
|
expect(scheme.surfaceContainerLow, isNot(scheme.surface));
|
|
expect(scheme.onSurface, isNot(scheme.onSurfaceVariant));
|
|
}
|
|
});
|
|
|
|
test('Notebook keeps the interface font and caches its themes', () {
|
|
expect(
|
|
_theme(Brightness.light, font: 'Inter').textTheme.bodyLarge?.fontFamily,
|
|
'Inter',
|
|
);
|
|
expect(identical(_theme(Brightness.dark), _theme(Brightness.dark)), isTrue);
|
|
expect(
|
|
AppDesign.notebook.build(Brightness.light),
|
|
_theme(Brightness.light),
|
|
);
|
|
});
|
|
|
|
testWidgets('Notebook: the composer is an In [ ]: input cell whose frame '
|
|
'takes the accent on focus', (tester) async {
|
|
final gateway = ComposerBarGateway();
|
|
addTearDown(gateway.close);
|
|
await tester.pumpWidget(_thread(gateway, AppDesign.notebook));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byKey(const Key('chat-composer-pill')), findsNothing);
|
|
expect(find.byKey(const Key('chat-composer-underline')), findsNothing);
|
|
final cell = find.byKey(const Key('chat-composer-cell'));
|
|
expect(cell, findsOneWidget);
|
|
expect(
|
|
find.descendant(of: cell, matching: find.text('In [ ]:')),
|
|
findsOneWidget,
|
|
);
|
|
for (final key in [
|
|
'chat-composer-attach',
|
|
'chat-composer-field',
|
|
'chat-composer-primary',
|
|
]) {
|
|
expect(
|
|
find.descendant(of: cell, matching: find.byKey(Key(key))),
|
|
findsOneWidget,
|
|
);
|
|
}
|
|
final scheme = Theme.of(tester.element(cell)).colorScheme;
|
|
Color frame() {
|
|
final paint = tester.widget<CustomPaint>(
|
|
find
|
|
.descendant(
|
|
of: find.byKey(const Key('chat-composer-cell-frame')),
|
|
matching: find.byType(CustomPaint),
|
|
)
|
|
.first,
|
|
);
|
|
return (paint.painter! as NotebookCellPainter).border;
|
|
}
|
|
|
|
expect(frame(), scheme.outlineVariant);
|
|
await tester.tap(find.byKey(const Key('chat-composer-field')));
|
|
await tester.pumpAndSettle();
|
|
expect(frame(), scheme.primary);
|
|
});
|
|
}
|