feat: 万花筒专区可设置门的通关状态

通关态与前两个动作一样落在 userKaleidxScopeList 同一行,是 isClear。
用三态下拉(不改动 / 已通关 / 未通关)而不是勾选框,因为通关可以往回改。

- 标记通关时补 clearDate,格式按客户端 TimeManager.GetDateString 的
  yyyy-MM-dd HH:mm:ss.f;已有首次通关日期不覆盖,撤销通关时一起清空
- 上行是整行替换,只叠加要改的位,playCount / best 成绩 / 日期保持原值
- 通关态只在 found && key 的前提下才显示得出来,缺钥匙时给一条短提示
- 校验放宽:三个动作任选其一即可执行
This commit is contained in:
Cookiues committed 2026-10-01 11:04:18 +08:00
1 parent 44c4a1daae
commit 6438fb2171
7 files changed
+241 -27

No files matched your search

+33 -2
View File
@@ -40,7 +40,7 @@ Finder _runFinder(WidgetTester tester) => find.ancestor(
);
void main() {
testWidgets('渲染门 ID 输入与两个动作勾选,且无溢出', (tester) async {
testWidgets('渲染门 ID 输入、两个勾选与通关下拉,且无溢出', (tester) async {
await _pumpPage(tester, loggedIn: true);
expect(tester.takeException(), isNull);
@@ -71,7 +71,7 @@ void main() {
expect(find.text(AppStrings.kaleidxPendingEmpty), findsNothing);
});
testWidgets('两个动作都不勾时被拦下', (tester) async {
testWidgets('三个动作都不选时被拦下', (tester) async {
await _pumpPage(tester, loggedIn: true);
await tester.enterText(find.byType(TextField), '3');
@@ -86,6 +86,37 @@ void main() {
expect(find.text(AppStrings.kaleidxNeedAction), findsOneWidget);
});
testWidgets('通关状态下拉默认「不改动」,选已通关才提示需要钥匙', (tester) async {
await _pumpPage(tester, loggedIn: true);
expect(find.text(AppStrings.kaleidxClearKeep), findsOneWidget);
expect(find.text(AppStrings.kaleidxClearNeedsKey), findsNothing);
await tester.tap(find.text(AppStrings.kaleidxClearKeep));
await tester.pumpAndSettle();
await tester.tap(find.text(AppStrings.kaleidxClearCleared).last);
await tester.pumpAndSettle();
expect(find.text(AppStrings.kaleidxClearCleared), findsOneWidget);
expect(find.text(AppStrings.kaleidxClearNeedsKey), findsOneWidget);
expect(tester.takeException(), isNull);
});
testWidgets('勾了钥匙时优先解释「钥匙离不开门」', (tester) async {
await _pumpPage(tester, loggedIn: true);
await tester.tap(find.text(AppStrings.kaleidxActionKey));
await tester.pump();
await tester.tap(find.text(AppStrings.kaleidxClearKeep));
await tester.pumpAndSettle();
await tester.tap(find.text(AppStrings.kaleidxClearCleared).last);
await tester.pumpAndSettle();
expect(find.text(AppStrings.kaleidxKeyNeedsGate), findsOneWidget);
// 两条提示不叠着刷屏。
expect(find.text(AppStrings.kaleidxClearNeedsKey), findsNothing);
});
testWidgets('列表为空时执行被拦下', (tester) async {
await _pumpPage(tester, loggedIn: true);
+92
View File
@@ -506,5 +506,97 @@ void main() {
contains('隐形'),
);
});
test('标记通关时落一个首次通关日期,已有日期不被覆盖', () {
const noDate = UserKaleidxScopeBean(gateId: 5);
final marked = noDate.withActions(
discover: true,
giveKey: true,
clear: true,
timestamp: '2026-10-01 12:00:00.0',
);
expect(marked.isClear, isTrue);
expect(marked.clearDate, '2026-10-01 12:00:00.0');
const already = UserKaleidxScopeBean(
gateId: 5,
isGateFound: true,
isKeyFound: true,
isClear: true,
clearDate: '2026-01-01 00:00:00.0',
);
final reMarked = already.withActions(
discover: false,
giveKey: false,
clear: true,
timestamp: '2026-10-01 12:00:00.0',
);
// clearDate 是「首次」通关日期,不能被后来的一次操作改掉。
expect(reMarked.clearDate, '2026-01-01 00:00:00.0');
});
test('撤销通关把 clearDate 一起清掉', () {
const cleared = UserKaleidxScopeBean(
gateId: 6,
isGateFound: true,
isKeyFound: true,
isClear: true,
clearDate: '2026-01-01 00:00:00.0',
playCount: 3,
);
final undone = cleared.withActions(
discover: false,
giveKey: false,
clear: false,
);
expect(undone.isClear, isFalse);
expect(undone.clearDate, '');
// 只动通关态,成绩与次数要原样留着。
expect(undone.playCount, 3);
expect(undone.isKeyFound, isTrue);
});
test('通关状态选「不改动」时 null 不覆写原值', () {
const cleared = UserKaleidxScopeBean(
gateId: 8,
isGateFound: true,
isKeyFound: true,
isClear: true,
clearDate: '2026-01-01 00:00:00.0',
);
final kept = cleared.withActions(discover: true, giveKey: false);
expect(kept.isClear, isTrue);
expect(kept.clearDate, '2026-01-01 00:00:00.0');
});
test('新行也能直接建成已通关', () {
final row = UserKaleidxScopeBean.discovered(
11,
giveKey: true,
clear: true,
timestamp: '2026-10-01 12:00:00.0',
).toWireJson();
expect(row['isGateFound'], isTrue);
expect(row['isKeyFound'], isTrue);
expect(row['isClear'], isTrue);
expect(row['clearDate'], '2026-10-01 12:00:00.0');
});
test('新行不选通关时 clearDate 留空', () {
final row = UserKaleidxScopeBean.discovered(
11,
giveKey: false,
clear: false,
timestamp: '2026-10-01 12:00:00.0',
).toWireJson();
expect(row['isClear'], isFalse);
expect(row['clearDate'], '');
});
});
}