Files
tasq/test/searchable_multi_select_dropdown_test.dart
T
redz1029 3cb980b629 QA hardening: security RLS fixes, Flutter 3.47.5 upgrade, UI/validation fixes
Security — enforce write authorization server-side (was UI/RPC-only):
- it_service_requests RLS: block cross-office read/edit + self-approve (QA-015)
- pass_slips RLS: owner can complete but not self-approve (QA-046)
- swap_requests RLS: scope select/update to participants + admin (QA-047)
- storage: tighten it_service_attachments + task_attachments write/delete (QA-027)
- admin_user_management edge function: allow programmers to manage users (QA-016)

Fixes:
- workforce generator "uncovered shifts" false alarms (QA-043/044)
- network-map VLAN + New-location dialog validation, disabled-until-valid (QA-048)
- de-flake time-of-day-dependent dashboard metrics test (QA-045)

Toolchain:
- upgrade to Flutter 3.47.5 / Dart 3.13.4; font_awesome_flutter 11.0.0,
  flutter_quill 11.6.0, pdfrx 2.6.5; clear resulting deprecations (QA-002)

analyze clean; 139 tests pass; web build succeeds. Report + evidence in docs/qa/.

Note: also carries the in-progress Brick model cleanup already present in the
working tree. QA-001 (AI keys public in the build) is deferred by owner decision.

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-09-26 11:52:16 +08:00

106 lines
3.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:tasq/models/office.model.dart';
import 'package:tasq/widgets/multi_select_picker.dart';
void main() {
testWidgets(
'SearchableMultiSelectDropdown: search / select-all / chips update',
(WidgetTester tester) async {
final offices = [
Office(id: 'o1', name: 'HQ'),
Office(id: 'o2', name: 'Branch'),
Office(id: 'o3', name: 'Remote'),
];
// Host state for selected IDs
List<String> selected = ['o1'];
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: StatefulBuilder(
builder: (context, setState) {
return Padding(
padding: const EdgeInsets.all(16.0),
child: MultiSelectPicker<Office>(
label: 'Offices',
items: offices,
selectedIds: selected,
getId: (o) => o.id,
getLabel: (o) => o.name,
onChanged: (ids) => setState(() => selected = ids),
),
);
},
),
),
),
);
// Initially the selected chip for 'HQ' must be visible
expect(find.text('HQ'), findsOneWidget);
expect(selected, equals(['o1']));
// Open dropdown dialog
await tester.tap(find.text('Select'));
await tester.pumpAndSettle();
// Dialog title present
expect(find.text('Select Offices'), findsOneWidget);
// All items are visible in the list initially
expect(find.widgetWithText(CheckboxListTile, 'HQ'), findsOneWidget);
expect(find.widgetWithText(CheckboxListTile, 'Branch'), findsOneWidget);
expect(find.widgetWithText(CheckboxListTile, 'Remote'), findsOneWidget);
// Search for 'Branch' -> only Branch should remain in the list
final searchField = find.descendant(
of: find.byType(AlertDialog),
matching: find.byType(TextField),
);
expect(searchField, findsOneWidget);
await tester.enterText(searchField, 'Branch');
await tester.pumpAndSettle();
expect(find.widgetWithText(CheckboxListTile, 'Branch'), findsOneWidget);
expect(find.widgetWithText(CheckboxListTile, 'HQ'), findsNothing);
expect(find.widgetWithText(CheckboxListTile, 'Remote'), findsNothing);
// Clear search, then use Select All
await tester.enterText(searchField, '');
await tester.pumpAndSettle();
await tester.tap(find.widgetWithText(CheckboxListTile, 'Select All'));
await tester.pumpAndSettle();
// Press Done to apply selection
await tester.tap(find.text('Done'));
await tester.pumpAndSettle();
// Now all chips should be present and selected list updated
expect(find.text('HQ'), findsOneWidget);
expect(find.text('Branch'), findsOneWidget);
expect(find.text('Remote'), findsOneWidget);
expect(selected.toSet(), equals({'o1', 'o2', 'o3'}));
// Re-open dialog and uncheck 'HQ'
await tester.tap(find.text('Select'));
await tester.pumpAndSettle();
await tester.tap(find.widgetWithText(CheckboxListTile, 'HQ'));
await tester.pumpAndSettle();
await tester.tap(find.text('Done'));
await tester.pumpAndSettle();
// HQ chip should be removed, others remain
expect(find.text('HQ'), findsNothing);
expect(find.text('Branch'), findsOneWidget);
expect(find.text('Remote'), findsOneWidget);
expect(selected.toSet(), equals({'o2', 'o3'}));
},
);
}