Files
pipelines/app/test/features/attention/runtime/attention_store_test.dart
T

37 lines
1.4 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/attention/domain/attention_models.dart';
import 'package:pipelines_app/features/attention/runtime/attention_store.dart';
import 'package:shared_preferences/shared_preferences.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
test('reads and writes only the attention model key', () async {
SharedPreferences.setMockInitialValues(<String, Object>{
attentionStorageKey: '["7:Failed"]',
'pipelines.next.workspace.v1': '/srv/keep',
});
const store = SharedPreferencesAttentionStore();
expect(await store.read(), '["7:Failed"]');
expect(await store.write('["8:Decision"]'), isTrue);
final preferences = await SharedPreferences.getInstance();
expect(preferences.getString(attentionStorageKey), '["8:Decision"]');
expect(
preferences.getString('pipelines.next.workspace.v1'),
'/srv/keep',
reason: 'another owned preference must not be rewritten',
);
});
test('an empty store reads as null and the key stays namespaced', () async {
SharedPreferences.setMockInitialValues(<String, Object>{});
const store = SharedPreferencesAttentionStore();
expect(await store.read(), isNull);
expect(attentionStorageKey, 'pipelines.next.attention.v1');
expect(await store.write('[]'), isTrue);
});
}