forked from baron/baron-sso
링크로 로그인 수정
This commit is contained in:
33
userfront/test/login_link_route_policy_test.dart
Normal file
33
userfront/test/login_link_route_policy_test.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:userfront/core/i18n/locale_registry.dart';
|
||||
import 'package:userfront/features/auth/domain/login_link_route_policy.dart';
|
||||
|
||||
void main() {
|
||||
group('login_link_route_policy', () {
|
||||
setUp(() {
|
||||
LocaleRegistry.setSupportedLocaleCodesForTest(['ko', 'en']);
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
LocaleRegistry.resetForTest();
|
||||
});
|
||||
|
||||
test('extracts short code from plain short-code route', () {
|
||||
final shortCode = extractLoginShortCode(Uri.parse('/l/AB123456'));
|
||||
expect(shortCode, 'AB123456');
|
||||
});
|
||||
|
||||
test('extracts short code from localized short-code route', () {
|
||||
final shortCode = extractLoginShortCode(Uri.parse('/ko/l/AB123456'));
|
||||
expect(shortCode, 'AB123456');
|
||||
});
|
||||
|
||||
test('treats localized short-code route as public path', () {
|
||||
final isPublic = isPublicAuthPath(
|
||||
'/l/AB123456',
|
||||
Uri.parse('/ko/l/AB123456'),
|
||||
);
|
||||
expect(isPublic, isTrue);
|
||||
});
|
||||
});
|
||||
}
|
||||
67
userfront/test/qr_camera_bootstrap_policy_test.dart
Normal file
67
userfront/test/qr_camera_bootstrap_policy_test.dart
Normal file
@@ -0,0 +1,67 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:userfront/features/auth/presentation/qr_camera_bootstrap_policy.dart';
|
||||
|
||||
void main() {
|
||||
group('bootstrapQrCamera', () {
|
||||
test('권한 허용 후 카메라 실행 성공 시 ready 상태를 반환한다', () async {
|
||||
var stopCalled = false;
|
||||
|
||||
final result = await bootstrapQrCamera(
|
||||
hasBarcodeDetector: true,
|
||||
openCameraAndPlay: () async {},
|
||||
stopCamera: () async {
|
||||
stopCalled = true;
|
||||
},
|
||||
);
|
||||
|
||||
expect(result.status, QrCameraBootstrapStatus.ready);
|
||||
expect(stopCalled, isFalse);
|
||||
});
|
||||
|
||||
test('권한 허용 후 play 단계 오류는 cameraError로 분류한다', () async {
|
||||
var stopCalled = false;
|
||||
|
||||
final result = await bootstrapQrCamera(
|
||||
hasBarcodeDetector: true,
|
||||
openCameraAndPlay: () async {
|
||||
throw Exception('NotReadableError: Could not start video source');
|
||||
},
|
||||
stopCamera: () async {
|
||||
stopCalled = true;
|
||||
},
|
||||
);
|
||||
|
||||
expect(result.status, QrCameraBootstrapStatus.cameraError);
|
||||
expect(result.errorDetail, contains('NotReadableError'));
|
||||
expect(stopCalled, isFalse);
|
||||
});
|
||||
|
||||
test('권한 거부 오류는 permissionError로 분류한다', () async {
|
||||
final result = await bootstrapQrCamera(
|
||||
hasBarcodeDetector: true,
|
||||
openCameraAndPlay: () async {
|
||||
throw Exception('NotAllowedError: Permission denied');
|
||||
},
|
||||
stopCamera: () async {},
|
||||
);
|
||||
|
||||
expect(result.status, QrCameraBootstrapStatus.permissionError);
|
||||
expect(result.errorDetail, contains('NotAllowedError'));
|
||||
});
|
||||
|
||||
test('detector 미지원이면 카메라를 정리하고 detectorUnsupported를 반환한다', () async {
|
||||
var stopCalled = false;
|
||||
|
||||
final result = await bootstrapQrCamera(
|
||||
hasBarcodeDetector: false,
|
||||
openCameraAndPlay: () async {},
|
||||
stopCamera: () async {
|
||||
stopCalled = true;
|
||||
},
|
||||
);
|
||||
|
||||
expect(result.status, QrCameraBootstrapStatus.detectorUnsupported);
|
||||
expect(stopCalled, isTrue);
|
||||
});
|
||||
});
|
||||
}
|
||||
27
userfront/test/qr_scan_route_test.dart
Normal file
27
userfront/test/qr_scan_route_test.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:userfront/features/auth/presentation/qr_scan_route.dart';
|
||||
|
||||
void main() {
|
||||
group('buildQrApprovePath', () {
|
||||
test('스캔 값을 trim/encode 해서 approve 경로를 만든다', () {
|
||||
final result = buildQrApprovePath(
|
||||
' https://sss.hmac.kr/ql/abc-123?x=1&y=2 ',
|
||||
localeCode: 'ko',
|
||||
);
|
||||
|
||||
expect(
|
||||
result,
|
||||
'/ko/approve?ref=https%3A%2F%2Fsss.hmac.kr%2Fql%2Fabc-123%3Fx%3D1%26y%3D2',
|
||||
);
|
||||
});
|
||||
|
||||
test('현재 URI에서 locale을 추출한다', () {
|
||||
final result = buildQrApprovePath(
|
||||
'abc123',
|
||||
currentUri: Uri.parse('https://sss.hmac.kr/en/dashboard'),
|
||||
);
|
||||
|
||||
expect(result, '/en/approve?ref=abc123');
|
||||
});
|
||||
});
|
||||
}
|
||||
16
userfront/test/qr_scan_screen_test.dart
Normal file
16
userfront/test/qr_scan_screen_test.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:userfront/features/auth/presentation/qr_scan_screen.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('QR 스캔 화면은 비활성 문구 대신 입력/이동 UI를 노출한다', (tester) async {
|
||||
await tester.pumpWidget(const MaterialApp(home: QRScanScreen()));
|
||||
|
||||
expect(
|
||||
find.text('QR Scanner is temporarily disabled for WASM build stability.'),
|
||||
findsNothing,
|
||||
);
|
||||
expect(find.byKey(const ValueKey('qr_scan_manual_input')), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('qr_scan_submit_button')), findsOneWidget);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user