FPI 랭킹 내 행성·내 국가 판정 · 콜드 스타트 약관 깜빡임 · 로그아웃 상한
This commit is contained in:
@@ -455,9 +455,11 @@ void main() {
|
||||
},
|
||||
'createdAt': DateTime(2026, 9, 1, 0),
|
||||
});
|
||||
// 내 행성 · 내 국가는 가입 목록과 사용자 프로필에서 읽는다.
|
||||
await db.doc('users/$_uid/memberships/bts').set({'fandomId': 'bts'});
|
||||
await db.doc('users/$_uid').set({'countryCode': 'KR'}, SetOptions(merge: true));
|
||||
await db.doc('fandoms/bts/members/$_uid').set({
|
||||
'nickname': '나',
|
||||
// 국가 랭킹의 「나의 랭킹 영역」이 읽는 비정규화 국가 코드.
|
||||
'countryCode': 'KR',
|
||||
'topPercentByAxis': {'bpm': 3, 'health': 12},
|
||||
'fpiAxes': {'bpm': 2740, 'referral': 3180},
|
||||
@@ -582,6 +584,32 @@ void main() {
|
||||
expect(ranking.mine!.change, 1);
|
||||
});
|
||||
|
||||
test('미가입 행성에서 연 랭킹은 그 행성이 아니라 내 대표 행성을 「나」로 둔다 — 10/6 C-7', () async {
|
||||
final db = await seedPlanet();
|
||||
// nj 는 가입하지 않은 행성이다. 대표 행성은 bts(users.fandomId).
|
||||
final ranking = await FirestorePlanetRepository(_backend(db), fandomId: 'nj')
|
||||
.planetRanking(metric: FpiMetric.bpm);
|
||||
expect(ranking.rows.where((r) => r.isMine).map((r) => r.id), ['bts']);
|
||||
expect(ranking.mine!.id, 'bts');
|
||||
// 국가는 보고 있는 행성의 멤버 문서가 아니라 내 프로필 국가다.
|
||||
await db.doc('rankings/country-bpm').set({
|
||||
'rows': [{'code': 'KR', 'value': 1, 'change': 0}],
|
||||
});
|
||||
final country = await FirestorePlanetRepository(_backend(db), fandomId: 'nj')
|
||||
.countryRanking(metric: FpiMetric.bpm);
|
||||
expect(country.mine!.id, 'KR');
|
||||
});
|
||||
|
||||
test('가입한 행성이 하나도 없으면 「나」 행이 없다', () async {
|
||||
final db = await seedPlanet();
|
||||
await db.doc('users/$_uid/memberships/bts').delete();
|
||||
await db.doc('users/$_uid').update({'fandomId': ''});
|
||||
final ranking = await FirestorePlanetRepository(_backend(db), fandomId: 'nj')
|
||||
.planetRanking(metric: FpiMetric.bpm);
|
||||
expect(ranking.rows.any((r) => r.isMine), isFalse);
|
||||
expect(ranking.mine, isNull);
|
||||
});
|
||||
|
||||
test('랭킹은 마지막 갱신 시각과 갱신 주기를 함께 준다 — 별첨 1 ② 예외처리', () async {
|
||||
final db = await seedPlanet();
|
||||
final at = DateTime.utc(2026, 10, 7, 3, 4);
|
||||
|
||||
@@ -1030,6 +1030,31 @@ void main() {
|
||||
await session.close();
|
||||
});
|
||||
|
||||
testWidgets('푸시 정리가 멈춰도 상한 안에 첫 확인으로 로그아웃된다 — 확인 버튼은 진행 중 (10/6 r3)', (tester) async {
|
||||
final session = _LogoutSession(
|
||||
const AuthAccount(uid: 'u1', provider: SocialProvider.google),
|
||||
);
|
||||
final auth = AuthRepository(providers: const [], session: session, releaseMode: true);
|
||||
await pumpWide(
|
||||
tester,
|
||||
SettingsScreen(repository: SampleMyRepository(), auth: auth, push: _HangingPush()),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.scrollUntilVisible(find.text('로그아웃'), 220, scrollable: find.byType(Scrollable).first);
|
||||
await tester.tap(find.text('로그아웃'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.widgetWithText(FilledButton, '로그아웃'));
|
||||
await tester.pump();
|
||||
// 정리가 도는 동안 확인 버튼은 진행 중 표시다.
|
||||
expect(find.byType(CircularProgressIndicator), findsOneWidget);
|
||||
expect(session.signOutCalls, 0);
|
||||
await tester.pump(const Duration(seconds: 4));
|
||||
await tester.pumpAndSettle();
|
||||
expect(session.signOutCalls, 1);
|
||||
auth.dispose();
|
||||
await session.close();
|
||||
});
|
||||
|
||||
testWidgets('로그아웃을 확인하면 세션이 끊긴다 (F6 · 554:22903)', (tester) async {
|
||||
final session = _LogoutSession(
|
||||
const AuthAccount(uid: 'u1', provider: SocialProvider.google),
|
||||
@@ -1074,6 +1099,15 @@ class _FailingPush implements PushMessaging {
|
||||
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
||||
}
|
||||
|
||||
/// 푸시 정리가 응답 없이 멈추는 경계 — 토픽 해제가 끝나지 않는다.
|
||||
class _HangingPush implements PushMessaging {
|
||||
@override
|
||||
Future<void> clearOnSignOut() => Completer<void>().future;
|
||||
|
||||
@override
|
||||
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
||||
}
|
||||
|
||||
/// 로그아웃 호출을 세는 최소 세션. 실제 Firebase 를 붙이지 않는다.
|
||||
final class _LogoutSession implements AuthSession {
|
||||
_LogoutSession(this._current);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fancake/app.dart';
|
||||
import 'package:fancake/core/data/repositories.dart';
|
||||
import 'package:fancake/core/firebase/firebase_boot.dart';
|
||||
@@ -5,6 +7,7 @@ import 'package:fancake/features/auth/auth.dart';
|
||||
import 'package:fancake/features/auth/auth_repository.dart';
|
||||
import 'package:fancake/features/auth/login_screen.dart';
|
||||
import 'package:fancake/features/auth/onboarding_data.dart';
|
||||
import 'package:fancake/features/auth/onboarding_screens.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
@@ -20,6 +23,7 @@ void main() {
|
||||
WidgetTester tester, {
|
||||
required bool needs,
|
||||
bool intro = false,
|
||||
Duration checkDelay = Duration.zero,
|
||||
}) async {
|
||||
tester.view.physicalSize = const Size(1080, 2400);
|
||||
tester.view.devicePixelRatio = 2;
|
||||
@@ -28,7 +32,7 @@ void main() {
|
||||
final auth = AuthRepository(
|
||||
providers: [_Provider()],
|
||||
releaseMode: true,
|
||||
needsOnboarding: (_) async => needs,
|
||||
needsOnboarding: (_) => Future.delayed(checkDelay, () => needs),
|
||||
introPending: intro,
|
||||
);
|
||||
addTearDown(auth.dispose);
|
||||
@@ -53,6 +57,22 @@ void main() {
|
||||
expect(find.byType(NavigationBar), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('동의한 계정은 셸로 가는 동안 약관 화면이 한 프레임도 그려지지 않는다 — 10/6 콜드 스타트 깜빡임', (tester) async {
|
||||
// 서버 판정이 몇 프레임 걸리는 실기기처럼 늦춘다.
|
||||
final (auth, _) = await boot(
|
||||
tester,
|
||||
needs: false,
|
||||
checkDelay: const Duration(milliseconds: 200),
|
||||
);
|
||||
unawaited(auth.signIn(SocialProvider.google));
|
||||
for (var i = 0; i < 60; i++) {
|
||||
await tester.pump(const Duration(milliseconds: 16));
|
||||
expect(find.byType(OnboardingFlow), findsNothing);
|
||||
}
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(NavigationBar), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('약관 → 프로필 → 관심 아티스트 → 행성 가입 → 권한 → 가입 완료 → 셸', (tester) async {
|
||||
final (auth, repo) = await boot(tester, needs: true);
|
||||
await auth.signIn(SocialProvider.google);
|
||||
|
||||
Reference in New Issue
Block a user