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);
    });
  });
}
