test: Add templates/:uuid mock handler

This adds a mock handler for the templates/:uuid end point to resolve following warning in the test output:
```
[MSW] Error: intercepted a request without a matching request handler:
  • GET /api/content-sources/v1/templates/c40e221b-93d6-4f7e-a704-f3041b8d75c3
```
This commit is contained in:
regexowl 2025-06-27 15:06:29 +02:00 committed by Gianluca Zuccarelli
parent 2894858838
commit fc874422de
2 changed files with 6 additions and 2 deletions

View file

@ -43,7 +43,7 @@ const filterTemplates = (args: templateArgs): ApiTemplateResponse[] => {
return templates;
};
const testingTemplates: ApiTemplateResponseRead[] = [
export const testingTemplates: ApiTemplateResponseRead[] = [
{
uuid: 'c40e221b-93d6-4f7e-a704-f3041b8d75c3',
name: 'template-abc',

View file

@ -45,7 +45,7 @@ import {
mockRepositoryResults,
} from '../fixtures/repositories';
import { mockSourcesByProvider, mockUploadInfo } from '../fixtures/sources';
import { mockTemplateResults } from '../fixtures/templates';
import { mockTemplateResults, testingTemplates } from '../fixtures/templates';
export const handlers = [
http.get(`${PROVISIONING_API}/sources`, ({ request }) => {
@ -129,6 +129,10 @@ export const handlers = [
};
return HttpResponse.json(mockTemplateResults(args));
}),
http.get(`${CONTENT_SOURCES_API}/templates/:uuid`, ({ params }) => {
const { uuid } = params;
return HttpResponse.json(testingTemplates[uuid]);
}),
http.get(`${CONTENT_SOURCES_API}/repositories/:repo_id`, ({ params }) => {
const { repo_id } = params;
return HttpResponse.json(mockPopularRepo(repo_id));