diff --git a/api/apps/api/test/project/create-project-wdpa-area-filter.e2e-spec.ts b/api/apps/api/test/project/create-project-wdpa-area-filter.e2e-spec.ts index 52ccbd9178..7d81bcf0c0 100644 --- a/api/apps/api/test/project/create-project-wdpa-area-filter.e2e-spec.ts +++ b/api/apps/api/test/project/create-project-wdpa-area-filter.e2e-spec.ts @@ -13,16 +13,22 @@ afterEach(async () => { }); test(`creating multiple projects should have different protectedAreaFilterByIds`, async () => { - const projectIdOne: string = await fixtures.WhenProjectIsCreated(`BWA`); - const scenarioIdOne: string = await fixtures.WhenScenarioIsCreated( + const projectIdOne: string = await fixtures.GivenProjectWasCreated(`BWA`); + const scenarioIdOne: string = await fixtures.GivenScenarioWasCreated( projectIdOne, - [IUCNCategory.NotApplicable], ); - const projectIdTwo: string = await fixtures.WhenProjectIsCreated(`ZMB`); - const scenarioIdTwo: string = await fixtures.WhenScenarioIsCreated( + const projectIdTwo: string = await fixtures.GivenProjectWasCreated(`ZMB`); + const scenarioIdTwo: string = await fixtures.GivenScenarioWasCreated( projectIdTwo, - [IUCNCategory.NotReported], ); + + await fixtures.WhenScenarioIsUpdated(scenarioIdOne, [ + IUCNCategory.NotApplicable, + ]); + await fixtures.WhenScenarioIsUpdated(scenarioIdTwo, [ + IUCNCategory.NotReported, + ]); + await fixtures.ThenProtectedAreaFiltersAreDifferent( scenarioIdOne, scenarioIdTwo, diff --git a/api/apps/api/test/project/create-project-wdpa-area-filter.fixtures.ts b/api/apps/api/test/project/create-project-wdpa-area-filter.fixtures.ts index 32f8588177..c3d212e2e6 100644 --- a/api/apps/api/test/project/create-project-wdpa-area-filter.fixtures.ts +++ b/api/apps/api/test/project/create-project-wdpa-area-filter.fixtures.ts @@ -32,7 +32,7 @@ export const getFixtures = async () => { ); await app.close(); }, - WhenProjectIsCreated: async (countryId: string) => { + GivenProjectWasCreated: async (countryId: string) => { const projectId = ( await ProjectsTestUtils.createProject(app, token, { name: `Project name ${Date.now()}`, @@ -44,18 +44,24 @@ export const getFixtures = async () => { addedProjects.push(projectId); return projectId; }, - WhenScenarioIsCreated: async ( - projectId: string, - categories: IUCNCategory[], - ) => + GivenScenarioWasCreated: async (projectId: string) => ( await ScenariosTestUtils.createScenario(app, token, { name: `Scenario for ${projectId} ${Date.now()}`, projectId, type: ScenarioType.marxan, - wdpaIucnCategories: categories, }) ).data.id, + WhenScenarioIsUpdated: async ( + scenarioId: string, + categories: IUCNCategory[], + ) => + await request(app.getHttpServer()) + .patch(`/api/v1/scenarios/${scenarioId}`) + .set('Authorization', `Bearer ${token}`) + .send({ + wdpaIucnCategories: categories, + }), ThenProtectedAreaFiltersAreDifferent: async ( scenarioIdOne: string, scenarioIdTwo: string,