생성 때 고른 행성 형태·색 표시 · HOME 주간 정보

This commit is contained in:
Sn-Kinos
2026-10-05 23:21:44 +09:00
parent 55424bd4a2
commit c8c1a1ae67
40 changed files with 688 additions and 40 deletions
+65
View File
@@ -0,0 +1,65 @@
import 'package:fancake/features/home/home_data.dart';
import 'package:fancake/features/home/home_repository_firestore.dart' show kstWeekStart;
import 'package:flutter_test/flutter_test.dart';
/// HOME 주간 정보(A-37 · HOME 정보위계 v1.0 §2 · §3).
void main() {
Map<String, dynamic> snap(int rank, {num? growthPop, num? sfpi}) => {
'planets': [
{'fandomId': 'other', 'rank': 1},
{
'fandomId': 'f',
'rank': rank,
'growthPop': ?growthPop,
'sfpi': ?sfpi,
},
],
};
test('순위는 주간 Snapshot · 변동은 직전 대비 · 성장은 두 축 증분 · 비율은 행성 주간 총량 대비', () {
final w = HomeWeekly.from(
fandomId: 'f',
snapshots: [snap(3, growthPop: 1000, sfpi: 40), snap(5)],
fandom: {'growthPop': 1500, 'sfpi': 52},
myWeekPop: 125,
wallet: {'activityBalance': 700, 'supportBalance': 30},
);
expect(w.rank, 3);
expect(w.rankChange, 2, reason: '5위 → 3위 = 두 계단 오름');
expect(w.weekGrowthPop, 500);
expect(w.weekSfpi, 12);
expect(w.myShare, 0.25);
expect((w.generalPop, w.supportPop), (700, 30));
});
test('기준선 · 직전 Snapshot · 내 기여를 모르면 0 으로 채우지 않는다', () {
final w = HomeWeekly.from(
fandomId: 'f',
snapshots: [snap(4)],
fandom: {'growthPop': 1500},
myWeekPop: null,
wallet: const {},
);
expect(w.rank, 4);
expect(w.rankChange, isNull);
expect(w.weekGrowthPop, isNull);
expect(w.myShare, isNull);
final none = HomeWeekly.from(
fandomId: 'f', snapshots: const [], fandom: const {}, myWeekPop: 0, wallet: const {},
);
expect(none.rank, isNull);
});
test('이번 주 시작은 KST 월요일 00:00', () {
// 2026-10-07(수) 15:00 KST → 2026-10-05(월) 00:00 KST = 10-04 15:00 UTC.
expect(
kstWeekStart(DateTime.parse('2026-10-07T06:00:00Z')),
DateTime.parse('2026-10-04T15:00:00Z'),
);
// 월요일 08:59 KST(= 일요일 23:59 UTC)도 그 주다.
expect(
kstWeekStart(DateTime.parse('2026-10-04T23:59:00Z')),
DateTime.parse('2026-10-04T15:00:00Z'),
);
});
}
+19
View File
@@ -17,6 +17,25 @@ void main() {
expect(PlanetVisualState.fromDocument({'stage': 2}).evolutionImminent, isFalse);
});
test('생성 때 고른 형태가 HOME · GALAXY · 상세 · MY 그림을 정한다 (A-08 · Figma 344:214421)', () {
for (var i = 1; i <= 5; i++) {
expect(planetShapeImage('shape$i'), 'assets/figma/planet-shape-$i.png');
}
expect(planetShapeImage('shape6'), 'assets/figma/planet-shape-placeholder.png');
expect(planetShapeImage(null), isNull, reason: '성운 · 옛 행성은 화면이 준 그림');
expect(planetShapeImage('shape7'), isNull);
// 생성 화면이 보내는 키와 같은 표여야 한다.
for (final k in PlanetCreateScreen.shapes) {
expect(planetShapeImage(k), isNotNull);
}
final state = PlanetVisualState.fromDocument({'planetType': 'shape3', 'colorKey': 'gold'});
expect(state.planetType, 'shape3');
final node = const PlanetNode(
id: 'f', name: 'F', rank: 1, fpi: 0, members: 0, online: 0, planetType: 'shape2',
);
expect(GalaxyField.imageOf(node, 0), 'assets/figma/planet-shape-2.png');
});
test('컬러는 마스터(config/planetColors)가 정한다 — 추가 색은 그리고 숨긴 색은 고르지 못한다 (10/3 #6)', () {
final master = planetColorsFrom({'colors': [
{'key': 'gold', 'hex': '#FFC500', 'visible': false},