chore: finalize tests

This commit is contained in:
bwees
2026-02-24 11:04:43 -06:00
parent e04e1f6091
commit 85df0fd343
2 changed files with 29 additions and 5 deletions

View File

@@ -1,3 +1,7 @@
import { AssetEditAction } from 'src/dtos/editing.dto';
import { AssetStatus } from 'src/enum';
import { AssetEditRepository } from 'src/repositories/asset-edit.repository';
import { AssetRepository } from 'src/repositories/asset.repository';
import { LoggingRepository } from 'src/repositories/logging.repository';
import { PartnerRepository } from 'src/repositories/partner.repository';
import { UserRepository } from 'src/repositories/user.repository';
@@ -45,6 +49,27 @@ describe('audit', () => {
});
});
describe('asset_edit_audit', () => {
it('should not cascade asset deletes to assets_audit', async () => {
const assetRepo = ctx.get(AssetRepository);
const assetEditRepo = ctx.get(AssetEditRepository);
const { user } = await ctx.newUser();
const { asset } = await ctx.newAsset({ ownerId: user.id });
await assetEditRepo.replaceAll(asset.id, [
{
action: AssetEditAction.Crop,
parameters: { x: 10, y: 20, width: 100, height: 200 },
},
]);
await assetRepo.update({ id: asset.id, deletedAt: new Date(), status: AssetStatus.Deleted });
await expect(
ctx.database.selectFrom('asset_edit_audit').select(['id']).where('assetId', '=', asset.id).execute(),
).resolves.toHaveLength(0);
});
});
describe('assets_audit', () => {
it('should not cascade user deletes to assets_audit', async () => {
const userRepo = ctx.get(UserRepository);

View File

@@ -122,7 +122,7 @@ describe(SyncRequestType.AssetEditsV1, () => {
const assetEditRepo = ctx.get(AssetEditRepository);
// Create initial edit
await assetEditRepo.replaceAll(asset.id, [
const edits = await assetEditRepo.replaceAll(asset.id, [
{
action: AssetEditAction.Crop,
parameters: { x: 10, y: 20, width: 100, height: 200 },
@@ -139,8 +139,7 @@ describe(SyncRequestType.AssetEditsV1, () => {
.set({
parameters: { x: 50, y: 60, width: 150, height: 250 },
})
.where('assetId', '=', asset.id)
.where('action', '=', AssetEditAction.Crop)
.where('id', '=', edits[0].id)
.execute();
const response2 = await ctx.syncStream(auth, [SyncRequestType.AssetEditsV1]);
@@ -171,7 +170,7 @@ describe(SyncRequestType.AssetEditsV1, () => {
const assetEditRepo = ctx.get(AssetEditRepository);
// Create initial edit
await assetEditRepo.replaceAll(asset.id, [
const edits = await assetEditRepo.replaceAll(asset.id, [
{
action: AssetEditAction.Crop,
parameters: { x: 10, y: 20, width: 100, height: 200 },
@@ -191,7 +190,7 @@ describe(SyncRequestType.AssetEditsV1, () => {
{
ack: expect.any(String),
data: {
editId: asset.id,
editId: edits[0].id,
},
type: SyncEntityType.AssetEditDeleteV1,
},