// auth_redesign_golden_test.dart — 登录页 Flutter 渲染图(供 design-distill 截图 diff)
// 900x700 @1x,与原型截图同 viewport;明/暗各一张。
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pangolin_vpn/l10n/strings_zh.dart';
import 'package:pangolin_vpn/pangolin_theme.dart';
import 'package:pangolin_vpn/services/token_store.dart';
import 'package:pangolin_vpn/state/auth_provider.dart';
import 'package:pangolin_vpn/widgets/auth_screen.dart';

class _NullTokenStore implements TokenStore {
  const _NullTokenStore();
  @override
  Future<void> saveTokens({required String access, required String refresh}) async {}
  @override
  Future<String?> loadAccessToken() async => null;
  @override
  Future<String?> loadRefreshToken() async => null;
  @override
  Future<void> clear() async {}
  @override
  Future<void> markOnboarded() async {}
  @override
  Future<bool> isOnboarded() async => true;
  @override
  Future<void> saveLastEmail(String email) async {}
  @override
  Future<String?> loadLastEmail() async => null;
}

Future<void> _shoot(WidgetTester tester, ThemeData theme, String name) async {
  tester.view.physicalSize = const Size(900, 700);
  tester.view.devicePixelRatio = 1.0;
  addTearDown(tester.view.resetPhysicalSize);
  addTearDown(tester.view.resetDevicePixelRatio);
  await tester.pumpWidget(ProviderScope(
    overrides: [tokenStoreProvider.overrideWithValue(const _NullTokenStore())],
    child: MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: theme,
      home: AuthScreen(t: const StringsZh(), onDone: () {}),
    ),
  ));
  await tester.pumpAndSettle();
  await expectLater(find.byType(AuthScreen), matchesGoldenFile('goldens/$name.png'));
}

void main() {
  testWidgets('auth login light', (t) => _shoot(t, PangolinTheme.light, 'auth_login_light'));
  testWidgets('auth login dark', (t) => _shoot(t, PangolinTheme.dark, 'auth_login_dark'));
}
