퀘스트 목록 페이지 판정 · 다시 읽기 · 캠페인 응원 수를 고유 후원자 기준으로

This commit is contained in:
Sn-Kinos
2026-10-06 02:19:40 +09:00
parent 807e446b8b
commit 82662b9b9f
8 changed files with 164 additions and 18 deletions
+28
View File
@@ -179,6 +179,34 @@ service cloud.firestore {
expect(cards.map((c) => c.id), contains('attend'));
});
test('비활성 문서가 첫 페이지를 채워도 11번째 이후 퀘스트가 보인다 (2026-10-06 실기기)', () async {
final db = FakeFirebaseFirestore();
// 문서 ID 순으로 앞 10건이 비활성(daily-*) — 걸러낸 뒤 개수로 끝을 판정하면 뒤가 사라진다.
for (var i = 0; i < 10; i++) {
await db.doc('quests/a-daily-$i').set({'type': 'attend', 'title': 'd$i', 'active': false});
}
await db.doc('quests/z-music').set({'type': 'music_shake', 'title': '박자 맞춰 흔들기'});
final repo = FirestoreQuestRepository(_RecordingBackend(db));
final first = await repo.load();
expect(first.map((c) => c.id), contains('z-music'));
// 10장보다 적으면 끝 — 다음 페이지는 비어 있다.
expect(first.length, lessThan(10));
expect(await repo.more(offset: first.length), isEmpty);
});
test('보이는 퀘스트가 10건을 넘으면 다음 페이지에서 11번째부터 온다', () async {
final db = FakeFirebaseFirestore();
for (var i = 0; i < 12; i++) {
await db.doc('quests/q${i.toString().padLeft(2, '0')}').set({'type': 'attend', 'title': 'q$i'});
}
final repo = FirestoreQuestRepository(_RecordingBackend(db));
final first = await repo.load();
expect(first, hasLength(10));
final next = await repo.more(offset: first.length);
expect(next, hasLength(2));
expect({...first, ...next}.map((c) => c.id).toSet(), hasLength(12));
});
test('내가 만든 퀘스트는 내 퀘스트 상태로 온다', () async {
final db = await _seed();
await db.doc('quests/mine').set({