diff --git a/README.md b/README.md index c0daadf4b..a14e8c598 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,18 @@ Then either rebuild the docker container or run `yarn update-runtime-env` as dis In the cloud instances, dev uses Helsinki AD identification while others use Suomi.fi. +### Windows Subsystem for Linux (WSL) + +If you use WSL as your local development environment and you bump into pre-push validation errors +in `git push` that other developers (with e.g. Mac) do not have, you could try to set `WSL=true` +in your local environment, e.g. in `~/.huskyrc` (Husky git hooks automatically loads this file): + +``` +export WSL=true +``` + +This setting adds `--runInBand` parameter for Jest tests (see https://jestjs.io/docs/cli#--runinband). + ## Excel for translations You can export an Excel-file with current translations. This can then be sent to translators. diff --git a/package.json b/package.json index 564eaa83e..56f27cc77 100644 --- a/package.json +++ b/package.json @@ -126,7 +126,7 @@ "husky": { "hooks": { "pre-commit": "lint-staged", - "pre-push": "yarn run type-check && yarn testCI" + "pre-push": "yarn run type-check && if test \"$WSL\" = \"true\" ; then yarn testCI --runInBand ; else yarn testCI ; fi" } }, "lint-staged": { diff --git a/src/domain/hanke/edit/utils.test.ts b/src/domain/hanke/edit/utils.test.ts index a3141ef66..a55ac536f 100644 --- a/src/domain/hanke/edit/utils.test.ts +++ b/src/domain/hanke/edit/utils.test.ts @@ -1,8 +1,10 @@ -import { HankeAlueFormState } from './types'; -import { getAreaDefaultName } from './utils'; +import { Feature } from 'ol'; +import { HankeAlueFormState, HankeDataFormState } from './types'; +import { convertFormStateToHankeData, getAreaDefaultName } from './utils'; function getArea(areaName: string): HankeAlueFormState { return { + feature: new Feature(), nimi: areaName, id: null, haittaAlkuPvm: '2023-01-12T00:00:00Z', @@ -15,6 +17,15 @@ function getArea(areaName: string): HankeAlueFormState { }; } +function getHankeData(): HankeDataFormState { + return { + alueet: [getArea('Hankealue 1')], + rakennuttajat: [], + toteuttajat: [], + muut: [], + }; +} + test('Should get default area name when there are no areas', () => { const areaName = getAreaDefaultName([]); @@ -49,3 +60,10 @@ test('Should get correct default area name based on other areas', () => { expect(thirdAreaName).toBe('Hankealue 8'); }); + +test('Should get area data without feature', () => { + const hankeData = convertFormStateToHankeData(getHankeData()); + + expect(hankeData.alueet![0].feature).toBeUndefined(); + expect(hankeData.alueet![0].nimi).toBe('Hankealue 1'); +}); diff --git a/src/domain/hanke/edit/utils.ts b/src/domain/hanke/edit/utils.ts index 8597e1330..ff4dfd856 100644 --- a/src/domain/hanke/edit/utils.ts +++ b/src/domain/hanke/edit/utils.ts @@ -38,8 +38,10 @@ export const convertFormStateToHankeData = (hankeData: HankeDataFormState): Hank return { ...hankeData, [FORMFIELD.HANKEALUEET]: hankeData[FORMFIELD.HANKEALUEET]?.map((alue) => { + // eslint-disable-next-line + const { feature, ...hankeAlue } = alue; // exclude virtual field 'feature' from API call return { - ...alue, + ...hankeAlue, geometriat: { featureCollection: formatFeaturesToHankeGeoJSON(alue.feature ? [alue.feature] : []), },