Skip to content

Commit 26e7dec

Browse files
committed
Fix e2e tests because of new quarter
1 parent 4c9750e commit 26e7dec

File tree

5 files changed

+72
-39
lines changed

5 files changed

+72
-39
lines changed

frontend/cypress/e2e/checkIn.cy.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ describe('OKR Check-in e2e tests', () => {
259259

260260
it(`Should display confirm dialog when creating checkin on draft objective`, () => {
261261
cy.getByTestId('add-objective').first().click();
262-
cy.fillOutObjective('draft objective title', 'safe-draft', '3');
263-
cy.visit('/?quarter=3');
262+
cy.fillOutObjective('draft objective title', 'safe-draft', '1');
263+
cy.visit('/?quarter=1');
264264
cy.contains('draft objective title').first().parentsUntil('#objective-column').last().focus();
265265

266266
cy.tabForwardUntil('[data-testId="add-keyResult"]');
@@ -290,8 +290,8 @@ describe('OKR Check-in e2e tests', () => {
290290

291291
it(`Should not display last value div if last checkin is not present`, () => {
292292
cy.getByTestId('add-objective').first().click();
293-
cy.fillOutObjective('new objective', 'safe', '3');
294-
cy.visit('/?quarter=3');
293+
cy.fillOutObjective('new objective', 'safe', '1');
294+
cy.visit('/?quarter=1');
295295
cy.contains('new objective').first().parentsUntil('#objective-column').last().focus();
296296

297297
cy.tabForwardUntil('[data-testId="add-keyResult"]');

frontend/cypress/e2e/crud.cy.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ describe('CRUD operations', () => {
1212
].forEach(([objectiveTitle, buttonTestId, icon]) => {
1313
it(`Create objective, no keyresults`, () => {
1414
cy.getByTestId('add-objective').first().click();
15-
cy.fillOutObjective(objectiveTitle, buttonTestId, '3');
16-
cy.visit('/?quarter=3');
15+
cy.fillOutObjective(objectiveTitle, buttonTestId, '1');
16+
cy.visit('/?quarter=1');
1717
const objective = cy.contains(objectiveTitle).first().parentsUntil('#objective-column').last();
1818
objective.getByTestId('objective-state').should('have.attr', 'src', `assets/icons/${icon}`);
1919
});
@@ -25,7 +25,7 @@ describe('CRUD operations', () => {
2525
].forEach(([objectiveTitle, buttonTestId, icon]) => {
2626
it(`Create objective, no keyresults`, () => {
2727
cy.getByTestId('add-objective').first().click();
28-
cy.fillOutObjective(objectiveTitle, buttonTestId, '3', '', true);
28+
cy.fillOutObjective(objectiveTitle, buttonTestId, '1', '', true);
2929
cy.contains('Key Result erfassen');
3030
});
3131
});
@@ -42,8 +42,8 @@ describe('CRUD operations', () => {
4242
it(`Create objective, cancel`, () => {
4343
const objectiveTitle = 'this is a canceled objective';
4444
cy.getByTestId('add-objective').first().click();
45-
cy.fillOutObjective(objectiveTitle, 'cancel', '3');
46-
cy.visit('/?quarter=3');
45+
cy.fillOutObjective(objectiveTitle, 'cancel', '1');
46+
cy.visit('/?quarter=1');
4747
cy.contains(objectiveTitle).should('not.exist');
4848
});
4949

frontend/cypress/e2e/duplicated-scoring.cy.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ describe('e2e test for scoring adjustment on objective duplicate', () => {
2222

2323
cy.get('.objective').first().getByTestId('three-dot-menu').click();
2424
cy.get('.mat-mdc-menu-content').contains('Objective duplizieren').click();
25-
cy.fillOutObjective('A duplicated Objective for this tool', 'safe', '3');
26-
cy.visit('/?quarter=3');
25+
cy.fillOutObjective('A duplicated Objective for this tool', 'safe', '1');
26+
cy.visit('/?quarter=1');
2727

2828
let scoringBlock1 = cy
2929
.getByTestId('objective')

frontend/cypress/e2e/objective-alignment.cy.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ describe('OKR Objective Alignment e2e tests', () => {
106106
.contains('Objective bearbeiten')
107107
.click();
108108

109-
cy.get('select#alignment').select('Bitte wählen');
109+
cy.get('select#alignment').select('Kein Alignment');
110110
cy.getByTestId('safe').click();
111111

112112
cy.getByTestId('objective')
@@ -123,7 +123,7 @@ describe('OKR Objective Alignment e2e tests', () => {
123123
});
124124

125125
it(`Alignment Possibilites change when quarter change`, () => {
126-
cy.visit('/?quarter=3');
126+
cy.visit('/?quarter=1');
127127

128128
cy.getByTestId('add-objective').first().click();
129129
cy.getByTestId('title').first().clear().type('We can link later on this');
@@ -145,12 +145,12 @@ describe('OKR Objective Alignment e2e tests', () => {
145145
cy.get('select#alignment option:selected').should('not.contain.text', selectValue);
146146
cy.getByTestId('cancel').click();
147147

148-
cy.visit('/?quarter=4');
148+
cy.visit('/?quarter=2');
149149

150150
cy.getByTestId('add-objective').first().click();
151151
cy.getByTestId('title').first().clear().type('Quarter change objective');
152152

153-
cy.get('select#quarter').select('GJ 22/23-Q3');
153+
cy.get('select#quarter').select('GJ 22/23-Q4');
154154
cy.getByTestId('title').first().clear().type('A new title');
155155
cy.get('select#alignment').select(1);
156156

frontend/src/app/shared/dialog/objective-dialog/objective-form.component.spec.ts

+57-24
Original file line numberDiff line numberDiff line change
@@ -74,24 +74,6 @@ const mockActivatedRoute = {
7474
},
7575
};
7676

77-
const alignmentPossibilities = [
78-
{
79-
objectiveId: 1003,
80-
objectiveTitle: 'O - Test Objective',
81-
keyResultAlignmentsDtos: [],
82-
},
83-
{
84-
objectiveId: 1005,
85-
objectiveTitle: 'O - Company will grow',
86-
keyResultAlignmentsDtos: [
87-
{
88-
keyResultId: 6,
89-
keyResultTitle: 'K - New structure',
90-
},
91-
],
92-
},
93-
];
94-
9577
describe('ObjectiveDialogComponent', () => {
9678
let component: ObjectiveFormComponent;
9779
let fixture: ComponentFixture<ObjectiveFormComponent>;
@@ -430,12 +412,66 @@ describe('ObjectiveDialogComponent', () => {
430412
fixture.detectChanges();
431413
expect(component.allowedOption(quarter)).toBeTruthy();
432414
});
415+
});
416+
417+
describe('AlignmentPossibilities', () => {
418+
beforeEach(() => {
419+
TestBed.configureTestingModule({
420+
imports: [
421+
HttpClientTestingModule,
422+
MatDialogModule,
423+
MatIconModule,
424+
MatFormFieldModule,
425+
MatSelectModule,
426+
ReactiveFormsModule,
427+
MatInputModule,
428+
NoopAnimationsModule,
429+
MatCheckboxModule,
430+
RouterTestingModule,
431+
TranslateTestingModule.withTranslations({
432+
de: de,
433+
}),
434+
],
435+
declarations: [ObjectiveFormComponent, DialogHeaderComponent],
436+
providers: [
437+
{ provide: MatDialogRef, useValue: dialogMock },
438+
{ provide: MAT_DIALOG_DATA, useValue: matDataMock },
439+
{ provide: ObjectiveService, useValue: objectiveService },
440+
{ provide: QuarterService, useValue: quarterService },
441+
{ provide: TeamService, useValue: teamService },
442+
],
443+
});
444+
445+
let alignmentPossibilities = [
446+
{
447+
objectiveId: 1003,
448+
objectiveTitle: 'O - Test Objective',
449+
keyResultAlignmentsDtos: [],
450+
},
451+
{
452+
objectiveId: 1005,
453+
objectiveTitle: 'O - Company will grow',
454+
keyResultAlignmentsDtos: [
455+
{
456+
keyResultId: 6,
457+
keyResultTitle: 'K - New structure',
458+
},
459+
],
460+
},
461+
];
433462

434-
it('should load correct alignment possibilities', async () => {
435463
jest.spyOn(objectiveService, 'getAlignmentPossibilities').mockReturnValue(of(alignmentPossibilities));
464+
fixture = TestBed.createComponent(ObjectiveFormComponent);
465+
component = fixture.componentInstance;
436466
fixture.detectChanges();
437-
component.ngOnInit();
467+
loader = TestbedHarnessEnvironment.loader(fixture);
468+
});
469+
470+
it('should create', () => {
471+
expect(component).toBeTruthy();
472+
});
438473

474+
it('should load correct alignment possibilities', async () => {
439475
let generatedPossibilities = [
440476
{
441477
objectiveId: null,
@@ -470,7 +506,6 @@ describe('ObjectiveDialogComponent', () => {
470506
matDataMock.objective.objectiveId = 1;
471507
component.objective = objectiveWithAlignment;
472508
objectiveService.getFullObjective.mockReturnValue(of(objectiveWithAlignment));
473-
jest.spyOn(objectiveService, 'getAlignmentPossibilities').mockReturnValue(of(alignmentPossibilities));
474509
fixture.detectChanges();
475510
component.ngOnInit();
476511

@@ -508,7 +543,6 @@ describe('ObjectiveDialogComponent', () => {
508543
component.objective = objective;
509544
component.data.objective.objectiveId = 5;
510545
objectiveService.getFullObjective.mockReturnValue(of(objectiveWithAlignment));
511-
jest.spyOn(objectiveService, 'getAlignmentPossibilities').mockReturnValue(of(alignmentPossibilities));
512546
fixture.detectChanges();
513547
component.ngOnInit();
514548

@@ -543,7 +577,6 @@ describe('ObjectiveDialogComponent', () => {
543577
});
544578

545579
it('should load Kein Alignment to alignment possibilities when choosing one alignment', async () => {
546-
jest.spyOn(objectiveService, 'getAlignmentPossibilities').mockReturnValue(of(alignmentPossibilities));
547580
objectiveService.getFullObjective.mockReturnValue(of(objective));
548581
component.objective = objective;
549582
component.data.objective.objectiveId = 5;
@@ -615,7 +648,7 @@ describe('ObjectiveDialogComponent', () => {
615648
{ provide: ActivatedRoute, useValue: mockActivatedRoute },
616649
],
617650
});
618-
jest.spyOn(objectiveService, 'getAlignmentPossibilities').mockReturnValue(of(alignmentPossibilities));
651+
jest.spyOn(objectiveService, 'getAlignmentPossibilities').mockReturnValue(of([]));
619652
fixture = TestBed.createComponent(ObjectiveFormComponent);
620653
component = fixture.componentInstance;
621654
fixture.detectChanges();

0 commit comments

Comments
 (0)