Design: Terminal is the default when none is stored; Default is now Classic
An unset (or unknown) design id resolves to Terminal, in the controller's initial value, AppDesign.fromId and the boot spinner. A stored choice, including Classic's stable 'default' id, is respected. The picker calls the original Material look Classic so no row reads 'Default'. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -18,6 +19,8 @@ import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_screen.dar
|
||||
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
||||
import '../native_back.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_design.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_design_controller.dart';
|
||||
|
||||
ServerEndpoint webServer() => ServerEndpoint.resolve(
|
||||
base: Uri.parse('http://127.0.0.1:8096/'),
|
||||
@@ -300,6 +303,15 @@ void main() {
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
// The Classic design's transcript (its activity summary line); the
|
||||
// app starts on Terminal when no design is stored.
|
||||
// The choice applies at once; its save need not finish here.
|
||||
unawaited(AppDesignController.instance.select(AppDesign.standard));
|
||||
addTearDown(
|
||||
() => unawaited(
|
||||
AppDesignController.instance.select(AppDesign.defaultDesign),
|
||||
),
|
||||
);
|
||||
|
||||
final channel = FakeChannel()..readyCompleter.complete();
|
||||
final client = PipelinesClient(
|
||||
|
||||
@@ -29,7 +29,7 @@ AppDesignTokens _tokens(WidgetTester tester) =>
|
||||
AppDesignTokens.of(tester.element(find.text(designSectionTitle)));
|
||||
|
||||
void main() {
|
||||
testWidgets('every design is a radio row; Default is chosen at first', (
|
||||
testWidgets('every design is a radio row; Terminal is chosen at first', (
|
||||
tester,
|
||||
) async {
|
||||
final designs = AppDesignController(store: MemoryAppDesignStore());
|
||||
@@ -43,40 +43,43 @@ void main() {
|
||||
final group = tester.widget<RadioGroup<AppDesign>>(
|
||||
find.byType(RadioGroup<AppDesign>),
|
||||
);
|
||||
expect(group.groupValue, AppDesign.standard);
|
||||
expect(_tokens(tester).terminal, isFalse);
|
||||
expect(group.groupValue, AppDesign.terminal);
|
||||
expect(_tokens(tester).terminal, isTrue);
|
||||
// The Material look is called Classic, so no row reads "Default".
|
||||
expect(find.text('Classic'), findsOneWidget);
|
||||
expect(find.text('Default'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('choosing Terminal stores it and restyles the page live', (
|
||||
testWidgets('choosing Classic stores it and restyles the page live', (
|
||||
tester,
|
||||
) async {
|
||||
final store = MemoryAppDesignStore();
|
||||
final designs = AppDesignController(store: store);
|
||||
await _pump(tester, designs);
|
||||
|
||||
await tester.tap(find.text(AppDesign.terminal.label));
|
||||
await tester.pumpAndSettle();
|
||||
expect(store.id, AppDesign.terminal.id);
|
||||
expect(designs.design, AppDesign.terminal);
|
||||
expect(_tokens(tester).terminal, isTrue);
|
||||
expect(find.text(designSaveFailedText), findsNothing);
|
||||
|
||||
await tester.tap(find.text(AppDesign.standard.label));
|
||||
await tester.pumpAndSettle();
|
||||
expect(store.id, AppDesign.standard.id);
|
||||
expect(designs.design, AppDesign.standard);
|
||||
expect(_tokens(tester).terminal, isFalse);
|
||||
expect(find.text(designSaveFailedText), findsNothing);
|
||||
|
||||
await tester.tap(find.text(AppDesign.terminal.label));
|
||||
await tester.pumpAndSettle();
|
||||
expect(store.id, AppDesign.terminal.id);
|
||||
expect(_tokens(tester).terminal, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('a stored choice is restored into the picker', (tester) async {
|
||||
final designs = AppDesignController(
|
||||
store: MemoryAppDesignStore(AppDesign.terminal.id),
|
||||
store: MemoryAppDesignStore(AppDesign.standard.id),
|
||||
);
|
||||
await designs.restore();
|
||||
await _pump(tester, designs);
|
||||
final group = tester.widget<RadioGroup<AppDesign>>(
|
||||
find.byType(RadioGroup<AppDesign>),
|
||||
);
|
||||
expect(group.groupValue, AppDesign.terminal);
|
||||
expect(group.groupValue, AppDesign.standard);
|
||||
});
|
||||
|
||||
testWidgets('a failed save says the choice lasts until reload', (
|
||||
@@ -86,10 +89,10 @@ void main() {
|
||||
store: MemoryAppDesignStore()..failSaves = true,
|
||||
);
|
||||
await _pump(tester, designs);
|
||||
await tester.tap(find.text(AppDesign.terminal.label));
|
||||
await tester.tap(find.text(AppDesign.paper.label));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(designSaveFailedText), findsOneWidget);
|
||||
expect(designs.design, AppDesign.terminal);
|
||||
expect(designs.design, AppDesign.paper);
|
||||
});
|
||||
|
||||
testWidgets('choosing Paper stores it, restyles the page live and is '
|
||||
|
||||
@@ -4,34 +4,52 @@ import 'package:pipelines_app/ui/theme/app_design_controller.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
void main() {
|
||||
test('restore applies the stored design; unknown ids keep Default', () async {
|
||||
final stored = AppDesignController(store: MemoryAppDesignStore('terminal'));
|
||||
var notified = 0;
|
||||
stored.addListener(() => notified++);
|
||||
await stored.restore();
|
||||
expect(stored.design, AppDesign.terminal);
|
||||
expect(notified, 1);
|
||||
|
||||
final unknown = AppDesignController(store: MemoryAppDesignStore('neon'));
|
||||
await unknown.restore();
|
||||
expect(unknown.design, AppDesign.standard);
|
||||
test('an unset device starts on Terminal and keeps it', () async {
|
||||
final unset = AppDesignController(store: MemoryAppDesignStore());
|
||||
expect(unset.design, AppDesign.terminal);
|
||||
await unset.restore();
|
||||
expect(unset.design, AppDesign.terminal);
|
||||
});
|
||||
|
||||
test(
|
||||
'restore applies the stored design; unknown ids are the default',
|
||||
() async {
|
||||
// An explicit Classic choice, stored as `default` back when Classic was
|
||||
// the default, is respected.
|
||||
final stored = AppDesignController(
|
||||
store: MemoryAppDesignStore('default'),
|
||||
);
|
||||
var notified = 0;
|
||||
stored.addListener(() => notified++);
|
||||
await stored.restore();
|
||||
expect(stored.design, AppDesign.standard);
|
||||
expect(notified, 1);
|
||||
|
||||
final paper = AppDesignController(store: MemoryAppDesignStore('paper'));
|
||||
await paper.restore();
|
||||
expect(paper.design, AppDesign.paper);
|
||||
|
||||
final unknown = AppDesignController(store: MemoryAppDesignStore('neon'));
|
||||
await unknown.restore();
|
||||
expect(unknown.design, AppDesign.terminal);
|
||||
},
|
||||
);
|
||||
|
||||
test('select applies at once and stores the id', () async {
|
||||
final store = MemoryAppDesignStore();
|
||||
final designs = AppDesignController(store: store);
|
||||
final pending = designs.select(AppDesign.terminal);
|
||||
expect(designs.design, AppDesign.terminal);
|
||||
final pending = designs.select(AppDesign.standard);
|
||||
expect(designs.design, AppDesign.standard);
|
||||
await pending;
|
||||
expect(store.id, 'terminal');
|
||||
expect(store.id, 'default');
|
||||
expect(designs.saveFailed, isFalse);
|
||||
});
|
||||
|
||||
test('a failed save is reported and the choice still applies', () async {
|
||||
final store = MemoryAppDesignStore()..failSaves = true;
|
||||
final designs = AppDesignController(store: store);
|
||||
await designs.select(AppDesign.terminal);
|
||||
expect(designs.design, AppDesign.terminal);
|
||||
await designs.select(AppDesign.paper);
|
||||
expect(designs.design, AppDesign.paper);
|
||||
expect(designs.saveFailed, isTrue);
|
||||
store.failSaves = false;
|
||||
await designs.select(AppDesign.standard);
|
||||
|
||||
@@ -11,16 +11,19 @@ import 'package:pipelines_app/ui/theme/app_font_store.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_theme.dart';
|
||||
|
||||
void main() {
|
||||
test('ids round-trip and an unknown id is the Default design', () {
|
||||
test('ids round-trip and a missing or unknown id is Terminal', () {
|
||||
for (final design in AppDesign.values) {
|
||||
expect(AppDesign.fromId(design.id), design);
|
||||
}
|
||||
expect(AppDesign.fromId(null), AppDesign.standard);
|
||||
expect(AppDesign.fromId('neon'), AppDesign.standard);
|
||||
expect(AppDesign.defaultDesign, AppDesign.terminal);
|
||||
expect(AppDesign.fromId(null), AppDesign.terminal);
|
||||
expect(AppDesign.fromId('neon'), AppDesign.terminal);
|
||||
// Classic keeps the id it was stored under when it was the default.
|
||||
expect(AppDesign.standard.id, 'default');
|
||||
expect(AppDesign.standard.label, 'Classic');
|
||||
});
|
||||
|
||||
test('the Default design builds exactly the existing themes', () {
|
||||
test('the Classic design builds exactly the existing themes', () {
|
||||
expect(AppDesign.standard.light(), appLightTheme());
|
||||
expect(AppDesign.standard.dark(), appDarkTheme());
|
||||
expect(
|
||||
@@ -97,14 +100,15 @@ void main() {
|
||||
},
|
||||
),
|
||||
);
|
||||
expect(tokens.terminal, isFalse);
|
||||
expect(family, isNot(appMonospaceFamily));
|
||||
await designs.select(AppDesign.terminal);
|
||||
await tester.pumpAndSettle();
|
||||
// Terminal until the device chooses.
|
||||
expect(tokens.terminal, isTrue);
|
||||
expect(family, appMonospaceFamily);
|
||||
await designs.select(AppDesign.standard);
|
||||
await tester.pumpAndSettle();
|
||||
expect(tokens.terminal, isFalse);
|
||||
expect(family, isNot(appMonospaceFamily));
|
||||
await designs.select(AppDesign.terminal);
|
||||
await tester.pumpAndSettle();
|
||||
expect(tokens.terminal, isTrue);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/application/app.dart';
|
||||
import 'package:pipelines_app/shell/destination.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';
|
||||
@@ -36,10 +37,14 @@ void main() {
|
||||
store: MemoryAppFontStore(),
|
||||
loader: (family, assets) async {},
|
||||
);
|
||||
// Classic follows the interface font (Terminal keeps its monospace).
|
||||
final designs = AppDesignController(store: MemoryAppDesignStore('default'));
|
||||
await designs.restore();
|
||||
String? family;
|
||||
await tester.pumpWidget(
|
||||
MyApp(
|
||||
fonts: fonts,
|
||||
designs: designs,
|
||||
destination: AppDestination.settings,
|
||||
destinationBodies: <AppDestination, WidgetBuilder>{
|
||||
AppDestination.settings: (context) => Builder(
|
||||
|
||||
Reference in New Issue
Block a user