Skip to content

Commit

Permalink
Fix e2e tests because of new quarter
Browse files Browse the repository at this point in the history
  • Loading branch information
lkleisa committed Apr 26, 2024
1 parent 4c9750e commit 26e7dec
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 39 deletions.
8 changes: 4 additions & 4 deletions frontend/cypress/e2e/checkIn.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"]');
Expand Down Expand Up @@ -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"]');
Expand Down
10 changes: 5 additions & 5 deletions frontend/cypress/e2e/crud.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
});
Expand All @@ -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');
});
});
Expand All @@ -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');
});

Expand Down
4 changes: 2 additions & 2 deletions frontend/cypress/e2e/duplicated-scoring.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
8 changes: 4 additions & 4 deletions frontend/cypress/e2e/objective-alignment.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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');
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ObjectiveFormComponent>;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 26e7dec

Please sign in to comment.