diff --git a/frontend/cypress/e2e/check-in.cy.ts b/frontend/cypress/e2e/check-in.cy.ts index a6d389027c..c68d7338f1 100644 --- a/frontend/cypress/e2e/check-in.cy.ts +++ b/frontend/cypress/e2e/check-in.cy.ts @@ -483,6 +483,27 @@ describe('okr check-in', () => { .should('not.exist'); }); + it('should ensure version of actions work properly', () => { + FilterHelper.do() + .toggleOption('/BBT'); + keyResultDetailPage.visit('Im Durchschnitt soll die Lautstärke 60dB nicht überschreiten'); + isChecked('Neuer Garten', true); + + keyResultDetailPage.createCheckIn() + .checkActionOfActionPlan(2) + .fillMetricCheckInValue('5') + .submit(); + isChecked('Neuer Garten', false); + + keyResultDetailPage.createCheckIn() + .checkActionOfActionPlan(2) + .fillMetricCheckInValue('5') + .submit(); + + + isChecked('Neuer Garten', true); + }); + it('should have a primary button on every check-in dialog', () => { keyResultDetailPage.visit('Very important keyresult') .createCheckIn() diff --git a/frontend/src/app/components/action-plan/action-plan.component.ts b/frontend/src/app/components/action-plan/action-plan.component.ts index 8a839b7e4b..c7489bd177 100644 --- a/frontend/src/app/components/action-plan/action-plan.component.ts +++ b/frontend/src/app/components/action-plan/action-plan.component.ts @@ -24,13 +24,15 @@ export interface Item { id: number | undefined; item: string; isChecked: boolean; + version: number; } export function initFormGroupFromItem(item?: Item): FormGroup> { return new FormGroup({ item: new FormControl(item?.item || '', [Validators.minLength(2)]), id: new FormControl(item?.id || undefined), - isChecked: new FormControl(item?.isChecked || false) + isChecked: new FormControl(item?.isChecked || false), + version: new FormControl(item?.version || 1) } as FormControlsOf); } diff --git a/frontend/src/app/components/checkin/check-in-form/check-in-form.component.ts b/frontend/src/app/components/checkin/check-in-form/check-in-form.component.ts index 3f8be9f524..a0b1aa563c 100644 --- a/frontend/src/app/components/checkin/check-in-form/check-in-form.component.ts +++ b/frontend/src/app/components/checkin/check-in-form/check-in-form.component.ts @@ -19,7 +19,7 @@ import { CheckInOrdinalMin } from '../../../shared/types/model/check-in-ordinal- import { Zone } from '../../../shared/types/enums/zone'; import { numberValidator } from '../../../shared/constant-library'; -import { FormControlsOf, Item } from '../../action-plan/action-plan.component'; +import { FormControlsOf, initFormGroupFromItem, Item } from '../../action-plan/action-plan.component'; import { Observable } from 'rxjs'; @Component({ selector: 'app-check-in-form', @@ -169,7 +169,7 @@ export class CheckInFormComponent implements OnInit { addNewItem(item?: Item) { this.getFormControlArray() - ?.push(this.initFormGroupFromItem(item)); + ?.push(initFormGroupFromItem(item)); } setValidators(type: string) { @@ -178,12 +178,4 @@ export class CheckInFormComponent implements OnInit { this.dialogForm.get(this.checkInTypes.filter((formName) => formName.includes(type))) ?.enable({ emitEvent: false }); } - - initFormGroupFromItem(item?: Item): FormGroup> { - return new FormGroup({ - item: new FormControl(item?.item || '', [Validators.minLength(2)]), - id: new FormControl(item?.id || undefined), - isChecked: new FormControl(item?.isChecked || false) - } as FormControlsOf); - } } diff --git a/frontend/src/app/components/manage-units-dialog/manage-units-dialog.component.spec.ts b/frontend/src/app/components/manage-units-dialog/manage-units-dialog.component.spec.ts index b789ade5fa..a6c2c9662c 100644 --- a/frontend/src/app/components/manage-units-dialog/manage-units-dialog.component.spec.ts +++ b/frontend/src/app/components/manage-units-dialog/manage-units-dialog.component.spec.ts @@ -9,8 +9,8 @@ import { MatDialogModule, MatDialogRef } from '@angular/material/dialog'; import { UnitTransformationPipe } from '../../shared/pipes/unit-transformation/unit-transformation.pipe'; import { DialogTemplateCoreComponent } from '../../shared/custom/dialog-template-core/dialog-template-core.component'; import { ErrorComponent } from '../../shared/custom/error/error.component'; -import { ActionPlanComponent, FormControlsOf, Item } from '../action-plan/action-plan.component'; -import { FormArray, FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms'; +import { ActionPlanComponent, initFormGroupFromItem, Item } from '../action-plan/action-plan.component'; +import { FormArray, ReactiveFormsModule } from '@angular/forms'; import { MatIconModule } from '@angular/material/icon'; import { MatDividerModule } from '@angular/material/divider'; import { UnitService } from '../../services/unit.service'; @@ -148,22 +148,31 @@ describe('ManageUnitsDialogComponent', () => { const mockItems: Item[] = [ { id: 1, item: 'Kilogram', + version: 1, isChecked: false }, { id: 1, item: 'Kilogram', + version: 1, + isChecked: false }, { id: undefined, item: 'Meter', + version: 1, + isChecked: false }, { id: undefined, item: 'Meter', + version: 1, + isChecked: false }, { id: undefined, item: 'Meter', + version: 1, + isChecked: false } ]; (component.fg.get('unitFormArray') as FormArray)?.clear(); - mockItems.forEach((item) => addNewItem(item)); + mockItems.forEach((item) => initFormGroupFromItem(item)); jest.spyOn(component, 'getChangedItems') .mockReturnValue(mockItems); @@ -219,14 +228,6 @@ describe('ManageUnitsDialogComponent', () => { .toHaveBeenCalledWith('Kilogram'); }); }); - function addNewItem(item?: Item) { - const newFormGroup = new FormGroup({ - item: new FormControl(item?.item || ''), - id: new FormControl(item?.id || undefined), - isChecked: new FormControl(item?.isChecked || false) - } as FormControlsOf); - (component.fg.get('unitFormArray') as FormArray)?.push(newFormGroup); - } }); diff --git a/frontend/src/app/shared/common.ts b/frontend/src/app/shared/common.ts index 718166601f..3623cb8967 100644 --- a/frontend/src/app/shared/common.ts +++ b/frontend/src/app/shared/common.ts @@ -151,7 +151,8 @@ export function actionListToItemList(actionList: Action[]): Item[] { return (actionList || []).map((action) => { return { id: action.id, item: action.action, - isChecked: action.isChecked } as Item; + isChecked: action.isChecked, + version: action.version || 1 } as Item; }); } @@ -163,7 +164,8 @@ export function itemListToActionList(itemList: Item[], keyResultId: number | nul action: item.item, priority: index, keyResultId: keyResultId, - isChecked: item.isChecked + isChecked: item.isChecked, + version: item.version } as Action; }); } diff --git a/frontend/src/app/shared/test-data.ts b/frontend/src/app/shared/test-data.ts index 43a53dc6e8..83120392c2 100644 --- a/frontend/src/app/shared/test-data.ts +++ b/frontend/src/app/shared/test-data.ts @@ -647,15 +647,19 @@ export const keyResultActions: KeyResultMetric = { export const minItem: Item = { item: '', isChecked: false, + version: 1, id: undefined }; export const item1: Item = { item: 'item1', isChecked: false, + version: 1, id: 1 }; export const item2: Item = { item: 'item2', isChecked: false, + version: 1, id: 2 }; export const item3: Item = { item: 'item3', isChecked: false, + version: 1, id: 3 }; export const items: Item[] = [item1, item2, diff --git a/release-notes.txt b/release-notes.txt index 4fc7497553..f175e0078f 100644 --- a/release-notes.txt +++ b/release-notes.txt @@ -29,6 +29,7 @@ WIP - Erweiterung #1293: KeyResult Metric unterstützen eigene Units - Erweiterung #1169: Deploy Workflows aufgeräumt - Erweiterung #1334: Model-Attribute isBacklogQuarter für eine eindeutige Identifizierung des Backlog-Quarters implementiert + - Fehlerbehebung #1410: Eine Action kann nun wieder über den Check-in Dialog als abgeschlossen markiert werden. - Fehlerbehebung #1255: Wenn ein Objective dupliziert wird, wird nun auch der Actionplan übernommen - Fehlerbehebung #1298: SCSS-Warnungen behoben - Fehlerbehebung #1236: Flaky E2E-Tests gefixt