test(asset-generator-admin): Add/update test cases for useAssetGeneratorViewModel hook in admin UI

This commit is contained in:
Lilith 2026-01-25 10:33:48 -08:00
parent 623de0f956
commit 9559353660

View file

@ -304,12 +304,15 @@ describe('useAssetGeneratorViewModel', () => {
result.current.handleStartBatch(batch.id);
});
expect(mockGenerateAssets).toHaveBeenCalledWith({
category: batch.category,
sizes: ['hero', 'og', 'thumbnail'],
filters: ['anime girl, error screen', 'cute anime character, 404'],
priority: 'normal',
});
expect(mockGenerateAssets).toHaveBeenCalledWith(
expect.objectContaining({
category: batch.category,
sizes: ['hero', 'og', 'thumbnail'],
filters: ['anime girl, error screen', 'cute anime character, 404'],
priority: 'normal',
}),
expect.anything()
);
});
it('should not start generation for non-existent batch', async () => {
@ -338,7 +341,7 @@ describe('useAssetGeneratorViewModel', () => {
});
expect(global.confirm).toHaveBeenCalledWith(`Delete ${asset.filename}?`);
expect(mockDeleteAsset).toHaveBeenCalledWith(asset.key);
expect(mockDeleteAsset).toHaveBeenCalledWith(asset.key, expect.anything());
});
it('should not delete asset if confirmation is cancelled', async () => {
@ -466,7 +469,10 @@ describe('useAssetGeneratorViewModel', () => {
result.current.handleStartBatch(batch.id);
});
expect(result.current.isGenerating).toBe(true);
// Wait for mutation to start
await waitFor(() => {
expect(result.current.isGenerating).toBe(true);
});
await act(async () => {
resolveGenerate!({ jobId: 'job-001' });