Files
pipelines/app/test/application/detached/detached_preferences_test.dart
T
alan 03983cfd1f Detached chat: read the chat again once its machine connects, and follow the main window's look
A detached chat window read the chat list once, before any saved machine had
connected, and never again; its pane also did not rebuild when the runtime
adopted a row. Without the row the header showed a bare "Chat" with no folder
or model, the window was named by the session id, and the chat's colour (bar
tint, focus ring, prompt bar) was missing. The window now re-reads the list on
each connection change and rebuilds on the runtime, as the Chat destination
does. It also re-reads the stored design and font on the browser's storage
event and on coming to the front, so a Settings change in the main window
follows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 17:28:47 +00:00

68 lines
2.5 KiB
Dart

import 'dart:async';
import 'dart:ui';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/application/detached/detached_preferences.dart';
import 'package:pipelines_app/ui/theme/app_design.dart';
import 'package:pipelines_app/ui/theme/app_design_controller.dart';
import 'package:pipelines_app/ui/theme/app_font.dart';
import 'package:pipelines_app/ui/theme/app_font_controller.dart';
import 'package:pipelines_app/ui/theme/app_font_store.dart';
void main() {
testWidgets('the design and font chosen in the main window follow into a '
'detached window, on a storage event and on coming to the front', (
tester,
) async {
final designStore = MemoryAppDesignStore();
final fontStore = MemoryAppFontStore();
final designs = AppDesignController(store: designStore);
final fonts = AppFontController(store: fontStore, loader: (_, _) async {});
final changes = StreamController<void>.broadcast();
var reloads = 0;
final follower = DetachedPreferencesFollower(
changes: changes.stream,
designs: designs,
fonts: fonts,
reload: () async => reloads++,
)..start();
addTearDown(() {
follower.dispose();
unawaited(changes.close());
});
// Another window stores the Terminal design and a font.
designStore.id = AppDesign.terminal.id;
fontStore.id = AppFont.inter.id;
changes.add(null);
await tester.pumpAndSettle();
expect(reloads, 1);
expect(designs.design, AppDesign.terminal);
expect(fonts.selected, AppFont.inter);
expect(fonts.family, AppFont.inter.family);
// Back to the defaults, seen when this window comes to the front.
designStore.id = AppDesign.standard.id;
fontStore.id = AppFont.system.id;
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.inactive);
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.resumed);
await tester.pumpAndSettle();
expect(reloads, 2);
expect(designs.design, AppDesign.standard);
expect(fonts.selected, AppFont.system);
expect(fonts.family, isNull);
// Following never writes the choice back.
expect(designStore.id, AppDesign.standard.id);
});
test('a font id this device cannot resolve keeps the current font', () async {
final store = MemoryAppFontStore(AppFont.inter.id);
final fonts = AppFontController(store: store, loader: (_, _) async {});
await fonts.restore();
expect(fonts.selected, AppFont.inter);
store.id = 'custom-unknown';
await fonts.restore();
expect(fonts.selected, AppFont.inter);
});
}