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

Bug/1404 error complete action in check in #1410

Merged
merged 6 commits into from
Feb 21, 2025
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
21 changes: 21 additions & 0 deletions frontend/cypress/e2e/check-in.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ export interface Item {
id: number | undefined;
item: string;
isChecked: boolean;
version: number;
}

export function initFormGroupFromItem(item?: Item): FormGroup<FormControlsOf<Item>> {
return new FormGroup({
item: new FormControl<string>(item?.item || '', [Validators.minLength(2)]),
id: new FormControl<number | undefined>(item?.id || undefined),
isChecked: new FormControl<boolean>(item?.isChecked || false)
isChecked: new FormControl<boolean>(item?.isChecked || false),
version: new FormControl<number>(item?.version || 1)
} as FormControlsOf<Item>);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -169,7 +169,7 @@ export class CheckInFormComponent implements OnInit {

addNewItem(item?: Item) {
this.getFormControlArray()
?.push(this.initFormGroupFromItem(item));
?.push(initFormGroupFromItem(item));
}

setValidators(type: string) {
Expand All @@ -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<FormControlsOf<Item>> {
return new FormGroup({
item: new FormControl<string>(item?.item || '', [Validators.minLength(2)]),
id: new FormControl<number | undefined>(item?.id || undefined),
isChecked: new FormControl<boolean>(item?.isChecked || false)
} as FormControlsOf<Item>);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -219,14 +228,6 @@ describe('ManageUnitsDialogComponent', () => {
.toHaveBeenCalledWith('Kilogram');
});
});
function addNewItem(item?: Item) {
const newFormGroup = new FormGroup({
item: new FormControl<string>(item?.item || ''),
id: new FormControl<number | undefined>(item?.id || undefined),
isChecked: new FormControl<boolean>(item?.isChecked || false)
} as FormControlsOf<Item>);
(component.fg.get('unitFormArray') as FormArray)?.push(newFormGroup);
}
});


6 changes: 4 additions & 2 deletions frontend/src/app/shared/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}

Expand All @@ -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;
});
}
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/app/shared/test-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions release-notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading