Source Code added
This commit is contained in:
parent
800376eafd
commit
9efa9bc6dd
3912 changed files with 754770 additions and 2 deletions
118
mobile/test/fixtures/album.stub.dart
vendored
Normal file
118
mobile/test/fixtures/album.stub.dart
vendored
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
import 'package:immich_mobile/domain/models/album/local_album.model.dart';
|
||||
import 'package:immich_mobile/entities/album.entity.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/user.entity.dart';
|
||||
|
||||
import 'asset.stub.dart';
|
||||
import 'user.stub.dart';
|
||||
|
||||
final class AlbumStub {
|
||||
const AlbumStub._();
|
||||
|
||||
static final emptyAlbum = Album(
|
||||
name: "empty-album",
|
||||
localId: "empty-album-local",
|
||||
remoteId: "empty-album-remote",
|
||||
createdAt: DateTime(2000),
|
||||
modifiedAt: DateTime(2023),
|
||||
shared: false,
|
||||
activityEnabled: false,
|
||||
startDate: DateTime(2020),
|
||||
);
|
||||
|
||||
static final sharedWithUser = Album(
|
||||
name: "empty-album-shared-with-user",
|
||||
localId: "empty-album-shared-with-user-local",
|
||||
remoteId: "empty-album-shared-with-user-remote",
|
||||
createdAt: DateTime(2023),
|
||||
modifiedAt: DateTime(2023),
|
||||
shared: true,
|
||||
activityEnabled: false,
|
||||
endDate: DateTime(2020),
|
||||
)..sharedUsers.addAll([User.fromDto(UserStub.admin)]);
|
||||
|
||||
static final oneAsset = Album(
|
||||
name: "album-with-single-asset",
|
||||
localId: "album-with-single-asset-local",
|
||||
remoteId: "album-with-single-asset-remote",
|
||||
createdAt: DateTime(2022),
|
||||
modifiedAt: DateTime(2023),
|
||||
shared: false,
|
||||
activityEnabled: false,
|
||||
startDate: DateTime(2020),
|
||||
endDate: DateTime(2023),
|
||||
)..assets.addAll([AssetStub.image1]);
|
||||
|
||||
static final twoAsset =
|
||||
Album(
|
||||
name: "album-with-two-assets",
|
||||
localId: "album-with-two-assets-local",
|
||||
remoteId: "album-with-two-assets-remote",
|
||||
createdAt: DateTime(2001),
|
||||
modifiedAt: DateTime(2010),
|
||||
shared: false,
|
||||
activityEnabled: false,
|
||||
startDate: DateTime(2019),
|
||||
endDate: DateTime(2020),
|
||||
)
|
||||
..assets.addAll([AssetStub.image1, AssetStub.image2])
|
||||
..activityEnabled = true
|
||||
..owner.value = User.fromDto(UserStub.admin);
|
||||
|
||||
static final create2020end2020Album = Album(
|
||||
name: "create2020update2020Album",
|
||||
localId: "create2020update2020Album-local",
|
||||
remoteId: "create2020update2020Album-remote",
|
||||
createdAt: DateTime(2020),
|
||||
modifiedAt: DateTime(2020),
|
||||
shared: false,
|
||||
activityEnabled: false,
|
||||
startDate: DateTime(2020),
|
||||
endDate: DateTime(2020),
|
||||
);
|
||||
static final create2020end2022Album = Album(
|
||||
name: "create2020update2021Album",
|
||||
localId: "create2020update2021Album-local",
|
||||
remoteId: "create2020update2021Album-remote",
|
||||
createdAt: DateTime(2020),
|
||||
modifiedAt: DateTime(2022),
|
||||
shared: false,
|
||||
activityEnabled: false,
|
||||
startDate: DateTime(2020),
|
||||
endDate: DateTime(2022),
|
||||
);
|
||||
static final create2020end2024Album = Album(
|
||||
name: "create2020update2022Album",
|
||||
localId: "create2020update2022Album-local",
|
||||
remoteId: "create2020update2022Album-remote",
|
||||
createdAt: DateTime(2020),
|
||||
modifiedAt: DateTime(2024),
|
||||
shared: false,
|
||||
activityEnabled: false,
|
||||
startDate: DateTime(2020),
|
||||
endDate: DateTime(2024),
|
||||
);
|
||||
static final create2020end2026Album = Album(
|
||||
name: "create2020update2023Album",
|
||||
localId: "create2020update2023Album-local",
|
||||
remoteId: "create2020update2023Album-remote",
|
||||
createdAt: DateTime(2020),
|
||||
modifiedAt: DateTime(2026),
|
||||
shared: false,
|
||||
activityEnabled: false,
|
||||
startDate: DateTime(2020),
|
||||
endDate: DateTime(2026),
|
||||
);
|
||||
}
|
||||
|
||||
abstract final class LocalAlbumStub {
|
||||
const LocalAlbumStub._();
|
||||
|
||||
static final recent = LocalAlbum(
|
||||
id: "recent-local-id",
|
||||
name: "Recent",
|
||||
updatedAt: DateTime(2023),
|
||||
assetCount: 1000,
|
||||
backupSelection: BackupSelection.none,
|
||||
isIosSharedAlbum: false,
|
||||
);
|
||||
}
|
||||
78
mobile/test/fixtures/asset.stub.dart
vendored
Normal file
78
mobile/test/fixtures/asset.stub.dart
vendored
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||
import 'package:immich_mobile/domain/models/exif.model.dart';
|
||||
import 'package:immich_mobile/entities/asset.entity.dart' as old;
|
||||
|
||||
final class AssetStub {
|
||||
const AssetStub._();
|
||||
|
||||
static final image1 = old.Asset(
|
||||
checksum: "image1-checksum",
|
||||
localId: "image1",
|
||||
remoteId: 'image1-remote',
|
||||
ownerId: 1,
|
||||
fileCreatedAt: DateTime(2019),
|
||||
fileModifiedAt: DateTime(2020),
|
||||
updatedAt: DateTime.now(),
|
||||
durationInSeconds: 0,
|
||||
type: old.AssetType.image,
|
||||
fileName: "image1.jpg",
|
||||
isFavorite: true,
|
||||
isArchived: false,
|
||||
isTrashed: false,
|
||||
exifInfo: const ExifInfo(isFlipped: false),
|
||||
);
|
||||
|
||||
static final image2 = old.Asset(
|
||||
checksum: "image2-checksum",
|
||||
localId: "image2",
|
||||
remoteId: 'image2-remote',
|
||||
ownerId: 1,
|
||||
fileCreatedAt: DateTime(2000),
|
||||
fileModifiedAt: DateTime(2010),
|
||||
updatedAt: DateTime.now(),
|
||||
durationInSeconds: 60,
|
||||
type: old.AssetType.video,
|
||||
fileName: "image2.jpg",
|
||||
isFavorite: false,
|
||||
isArchived: false,
|
||||
isTrashed: false,
|
||||
exifInfo: const ExifInfo(isFlipped: true),
|
||||
);
|
||||
|
||||
static final image3 = old.Asset(
|
||||
checksum: "image3-checksum",
|
||||
localId: "image3",
|
||||
ownerId: 1,
|
||||
fileCreatedAt: DateTime(2025),
|
||||
fileModifiedAt: DateTime(2025),
|
||||
updatedAt: DateTime.now(),
|
||||
durationInSeconds: 60,
|
||||
type: old.AssetType.image,
|
||||
fileName: "image3.jpg",
|
||||
isFavorite: true,
|
||||
isArchived: false,
|
||||
isTrashed: false,
|
||||
);
|
||||
}
|
||||
|
||||
abstract final class LocalAssetStub {
|
||||
const LocalAssetStub._();
|
||||
|
||||
static final image1 = LocalAsset(
|
||||
id: "image1",
|
||||
name: "image1.jpg",
|
||||
type: AssetType.image,
|
||||
createdAt: DateTime(2025),
|
||||
updatedAt: DateTime(2025, 2),
|
||||
isEdited: false,
|
||||
);
|
||||
|
||||
static final image2 = LocalAsset(
|
||||
id: "image2",
|
||||
name: "image2.jpg",
|
||||
type: AssetType.image,
|
||||
createdAt: DateTime(2000),
|
||||
updatedAt: DateTime(20021),
|
||||
isEdited: false,
|
||||
);
|
||||
}
|
||||
18
mobile/test/fixtures/exif.stub.dart
vendored
Normal file
18
mobile/test/fixtures/exif.stub.dart
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import 'package:immich_mobile/domain/models/exif.model.dart';
|
||||
|
||||
abstract final class ExifStub {
|
||||
static final size = const ExifInfo(assetId: 1, fileSize: 1000);
|
||||
|
||||
static final gps = const ExifInfo(
|
||||
assetId: 2,
|
||||
latitude: 20,
|
||||
longitude: 20,
|
||||
city: 'city',
|
||||
state: 'state',
|
||||
country: 'country',
|
||||
);
|
||||
|
||||
static final rotated90CW = const ExifInfo(assetId: 3, orientation: "90");
|
||||
|
||||
static final rotated270CW = const ExifInfo(assetId: 4, orientation: "-90");
|
||||
}
|
||||
136
mobile/test/fixtures/sync_stream.stub.dart
vendored
Normal file
136
mobile/test/fixtures/sync_stream.stub.dart
vendored
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
import 'package:immich_mobile/domain/models/sync_event.model.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
abstract final class SyncStreamStub {
|
||||
static final userV1Admin = SyncEvent(
|
||||
type: SyncEntityType.userV1,
|
||||
data: SyncUserV1(
|
||||
deletedAt: DateTime(2020),
|
||||
email: "admin@admin",
|
||||
id: "1",
|
||||
name: "Admin",
|
||||
avatarColor: null,
|
||||
hasProfileImage: false,
|
||||
profileChangedAt: DateTime(2025),
|
||||
),
|
||||
ack: "1",
|
||||
);
|
||||
static final userV1User = SyncEvent(
|
||||
type: SyncEntityType.userV1,
|
||||
data: SyncUserV1(
|
||||
deletedAt: DateTime(2021),
|
||||
email: "user@user",
|
||||
id: "5",
|
||||
name: "User",
|
||||
avatarColor: null,
|
||||
hasProfileImage: false,
|
||||
profileChangedAt: DateTime(2025),
|
||||
),
|
||||
ack: "5",
|
||||
);
|
||||
static final userDeleteV1 = SyncEvent(
|
||||
type: SyncEntityType.userDeleteV1,
|
||||
data: SyncUserDeleteV1(userId: "2"),
|
||||
ack: "2",
|
||||
);
|
||||
|
||||
static final partnerV1 = SyncEvent(
|
||||
type: SyncEntityType.partnerV1,
|
||||
data: SyncPartnerV1(inTimeline: true, sharedById: "1", sharedWithId: "2"),
|
||||
ack: "3",
|
||||
);
|
||||
static final partnerDeleteV1 = SyncEvent(
|
||||
type: SyncEntityType.partnerDeleteV1,
|
||||
data: SyncPartnerDeleteV1(sharedById: "3", sharedWithId: "4"),
|
||||
ack: "4",
|
||||
);
|
||||
|
||||
static final memoryV1 = SyncEvent(
|
||||
type: SyncEntityType.memoryV1,
|
||||
data: SyncMemoryV1(
|
||||
createdAt: DateTime(2023, 1, 1),
|
||||
data: {"year": 2023, "title": "Test Memory"},
|
||||
deletedAt: null,
|
||||
hideAt: null,
|
||||
id: "memory-1",
|
||||
isSaved: false,
|
||||
memoryAt: DateTime(2023, 1, 1),
|
||||
ownerId: "user-1",
|
||||
seenAt: null,
|
||||
showAt: DateTime(2023, 1, 1),
|
||||
type: MemoryType.onThisDay,
|
||||
updatedAt: DateTime(2023, 1, 1),
|
||||
),
|
||||
ack: "5",
|
||||
);
|
||||
|
||||
static final memoryDeleteV1 = SyncEvent(
|
||||
type: SyncEntityType.memoryDeleteV1,
|
||||
data: SyncMemoryDeleteV1(memoryId: "memory-2"),
|
||||
ack: "6",
|
||||
);
|
||||
|
||||
static final memoryToAssetV1 = SyncEvent(
|
||||
type: SyncEntityType.memoryToAssetV1,
|
||||
data: SyncMemoryAssetV1(assetId: "asset-1", memoryId: "memory-1"),
|
||||
ack: "7",
|
||||
);
|
||||
|
||||
static final memoryToAssetDeleteV1 = SyncEvent(
|
||||
type: SyncEntityType.memoryToAssetDeleteV1,
|
||||
data: SyncMemoryAssetDeleteV1(assetId: "asset-2", memoryId: "memory-1"),
|
||||
ack: "8",
|
||||
);
|
||||
|
||||
static final assetDeleteV1 = SyncEvent(
|
||||
type: SyncEntityType.assetDeleteV1,
|
||||
data: SyncAssetDeleteV1(assetId: "remote-asset"),
|
||||
ack: "asset-delete-ack",
|
||||
);
|
||||
|
||||
static SyncEvent assetTrashed({
|
||||
required String id,
|
||||
required String checksum,
|
||||
required String ack,
|
||||
DateTime? trashedAt,
|
||||
}) {
|
||||
return _assetV1(id: id, checksum: checksum, deletedAt: trashedAt ?? DateTime(2025, 1, 1), ack: ack);
|
||||
}
|
||||
|
||||
static SyncEvent assetModified({required String id, required String checksum, required String ack}) {
|
||||
return _assetV1(id: id, checksum: checksum, deletedAt: null, ack: ack);
|
||||
}
|
||||
|
||||
static SyncEvent _assetV1({
|
||||
required String id,
|
||||
required String checksum,
|
||||
required DateTime? deletedAt,
|
||||
required String ack,
|
||||
}) {
|
||||
return SyncEvent(
|
||||
type: SyncEntityType.assetV1,
|
||||
data: SyncAssetV1(
|
||||
checksum: checksum,
|
||||
deletedAt: deletedAt,
|
||||
duration: '0',
|
||||
fileCreatedAt: DateTime(2025),
|
||||
fileModifiedAt: DateTime(2025, 1, 2),
|
||||
id: id,
|
||||
isFavorite: false,
|
||||
libraryId: null,
|
||||
livePhotoVideoId: null,
|
||||
localDateTime: DateTime(2025, 1, 3),
|
||||
originalFileName: '$id.jpg',
|
||||
ownerId: 'owner',
|
||||
stackId: null,
|
||||
thumbhash: null,
|
||||
type: AssetTypeEnum.IMAGE,
|
||||
visibility: AssetVisibility.timeline,
|
||||
width: null,
|
||||
height: null,
|
||||
isEdited: false,
|
||||
),
|
||||
ack: ack,
|
||||
);
|
||||
}
|
||||
}
|
||||
35
mobile/test/fixtures/user.stub.dart
vendored
Normal file
35
mobile/test/fixtures/user.stub.dart
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import 'package:immich_mobile/domain/models/user.model.dart';
|
||||
|
||||
abstract final class UserStub {
|
||||
const UserStub._();
|
||||
|
||||
static final admin = UserDto(
|
||||
id: "admin",
|
||||
email: "admin@test.com",
|
||||
name: "admin",
|
||||
isAdmin: true,
|
||||
updatedAt: DateTime(2021),
|
||||
profileChangedAt: DateTime(2021),
|
||||
avatarColor: AvatarColor.green,
|
||||
);
|
||||
|
||||
static final user1 = UserDto(
|
||||
id: "user1",
|
||||
email: "user1@test.com",
|
||||
name: "user1",
|
||||
isAdmin: false,
|
||||
updatedAt: DateTime(2022),
|
||||
profileChangedAt: DateTime(2022),
|
||||
avatarColor: AvatarColor.red,
|
||||
);
|
||||
|
||||
static final user2 = UserDto(
|
||||
id: "user2",
|
||||
email: "user2@test.com",
|
||||
name: "user2",
|
||||
isAdmin: false,
|
||||
updatedAt: DateTime(2023),
|
||||
profileChangedAt: DateTime(2023),
|
||||
avatarColor: AvatarColor.primary,
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue