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

HAI-2057 Delete Suunnitteluvaihe from Hanke #396

Merged
merged 4 commits into from
Oct 24, 2023
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
2 changes: 0 additions & 2 deletions cypress/integration/E2E.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
HankeDataDraft,
HankeIndexData,
HANKE_INDEX_TYPE,
HANKE_SUUNNITTELUVAIHE,
} from '../../src/domain/types/hanke';
import { createHankeFromUI } from '../utils/formFiller';
import { validateIndexes } from '../utils/indexValidator';
Expand Down Expand Up @@ -68,7 +67,6 @@ const hankeMock: HankeDataDraft = {
],
tyomaaKatuosoite: 'Mannerheimintie 14',
vaihe: HANKE_VAIHE.SUUNNITTELU,
suunnitteluVaihe: HANKE_SUUNNITTELUVAIHE.KATUSUUNNITTELU_TAI_ALUEVARAUS,
omistajat: [
{
id: null, // not used but types require it
Expand Down
33 changes: 2 additions & 31 deletions cypress/utils/formFiller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,17 @@ import {
HANKE_TARINAHAITTA_KEY,
HANKE_VAIHE,
HankeDataDraft,
HANKE_SUUNNITTELUVAIHE,
HANKE_VAIHE_KEY,
HANKE_SUUNNITTELUVAIHE_KEY,
} from '../../src/domain/types/hanke';

export const selectHankeVaihe = (
vaihe: HANKE_VAIHE_KEY,
suunnitteluVaihe?: HANKE_SUUNNITTELUVAIHE_KEY
) => {
export const selectHankeVaihe = (vaihe: HANKE_VAIHE_KEY) => {
cy.get('#vaihe-toggle-button').click();
switch (vaihe) {
case HANKE_VAIHE.OHJELMOINTI:
cy.get('#vaihe-item-0').click();
break;
case HANKE_VAIHE.SUUNNITTELU:
cy.get('#vaihe-item-1').click();
if (suunnitteluVaihe) {
cy.get('#suunnitteluVaihe-toggle-button').click();
switch (suunnitteluVaihe) {
case HANKE_SUUNNITTELUVAIHE.YLEIS_TAI_HANKE:
cy.get('#suunnitteluVaihe-item-0').click();
break;
case HANKE_SUUNNITTELUVAIHE.KATUSUUNNITTELU_TAI_ALUEVARAUS:
cy.get('#suunnitteluVaihe-item-1').click();
break;
case HANKE_SUUNNITTELUVAIHE.RAKENNUS_TAI_TOTEUTUS:
cy.get('#suunnitteluVaihe-item-2').click();
break;
case HANKE_SUUNNITTELUVAIHE.TYOMAAN_TAI_HANKKEEN_AIKAINEN:
cy.get('#suunnitteluVaihe-item-3').click();
break;
default:
break;
}
} else {
throw new Error('Tämä testin vaihe tarvitsee suunnitteluvaiheen');
}
break;
case HANKE_VAIHE.RAKENTAMINEN:
cy.get('#vaihe-item-2').click();
Expand All @@ -69,10 +43,7 @@ export const fillForm0 = (hankeData: HankeDataDraft) => {
}
cy.get('input[data-testid=nimi]').click();

selectHankeVaihe(
hankeData.vaihe,
hankeData.suunnitteluVaihe ? hankeData.suunnitteluVaihe : undefined
);
selectHankeVaihe(hankeData.vaihe);

if (hankeData.onYKTHanke) {
cy.get('input[data-testid=onYKTHanke]').click();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build-and-serve": "yarn run build && yarn run serve",
"update-runtime-env": "ts-node -P ./scripts/tsconfig.json --files scripts/update-runtime-env.ts",
"test": "TEST=true yarn run update-runtime-env && DEBUG_PRINT_LIMIT=50000 react-scripts test",
"testCI": "CI=true react-scripts test",
"testCI": "TEST=true yarn run update-runtime-env && CI=TRUE DEBUG_PRINT_LIMIT=50000 react-scripts test",
"eject": "react-scripts eject",
"type-check": "tsc --pretty --noEmit",
"format": "prettier --write",
Expand Down
29 changes: 0 additions & 29 deletions src/domain/hanke/edit/HankeForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const hankeData: HankeDataDraft = {
alkuPvm: '24.03.2025',
loppuPvm: '25.03.2025',
vaihe: 'OHJELMOINTI',
suunnitteluVaihe: 'KATUSUUNNITTELU_TAI_ALUEVARAUS',
omistajat: [
{
id: null,
Expand Down Expand Up @@ -88,34 +87,6 @@ async function setupYhteystiedotPage(jsx: JSX.Element) {
}

describe('HankeForm', () => {
test('suunnitteluVaihde should be required when vaihe is suunnittelu', async () => {
const handleIsDirtyChange = jest.fn();
const handleFormClose = jest.fn();

const { user } = render(
<HankeForm
formData={formData}
onIsDirtyChange={handleIsDirtyChange}
onFormClose={handleFormClose}
>
child
</HankeForm>,
);

fireEvent.change(screen.getByTestId(FORMFIELD.NIMI), { target: { value: nimi } });
fireEvent.change(screen.getByTestId(FORMFIELD.KUVAUS), { target: { value: hankkeenKuvaus } });
fireEvent.change(screen.getByTestId(FORMFIELD.KATUOSOITE), {
target: { value: hankkeenOsoite },
});

await user.click(screen.getByRole('radio', { name: 'Suunnittelu' }));

await user.click(screen.getByRole('checkbox', { name: 'Hanke on YKT-hanke' }));

await user.click(screen.getByText('Hankkeen suunnitteluvaihe'));
pitkni marked this conversation as resolved.
Show resolved Hide resolved
await user.click(screen.getByText('Yleis- tai hankesuunnittelu'));
});

test('Form should be populated correctly ', () => {
render(
<HankeForm
Expand Down
30 changes: 4 additions & 26 deletions src/domain/hanke/edit/HankeFormPerustiedot.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React, { useEffect } from 'react';
import React from 'react';
import { useTranslation, Trans } from 'react-i18next';
import { Tooltip, TextArea, SelectionGroup, RadioButton } from 'hds-react';
import { $enum } from 'ts-enum-util';
import { useFormContext } from 'react-hook-form';
import { Box } from '@chakra-ui/react';
import Dropdown from '../../../common/components/dropdown/Dropdown';
import TextInput from '../../../common/components/textInput/TextInput';
import { HANKE_VAIHE, HANKE_SUUNNITTELUVAIHE, HANKE_TYOMAATYYPPI } from '../../types/hanke';
import { HANKE_VAIHE, HANKE_TYOMAATYYPPI } from '../../types/hanke';
import { FORMFIELD, FormProps } from './types';
import { useFormPage } from './hooks/useFormPage';
import DropdownMultiselect from '../../../common/components/dropdown/DropdownMultiselect';
Expand All @@ -21,19 +20,13 @@ const HankeFormPerustiedot: React.FC<React.PropsWithChildren<FormProps>> = ({
formData,
}) => {
const { t } = useTranslation();
const { watch, setValue } = useFormContext();
const { watch } = useFormContext();
const { JOHTOSELVITYSHAKEMUS } = useLocalizedRoutes();
useFormPage();

// Subscribe to vaihe changes
// Subscribe to vaihe changes in order to update the selected radio button
const hankeVaiheField = watch(FORMFIELD.VAIHE);

useEffect(() => {
if (hankeVaiheField !== HANKE_VAIHE.SUUNNITTELU) {
setValue(FORMFIELD.SUUNNITTELUVAIHE, null);
}
}, [hankeVaiheField, setValue]);

return (
<div className="form0">
<div className="formInstructions">
Expand Down Expand Up @@ -98,21 +91,6 @@ const HankeFormPerustiedot: React.FC<React.PropsWithChildren<FormProps>> = ({
})}
</SelectionGroup>
</div>
<div className="formWpr">
<Dropdown
id={FORMFIELD.SUUNNITTELUVAIHE}
name={FORMFIELD.SUUNNITTELUVAIHE}
options={$enum(HANKE_SUUNNITTELUVAIHE).map((value) => ({
value,
label: t(`hanke:suunnitteluVaihe:${value}`),
}))}
defaultValue={formData[FORMFIELD.SUUNNITTELUVAIHE] || null}
label={t(`hankeForm:labels:${FORMFIELD.SUUNNITTELUVAIHE}`)}
invalid={!!errors[FORMFIELD.SUUNNITTELUVAIHE]}
required={hankeVaiheField === HANKE_VAIHE.SUUNNITTELU}
disabled={hankeVaiheField !== HANKE_VAIHE.SUUNNITTELU}
/>
</div>
<div className="formWpr">
<DropdownMultiselect
name={FORMFIELD.TYOMAATYYPPI}
Expand Down
8 changes: 0 additions & 8 deletions src/domain/hanke/edit/hankeSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { $enum } from 'ts-enum-util';
import yup from '../../../common/utils/yup';
import {
HANKE_VAIHE,
HANKE_SUUNNITTELUVAIHE,
HANKE_MELUHAITTA,
HANKE_POLYHAITTA,
HANKE_TARINAHAITTA,
Expand Down Expand Up @@ -81,13 +80,6 @@ export const hankeSchema = yup.object().shape({
[FORMFIELD.KUVAUS]: yup.string().required().min(1),
[FORMFIELD.KATUOSOITE]: yup.string().required(),
[FORMFIELD.VAIHE]: yup.mixed().oneOf($enum(HANKE_VAIHE).getValues()).required(),
[FORMFIELD.SUUNNITTELUVAIHE]: yup
.mixed()
.nullable()
.when([FORMFIELD.VAIHE], {
is: HANKE_VAIHE.SUUNNITTELU,
then: yup.mixed().oneOf($enum(HANKE_SUUNNITTELUVAIHE).getValues()).required(),
}),
[FORMFIELD.HANKEALUEET]: yup.array().ensure().of(hankeAlueSchema),
[FORMFIELD.OMISTAJAT]: yup.array().length(1).ensure().of(contactSchema),
[FORMFIELD.RAKENNUTTAJAT]: yup.array().ensure().of(contactSchema),
Expand Down
1 change: 0 additions & 1 deletion src/domain/hanke/edit/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export enum FORMFIELD {
NIMI = 'nimi',
KUVAUS = 'kuvaus',
KATUOSOITE = 'tyomaaKatuosoite',
SUUNNITTELUVAIHE = 'suunnitteluVaihe',
TYOMAATYYPPI = 'tyomaaTyyppi',
HAITTA_ALKU_PVM = 'haittaAlkuPvm',
HAITTA_LOPPU_PVM = 'haittaLoppuPvm',
Expand Down
11 changes: 0 additions & 11 deletions src/domain/mocks/data/hankkeet-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const hankkeet: HankeDataDraft[] = [
alkuPvm: '2022-11-26T00:00:00Z',
loppuPvm: '2022-12-17T00:00:00Z',
vaihe: 'OHJELMOINTI',
suunnitteluVaihe: null,
version: 0,
createdBy: '1',
createdAt: '2020-11-27T11:33:17.0875Z',
Expand All @@ -35,7 +34,6 @@ const hankkeet: HankeDataDraft[] = [
alkuPvm: '2023-01-12T00:00:00Z',
loppuPvm: '2024-11-27T00:00:00Z',
vaihe: 'OHJELMOINTI',
suunnitteluVaihe: null,
version: 0,
createdBy: '1',
createdAt: '2022-11-27T11:43:43.481215Z',
Expand Down Expand Up @@ -234,7 +232,6 @@ const hankkeet: HankeDataDraft[] = [
alkuPvm: '2023-01-02T00:00:00Z',
loppuPvm: '2023-02-24T00:00:00Z',
vaihe: 'OHJELMOINTI',
suunnitteluVaihe: null,
tyomaaTyyppi: ['KAUKOLAMPO'],
version: 0,
createdBy: '1',
Expand Down Expand Up @@ -339,7 +336,6 @@ const hankkeet: HankeDataDraft[] = [
loppuPvm: '2022-11-28T00:00:00Z',
tyomaaKatuosoite: 'Pohjoisesplanadi 2',
vaihe: 'RAKENTAMINEN',
suunnitteluVaihe: null,
version: 0,
createdBy: '1',
createdAt: '2020-11-27T12:07:41.210244Z',
Expand All @@ -362,7 +358,6 @@ const hankkeet: HankeDataDraft[] = [
alkuPvm: '2022-11-23T00:00:00Z',
loppuPvm: '2022-11-28T00:00:00Z',
vaihe: 'OHJELMOINTI',
suunnitteluVaihe: null,
version: 0,
createdBy: '1',
createdAt: '2022-11-23T10:37:36.362778Z',
Expand All @@ -385,7 +380,6 @@ const hankkeet: HankeDataDraft[] = [
alkuPvm: '2022-11-24T00:00:00Z',
loppuPvm: '2022-11-28T00:00:00Z',
vaihe: 'SUUNNITTELU',
suunnitteluVaihe: null,
version: 0,
createdBy: '1',
createdAt: '2020-11-30T13:43:13.599591Z',
Expand All @@ -408,7 +402,6 @@ const hankkeet: HankeDataDraft[] = [
alkuPvm: '2022-11-24T00:00:00Z',
loppuPvm: '2022-11-28T00:00:00Z',
vaihe: 'SUUNNITTELU',
suunnitteluVaihe: null,
version: 0,
createdBy: '1',
createdAt: '2020-11-30T13:43:15.322044Z',
Expand All @@ -431,7 +424,6 @@ const hankkeet: HankeDataDraft[] = [
alkuPvm: '2022-11-24T00:00:00Z',
loppuPvm: '2022-11-28T00:00:00Z',
vaihe: 'OHJELMOINTI',
suunnitteluVaihe: null,
version: 0,
createdBy: '1',
createdAt: '2020-11-30T13:43:24.301796Z',
Expand All @@ -454,7 +446,6 @@ const hankkeet: HankeDataDraft[] = [
alkuPvm: '2022-11-24T00:00:00Z',
loppuPvm: '2022-11-28T00:00:00Z',
vaihe: 'OHJELMOINTI',
suunnitteluVaihe: null,
version: 0,
createdBy: '1',
createdAt: '2020-11-30T13:43:27.330822Z',
Expand All @@ -477,7 +468,6 @@ const hankkeet: HankeDataDraft[] = [
alkuPvm: '2022-12-02T00:00:00Z',
loppuPvm: '2022-12-05T00:00:00Z',
vaihe: 'OHJELMOINTI',
suunnitteluVaihe: null,
version: 0,
createdBy: '1',
createdAt: '2020-12-01T14:22:11.838844Z',
Expand All @@ -500,7 +490,6 @@ const hankkeet: HankeDataDraft[] = [
alkuPvm: '2022-12-02T00:00:00Z',
loppuPvm: '2022-11-28T00:00:00Z',
vaihe: 'OHJELMOINTI',
suunnitteluVaihe: null,
version: 0,
createdBy: '1',
createdAt: '2020-12-01T14:34:24.443622Z',
Expand Down
1 change: 0 additions & 1 deletion src/domain/mocks/data/hankkeet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export async function create(data: HankeDataDraft) {
const newHanke: HankeDataDraft = {
id: hankkeet.length + 1,
hankeTunnus: generateHankeTunnus(),
suunnitteluVaihe: null,
tyomaaKatuosoite: '',
tyomaaTyyppi: [],
alueet: [],
Expand Down
1 change: 0 additions & 1 deletion src/domain/mocks/hankeDraft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const hankeDraft: HankeDataDraft = {
alkuPvm: '2023-11-26T00:00:00Z',
loppuPvm: '2024-11-17T00:00:00Z',
vaihe: 'OHJELMOINTI',
suunnitteluVaihe: null,
version: 0,
createdBy: '1',
createdAt: '2023-11-27T11:33:17.0875Z',
Expand Down
2 changes: 0 additions & 2 deletions src/domain/mocks/hankeList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const hankeList: HankeData[] = [
alkuPvm: '2022-10-02:00:00Z',
loppuPvm: '2022-10-10:00:00Z',
vaihe: 'OHJELMOINTI',
suunnitteluVaihe: null,
version: 0,
createdBy: '1',
createdAt: '2020-11-27T11:33:17.0875Z',
Expand Down Expand Up @@ -79,7 +78,6 @@ const hankeList: HankeData[] = [
alkuPvm: '2022-10-02:00:00Z',
loppuPvm: '2022-10-05:00:00Z',
vaihe: 'OHJELMOINTI',
suunnitteluVaihe: null,
version: 0,
createdBy: '1',
createdAt: '2020-11-27T11:43:43.481215Z',
Expand Down
9 changes: 0 additions & 9 deletions src/domain/types/hanke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ export enum HANKE_VAIHE {
}
export type HANKE_VAIHE_KEY = keyof typeof HANKE_VAIHE;

export enum HANKE_SUUNNITTELUVAIHE {
YLEIS_TAI_HANKE = 'YLEIS_TAI_HANKE',
KATUSUUNNITTELU_TAI_ALUEVARAUS = 'KATUSUUNNITTELU_TAI_ALUEVARAUS',
RAKENNUS_TAI_TOTEUTUS = 'RAKENNUS_TAI_TOTEUTUS',
TYOMAAN_TAI_HANKKEEN_AIKAINEN = 'TYOMAAN_TAI_HANKKEEN_AIKAINEN',
}
export type HANKE_SUUNNITTELUVAIHE_KEY = keyof typeof HANKE_SUUNNITTELUVAIHE;

export enum HANKE_TYOMAATYYPPI {
VESI = 'VESI',
VIEMARI = 'VIEMARI',
Expand Down Expand Up @@ -196,7 +188,6 @@ export interface HankeData {
alkuPvm: string;
loppuPvm: string;
vaihe: HANKE_VAIHE_KEY;
suunnitteluVaihe: HANKE_SUUNNITTELUVAIHE_KEY | null;
tyomaaKatuosoite: string | null;
tyomaaTyyppi: HANKE_TYOMAATYYPPI_KEY[];
alueet: HankeAlue[];
Expand Down
11 changes: 1 addition & 10 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,6 @@
"OHJELMOINTI": "Programming",
"RAKENTAMINEN": "Construction"
},
"suunnitteluVaihe": {
"YLEIS_TAI_HANKE": "General or project planning",
"KATUSUUNNITTELU_TAI_ALUEVARAUS": "Street planning or planning of area reservations",
"RAKENNUS_TAI_TOTEUTUS": "Construction planning or implementation planning",
"TYOMAAN_TAI_HANKKEEN_AIKAINEN": "Early planning of a worksite or project"
},
"tyomaaTyyppi": {
"VESI": "Water",
"VIEMARI": "Sewer",
Expand Down Expand Up @@ -473,7 +467,6 @@
"nimi": "Project name",
"vaihe": "Project phase",
"kuvaus": "Project description",
"suunnitteluVaihe": "Project planning phase",
"alkuPvm": "Project start date",
"loppuPvm": "Project end date",
"tyomaaTyyppi": "Worksite type",
Expand Down Expand Up @@ -504,9 +497,8 @@
"onYKTHanke": "Joint municipal worksite – a joint project under the cooperation agreement. In addition to the City of Helsinki’s Urban Environment Division, the parties are Helsinki City Transport (HKL), Helsinki Region Environmental Services (HSY), Helen Ltd, Helen Electricity Network Ltd, Auris Kaasunjakelu Ltd and the communications network operators Cinia Ltd, DNA Plc, Elisa Plc and Telia Finland Plc. The aim of the Shared Public Utility Site (YKT) partnership is to streamline the construction of public spaces in the city and adapt the contracting parties’ individual projects into jointly implemented projects that improve the quality and supply of infrastructure services.",
"alkuPvm": "Start date of project implementation (Note! Implementation in a public area, not, for example, on a plot)",
"loppuPvm": "End date of project implementation (Note! Implementation in a public area, not, for example, on the side of a plot)",
"vaihe": "A description of the progress of the project which will be updated as the project progresses. The programming phase is the initial project planning or pre-planning phase. The planning phase has subphases depending on the level of detail of the planning. In terms of the permit application process, the project is in the planning phase until it receives an execution permit from the city. At the construction phase, the project has received a permit from the city. Haitaton does not cover the permit application, construction or completion/maintenance/handover phases of the project.",
"vaihe": "A description of the progress of the project which will be updated as the project progresses. The programming phase is the initial project planning or pre-planning phase. In terms of the permit application process, the project is in the planning phase until it receives an execution permit from the city. At the construction phase, the project has received a permit from the city. Haitaton does not cover the permit application, construction or completion/maintenance/handover phases of the project.",
"kuvaus": "Description of the main content and objectives of the project. (Note! Implementation in a public area, not, for example, on the side of a plot)",
"suunnitteluVaihe": "A subphase refining the planning phase, which will be updated as the project progresses.",
"omistajat": "The project owner is responsible for the entire project from its beginning to its end/completion/handover.",
"arvioijat": "The project analyst or assessor may be the project owner or another party authorised by the owner (for example, a project planning consultant or contractor not affiliated with the owner).",
"toteuttajat": "The person responsible for implementing the project may be the project owner or another party authorised by the owner (for example, a contractor not affiliated with the owner).",
Expand Down Expand Up @@ -775,7 +767,6 @@
"labels": {
"kuvaus": "Project description",
"hankeVaihe": "Project phase",
"suunnitteluVaihe": "Planning phase",
"katuosoite": "Street address",
"avaaKartalla": "Open on a map",
"hankkeenKesto": "Project duration",
Expand Down
Loading
Loading