Skip to content

High performance self-hosted photo and video management solution.

chore(server): test assetDateFilter workflow method (#30110)

Ben Beckford0f5bf6071fd9
diff --git a/server/test/medium/specs/workflow/workflow-core-plugin.spec.ts b/server/test/medium/specs/workflow/workflow-core-plugin.spec.ts
index d8830e91e6..1ad40ecca7 100644
--- a/server/test/medium/specs/workflow/workflow-core-plugin.spec.ts
+++ b/server/test/medium/specs/workflow/workflow-core-plugin.spec.ts
@@ -433,9 +433,10 @@ describe('core plugin', () => {
describe('assetDateFilter', () => {
it('should favorite assets created during the first 7 days of a specific year and month', async () => {
const { user } = await ctx.newUser();
- const [{ asset: asset1 }, { asset: asset2 }] = await Promise.all([
+ const [{ asset: asset1 }, { asset: asset2 }, { asset: asset3 }] = await Promise.all([
ctx.newAsset({ ownerId: user.id, localDateTime: new Date('2000-04-01') }),
ctx.newAsset({ ownerId: user.id, localDateTime: new Date('2000-04-07T23:59:59Z') }),
+ ctx.newAsset({ ownerId: user.id, localDateTime: new Date('2000-04-08T00:00:00Z') }),
]);
const workflow = await createWorkflow({
@@ -461,6 +462,46 @@ describe('core plugin', () => {
await ctx.sut.handleAssetTrigger({ workflowId: workflow.id, assetId: asset2.id });
await expect(ctx.get(AssetRepository).getById(asset2.id)).resolves.toMatchObject({ isFavorite: true });
+
+ await ctx.sut.handleAssetTrigger({ workflowId: workflow.id, assetId: asset3.id });
+ await expect(ctx.get(AssetRepository).getById(asset3.id)).resolves.toMatchObject({ isFavorite: false });
+ });
+
+ it('should match recurring dates regardless of the year', async () => {
+ const { user } = await ctx.newUser();
+ const [{ asset: asset1 }, { asset: asset2 }, { asset: asset3 }] = await Promise.all([
+ ctx.newAsset({ ownerId: user.id, localDateTime: new Date('2026-03-01') }),
+ ctx.newAsset({ ownerId: user.id, localDateTime: new Date('1998-12-21') }),
+ ctx.newAsset({ ownerId: user.id, localDateTime: new Date('2000-04-08T00:00:00Z') }),
+ ]);
+ await ctx.newAsset({ ownerId: user.id, localDateTime: new Date('2010-06-15') });
+
+ const workflow = await createWorkflow({
+ ownerId: user.id,
+ trigger: WorkflowTrigger.AssetCreate,
+ steps: [
+ {
+ method: 'immich-plugin-core#assetDateFilter',
+ config: {
+ startDate: { day: 12, month: 12, year: 2000 },
+ endDate: { day: 30, month: 3, year: 2001 },
+ recurring: true,
+ },
+ },
+ {
+ method: 'immich-plugin-core#assetFavorite',
+ },
+ ],
+ });
+
+ await ctx.sut.handleAssetTrigger({ workflowId: workflow.id, assetId: asset1.id });
+ await expect(ctx.get(AssetRepository).getById(asset1.id)).resolves.toMatchObject({ isFavorite: true });
+
+ await ctx.sut.handleAssetTrigger({ workflowId: workflow.id, assetId: asset2.id });
+ await expect(ctx.get(AssetRepository).getById(asset2.id)).resolves.toMatchObject({ isFavorite: true });
+
+ await ctx.sut.handleAssetTrigger({ workflowId: workflow.id, assetId: asset3.id });
+ await expect(ctx.get(AssetRepository).getById(asset3.id)).resolves.toMatchObject({ isFavorite: false });
});
});