feat(workspace): 桌面工作区、主题与交互更新,发布 0.1.2
Gitea CI / Check code and tests (push) Successful in 6m37s
Gitea CI / Build Windows x64 app (push) Successful in 3m18s
Gitea CI / Build Android APK (push) Successful in 3m47s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m7s
Gitea CI / Assemble and validate CI artifacts (push) Successful in 50s
Gitea CI / Gitea CI passed (push) Successful in 2s
Gitea Release / Prepare draft Release (push) Successful in 9s
Gitea Release / Upload Android to draft Release (push) Successful in 16s
Gitea Release / Upload Windows to draft Release (push) Successful in 22s
Gitea Release / Verify and publish Release (push) Successful in 14s

This commit was merged in pull request #13.
This commit is contained in:
lingjhf committed 2026-10-08 18:17:12 +00:00
1 parent aa5255d1e4
commit abc1868550
260 files changed
+43964 -5591

No files matched your search

+104
View File
@@ -0,0 +1,104 @@
import 'package:cutdex/app/app.dart';
import 'package:cutdex/app/router/app_router.dart';
import 'package:cutdex/features/settings/appearance_settings.dart';
import 'package:cutdex/features/settings/settings_content.dart';
import 'package:cutdex/integrations/agent/conversation_repository.dart';
import 'package:cutdex/persistence/app_settings_repositories.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:cutdex_ui/widgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:go_router/go_router.dart';
import 'support/empty_conversation_repository.dart';
import 'support/memory_app_settings.dart';
void main() {
testWidgets('settings switch all six themes and follow system appearance', (
tester,
) async {
tester.view.physicalSize = const Size(1200, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
addTearDown(tester.platformDispatcher.clearPlatformBrightnessTestValue);
final appearance = MemoryAppearanceSettingsRepository();
final palette = MemoryPaletteSettingsRepository();
final router = GoRouter(
routes: [
GoRoute(
path: '/',
builder: (_, _) => const Scaffold(body: SettingsContent()),
),
],
);
addTearDown(router.dispose);
final scope = ProviderContainer(
overrides: [
appRouterProvider.overrideWithValue(router),
appearanceSettingsRepositoryProvider.overrideWithValue(appearance),
paletteSettingsRepositoryProvider.overrideWithValue(palette),
conversationRepositoryProvider.overrideWith(
(ref) async => EmptyConversationRepository(),
),
],
);
addTearDown(scope.dispose);
await tester.pumpWidget(
UncontrolledProviderScope(container: scope, child: const CutdexApp()),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const ValueKey('settings-navigation-3')));
await tester.pumpAndSettle();
final settings = tester.element(find.byType(SettingsContent));
final select = find.byKey(const Key('settings-color-palette'));
expect(select, findsOneWidget);
for (final option in AppPalette.values) {
for (final mode in [AppAppearance.penLight, AppAppearance.penDark]) {
await scope.read(appearanceSettingsProvider.notifier).setMode(mode);
await tester.pumpAndSettle();
await tester.tap(select);
await tester.pumpAndSettle();
final field = tester.widget<AppSelect<AppPalette>>(select);
final label = field.options
.singleWhere((item) => item.value == option)
.label;
final menuItem = find.widgetWithText(MenuItemButton, label);
await tester.tap(menuItem);
await tester.pumpAndSettle();
expect(palette.value, option);
expect(appearance.value, mode);
expect(tester.element(find.byType(SettingsContent)), same(settings));
final theme = Theme.of(settings);
expect(AppColors.of(theme).family, option);
expect(
theme.brightness,
mode == AppAppearance.penLight ? Brightness.light : Brightness.dark,
);
expect(
theme.colorScheme.primary,
AppColors.forPalette(option, theme.brightness).primary,
);
expect(tester.takeException(), isNull);
}
}
await scope
.read(appearanceSettingsProvider.notifier)
.setMode(AppAppearance.system);
for (final brightness in Brightness.values) {
tester.platformDispatcher.platformBrightnessTestValue = brightness;
await tester.pumpAndSettle();
expect(Theme.of(settings).brightness, brightness);
expect(AppColors.of(Theme.of(settings)).family, AppPalette.teal);
expect(palette.value, AppPalette.teal);
}
for (final width in [800.0, 360.0]) {
tester.view.physicalSize = Size(width, 900);
await tester.pumpAndSettle();
expect(find.byKey(const Key('settings-color-palette')), findsOneWidget);
expect(tester.takeException(), isNull);
}
await tester.pumpWidget(const SizedBox());
});
}