-
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.
- Loading branch information
Showing
29 changed files
with
145 additions
and
22 deletions.
There are no files selected for viewing
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
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
17 changes: 17 additions & 0 deletions
17
api/apps/api/test/upload-feature/upload-feature.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,17 @@ | ||
import { FixtureType } from '@marxan/utils/tests/fixture-type'; | ||
import { getFixtures } from './upload-feature.fixtures'; | ||
|
||
let fixtures: FixtureType<typeof getFixtures>; | ||
|
||
beforeEach(async () => { | ||
fixtures = await getFixtures(); | ||
}); | ||
|
||
afterEach(async () => { | ||
await fixtures?.cleanup(); | ||
}); | ||
|
||
test(`custom feature upload`, async () => { | ||
const result = await fixtures.WhenUploadingCustomFeature(); | ||
await fixtures.ThenGeoFeaturesAreCreated(result); | ||
}); |
75 changes: 75 additions & 0 deletions
75
api/apps/api/test/upload-feature/upload-feature.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,75 @@ | ||
import { bootstrapApplication } from '../utils/api-application'; | ||
import { GivenUserIsLoggedIn } from '../steps/given-user-is-logged-in'; | ||
import { GivenProjectExists } from '../steps/given-project'; | ||
|
||
import { GeoFeature } from '@marxan-api/modules/geo-features/geo-feature.api.entity'; | ||
import { getRepositoryToken } from '@nestjs/typeorm'; | ||
import { Repository } from 'typeorm'; | ||
import * as request from 'supertest'; | ||
|
||
export const getFixtures = async () => { | ||
const app = await bootstrapApplication(); | ||
const token = await GivenUserIsLoggedIn(app); | ||
const { projectId, cleanup } = await GivenProjectExists( | ||
app, | ||
token, | ||
{ | ||
name: `Project ${Date.now()}`, | ||
countryCode: undefined!, | ||
}, | ||
{ | ||
name: `Organization ${Date.now()}`, | ||
}, | ||
); | ||
const customFeatureName = `User custom feature ${Date.now()}`; | ||
const customFeatureTag = `bioregional`; | ||
const customFeatureDesc = `User custom feature desc`; | ||
|
||
const geoFeaturesApiRepo: Repository<GeoFeature> = app.get( | ||
getRepositoryToken(GeoFeature), | ||
); | ||
|
||
return { | ||
cleanup: async () => { | ||
await geoFeaturesApiRepo.delete({ | ||
projectId, | ||
}); | ||
await cleanup(); | ||
await app.close(); | ||
}, | ||
WhenUploadingCustomFeature: async () => | ||
request(app.getHttpServer()) | ||
.post(`/api/v1/projects/${projectId}/features/shapefile`) | ||
.set('Authorization', `Bearer ${token}`) | ||
.attach(`file`, __dirname + `/wetlands.zip`) | ||
.field({ | ||
name: customFeatureName, | ||
type: customFeatureTag, | ||
description: customFeatureDesc, | ||
}), | ||
ThenGeoFeaturesAreCreated: async (result: request.Response) => { | ||
expect(result.body).toEqual({ | ||
success: true, | ||
}); | ||
expect( | ||
await geoFeaturesApiRepo.find({ | ||
where: { | ||
projectId, | ||
}, | ||
}), | ||
).toEqual([ | ||
{ | ||
id: expect.any(String), | ||
featureClassName: customFeatureName, | ||
description: customFeatureDesc, | ||
alias: null, | ||
propertyName: null, | ||
intersection: null, | ||
tag: customFeatureTag, | ||
creationStatus: `done`, | ||
projectId, | ||
}, | ||
]); | ||
}, | ||
}; | ||
}; |
Binary file not shown.
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
2 changes: 1 addition & 1 deletion
2
api/apps/geoprocessing/src/modules/planning-area/planning-area.module.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
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
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
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
2 changes: 1 addition & 1 deletion
2
api/apps/geoprocessing/src/modules/surface-cost/adapters/shapefile-converter.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
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
api/apps/geoprocessing/src/utils/__mocks__/shapefile-service.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
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
File renamed without changes.
File renamed without changes.
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,4 @@ | ||
export { FilesModule } from './files/files.module'; | ||
export { FileService } from './files/files.service'; | ||
export { ShapefilesModule } from './shapefiles/shapefiles.module'; | ||
export { ShapefileService } from './shapefiles/shapefiles.service'; |
File renamed without changes.
File renamed without changes.
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,9 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"declaration": true, | ||
"outDir": "../../dist/libs/shapefile-converter" | ||
}, | ||
"include": ["src/**/*"], | ||
"exclude": ["node_modules", "dist", "test", "**/*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
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