mirror of
https://github.com/immich-app/immich.git
synced 2024-12-21 01:39:59 +02:00
af32183728
* refactor: autoroutex pushroute * refactor: autoroutex popRoute * refactor: autoroutex navigate and replace * chore: add doc comments for extension methods * refactor: Add LoggerMixin and refactor Album activities to use mixin * refactor: Activity page * chore: activity user from user constructor * fix: update current asset after build method * refactor: tests with similar structure as lib * chore: remove avoid-declaring-call-method rule from dcm analysis * test: fix proper expect order * test: activity_statistics_provider_test * test: activity_provider_test * test: use proper matchers * test: activity_text_field_test & dismissible_activity_test added * test: add http mock to return transparent image * test: download isar core libs during test * test: add widget tags to widget test cases * test: activity_tile_test * build: currentAlbumProvider to generator * movie add / remove like to activity input tile * test: activities_page_test.dart * chore: better error logs * chore: dismissibleactivity as statelesswidget --------- Co-authored-by: shalong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
133 lines
3.2 KiB
Dart
133 lines
3.2 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:immich_mobile/modules/home/ui/asset_grid/asset_grid_data_structure.dart';
|
|
import 'package:immich_mobile/shared/models/asset.dart';
|
|
|
|
void main() {
|
|
final List<Asset> testAssets = [];
|
|
|
|
for (int i = 0; i < 150; i++) {
|
|
int month = i ~/ 31;
|
|
int day = (i % 31).toInt();
|
|
|
|
DateTime date = DateTime(2022, month, day);
|
|
|
|
testAssets.add(
|
|
Asset(
|
|
checksum: "",
|
|
localId: '$i',
|
|
ownerId: 1,
|
|
fileCreatedAt: date,
|
|
fileModifiedAt: date,
|
|
updatedAt: date,
|
|
durationInSeconds: 0,
|
|
type: AssetType.image,
|
|
fileName: '',
|
|
isFavorite: false,
|
|
isArchived: false,
|
|
isTrashed: false,
|
|
stackCount: 0,
|
|
),
|
|
);
|
|
}
|
|
|
|
final List<Asset> assets = [];
|
|
|
|
assets.addAll(
|
|
testAssets.sublist(0, 5).map((e) {
|
|
e.fileCreatedAt = DateTime(2022, 1, 5);
|
|
return e;
|
|
}).toList(),
|
|
);
|
|
assets.addAll(
|
|
testAssets.sublist(5, 10).map((e) {
|
|
e.fileCreatedAt = DateTime(2022, 1, 10);
|
|
return e;
|
|
}).toList(),
|
|
);
|
|
assets.addAll(
|
|
testAssets.sublist(10, 15).map((e) {
|
|
e.fileCreatedAt = DateTime(2022, 2, 17);
|
|
return e;
|
|
}).toList(),
|
|
);
|
|
assets.addAll(
|
|
testAssets.sublist(15, 30).map((e) {
|
|
e.fileCreatedAt = DateTime(2022, 10, 15);
|
|
return e;
|
|
}).toList(),
|
|
);
|
|
|
|
group('Test grouped', () {
|
|
test('test grouped check months', () async {
|
|
final renderList = await RenderList.fromAssets(
|
|
assets,
|
|
GroupAssetsBy.day,
|
|
);
|
|
|
|
// Oct
|
|
// Day 1
|
|
// 15 Assets => 5 Rows
|
|
// Feb
|
|
// Day 1
|
|
// 5 Assets => 2 Rows
|
|
// Jan
|
|
// Day 2
|
|
// 5 Assets => 2 Rows
|
|
// Day 1
|
|
// 5 Assets => 2 Rows
|
|
expect(renderList.elements, hasLength(4));
|
|
expect(
|
|
renderList.elements[0].type,
|
|
RenderAssetGridElementType.monthTitle,
|
|
);
|
|
expect(renderList.elements[0].date.month, 1);
|
|
expect(
|
|
renderList.elements[1].type,
|
|
RenderAssetGridElementType.groupDividerTitle,
|
|
);
|
|
expect(renderList.elements[1].date.month, 1);
|
|
expect(
|
|
renderList.elements[2].type,
|
|
RenderAssetGridElementType.monthTitle,
|
|
);
|
|
expect(renderList.elements[2].date.month, 2);
|
|
expect(
|
|
renderList.elements[3].type,
|
|
RenderAssetGridElementType.monthTitle,
|
|
);
|
|
expect(renderList.elements[3].date.month, 10);
|
|
});
|
|
|
|
test('test grouped check types', () async {
|
|
final renderList = await RenderList.fromAssets(
|
|
assets,
|
|
GroupAssetsBy.day,
|
|
);
|
|
|
|
// Oct
|
|
// Day 1
|
|
// 15 Assets => 3 Rows
|
|
// Feb
|
|
// Day 1
|
|
// 5 Assets => 1 Row
|
|
// Jan
|
|
// Day 2
|
|
// 5 Assets => 1 Row
|
|
// Day 1
|
|
// 5 Assets => 1 Row
|
|
final types = [
|
|
RenderAssetGridElementType.monthTitle,
|
|
RenderAssetGridElementType.groupDividerTitle,
|
|
RenderAssetGridElementType.monthTitle,
|
|
RenderAssetGridElementType.monthTitle,
|
|
];
|
|
|
|
expect(renderList.elements, hasLength(types.length));
|
|
|
|
for (int i = 0; i < renderList.elements.length; i++) {
|
|
expect(renderList.elements[i].type, types[i]);
|
|
}
|
|
});
|
|
});
|
|
}
|