diff --git a/api/apps/geoprocessing/src/legacy-project-import/legacy-piece-importers/file-readers/input-dat.reader.spec.ts b/api/apps/geoprocessing/src/legacy-project-import/legacy-piece-importers/file-readers/input-dat.reader.spec.ts index 052e7d9696..e58cdd4b37 100644 --- a/api/apps/geoprocessing/src/legacy-project-import/legacy-piece-importers/file-readers/input-dat.reader.spec.ts +++ b/api/apps/geoprocessing/src/legacy-project-import/legacy-piece-importers/file-readers/input-dat.reader.spec.ts @@ -40,17 +40,26 @@ const getFixtures = async () => { const sut = sandbox.get(InputDatReader); const fakeMarxanInput: FakeMarxanInput = sandbox.get(MarxanInput); - const inputDatVariables: MarxanParameters = { BLM: 1, BESTSCORE: 2 }; - const file = { ...inputDatVariables, RandomName: 2, blm: 4 }; + const inputDatVariables: MarxanParameters = { + BLM: 1, + BESTSCORE: 2, + THRESHPEN1: 14.5, + }; + const file = { + ...inputDatVariables, + RandomName: 2, + blm: 4, + VARIABLE1: 'invalid', + }; return { GivenAValidInputDatFile: () => Readable.from( - 'Skip comments in input/n' + - '.dat file/n' + + 'Skip comments in input\n' + + '.dat file\n' + Object.entries(file) .map(([key, value]) => `${key} ${value}`) - .join('/n'), + .join('\n'), ), GivenAnInvalidInputDatFile: () => { fakeMarxanInput.failFromOperation = true; diff --git a/api/apps/geoprocessing/src/legacy-project-import/legacy-piece-importers/file-readers/input-dat.reader.ts b/api/apps/geoprocessing/src/legacy-project-import/legacy-piece-importers/file-readers/input-dat.reader.ts index 4adc5a9184..1a973d326e 100644 --- a/api/apps/geoprocessing/src/legacy-project-import/legacy-piece-importers/file-readers/input-dat.reader.ts +++ b/api/apps/geoprocessing/src/legacy-project-import/legacy-piece-importers/file-readers/input-dat.reader.ts @@ -46,7 +46,7 @@ export class InputDatReader { private filterCommentsInInputFile(words: string[]) { //valid line must only have 2 words separated by one space and //variable name must be in capital letters - return words.length === 2 && /^[A-Z]*$/.test(words[0]); + return words.length === 2 && /^[A-Z0-9]*$/.test(words[0]); } private isKeyInInputDatFile( @@ -80,7 +80,8 @@ export class InputDatReader { const stringInputDatFile = buffer.toString(); const inputLines = stringInputDatFile - .split('/n') + .split('\n') + .filter((line) => line !== '') .map((inputLine) => inputLine.split(' ')); const possibleInputLineVariables = inputLines.filter((wordsInLine) => diff --git a/api/apps/geoprocessing/src/legacy-project-import/legacy-piece-importers/solutions.legacy-piece-importer.ts b/api/apps/geoprocessing/src/legacy-project-import/legacy-piece-importers/solutions.legacy-piece-importer.ts index d3c085bcb0..91b4ac8366 100644 --- a/api/apps/geoprocessing/src/legacy-project-import/legacy-piece-importers/solutions.legacy-piece-importer.ts +++ b/api/apps/geoprocessing/src/legacy-project-import/legacy-piece-importers/solutions.legacy-piece-importer.ts @@ -226,7 +226,7 @@ export class SolutionsLegacyProjectPieceImporter ); const outputSumPath = `${outputFolder}/${outputSumFileName}.${outputSumFileNameExtension}`; - this.geoEntityManager.transaction(async (em) => { + await this.geoEntityManager.transaction(async (em) => { await this.insertOutputScenarioFeaturesData(em, scenarioFeatureRunData); await this.insertOutputScenariosPuData(em, planningUnitsState); diff --git a/api/apps/geoprocessing/test/integration/legacy-project-import/input.legacy-piece-importer.e2e-spec.ts b/api/apps/geoprocessing/test/integration/legacy-project-import/input.legacy-piece-importer.e2e-spec.ts index 3b60681a88..dc23f4fc16 100644 --- a/api/apps/geoprocessing/test/integration/legacy-project-import/input.legacy-piece-importer.e2e-spec.ts +++ b/api/apps/geoprocessing/test/integration/legacy-project-import/input.legacy-piece-importer.e2e-spec.ts @@ -192,7 +192,7 @@ const getFixtures = async () => { ...validVariableValues, }; - return saveFile('BESTSCORE 100/nBLM 200'); + return saveFile('BESTSCORE 100\nBLM 200'); }, GivenInvalidInputDatFile: () => { const invalidVariableValues = 'BESTSCORE invalidBestScore';