mirror of
https://github.com/wger-project/flutter.git
synced 2026-11-29 17:31:01 +01:00
Switch the pasted-token field from DRF tokens to refresh tokens
This commit is contained in:
@@ -68,7 +68,7 @@ void main() {
|
||||
expect(state.exerciseId, source.exerciseId);
|
||||
expect(state.weight, source.weight);
|
||||
expect(state.date, fixed);
|
||||
// setLog must clear the id — the source log is a template, the new
|
||||
// setLog must clear the id, the source log is a template, the new
|
||||
// state is a separate entry that will get its own UUID from Drift on
|
||||
// insert.
|
||||
expect(state.id, isNull);
|
||||
|
||||
@@ -74,7 +74,7 @@ void main() {
|
||||
mockExerciseRepo.watchAllDrift(),
|
||||
).thenAnswer((_) => Stream.value(ExerciseState(testExercises)));
|
||||
|
||||
// Drift the test routine in via the routines repository — the real
|
||||
// Drift the test routine in via the routines repository, the real
|
||||
// [RoutinesRiverpod] picks it up and exposes it through state.
|
||||
when(
|
||||
mockRoutinesRepo.watchAllDrift(),
|
||||
@@ -95,7 +95,7 @@ void main() {
|
||||
exerciseRepositoryProvider.overrideWithValue(mockExerciseRepo),
|
||||
workoutSessionRepositoryProvider.overrideWithValue(mockSessionRepo),
|
||||
// The repetition + weight unit catalogues are tiny direct-Drift
|
||||
// stream providers — overriding them inline is the established
|
||||
// stream providers, overriding them inline is the established
|
||||
// pattern (see also [exerciseCategoriesProvider] etc.).
|
||||
routineRepetitionUnitProvider.overrideWith(
|
||||
(ref) => Stream<List<RepetitionUnit>>.value(testRepetitionUnits),
|
||||
@@ -174,8 +174,8 @@ void main() {
|
||||
expect(find.byIcon(Icons.chevron_left), findsOneWidget);
|
||||
expect(find.byIcon(Icons.chevron_right), findsOneWidget);
|
||||
|
||||
// The form shows reps and weight — each with its own unit
|
||||
// picker (PopupMenuButton<int>) — plus the RiR slider, all at
|
||||
// The form shows reps and weight, each with its own unit
|
||||
// picker (PopupMenuButton<int>), plus the RiR slider, all at
|
||||
// once. Scope the popup-menu lookup to the LogPage so other
|
||||
// popup menus elsewhere in the app shell don't interfere.
|
||||
expect(find.byType(TextFormField), findsNWidgets(2));
|
||||
@@ -187,7 +187,7 @@ void main() {
|
||||
findsNWidgets(2),
|
||||
);
|
||||
expect(find.byType(RiRInputWidget), findsOneWidget);
|
||||
// Advance to the next page via the chevron — the RiR slider
|
||||
// Advance to the next page via the chevron, the RiR slider
|
||||
// would otherwise eat a horizontal-drag gesture started over
|
||||
// its track.
|
||||
await tester.tap(find.byIcon(Icons.chevron_right));
|
||||
|
||||
@@ -41,7 +41,7 @@ export 'routine_form_test_overrides.mocks.dart'
|
||||
/// without this stub.
|
||||
///
|
||||
/// When [exercise] / [session] are passed in by the caller they are used
|
||||
/// as-is — the caller owns the stubbing. Only the locally-created fallback
|
||||
/// as-is, the caller owns the stubbing. Only the locally-created fallback
|
||||
/// mocks get a default empty-stream stub here.
|
||||
List<Override> exerciseAndSessionRepoOverrides({
|
||||
MockExerciseRepository? exercise,
|
||||
@@ -73,7 +73,7 @@ MockWorkoutSessionRepository _emptySessionRepoMock() {
|
||||
/// Use this in widget tests that don't override the reference-data streams
|
||||
/// themselves; otherwise mix in [exerciseAndSessionRepoOverrides] alone.
|
||||
///
|
||||
/// [repetitionUnits] / [weightUnits] default to empty lists — sufficient for
|
||||
/// [repetitionUnits] / [weightUnits] default to empty lists, sufficient for
|
||||
/// most form widget tests where the units only need to satisfy the
|
||||
/// `awaitFirstValue` step. Pass real fixtures when the test exercises
|
||||
/// hydration logic that looks units up by id.
|
||||
|
||||
@@ -145,7 +145,7 @@ void main() {
|
||||
//
|
||||
// When the user taps "+" in gym mode to add an extra exercise,
|
||||
// addExerciseAfterPage() creates a SetConfigData with only exerciseId and
|
||||
// slotEntryId — no unit objects. The default constructor sets
|
||||
// slotEntryId, no unit objects. The default constructor sets
|
||||
// weightUnitId=WEIGHT_UNIT_KG and repetitionsUnitId=REP_UNIT_REPETITIONS_ID,
|
||||
// but Log.fromSetConfigData was using the object setters which overwrite
|
||||
// those IDs with null when the objects are null, causing the server to
|
||||
@@ -154,7 +154,7 @@ void main() {
|
||||
exerciseId: 1,
|
||||
slotEntryId: 1,
|
||||
exercise: exercise,
|
||||
// no weightUnit or repetitionsUnit objects — mirrors addExerciseAfterPage()
|
||||
// no weightUnit or repetitionsUnit objects, mirrors addExerciseAfterPage()
|
||||
);
|
||||
|
||||
final log = Log.fromSetConfigData(setConfig);
|
||||
|
||||
@@ -33,7 +33,7 @@ import 'routines_provider_repository_test.mocks.dart';
|
||||
void main() {
|
||||
final mockBaseProvider = MockWgerBaseProvider();
|
||||
// The repository now takes a Drift database in its constructor, but
|
||||
// none of the REST methods exercised in this file touch it — a plain
|
||||
// none of the REST methods exercised in this file touch it, a plain
|
||||
// mock instance is enough.
|
||||
final mockDb = MockDriftPowersyncDatabase();
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ void main() {
|
||||
mockRepo = MockRoutinesRepository();
|
||||
when(mockRepo.watchAllDrift()).thenAnswer((_) => Stream.value(const <Routine>[]));
|
||||
// Mock repos for the two reference-data notifiers `fetchAndSetRoutineFull`
|
||||
// awaits — kept locally so individual tests can re-stub them with
|
||||
// awaits, kept locally so individual tests can re-stub them with
|
||||
// specific session/exercise data.
|
||||
mockSessionRepo = MockWorkoutSessionRepository();
|
||||
when(
|
||||
@@ -178,7 +178,7 @@ void main() {
|
||||
verify(mockRepo.editDayServer(day1)).called(1);
|
||||
verify(mockRepo.editDayServer(day2)).called(1);
|
||||
// dayData/dayDataGym are server-computed, so we must refresh once after
|
||||
// the batch — not once per edit.
|
||||
// the batch, not once per edit.
|
||||
verify(mockRepo.fetchAndSetRoutineFullServer(101)).called(1);
|
||||
});
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ void main() {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
group('Routines — Drift', () {
|
||||
group('Routines, Drift', () {
|
||||
test('watchAllDrift emits an empty list when no routines exist', () async {
|
||||
expect(await repo.watchAllDrift().first, isEmpty);
|
||||
});
|
||||
@@ -155,7 +155,7 @@ void main() {
|
||||
// else lives here.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
group('Days — REST', () {
|
||||
group('Days, REST', () {
|
||||
test('addDayServer POSTs to /day/ and returns the created Day', () async {
|
||||
final dayUri = Uri.https('localhost', 'api/v2/day/');
|
||||
when(mockBase.makeUrl('day')).thenReturn(dayUri);
|
||||
@@ -200,7 +200,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
group('Slots — REST', () {
|
||||
group('Slots, REST', () {
|
||||
test('addSlotServer POSTs to /slot/ and returns the created Slot', () async {
|
||||
final uri = Uri.https('localhost', 'api/v2/slot/');
|
||||
when(mockBase.makeUrl('slot')).thenReturn(uri);
|
||||
@@ -232,7 +232,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
group('Slot entries — REST', () {
|
||||
group('Slot entries, REST', () {
|
||||
SlotEntry makeEntry({int? id, int slotId = 1}) {
|
||||
// `config` is `late Object?` and required for toJson to work.
|
||||
return SlotEntry(
|
||||
@@ -292,7 +292,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
group('Configs — REST', () {
|
||||
group('Configs, REST', () {
|
||||
Map<String, dynamic> configResponse(int id, num value) => {
|
||||
'id': id,
|
||||
'iteration': 1,
|
||||
|
||||
@@ -108,7 +108,7 @@ void main() {
|
||||
// Confirmation dialog
|
||||
expect(find.byType(AlertDialog), findsOneWidget);
|
||||
|
||||
// Confirm tap — note: the actual delete now goes through Drift +
|
||||
// Confirm tap, note: the actual delete now goes through Drift +
|
||||
// PowerSync (not REST), so we don't verify a repository call here.
|
||||
// The UI flow up to dispatch is what's covered.
|
||||
await tester.tap(find.text('Delete'));
|
||||
|
||||
@@ -58,7 +58,7 @@ void main() {
|
||||
Future<List<dynamic>> readLogs() => db.select(db.workoutLogTable).get();
|
||||
Future<List<dynamic>> readSessions() => db.select(db.workoutSessionTable).get();
|
||||
|
||||
group('addLocalDrift — log already has a sessionId', () {
|
||||
group('addLocalDrift, log already has a sessionId', () {
|
||||
test('inserts the log without touching the session table', () async {
|
||||
final log = makeLog(sessionId: 'existing-session');
|
||||
|
||||
@@ -71,7 +71,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
group('addLocalDrift — log without sessionId', () {
|
||||
group('addLocalDrift, log without sessionId', () {
|
||||
test('reuses an existing session for the same routine and day', () async {
|
||||
final existingSession = WorkoutSession(
|
||||
id: 'existing-session-1',
|
||||
|
||||
Reference in New Issue
Block a user