feat(project): persist catalog snapshot in project data
This commit is contained in:
@@ -4,7 +4,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:korken_mosaic/project_codec.dart';
|
||||
|
||||
void main() {
|
||||
test('MosaicProjectData json roundtrip keeps values', () {
|
||||
test('MosaicProjectData json roundtrip keeps values including catalog snapshot', () {
|
||||
final original = MosaicProjectData(
|
||||
useCapSize: true,
|
||||
gridWidth: '50',
|
||||
@@ -16,6 +16,10 @@ void main() {
|
||||
colorVariation: 0.5,
|
||||
selectedPreset: 'realistisch',
|
||||
sourceImageBytes: Uint8List.fromList([1, 2, 3]),
|
||||
catalogSnapshot: const [
|
||||
MosaicPaletteSnapshotEntry(name: 'White', colorValue: 0xFFF2F2F2),
|
||||
MosaicPaletteSnapshotEntry(name: 'Blue', colorValue: 0xFF3F6FD8),
|
||||
],
|
||||
savedAt: DateTime.parse('2026-01-01T12:00:00Z'),
|
||||
);
|
||||
|
||||
@@ -28,5 +32,22 @@ void main() {
|
||||
expect(decoded.selectedPreset, 'realistisch');
|
||||
expect(decoded.sourceImageBytes, isNotNull);
|
||||
expect(decoded.sourceImageBytes!, [1, 2, 3]);
|
||||
expect(decoded.catalogSnapshot.length, 2);
|
||||
expect(decoded.catalogSnapshot.first.name, 'White');
|
||||
expect(decoded.catalogSnapshot.last.colorValue, 0xFF3F6FD8);
|
||||
});
|
||||
|
||||
test('MosaicProjectData defaults to empty snapshot when old project has none', () {
|
||||
final decoded = MosaicProjectData.fromJson({
|
||||
'useCapSize': false,
|
||||
'gridWidth': '40',
|
||||
'gridHeight': '30',
|
||||
'capSize': '12',
|
||||
'selectedPreset': 'ausgewogen',
|
||||
'savedAt': '2026-01-01T12:00:00Z',
|
||||
});
|
||||
|
||||
expect(decoded.catalogSnapshot, isEmpty);
|
||||
expect(decoded.sourceImageBytes, isNull);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user