cec4c3e427
Adds an in-app review prompt gated by ReviewPromptPolicy: only after a 3-star stage win, once the player has cleared >=5 stages, at most once ever (persisted reviewRequested flag). ReviewService swallows all failures and only burns the one-shot when the store actually shows the sheet, so an unavailable store retries on a later win. StoreReviewer wraps in_app_review behind a Reviewer seam so unit tests skip platform channels. 13 new tests; full suite 194 green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
67 lines
1.4 KiB
Dart
67 lines
1.4 KiB
Dart
import 'package:block_seasons/services/review_prompt_policy.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
const policy = ReviewPromptPolicy(); // minStagesWon: 5, requiredStars: 3
|
|
|
|
test('asks for a review on a 3-star win once enough stages are cleared', () {
|
|
expect(
|
|
policy.shouldRequest(
|
|
alreadyRequested: false,
|
|
won: true,
|
|
stars: 3,
|
|
totalStagesWon: 5,
|
|
),
|
|
isTrue,
|
|
);
|
|
});
|
|
|
|
test('never asks again once a review has been requested', () {
|
|
expect(
|
|
policy.shouldRequest(
|
|
alreadyRequested: true,
|
|
won: true,
|
|
stars: 3,
|
|
totalStagesWon: 20,
|
|
),
|
|
isFalse,
|
|
);
|
|
});
|
|
|
|
test('does not ask after a loss', () {
|
|
expect(
|
|
policy.shouldRequest(
|
|
alreadyRequested: false,
|
|
won: false,
|
|
stars: 0,
|
|
totalStagesWon: 10,
|
|
),
|
|
isFalse,
|
|
);
|
|
});
|
|
|
|
test('does not ask before enough stages are cleared', () {
|
|
expect(
|
|
policy.shouldRequest(
|
|
alreadyRequested: false,
|
|
won: true,
|
|
stars: 3,
|
|
totalStagesWon: 4, // one short of the 5-stage gate
|
|
),
|
|
isFalse,
|
|
);
|
|
});
|
|
|
|
test('does not ask on a win below the star bar (2 stars)', () {
|
|
expect(
|
|
policy.shouldRequest(
|
|
alreadyRequested: false,
|
|
won: true,
|
|
stars: 2,
|
|
totalStagesWon: 10,
|
|
),
|
|
isFalse,
|
|
);
|
|
});
|
|
}
|