diff --git a/api/apps/geoprocessing/src/export/pieces-exporters/project-metadata.piece-exporter.ts b/api/apps/geoprocessing/src/export/pieces-exporters/project-metadata.piece-exporter.ts index 4659872ecc..426403da5e 100644 --- a/api/apps/geoprocessing/src/export/pieces-exporters/project-metadata.piece-exporter.ts +++ b/api/apps/geoprocessing/src/export/pieces-exporters/project-metadata.piece-exporter.ts @@ -85,7 +85,9 @@ export class ProjectMetadataPieceExporter implements ExportPieceProcessor { const warningMessage = `${ProjectMetadataPieceExporter.name} - Output Summary for project with id ${projectId} does not exist.`; this.logger.log(warningMessage); } - const summaryZip64 = outputSummary?.summaryZip ? outputSummary.summaryZip.toString('base64') : undefined; + const summaryZip64 = outputSummary?.summaryZip + ? outputSummary.summaryZip.toString('base64') + : undefined; const [blmRange]: [ SelectProjectBlmResult, diff --git a/api/apps/geoprocessing/src/import/pieces-importers/project-metadata.piece-importer.ts b/api/apps/geoprocessing/src/import/pieces-importers/project-metadata.piece-importer.ts index 8c04a8be46..90e311f20a 100644 --- a/api/apps/geoprocessing/src/import/pieces-importers/project-metadata.piece-importer.ts +++ b/api/apps/geoprocessing/src/import/pieces-importers/project-metadata.piece-importer.ts @@ -178,7 +178,7 @@ export class ProjectMetadataPieceImporter implements ImportPieceProcessor { .values({ id: projectId, ...projectMetadata.blmRange }) .execute(); - if(projectMetadata?.outputSummaryZip) { + if (projectMetadata?.outputSummaryZip) { await em .createQueryBuilder() .insert() @@ -192,7 +192,9 @@ export class ProjectMetadataPieceImporter implements ImportPieceProcessor { }) .execute(); } else { - this.logger.log(`No output summary data for project ${projectId}: the source project may not have any scenarios run yet.`); + this.logger.log( + `No output summary data for project ${projectId}: the source project may not have any scenarios run yet.`, + ); } }); } catch (e) { diff --git a/api/apps/geoprocessing/test/integration/cloning/piece-exporters/project-metadata.piece-exporter.e2e-spec.ts b/api/apps/geoprocessing/test/integration/cloning/piece-exporters/project-metadata.piece-exporter.e2e-spec.ts index 5526f36079..4c4c10a324 100644 --- a/api/apps/geoprocessing/test/integration/cloning/piece-exporters/project-metadata.piece-exporter.e2e-spec.ts +++ b/api/apps/geoprocessing/test/integration/cloning/piece-exporters/project-metadata.piece-exporter.e2e-spec.ts @@ -41,12 +41,14 @@ describe(ProjectMetadataPieceExporter, () => { .ThenAProjectExistErrorShouldBeThrown(); }); - it('fails when project output summary is not found', async () => { - await fixtures.GivenProjectExist(ProjectSourcesEnum.marxanCloud); + it('saves file successfully even when project output summary was never created yet', async () => { + const marxanSource = ProjectSourcesEnum.marxanCloud; const input = fixtures.GivenAProjectMetadataExportJob(); + await fixtures.GivenProjectExist(marxanSource); + await fixtures.GivenProjectBlmRangeExist(); await fixtures .WhenPieceExporterIsInvoked(input) - .ThenAnOtuputSummaryExistErrorShouldBeThrown(); + .ThenProjectMetadataFileIsSaved(marxanSource); }); it('fails when project blm range is not found', async () => { @@ -116,18 +118,28 @@ const getFixtures = async () => { const expectedContent: ( sources: ProjectSourcesEnum, - ) => ProjectMetadataContent = (sources: ProjectSourcesEnum) => ({ - name: `test project - ${projectId}`, - planningUnitGridShape: PlanningUnitGridShape.Square, - blmRange: { - defaults: [0, 20, 40, 60, 80, 100], - range: [0, 100], - values: [], - }, - outputSummaryZip: summaryZipEncoded, - metadata, - sources, - }); + options: { withProjectSummary?: boolean }, + ) => ProjectMetadataContent = ( + sources: ProjectSourcesEnum, + options: { withProjectSummary?: boolean }, + ) => { + const expected: ProjectMetadataContent = { + name: `test project - ${projectId}`, + planningUnitGridShape: PlanningUnitGridShape.Square, + blmRange: { + defaults: [0, 20, 40, 60, 80, 100], + range: [0, 100], + values: [], + }, + outputSummaryZip: summaryZipEncoded, + metadata, + sources, + }; + if (options?.withProjectSummary) { + expected.outputSummaryZip = summaryZipEncoded; + } + return expected; + }; return { cleanUp: async () => { @@ -187,11 +199,6 @@ const getFixtures = async () => { ThenAProjectBlmExistErrorShouldBeThrown: async () => { await expect(sut.run(input)).rejects.toThrow(/blm.*does not exist/gi); }, - ThenAnOtuputSummaryExistErrorShouldBeThrown: async () => { - await expect(sut.run(input)).rejects.toThrow( - /Output Summary.*does not exist/gi, - ); - }, ThenProjectMetadataFileIsSaved: async (sources: ProjectSourcesEnum) => { const result = await sut.run(input); const file = await fileRepository.get(result.uris[0].uri);