Skip to content

Commit

Permalink
feat: error if request not intercepted while e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
rmonnier9 committed Dec 17, 2024
1 parent 26133f2 commit 60d4142
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 123 deletions.
2 changes: 1 addition & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if (
// https://github.com/mswjs/examples/pull/101/files
const { mockServer } = require('#cypress/mocks/server');
mockServer.listen({
onUnhandledRequest: 'warn',
onUnhandledRequest: 'error',
});
}

Expand Down
121 changes: 0 additions & 121 deletions clients/stub-client-with-snaphots.ts

This file was deleted.

57 changes: 57 additions & 0 deletions cypress/fixtures/api-inclusion-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"count": 10,
"next": null,
"previous": null,
"results": [
{
"id": "EI",
"name": "Entreprise d'insertion",
"parent": "Insertion"
},
{
"id": "AI",
"name": "Association intermédiaire",
"parent": "Insertion"
},
{
"id": "ACI",
"name": "Atelier chantier d'insertion",
"parent": "Insertion"
},
{
"id": "ETTI",
"name": "Entreprise de travail temporaire d'insertion",
"parent": "Insertion"
},
{
"id": "EITI",
"name": "Entreprise d'insertion par le travail indépendant",
"parent": "Insertion"
},
{
"id": "GEIQ",
"name": "Groupement d'employeurs pour l'insertion et la qualification",
"parent": "Insertion"
},
{
"id": "SEP",
"name": "Produits et services réalisés en prison",
"parent": "Insertion"
},
{
"id": "EA",
"name": "Entreprise adaptée",
"parent": "Handicap"
},
{
"id": "EATT",
"name": "Entreprise adaptée de travail temporaire",
"parent": "Handicap"
},
{
"id": "ESAT",
"name": "Etablissement et service d'aide par le travail",
"parent": "Handicap"
}
]
}
7 changes: 7 additions & 0 deletions cypress/mocks/handlers/api-inclusion.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { HttpResponse, HttpResponseResolver } from 'msw';
import apiInclusionMetadata from '../../fixtures/api-inclusion-metadata.json';
import apiInclusion from '../../fixtures/api-inclusion.json';

export const apiInclusionHandler: HttpResponseResolver = ({ request }) => {
return HttpResponse.json(apiInclusion);
};

export const apiInclusionMetadataHandler: HttpResponseResolver = ({
request,
}) => {
return HttpResponse.json(apiInclusionMetadata);
};
9 changes: 8 additions & 1 deletion cypress/mocks/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import {
apiGeoEpcisHandler,
apiGeoRegionsHandler,
} from './handlers/api-geo';
import { apiInclusionHandler } from './handlers/api-inclusion';
import {
apiInclusionHandler,
apiInclusionMetadataHandler,
} from './handlers/api-inclusion';
import {
apiSireneInseeAuthHandler,
apiSireneInseeSirenHandler,
Expand Down Expand Up @@ -51,6 +54,10 @@ export const routesHandlers = [
routes.certifications.entrepriseInclusive.api.getBySiren('*'),
apiInclusionHandler
),
http.get(
routes.certifications.entrepriseInclusive.api.metadata,
apiInclusionMetadataHandler
),
http.get(routes.datagouv.ess, apiDataGouvEssHandler),
http.get(routes.tooling.monitoring.getBySlug('*'), upDownIoHandler),
http.get(routes.apiDataSubvention.grants('*'), apiDataSubventionHandler),
Expand Down

0 comments on commit 60d4142

Please sign in to comment.