Skip to content

Commit

Permalink
test(scenarios): update case to follow regression scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
kgajowy committed Sep 23, 2021
1 parent 29c901c commit 2ac2ec6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()}`,
Expand All @@ -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,
Expand Down

0 comments on commit 2ac2ec6

Please sign in to comment.