P0 - GC-SAVEDOG:更新改为整目录替换(旧文件备份到 .GC/update/backup, 失败可完整回滚),不再只搬一个 exe;回滚会删掉新包独有文件 - GC-SAVEDOG:包名校验放宽为单文件名模式,Linux 启动器(无扩展名)可更新 - GC-DOWNLOAD:测速全失败时不再回退 GitCode,改为返回「不可用」并保留上次可用源 - GC-DOWNLOAD:识别并赋予 Linux 无扩展名启动器可执行位;兼容脚本清理旧版时 也覆盖无扩展名产物 - CI:删除 nightly-prerelease(绕开 build.sh,产出无前端空壳);alpha 工作流 去掉非法 cron,只保留手动触发 P1 - 前端:主题设置真正生效(深色/浅色/跟随系统 + 持久化),去掉死字段 - 前端:下载页轮询改为自适应单次链,页面不可见或任务结束后降频/停止 - 前端:下载完成 / 删除模型后首页列表自动刷新 - 前端:复用 http.Client,不再每次轮询新建连接 - 后端:/api/models 走缓存,不再每次全盘递归统计体积 - 设置页:外部改动能同步进表单,不再只同步一次 P2 - 错误响应统一为 ErrorDto,不再复用 LaunchResultDto - 限流桶定期清理,避免无限增长 - 播放器窗口去重,避免同一模型重复开窗 - 封面按实际格式返回,去掉错误的 image/png 与 no-store - 端口集中到 GcUiContract,前端可用 GC_UI_PORT 或 ui-backend.json 发现后端 - 构建:Windows 包改为散开发布,与后端共用运行时(体积约 109MB -> 72MB) - 文档:更新仓库地址与更新流程说明 测试:dotnet build 全绿;GC.Tests 更新链路全通过;flutter analyze 无问题; flutter test 11 项全通过。
86 lines
2.5 KiB
Dart
86 lines
2.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:gc_ui/api_client.dart';
|
|
import 'package:gc_ui/i18n.dart';
|
|
import 'package:gc_ui/theme.dart';
|
|
|
|
void main() {
|
|
group('I18n', () {
|
|
test('resolves auto to a supported language', () {
|
|
expect(I18n.supported.contains(I18n.resolve('auto')), isTrue);
|
|
expect(I18n.resolve('en-US'), 'en');
|
|
expect(I18n.resolve('zh-CN'), 'zh-CN');
|
|
});
|
|
|
|
test('translates keys and fills placeholders', () {
|
|
I18n.language.value = 'zh-CN';
|
|
expect(T('nav.home'), '主页');
|
|
expect(T('home.count', <Object?>[3]), '3 个模型');
|
|
|
|
I18n.language.value = 'en';
|
|
expect(T('nav.home'), 'Home');
|
|
expect(T('home.count', <Object?>[3]), '3 models');
|
|
});
|
|
|
|
test('falls back to the key for unknown entries', () {
|
|
expect(T('does.not.exist'), 'does.not.exist');
|
|
});
|
|
});
|
|
|
|
group('SettingsPatch', () {
|
|
test('only serialises the fields that were set', () {
|
|
const patch = SettingsPatch(renderFps: 60, memoryAuto: false);
|
|
expect(patch.toJson(), <String, dynamic>{
|
|
'renderFps': 60,
|
|
'memoryAuto': false,
|
|
});
|
|
});
|
|
|
|
test('empty patch serialises to an empty map', () {
|
|
expect(const SettingsPatch().toJson(), isEmpty);
|
|
});
|
|
});
|
|
|
|
group('GcApi', () {
|
|
test('builds model preview urls from the base url', () {
|
|
final api = GcApi(baseUrl: 'http://127.0.0.1:17890');
|
|
final model = ModelInfo.fromJson(<String, dynamic>{
|
|
'id': 'solar-system',
|
|
'name': '太阳系',
|
|
'previewUrl': '/api/models/solar-system/preview',
|
|
});
|
|
expect(api.previewUrl(model),
|
|
'http://127.0.0.1:17890/api/models/solar-system/preview');
|
|
});
|
|
|
|
test('parses a model payload', () {
|
|
final model = ModelInfo.fromJson(<String, dynamic>{
|
|
'id': 'earth',
|
|
'name': '地球',
|
|
'version': '1.2.0',
|
|
'sizeBytes': 1048576,
|
|
'sizeText': '1.0 MB',
|
|
'tags': <dynamic>['天文', '地球'],
|
|
'hasPreview': true,
|
|
});
|
|
expect(model.id, 'earth');
|
|
expect(model.tags, <String>['天文', '地球']);
|
|
expect(model.metaText, 'v1.2.0 · 1.0 MB');
|
|
});
|
|
});
|
|
|
|
group('theme', () {
|
|
testWidgets('renders a card with its child', (tester) async {
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
theme: buildGcTheme(Brightness.dark),
|
|
home: const Scaffold(
|
|
body: GcCard(child: Text('hello')),
|
|
),
|
|
),
|
|
);
|
|
expect(find.text('hello'), findsOneWidget);
|
|
});
|
|
});
|
|
}
|