From 6be0914b65cfbc00961249f7ff536597ecfafec3 Mon Sep 17 00:00:00 2001 From: kyy Date: Tue, 28 Apr 2026 10:58:14 +0900 Subject: [PATCH] =?UTF-8?q?=ED=85=8C=EB=84=8C=ED=8A=B8=20=EC=A0=91?= =?UTF-8?q?=EA=B7=BC=20=EC=A0=9C=ED=95=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/consent_error_routing_test.dart | 23 +++++++++ userfront/test/error_screen_test.dart | 51 +++++++++++++++---- 2 files changed, 64 insertions(+), 10 deletions(-) create mode 100644 userfront/test/consent_error_routing_test.dart diff --git a/userfront/test/consent_error_routing_test.dart b/userfront/test/consent_error_routing_test.dart new file mode 100644 index 00000000..4373e3d1 --- /dev/null +++ b/userfront/test/consent_error_routing_test.dart @@ -0,0 +1,23 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:userfront/core/services/auth_proxy_service.dart'; +import 'package:userfront/features/auth/domain/consent_error_routing.dart'; + +void main() { + test('tenant_not_allowed consent error routes to dedicated error screen', () { + const error = AuthProxyException( + errorCode: 'tenant_not_allowed', + message: '허용되지 않은 테넌트입니다.', + ); + + expect(shouldRouteConsentErrorToErrorScreen(error), isTrue); + }); + + test('generic consent error stays on consent screen', () { + const error = AuthProxyException( + errorCode: 'forbidden', + message: '동의 정보를 가져오지 못했습니다.', + ); + + expect(shouldRouteConsentErrorToErrorScreen(error), isFalse); + }); +} diff --git a/userfront/test/error_screen_test.dart b/userfront/test/error_screen_test.dart index 036c5aa2..6c38c57d 100644 --- a/userfront/test/error_screen_test.dart +++ b/userfront/test/error_screen_test.dart @@ -10,6 +10,7 @@ Future _pumpErrorScreen( String? description, bool? isProdOverride, Future> Function()? sessionProfileLoader, + Map? tenantAccessDetails, }) async { await tester.pumpWidget( MaterialApp( @@ -18,6 +19,7 @@ Future _pumpErrorScreen( description: description, isProdOverride: isProdOverride, sessionProfileLoader: sessionProfileLoader, + tenantAccessDetails: tenantAccessDetails, ), ), ); @@ -213,20 +215,21 @@ void main() { ); final title = tr( - 'msg.userfront.error.title', - fallback: '인증 과정에서 오류가 발생했습니다', + 'msg.userfront.error.tenant.page_title', + fallback: '애플리케이션 접근이 제한되었습니다', ); final detail = tr( 'msg.userfront.error.tenant.detail', fallback: '현재 로그인된 계정은 이 애플리케이션에 접근할 수 없습니다.', ); - final account = tr( - 'msg.userfront.error.tenant.account', - fallback: '계정', + final account = tr('msg.userfront.error.tenant.account', fallback: '계정'); + final primaryTenant = tr( + 'msg.userfront.error.tenant.primary_tenant', + fallback: '대표 소속 테넌트', ); - final tenant = tr( - 'msg.userfront.error.tenant.tenant', - fallback: '소속 테넌트', + final affiliatedTenants = tr( + 'msg.userfront.error.tenant.affiliated_tenants', + fallback: '전체 소속 테넌트', ); final switchAccount = tr( 'ui.userfront.error.switch_account', @@ -237,8 +240,36 @@ void main() { expect(find.text(detail), findsOneWidget); expect(find.text(account), findsOneWidget); expect(find.text('employee@example.com'), findsOneWidget); - expect(find.text(tenant), findsOneWidget); - expect(find.text('Baron HQ'), findsOneWidget); + expect(find.text(primaryTenant), findsOneWidget); + expect(find.text(affiliatedTenants), findsOneWidget); + expect(find.text('Baron HQ'), findsNWidgets(2)); expect(find.text(switchAccount), findsOneWidget); }); + + testWidgets('tenant_not_allowed는 details를 우선 사용해 계정과 테넌트 정보를 노출한다', ( + WidgetTester tester, + ) async { + await _pumpErrorScreen( + tester, + errorCode: 'tenant_not_allowed', + isProdOverride: true, + tenantAccessDetails: { + 'account': {'email': 'dyddus1210@gmail.com'}, + 'current_tenant': {'name': 'test1 company', 'slug': 'test1-company'}, + 'affiliated_tenants': [ + {'name': 'test1 company', 'slug': 'test1-company'}, + {'name': 'test2 company', 'slug': 'test-company'}, + ], + 'allowed_tenants': [ + {'name': 'test4', 'slug': 'test4'}, + ], + }, + ); + + expect(find.text('dyddus1210@gmail.com'), findsOneWidget); + expect(find.text('test1 company'), findsOneWidget); + expect(find.text('test1 company, test2 company'), findsOneWidget); + expect(find.text('test4'), findsOneWidget); + expect(find.text('알 수 없음'), findsNothing); + }); }