앱 단위·화면·통합 테스트
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fancake/core/theme/app_theme.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('기여 기록이 없으면 두 성장 영역에 가짜 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user