Files
BlockSeasons/test/state/season_refresh_test.dart
T
airkjw 1682578501 feat: start at Season 1, add menu/season_001 BGM tracks, settings build tag
- activeSeason now returns the first season (Season 1 'First Bloom') so a new
  player starts at spring instead of the newest season.
- Bundle the owner-picked CC0 tracks menu.mp3 + season_001.mp3 (BGM now audible).
- Settings footer shows 'v1.0.0 (build 3)' so test builds are identifiable.
180 tests green, analyze clean.
2026-06-14 10:32:12 +09:00

60 lines
1.7 KiB
Dart

import 'package:block_seasons/data/content_repository.dart';
import 'package:block_seasons/game/models/season.dart';
import 'package:block_seasons/game/models/stage.dart';
import 'package:block_seasons/state/providers.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
class _FakeRepo extends ContentRepository {
_FakeRepo(this.result);
final bool result;
int calls = 0;
@override
Future<bool> refresh() async {
calls++;
return result;
}
}
SeasonPack _pack(String id) => SeasonPack(
schemaVersion: 1,
seasonId: id,
version: 1,
title: const {'en': 'Test Season', 'ko': '테스트 시즌'},
theme: SeasonTheme.fallback,
stages: [
StageConfig(
id: 's1',
seed: 1,
moveLimit: 10,
preset: const [],
objectives: const [],
stars: const StarThresholds(twoMovesLeft: 2, threeMovesLeft: 4),
generatorProfile: 'mid',
),
],
);
void main() {
test('seasonRefreshProvider runs refresh once and exposes the result',
() async {
final repo = _FakeRepo(true);
final container = ProviderContainer(
overrides: [contentRepositoryProvider.overrideWithValue(repo)],
);
addTearDown(container.dispose);
expect(await container.read(seasonRefreshProvider.future), isTrue);
// Re-reading does not re-run (FutureProvider caches).
expect(await container.read(seasonRefreshProvider.future), isTrue);
expect(repo.calls, 1);
});
test('activeSeason starts at Season 1 (first by id)', () {
final p1 = _pack('season_001');
final p2 = _pack('season_002');
expect(activeSeason([p1, p2]).seasonId, 'season_001');
});
}