fix(client): 财务汇总往来搜索改为表头下拉框形态(验收反馈)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
// test/finance_summary_search_test.dart — 财务「应收/应付 汇总」往来单位搜索回归。
|
||||
// test/finance_summary_search_test.dart — 财务「应收/应付 汇总」往来单位筛选回归。
|
||||
//
|
||||
// financePartnerRowsProvider(GET /finance/summary)不分页、一次性全量加载,
|
||||
// 搜索口径=显示口径:仅需验证本地 contains 过滤在已加载行上生效——桌面
|
||||
// _summaryTable 工具头 DsSearchBox / 移动 应收·应付 分段头 MSearchRow 均覆盖:
|
||||
// 1. 输入关键字 → 汇总行按往来单位名过滤,未命中不显示;
|
||||
// 搜索口径=显示口径:
|
||||
// 桌面(验收反馈改版):表头「往来单位」内嵌 ComboSearchField(与 _flowTable
|
||||
// 往来单位筛选同款),单选精确匹配 → 汇总只显示该行;× 清除 → 恢复全量。
|
||||
// 移动 应收·应付 分段头仍是 MSearchRow 本地 contains 过滤,未改动:
|
||||
// 1. 输入关键字 → 汇总卡片按往来单位名过滤,未命中不显示;
|
||||
// 2. 关键字不匹配任何行 → 展示「没有匹配的往来单位」空态;
|
||||
// 3. 清空关键字 → 恢复全量展示。
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:lucide_icons_flutter/lucide_icons.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'package:jiu_client/core/api/api_client.dart';
|
||||
@@ -24,7 +27,7 @@ import 'package:jiu_client/providers/stock_in_provider.dart';
|
||||
import 'package:jiu_client/providers/stock_out_provider.dart';
|
||||
import 'package:jiu_client/repositories/finance_repository.dart';
|
||||
import 'package:jiu_client/screens/finance/finance_screen.dart';
|
||||
import 'package:jiu_client/widgets/ds/ds_atoms.dart' show DsSearchBox;
|
||||
import 'package:jiu_client/widgets/combo_search_field.dart';
|
||||
import 'package:jiu_client/widgets/ds/m_search_row.dart' show MSearchRow;
|
||||
|
||||
/// 不打真实网络:仅用于满足 FinanceRepository 构造签名,方法全部被覆写。
|
||||
@@ -122,8 +125,8 @@ void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
|
||||
group('桌面汇总卡往来单位搜索', () {
|
||||
testWidgets('输入关键字过滤汇总行,无匹配报空态,清空恢复全量', (tester) async {
|
||||
group('桌面汇总表头往来单位下拉筛选', () {
|
||||
testWidgets('选中往来单位只显示该行,× 清除恢复全量', (tester) async {
|
||||
await _pumpFinance(tester, size: const Size(1280, 900));
|
||||
|
||||
// 初始:3 条汇总行全部展示。
|
||||
@@ -131,28 +134,36 @@ void main() {
|
||||
expect(find.text('金樽商贸'), findsOneWidget);
|
||||
expect(find.text('茅台华南经销'), findsOneWidget);
|
||||
|
||||
final searchField = find.descendant(
|
||||
of: find.byType(DsSearchBox),
|
||||
matching: find.byType(TextField),
|
||||
// 定位表头内嵌的 ComboSearchField(按构造参数 hint 匹配,避免与
|
||||
// _flowTable toolbar 的往来单位 ComboSearchField(hint:'往来单位')
|
||||
// 混淆;选中后触发器文案会变成往来单位名,故不能用显示文字定位)。
|
||||
final combo = find.byWidgetPredicate(
|
||||
(w) => w is ComboSearchField && w.hint == '搜索往来单位',
|
||||
);
|
||||
expect(searchField, findsOneWidget);
|
||||
|
||||
// 输入「金樽」:只剩「金樽商贸」。
|
||||
await tester.enterText(searchField, '金樽');
|
||||
expect(combo, findsOneWidget);
|
||||
await tester.ensureVisible(combo);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('金樽商贸'), findsOneWidget);
|
||||
|
||||
// 打开弹层,选中「金樽商贸」。
|
||||
await tester.tap(combo);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.widgetWithText(InkWell, '金樽商贸'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// 只剩「金樽商贸」一行。
|
||||
expect(find.text('华东酒类批发'), findsNothing);
|
||||
expect(find.text('茅台华南经销'), findsNothing);
|
||||
expect(find.text('金樽商贸'), findsWidgets);
|
||||
|
||||
// 输入不存在的关键字:空态提示。
|
||||
await tester.enterText(searchField, '不存在的单位名');
|
||||
// 点触发器上的 × 清除选择 → 恢复全量 3 行。
|
||||
final clearIcon = find.descendant(
|
||||
of: combo,
|
||||
matching: find.byIcon(LucideIcons.x),
|
||||
);
|
||||
expect(clearIcon, findsOneWidget);
|
||||
await tester.tap(clearIcon);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('没有匹配的往来单位'), findsOneWidget);
|
||||
expect(find.text('金樽商贸'), findsNothing);
|
||||
|
||||
// 清空:恢复全量 3 行。
|
||||
await tester.enterText(searchField, '');
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('华东酒类批发'), findsOneWidget);
|
||||
expect(find.text('金樽商贸'), findsOneWidget);
|
||||
expect(find.text('茅台华南经销'), findsOneWidget);
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 285 KiB After Width: | Height: | Size: 285 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 282 KiB After Width: | Height: | Size: 282 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 286 KiB After Width: | Height: | Size: 285 KiB |
Reference in New Issue
Block a user