Files
jiu/client/test/golden/device_management_golden_test.dart
T
wangjia 9445042cb4 feat(client): 设置/用户/设备/关于窄屏对齐移动原型(hub 形态/卡片流/sheet/无打印)
- 系统设置窄屏改 hub 三组(门店/偏好/数据):门店信息/编号规则/默认仓库走
  底部 sheet,主题外观接 showThemeSheet,?tab= 深链窄屏忽略;桌面 subnav 不动
- 用户管理窄屏:m-section + 头像卡片流 + 角色图标徽章 + FAB 新增;
  点卡开详情 sheet(drow + 重置密码/启停/编辑),表单复用为 sheet 形态
- 设备管理窄屏:会话卡流(本机标注/在线图标徽章)+ 外设卡流(mc-foot 脚注),
  「+ 添加设备」在区块标题行右侧(m-pill 选择 sheet),打印模板窄屏不渲染
- 关于我们窄屏:品牌 hero + hub 链接组 + 产品信息 drow 卡 + 时间线 pill 标签
  + 意见反馈 sheet(类型 pill/描述/联系方式);授权信息不显示(已迁 /me/license)
- golden:四屏窄屏基准独立成 *_mobile_golden_test.dart(390×844 @2x 三主题),
  桌面 golden 零漂移

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-04 12:19:15 +08:00

159 lines
4.5 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:jiu_client/core/auth/auth_state.dart';
import 'package:jiu_client/models/session.dart';
import 'package:jiu_client/models/shop.dart';
import 'package:jiu_client/providers/session_provider.dart';
import 'package:jiu_client/providers/shop_provider.dart';
import 'package:jiu_client/screens/devices/device_management_screen.dart';
import '../support/shell_harness.dart';
/// design-distill 阶段4:设备管理 golden × 三主题(回归闸 + 保真基准)。
/// 桌面版挂进真 AppShell,数据照抄原型 screens/devices.html 的
/// SESSIONS4 行会话)与 DEVICES5 台外设 → 店级 custom_fields.peripherals):
/// node tools/fidelity.mjs devices
/// 窄屏卡片流另见 device_management_mobile_golden_test.dart。
/// 更新基准:flutter test --update-goldens test/golden/device_management_golden_test.dart
// 原型 SESSIONS 4 行(时间 MM-DD HH:mm
final _sessions = [
DeviceSession(
id: 1,
userId: 1,
username: '王经理',
realName: '王经理',
platform: 'macos',
platformClass: 'desktop',
deviceName: 'macos',
ip: '192.168.1.20',
createdAt: DateTime(2026, 6, 20, 11, 23),
lastSeenAt: DateTime(2026, 6, 22, 17, 40),
online: true,
isCurrent: true),
DeviceSession(
id: 2,
userId: 1,
username: '王经理',
realName: '王经理',
platform: 'windows',
platformClass: 'desktop',
deviceName: 'windows',
ip: '192.168.1.21',
createdAt: DateTime(2026, 6, 20, 10, 47),
lastSeenAt: DateTime(2026, 6, 22, 17, 40),
online: true,
isCurrent: false),
DeviceSession(
id: 3,
userId: 2,
username: '李采购',
realName: '李采购',
platform: 'windows',
platformClass: 'desktop',
deviceName: 'windows',
ip: '192.168.1.35',
createdAt: DateTime(2026, 6, 20, 9, 13),
lastSeenAt: DateTime(2026, 6, 22, 17, 11),
online: false,
isCurrent: false),
DeviceSession(
id: 4,
userId: 3,
username: '张前台',
realName: '张前台',
platform: 'ios',
platformClass: 'mobile',
deviceName: 'ios',
ip: '10.0.0.8',
createdAt: DateTime(2026, 6, 21, 17, 9),
lastSeenAt: DateTime(2026, 6, 22, 16, 32),
online: false,
isCurrent: false),
];
// 原型 DEVICES 5 台外设(登记式存档)
const _peripherals = [
{
'name': '前台标签打印机',
'kind': '标签打印机',
'status': '在线',
'model': 'Zebra GK888t',
'conn': 'USB',
'last': '2 分钟前'
},
{
'name': '收银台小票机',
'kind': '小票打印机',
'status': '在线',
'model': '佳博 GP-58MB',
'conn': '蓝牙',
'last': '刚刚'
},
{
'name': '入库扫码枪',
'kind': '扫码枪',
'status': '在线',
'model': 'Honeywell 1900',
'conn': 'USB',
'last': '5 分钟前'
},
{
'name': '仓库电子秤',
'kind': '电子秤',
'status': '离线',
'model': '香山 ACS-30',
'conn': 'WiFi 192.168.1.66',
'last': '昨天 17:42'
},
{
'name': '备用标签机',
'kind': '标签打印机',
'status': '离线',
'model': 'Brother QL-820',
'conn': '网络 192.168.1.51',
'last': '3 天前'
},
];
const _shopWithPeripherals = ShopInfo(
id: 1,
code: 'DSJH-001',
name: '鼎晟酒行',
address: '浙江省杭州市拱墅区运河路 168 号 1 幢',
phone: '0571-8888 6666',
managerName: '王经理',
wechatId: 'dingsheng-wine',
customFields: {'peripherals': _peripherals},
);
class _FakeSessionNotifier extends SessionListNotifier {
@override
Future<List<DeviceSession>> build() async => _sessions;
@override
Future<void> reload() async {}
}
List<Override> _overrides() => [
sessionListProvider.overrideWith(() => _FakeSessionNotifier()),
shopInfoProvider.overrideWith((ref) => _shopWithPeripherals),
isReadonlyProvider.overrideWithValue(false),
];
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
SharedPreferences.setMockInitialValues({});
// 桌面:外壳挂载整框,与原型整页同构
shellGoldenAcrossThemes(
'devices 整框(桌面)',
path: '/devices',
screen: (_) => const DeviceManagementScreen(),
goldenPrefix: 'device_management',
overrides: _overrides,
logical: const Size(1280, 900),
);
}