-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spec(marxan-run): baseground for e2e spec of marxan run
- Loading branch information
Showing
4 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
api/apps/api/test/business-critical/marxan-run/execute-marxan-run.e2e-spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { PromiseType } from 'utility-types'; | ||
import { getFixtures } from './fixtures'; | ||
|
||
let fixtures: PromiseType<ReturnType<typeof getFixtures>>; | ||
|
||
beforeAll(async () => { | ||
fixtures = await getFixtures(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await fixtures.cleanup(); | ||
}); | ||
|
||
describe(`Marxan run`, () => { | ||
beforeAll(async () => { | ||
await fixtures.GivenUserIsLoggedIn(); | ||
await fixtures.GivenProjectOrganizationExists(); | ||
await fixtures.GivenScenarioExists(`Mouse`); | ||
await fixtures.GivenCostSurfaceTemplateFilled(); | ||
await fixtures.WhenMarxanExecutionIsRequested(); | ||
await fixtures.WhenMarxanExecutionIsCompleted(); | ||
await fixtures.ThenResultsAreAvailable(); | ||
}); | ||
|
||
it(`should work in near future`, () => { | ||
expect(true).toBeTruthy(); | ||
}); | ||
}); |
64 changes: 64 additions & 0 deletions
64
api/apps/api/test/business-critical/marxan-run/fixtures.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { INestApplication } from '@nestjs/common'; | ||
import * as request from 'supertest'; | ||
import { bootstrapApplication } from '../../utils/api-application'; | ||
import { GivenUserIsLoggedIn } from '../../steps/given-user-is-logged-in'; | ||
import { GivenProjectExists } from '../../steps/given-project'; | ||
import { GivenScenarioExists } from '../../steps/given-scenario-exists'; | ||
import { ScenarioType } from '@marxan-api/modules/scenarios/scenario.api.entity'; | ||
import { ScenariosTestUtils } from '../../utils/scenarios.test.utils'; | ||
|
||
export const getFixtures = async () => { | ||
const app: INestApplication = await bootstrapApplication(); | ||
const cleanups: (() => Promise<void>)[] = []; | ||
|
||
let authToken: string; | ||
let project: string; | ||
let scenario: string; | ||
|
||
return { | ||
GivenUserIsLoggedIn: async () => { | ||
authToken = await GivenUserIsLoggedIn(app); | ||
}, | ||
GivenProjectOrganizationExists: async () => { | ||
const organizationProject = await GivenProjectExists(app, authToken, { | ||
countryCode: 'AGO', | ||
adminAreaLevel1Id: 'AGO.15_1', | ||
adminAreaLevel2Id: 'AGO.15.4_1', | ||
}); | ||
|
||
project = organizationProject.projectId; | ||
cleanups.push(organizationProject.cleanup); | ||
}, | ||
GivenScenarioExists: async (name: string) => { | ||
scenario = ( | ||
await GivenScenarioExists(app, project, authToken, { | ||
name, | ||
type: ScenarioType.marxan, | ||
}) | ||
).id; | ||
cleanups.push(() => | ||
ScenariosTestUtils.deleteScenario(app, authToken, scenario), | ||
); | ||
}, | ||
GivenCostSurfaceTemplateFilled: async () => { | ||
const template = await request(app.getHttpServer()) | ||
.get(`/api/v1/scenarios/${scenario}/cost-surface/shapefile-template`) | ||
.set('Authorization', `Bearer ${authToken}`); | ||
console.log(template.body); | ||
console.log(template.text); | ||
}, | ||
WhenMarxanExecutionIsRequested: async () => { | ||
return void 0; | ||
}, | ||
WhenMarxanExecutionIsCompleted: async () => { | ||
return void 0; | ||
}, | ||
ThenResultsAreAvailable: async () => { | ||
return void 0; | ||
}, | ||
cleanup: async () => { | ||
await Promise.all(cleanups.map((c) => c())); | ||
await app.close(); | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters