feat: webhook workflow action (#29258)

Co-authored-by: Daniel Dietzler <mail@ddietzler.dev>
This commit is contained in:
Ben Beckford 2026-06-26 07:08:45 -07:00 committed by GitHub
parent a876d4a9f1
commit 953ef5c047
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 159 additions and 99 deletions

View file

@ -427,4 +427,32 @@ describe('core plugin', () => {
await expect(ctx.get(AssetRepository).getById(asset.id)).resolves.toMatchObject({ isFavorite: true });
});
});
describe('webhook', () => {
it('should trigger a webhook on asset upload', async () => {
const { user } = await ctx.newUser();
const { asset } = await ctx.newAsset({ ownerId: user.id });
const fetchMock = vi.fn(() => Promise.resolve({ ok: true, status: 200, text: () => Promise.resolve('') }));
vi.stubGlobal('fetch', fetchMock);
const workflow = await createWorkflow({
ownerId: user.id,
trigger: WorkflowTrigger.AssetCreate,
steps: [
{
method: 'immich-plugin-core#webhook',
config: { url: 'http://localhost', method: 'POST' },
},
],
});
await expect(ctx.sut.handleAssetTrigger({ workflowId: workflow.id, assetId: asset.id })).resolves.toBeUndefined();
expect(fetchMock).toHaveBeenCalled();
});
afterEach(() => {
vi.unstubAllGlobals();
});
});
});