64 lines
3.4 KiB
Dart
64 lines
3.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:fancake/core/theme/app_theme.dart';
|
|
import 'package:fancake/core/ui/live_planet.dart';
|
|
import 'package:fancake/features/home/widgets/home_hero.dart';
|
|
import 'package:fancake/features/home/widgets/growth_conditions.dart';
|
|
import 'package:fancake/features/home/widgets/planet_growth_card.dart';
|
|
import 'package:fancake/features/home/home_data.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
testWidgets('행성 본체를 누르면 흔들린 뒤 커뮤니티로 간다 (Figma 2024:20758)', (tester) async {
|
|
const growth = PlanetGrowth(fandomName: 'BTS', contributorName: '팬', stage: 2,
|
|
contributedPop: 0, growthPercent: null, currentPop: null, requiredPop: null);
|
|
var opened = 0;
|
|
await tester.pumpWidget(MaterialApp(theme: buildAppTheme(),
|
|
home: Scaffold(body: HomeHero(growth: growth, fandomId: 'bts', onTapPlanet: () => opened++))));
|
|
await tester.pump(const Duration(milliseconds: 100));
|
|
await tester.tap(find.byType(LivePlanet25D), warnIfMissed: false);
|
|
await tester.pump(const Duration(milliseconds: 100));
|
|
expect(opened, 0, reason: '흔들림이 끝난 뒤 이동한다');
|
|
await tester.pump(const Duration(milliseconds: 400));
|
|
expect(opened, 1);
|
|
});
|
|
|
|
testWidgets('기여 기록이 없으면 두 성장 영역에 가짜 0 POP 기여를 표시하지 않는다', (tester) async {
|
|
const growth = PlanetGrowth(fandomName: 'BTS', contributorName: '팬',
|
|
contributedPop: 0, growthPercent: null, currentPop: null, requiredPop: null);
|
|
for (final widget in [const HomeHero(growth: growth), const PlanetGrowthCard(growth: growth)]) {
|
|
await tester.pumpWidget(MaterialApp(theme: buildAppTheme(), home: Scaffold(body: widget)));
|
|
await tester.pumpAndSettle();
|
|
expect(find.textContaining('0 POP', findRichText: true), findsNothing);
|
|
expect(find.textContaining('님의', findRichText: true), findsNothing);
|
|
expect(find.text('함께 키워가는 팬덤 행성'), findsOneWidget);
|
|
}
|
|
});
|
|
|
|
test('POP 진행만으로 진화 임박/완료를 단정하지 않고 문턱 누락을 구분한다', () {
|
|
PlanetGrowth growth(int? current, int? required) => PlanetGrowth(
|
|
fandomName: 'BTS',
|
|
contributorName: '팬',
|
|
contributedPop: 0,
|
|
growthPercent: 100,
|
|
currentPop: current,
|
|
requiredPop: required,
|
|
);
|
|
expect(growth(null, null).popConditionLabel, 'POP 조건 확인 중');
|
|
expect(growth(999, 1000).popConditionLabel, 'POP 조건 미충족');
|
|
expect(growth(1000, 1000).popConditionLabel, 'POP 조건 충족');
|
|
expect(growth(1200, 1000).popConditionLabel, 'POP 조건 충족');
|
|
});
|
|
|
|
testWidgets('목표 기간이 지난 성운은 기간 경과 문구를 보인다(Q-PN-02)', (tester) async {
|
|
PlanetGrowth nebula({required bool passed}) => PlanetGrowth(stage: 0, nebulaGoalPassed: passed,
|
|
fandomName: 'BTS', contributorName: '팬', contributedPop: 0, growthPercent: null,
|
|
currentPop: 500, requiredPop: null);
|
|
const text = '목표 기간이 지났어요 · 조건을 채우면 행성으로 탄생해요';
|
|
for (final (passed, expected) in [(true, findsOneWidget), (false, findsNothing)]) {
|
|
await tester.pumpWidget(MaterialApp(theme: buildAppTheme(),
|
|
home: Scaffold(body: GrowthConditions(growth: nebula(passed: passed)))));
|
|
expect(find.text(text), expected);
|
|
}
|
|
});
|
|
}
|