Files
pipelines/app/test/features/changes/diff_layout_preference_test.dart
T
alan cbc06b2f13 Remember the diff layout across reloads
One file at a time or all files stacked is saved in the app's
preferences and restored when the app starts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 19:23:21 +00:00

32 lines
1.0 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/changes/widgets/diff_layout_preference.dart';
import 'package:shared_preferences/shared_preferences.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
test('the chosen layout is saved and comes back after a reload', () async {
SharedPreferences.setMockInitialValues({});
final first = DiffLayoutPreference();
await first.restore();
expect(first.value, isFalse);
first.value = true;
await pumpEventQueue();
// A new app session reads it back.
final next = DiffLayoutPreference();
await next.restore();
expect(next.value, isTrue);
});
test('a choice made while the saved one loads wins', () async {
SharedPreferences.setMockInitialValues({
DiffLayoutPreference.storageKey: true,
});
final layout = DiffLayoutPreference();
final restoring = layout.restore();
layout.value = false;
await restoring;
expect(layout.value, isFalse);
});
}