Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Tests): Fixes a couple of tests, plus small tweaks #1664

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ export class AddFeatureShapefileApiEvents1708099064649
'features.shapefile.import.finished/v1/alpha',
'features.shapefile.import.failed/v1/alpha')
`);
await queryRunner.query(`
UPDATE features SET creation_status = 'done'
WHERE creation_status = 'created';
`);

// While creation_status mostly didn't have any real use so far, the 'created'->'done' migration is a non reversible operation
// as there's no way which creation_status any row had originally.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ export const validDataWithGivenPuIds = (
projectPuId: v4(),
id: id,
featureList: [],
setByUser: false,
}));
12 changes: 7 additions & 5 deletions api/apps/api/src/modules/geo-features/geo-features.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,13 @@ export class GeoFeaturesService extends AppBaseService<
data: UploadShapefileDTO,
featureDatas: Record<string, any>[],
) {
try {
setTimeout(async () => {
setTimeout(async () => {
try {
await this.createFeaturesForShapefile(projectId, data, featureDatas);
});
} catch (e) {}
} catch (e) {
this.logger.error(e.message, e.trace);
}
});
}

public async createFeaturesForShapefile(
Expand Down Expand Up @@ -991,7 +993,7 @@ export class GeoFeaturesService extends AppBaseService<
return left(featureDataCannotBeUploadedWithCsv);
}

this.featureAmountUploads.uploadFeatureFromCSVAsync(
await this.featureAmountUploads.uploadFeatureFromCSVAsync(
fileBuffer,
projectId,
userId,
Expand Down
13 changes: 12 additions & 1 deletion api/apps/geoprocessing/test/integration/cloning/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export async function GivenProjectExists(
organizationId: string,
projectData: Record<string, any> = {},
costSurfaceId = v4(),
costSurfaceStableId = v4(),
) {
await GivenOrganizationExists(em, organizationId);

Expand All @@ -133,7 +134,13 @@ export async function GivenProjectExists(
})
.execute();

await GivenDefaultCostSurfaceForProject(em, projectId, costSurfaceId);
await GivenDefaultCostSurfaceForProject(
em,
projectId,
costSurfaceId,
undefined,
costSurfaceStableId,
);

return insertResult;
}
Expand All @@ -150,6 +157,7 @@ async function GivenDefaultCostSurfaceForProject(
projectId: string,
id: string,
name?: string,
costSurfaceStableId = v4(),
) {
const nameForCostSurface = name || projectId;
return em
Expand All @@ -165,6 +173,7 @@ async function GivenDefaultCostSurfaceForProject(
min: 0,
max: 0,
is_default: true,
stable_id: costSurfaceStableId,
})
.execute();
}
Expand All @@ -177,13 +186,15 @@ export async function GivenScenarioExists(
scenarioData: Record<string, any> = {},
projectData: Record<string, any> = {},
costSurfaceId = v4(),
costSurfaceStableId = v4(),
) {
await GivenProjectExists(
em,
projectId,
organizationId,
projectData,
costSurfaceId,
costSurfaceStableId,
);

return em
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const getFixtures = async () => {
const projectId = v4();
const scenarioId = v4();
const costSurfaceId = v4();
const costSurfaceStableId = v4();
const organizationId = v4();
const sut = sandbox.get(ScenarioMetadataPieceExporter);
const apiEntityManager: EntityManager = sandbox.get(
Expand All @@ -106,7 +107,7 @@ const getFixtures = async () => {
ranAtLeastOnce: false,
solutionsAreLocked,
type: 'marxan',
cost_surface_id: costSurfaceId,
cost_surface_id: costSurfaceStableId,
});

return {
Expand Down Expand Up @@ -144,6 +145,7 @@ const getFixtures = async () => {
},
{},
costSurfaceId,
costSurfaceStableId,
);
},
GivenScenarioBlmRangeExist: async () => {
Expand Down
20 changes: 10 additions & 10 deletions api/apps/geoprocessing/test/steps/given-scenario-pu-data-exists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,79 +82,79 @@ export const GivenScenarioPuDataWithStatusesSetByUserExists = async (
projectPuId: first.id,
projectPu: first,
protectedByDefault,
setByUser: false,
lockStatusSetByUser: false,
},
{
scenarioId,
lockStatus: LockStatus.Available,
projectPuId: first.id,
projectPu: first,
protectedByDefault,
setByUser: false,
lockStatusSetByUser: false,
},
{
scenarioId,
lockStatus: LockStatus.Available,
projectPuId: first.id,
projectPu: first,
protectedByDefault,
setByUser: true,
lockStatusSetByUser: true,
},
{
scenarioId,
lockStatus: LockStatus.Available,
projectPuId: first.id,
projectPu: first,
protectedByDefault,
setByUser: true,
lockStatusSetByUser: true,
},
{
scenarioId,
lockStatus: LockStatus.Available,
projectPuId: first.id,
projectPu: first,
protectedByDefault,
setByUser: true,
lockStatusSetByUser: true,
},
{
scenarioId,
lockStatus: LockStatus.LockedOut,
projectPuId: second.id,
projectPu: second,
protectedByDefault,
setByUser: true,
lockStatusSetByUser: true,
},
{
scenarioId,
lockStatus: LockStatus.LockedOut,
projectPuId: second.id,
projectPu: second,
protectedByDefault,
setByUser: false,
lockStatusSetByUser: false,
},
{
scenarioId,
lockStatus: LockStatus.LockedIn,
projectPuId: third.id,
projectPu: third,
protectedByDefault,
setByUser: true,
lockStatusSetByUser: true,
},
{
scenarioId,
lockStatus: LockStatus.LockedIn,
projectPuId: third.id,
projectPu: third,
protectedByDefault,
setByUser: false,
lockStatusSetByUser: false,
},
{
scenarioId,
lockStatus: LockStatus.LockedIn,
projectPuId: third.id,
projectPu: third,
protectedByDefault,
setByUser: false,
lockStatusSetByUser: false,
},
]);
return rows as ScenariosPuPaDataGeo[];
Expand Down