feat: persistent memories (#8330)

* feat: persistent memories

* refactor: use new add/remove asset utility
This commit is contained in:
Jason Rasmussen
2024-04-02 10:23:17 -04:00
committed by GitHub
parent 0849dbd1af
commit cd0e537e3e
43 changed files with 3497 additions and 0 deletions

30
server/test/fixtures/memory.stub.ts vendored Normal file
View File

@@ -0,0 +1,30 @@
import { MemoryEntity, MemoryType } from 'src/entities/memory.entity';
import { assetStub } from 'test/fixtures/asset.stub';
import { userStub } from 'test/fixtures/user.stub';
export const memoryStub = {
empty: <MemoryEntity>{
id: 'memoryEmpty',
createdAt: new Date(),
updatedAt: new Date(),
memoryAt: new Date(2024),
ownerId: userStub.admin.id,
owner: userStub.admin,
type: MemoryType.ON_THIS_DAY,
data: { year: 2024 },
isSaved: false,
assets: [],
},
memory1: <MemoryEntity>{
id: 'memory1',
createdAt: new Date(),
updatedAt: new Date(),
memoryAt: new Date(2024),
ownerId: userStub.admin.id,
owner: userStub.admin,
type: MemoryType.ON_THIS_DAY,
data: { year: 2024 },
isSaved: false,
assets: [assetStub.image1],
},
};

View File

@@ -8,6 +8,7 @@ export interface IAccessRepositoryMock {
authDevice: jest.Mocked<IAccessRepository['authDevice']>;
library: jest.Mocked<IAccessRepository['library']>;
timeline: jest.Mocked<IAccessRepository['timeline']>;
memory: jest.Mocked<IAccessRepository['memory']>;
person: jest.Mocked<IAccessRepository['person']>;
partner: jest.Mocked<IAccessRepository['partner']>;
}
@@ -49,6 +50,10 @@ export const newAccessRepositoryMock = (reset = true): IAccessRepositoryMock =>
checkPartnerAccess: jest.fn().mockResolvedValue(new Set()),
},
memory: {
checkOwnerAccess: jest.fn().mockResolvedValue(new Set()),
},
person: {
checkFaceOwnerAccess: jest.fn().mockResolvedValue(new Set()),
checkOwnerAccess: jest.fn().mockResolvedValue(new Set()),

View File

@@ -0,0 +1,14 @@
import { IMemoryRepository } from 'src/interfaces/memory.interface';
export const newMemoryRepositoryMock = (): jest.Mocked<IMemoryRepository> => {
return {
search: jest.fn().mockResolvedValue([]),
get: jest.fn(),
create: jest.fn(),
update: jest.fn(),
delete: jest.fn(),
getAssetIds: jest.fn().mockResolvedValue(new Set()),
addAssetIds: jest.fn(),
removeAssetIds: jest.fn(),
};
};