Files
pfm-ocr/test/product_dropdown_card_test.dart
T
Rafhan Mazaya FathurrahmanandClaude Sonnet 5 ada6488592 feat(app): scan-mode sync, confirmation-gated documents, single-pass product classification
Fixes reported from APK field testing: DO/Product scan mode was inconsistent
between the camera drawer and documents screen (now one shared provider,
with an orange/green color cue); unconfirmed scans leaked into history with
placeholder data before the user tapped confirm (backend now gates
GET /documents on a new `confirmed` column, flipped only by PUT); and
Product Scan ran the GPU classifier twice, once at upload and again on
review (now a single pass at upload, persisted and read directly by the
editor). Also removes the unused "Hubungkan ke PO" field and fabricated
PO/SO/DO placeholder values from the Product Scan flow, closes out the
per-document-polling and save-recovery tasks (6.1/6.3), and splits several
touched files to stay under the repo's 256-line guideline.

Full detail in docs/iteration-log.md and backend/docs/iteration-log.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-10 15:19:32 +07:00

60 lines
1.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:app_pfm_ocr_v2/features/editor/widgets/product_dropdown_card.dart';
void main() {
final matches = [
{'no_sku': '1', 'nama_item': 'Produk A', 'confidence': 0.9},
];
testWidgets('shows the confidence score when there is a real automatic match', (tester) async {
await tester.pumpWidget(MaterialApp(
home: Scaffold(
body: ProductDropdownCard(
selectedSku: '1',
matches: matches,
hasAutoMatch: true,
onSkuChanged: (_) {},
),
),
));
expect(find.text('Confidence Score'), findsOneWidget);
expect(find.textContaining('%'), findsOneWidget);
expect(find.textContaining('rekomendasi otomatis'), findsNothing);
});
testWidgets('shows a manual-selection notice instead of a fake confidence score', (tester) async {
await tester.pumpWidget(MaterialApp(
home: Scaffold(
body: ProductDropdownCard(
selectedSku: '1',
matches: matches,
hasAutoMatch: false,
onSkuChanged: (_) {},
),
),
));
expect(find.text('Confidence Score'), findsNothing);
expect(find.textContaining('rekomendasi otomatis'), findsOneWidget);
});
testWidgets('shows the selected SKU\'s product name as info text below the dropdown, not a form field', (tester) async {
await tester.pumpWidget(MaterialApp(
home: Scaffold(
body: ProductDropdownCard(
selectedSku: '1',
matches: matches,
hasAutoMatch: true,
onSkuChanged: (_) {},
),
),
));
expect(find.text('Produk A'), findsOneWidget);
// No PO-link field anymore (removed - user request).
expect(find.text('Hubungkan ke PO Dokumen'), findsNothing);
});
}