import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:tdc114plus/src/app.dart'; void main() { testWidgets('shows Baron SSO login screen', (WidgetTester tester) async { await tester.pumpWidget(const ProviderScope(child: Tdc114PlusApp())); expect(find.text('Baron SSO 로그인'), findsOneWidget); expect(find.byIcon(Icons.phone_android), findsOneWidget); }); testWidgets('moves to directory screen after phone input', ( WidgetTester tester, ) async { await tester.pumpWidget(const ProviderScope(child: Tdc114PlusApp())); await tester.enterText(find.byType(TextField), '01012345678'); await tester.tap(find.text('로그인')); await tester.pumpAndSettle(); expect(find.text('직원검색'), findsWidgets); expect(find.text('김하늘'), findsOneWidget); expect(find.text('검색 결과 5명'), findsOneWidget); }); testWidgets('filters employees by search query', (WidgetTester tester) async { await _openDirectory(tester); await tester.enterText(find.byType(TextField), '서준'); await tester.pumpAndSettle(); expect(find.text('박서준'), findsOneWidget); expect(find.text('김하늘'), findsNothing); expect(find.text('검색 결과 1명'), findsOneWidget); }); testWidgets('filters employees by tenant chip', (WidgetTester tester) async { await _openDirectory(tester); await tester.tap(find.text('TDC')); await tester.pumpAndSettle(); expect(find.text('이도윤'), findsOneWidget); expect(find.text('정수빈'), findsOneWidget); expect(find.text('김하늘'), findsNothing); expect(find.text('검색 결과 2명'), findsOneWidget); }); testWidgets('shows favorite employees view', (WidgetTester tester) async { await _openDirectory(tester); await tester.tap(find.text('즐겨찾기')); await tester.pumpAndSettle(); expect(find.text('김하늘'), findsOneWidget); expect(find.text('박서준'), findsNothing); expect(find.text('검색 결과 1명'), findsOneWidget); }); testWidgets('opens employee detail bottom sheet', ( WidgetTester tester, ) async { await _openDirectory(tester); await tester.tap(find.text('김하늘')); await tester.pumpAndSettle(); expect(find.text('haneul.kim@example.com'), findsOneWidget); expect(find.text('전화'), findsOneWidget); expect(find.text('문자'), findsOneWidget); }); } Future _openDirectory(WidgetTester tester) async { await tester.pumpWidget(const ProviderScope(child: Tdc114PlusApp())); await tester.pumpAndSettle(); if (find.text('직원검색').evaluate().isNotEmpty) { return; } await tester.enterText(find.byType(TextField), '01012345678'); await tester.tap(find.text('로그인')); await tester.pumpAndSettle(); }