diff --git a/frontend/cypress/e2e/checkIn.cy.ts b/frontend/cypress/e2e/checkIn.cy.ts index 937a6f51ca..e3df4724d0 100644 --- a/frontend/cypress/e2e/checkIn.cy.ts +++ b/frontend/cypress/e2e/checkIn.cy.ts @@ -259,8 +259,8 @@ describe('OKR Check-in e2e tests', () => { it(`Should display confirm dialog when creating checkin on draft objective`, () => { cy.getByTestId('add-objective').first().click(); - cy.fillOutObjective('draft objective title', 'safe-draft', '3'); - cy.visit('/?quarter=3'); + cy.fillOutObjective('draft objective title', 'safe-draft', '1'); + cy.visit('/?quarter=1'); cy.contains('draft objective title').first().parentsUntil('#objective-column').last().focus(); cy.tabForwardUntil('[data-testId="add-keyResult"]'); @@ -290,8 +290,8 @@ describe('OKR Check-in e2e tests', () => { it(`Should not display last value div if last checkin is not present`, () => { cy.getByTestId('add-objective').first().click(); - cy.fillOutObjective('new objective', 'safe', '3'); - cy.visit('/?quarter=3'); + cy.fillOutObjective('new objective', 'safe', '1'); + cy.visit('/?quarter=1'); cy.contains('new objective').first().parentsUntil('#objective-column').last().focus(); cy.tabForwardUntil('[data-testId="add-keyResult"]'); diff --git a/frontend/cypress/e2e/crud.cy.ts b/frontend/cypress/e2e/crud.cy.ts index bbe1dec6cc..d72430259f 100644 --- a/frontend/cypress/e2e/crud.cy.ts +++ b/frontend/cypress/e2e/crud.cy.ts @@ -12,8 +12,8 @@ describe('CRUD operations', () => { ].forEach(([objectiveTitle, buttonTestId, icon]) => { it(`Create objective, no keyresults`, () => { cy.getByTestId('add-objective').first().click(); - cy.fillOutObjective(objectiveTitle, buttonTestId, '3'); - cy.visit('/?quarter=3'); + cy.fillOutObjective(objectiveTitle, buttonTestId, '1'); + cy.visit('/?quarter=1'); const objective = cy.contains(objectiveTitle).first().parentsUntil('#objective-column').last(); objective.getByTestId('objective-state').should('have.attr', 'src', `assets/icons/${icon}`); }); @@ -25,7 +25,7 @@ describe('CRUD operations', () => { ].forEach(([objectiveTitle, buttonTestId, icon]) => { it(`Create objective, no keyresults`, () => { cy.getByTestId('add-objective').first().click(); - cy.fillOutObjective(objectiveTitle, buttonTestId, '3', '', true); + cy.fillOutObjective(objectiveTitle, buttonTestId, '1', '', true); cy.contains('Key Result erfassen'); }); }); @@ -42,8 +42,8 @@ describe('CRUD operations', () => { it(`Create objective, cancel`, () => { const objectiveTitle = 'this is a canceled objective'; cy.getByTestId('add-objective').first().click(); - cy.fillOutObjective(objectiveTitle, 'cancel', '3'); - cy.visit('/?quarter=3'); + cy.fillOutObjective(objectiveTitle, 'cancel', '1'); + cy.visit('/?quarter=1'); cy.contains(objectiveTitle).should('not.exist'); }); diff --git a/frontend/cypress/e2e/duplicated-scoring.cy.ts b/frontend/cypress/e2e/duplicated-scoring.cy.ts index d1152ced59..5cc5565794 100644 --- a/frontend/cypress/e2e/duplicated-scoring.cy.ts +++ b/frontend/cypress/e2e/duplicated-scoring.cy.ts @@ -22,8 +22,8 @@ describe('e2e test for scoring adjustment on objective duplicate', () => { cy.get('.objective').first().getByTestId('three-dot-menu').click(); cy.get('.mat-mdc-menu-content').contains('Objective duplizieren').click(); - cy.fillOutObjective('A duplicated Objective for this tool', 'safe', '3'); - cy.visit('/?quarter=3'); + cy.fillOutObjective('A duplicated Objective for this tool', 'safe', '1'); + cy.visit('/?quarter=1'); let scoringBlock1 = cy .getByTestId('objective') diff --git a/frontend/cypress/e2e/objective-alignment.cy.ts b/frontend/cypress/e2e/objective-alignment.cy.ts index 540aad6a85..1d6cb6f990 100644 --- a/frontend/cypress/e2e/objective-alignment.cy.ts +++ b/frontend/cypress/e2e/objective-alignment.cy.ts @@ -106,7 +106,7 @@ describe('OKR Objective Alignment e2e tests', () => { .contains('Objective bearbeiten') .click(); - cy.get('select#alignment').select('Bitte wählen'); + cy.get('select#alignment').select('Kein Alignment'); cy.getByTestId('safe').click(); cy.getByTestId('objective') @@ -123,7 +123,7 @@ describe('OKR Objective Alignment e2e tests', () => { }); it(`Alignment Possibilites change when quarter change`, () => { - cy.visit('/?quarter=3'); + cy.visit('/?quarter=1'); cy.getByTestId('add-objective').first().click(); cy.getByTestId('title').first().clear().type('We can link later on this'); @@ -145,12 +145,12 @@ describe('OKR Objective Alignment e2e tests', () => { cy.get('select#alignment option:selected').should('not.contain.text', selectValue); cy.getByTestId('cancel').click(); - cy.visit('/?quarter=4'); + cy.visit('/?quarter=2'); cy.getByTestId('add-objective').first().click(); cy.getByTestId('title').first().clear().type('Quarter change objective'); - cy.get('select#quarter').select('GJ 22/23-Q3'); + cy.get('select#quarter').select('GJ 22/23-Q4'); cy.getByTestId('title').first().clear().type('A new title'); cy.get('select#alignment').select(1); diff --git a/frontend/src/app/shared/dialog/objective-dialog/objective-form.component.spec.ts b/frontend/src/app/shared/dialog/objective-dialog/objective-form.component.spec.ts index 808e91fbc4..059fb442d8 100644 --- a/frontend/src/app/shared/dialog/objective-dialog/objective-form.component.spec.ts +++ b/frontend/src/app/shared/dialog/objective-dialog/objective-form.component.spec.ts @@ -74,24 +74,6 @@ const mockActivatedRoute = { }, }; -const alignmentPossibilities = [ - { - objectiveId: 1003, - objectiveTitle: 'O - Test Objective', - keyResultAlignmentsDtos: [], - }, - { - objectiveId: 1005, - objectiveTitle: 'O - Company will grow', - keyResultAlignmentsDtos: [ - { - keyResultId: 6, - keyResultTitle: 'K - New structure', - }, - ], - }, -]; - describe('ObjectiveDialogComponent', () => { let component: ObjectiveFormComponent; let fixture: ComponentFixture; @@ -430,12 +412,66 @@ describe('ObjectiveDialogComponent', () => { fixture.detectChanges(); expect(component.allowedOption(quarter)).toBeTruthy(); }); + }); + + describe('AlignmentPossibilities', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ + HttpClientTestingModule, + MatDialogModule, + MatIconModule, + MatFormFieldModule, + MatSelectModule, + ReactiveFormsModule, + MatInputModule, + NoopAnimationsModule, + MatCheckboxModule, + RouterTestingModule, + TranslateTestingModule.withTranslations({ + de: de, + }), + ], + declarations: [ObjectiveFormComponent, DialogHeaderComponent], + providers: [ + { provide: MatDialogRef, useValue: dialogMock }, + { provide: MAT_DIALOG_DATA, useValue: matDataMock }, + { provide: ObjectiveService, useValue: objectiveService }, + { provide: QuarterService, useValue: quarterService }, + { provide: TeamService, useValue: teamService }, + ], + }); + + let alignmentPossibilities = [ + { + objectiveId: 1003, + objectiveTitle: 'O - Test Objective', + keyResultAlignmentsDtos: [], + }, + { + objectiveId: 1005, + objectiveTitle: 'O - Company will grow', + keyResultAlignmentsDtos: [ + { + keyResultId: 6, + keyResultTitle: 'K - New structure', + }, + ], + }, + ]; - it('should load correct alignment possibilities', async () => { jest.spyOn(objectiveService, 'getAlignmentPossibilities').mockReturnValue(of(alignmentPossibilities)); + fixture = TestBed.createComponent(ObjectiveFormComponent); + component = fixture.componentInstance; fixture.detectChanges(); - component.ngOnInit(); + loader = TestbedHarnessEnvironment.loader(fixture); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); + it('should load correct alignment possibilities', async () => { let generatedPossibilities = [ { objectiveId: null, @@ -470,7 +506,6 @@ describe('ObjectiveDialogComponent', () => { matDataMock.objective.objectiveId = 1; component.objective = objectiveWithAlignment; objectiveService.getFullObjective.mockReturnValue(of(objectiveWithAlignment)); - jest.spyOn(objectiveService, 'getAlignmentPossibilities').mockReturnValue(of(alignmentPossibilities)); fixture.detectChanges(); component.ngOnInit(); @@ -508,7 +543,6 @@ describe('ObjectiveDialogComponent', () => { component.objective = objective; component.data.objective.objectiveId = 5; objectiveService.getFullObjective.mockReturnValue(of(objectiveWithAlignment)); - jest.spyOn(objectiveService, 'getAlignmentPossibilities').mockReturnValue(of(alignmentPossibilities)); fixture.detectChanges(); component.ngOnInit(); @@ -543,7 +577,6 @@ describe('ObjectiveDialogComponent', () => { }); it('should load Kein Alignment to alignment possibilities when choosing one alignment', async () => { - jest.spyOn(objectiveService, 'getAlignmentPossibilities').mockReturnValue(of(alignmentPossibilities)); objectiveService.getFullObjective.mockReturnValue(of(objective)); component.objective = objective; component.data.objective.objectiveId = 5; @@ -615,7 +648,7 @@ describe('ObjectiveDialogComponent', () => { { provide: ActivatedRoute, useValue: mockActivatedRoute }, ], }); - jest.spyOn(objectiveService, 'getAlignmentPossibilities').mockReturnValue(of(alignmentPossibilities)); + jest.spyOn(objectiveService, 'getAlignmentPossibilities').mockReturnValue(of([])); fixture = TestBed.createComponent(ObjectiveFormComponent); component = fixture.componentInstance; fixture.detectChanges();