Skip to content

Commit

Permalink
add e2e for feature
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Jan 10, 2025
1 parent 1f5bb41 commit 2264b6f
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 6 deletions.
38 changes: 38 additions & 0 deletions frontend/cypress/e2e/check-in.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,43 @@ describe('okr check-in', () => {
cy.contains('We bought a new house');
});

it('should create check-in metric and assert correct owner', () => {
overviewPage
.addKeyResult()
.fillKeyResultTitle('This keyresult is for the owner')
.withMetricValues(Unit.PERCENT, '21', '51')
.fillKeyResultDescription('This is my description')
.submit();
keyResultDetailPage
.visit('This keyresult is for the owner')
.createCheckIn()
.checkForDialogTextMetric()
.fillMetricCheckInValue('30')
.setCheckInConfidence(6)
.fillCheckInCommentary('We bought a new house')
.fillCheckInInitiatives('We have to buy more PCs')
.submit();

keyResultDetailPage.showAllCheckIns()
.checkOnDialog(() => cy.contains('Jaya Norris'))
.cancel();
cy.logout();
cy.loginAsUser(users.bl);

keyResultDetailPage
.visit('This keyresult is for the owner')
.showAllCheckIns()
.checkOnDialog(() => cy.contains('Jaya Norris'))
.editLatestCheckIn()
.setCheckInConfidence(7)
.submit();

CheckInHistoryDialog.do()
.checkOnDialog(() => cy.contains('Test'))
.checkForAttribute('Confidence:', '7 / 10')
.cancel();
});

it('should create check-in metric with confidence 0', () => {
overviewPage
.addKeyResult()
Expand Down Expand Up @@ -249,6 +286,7 @@ describe('okr check-in', () => {
cy.contains('STRETCH');
});


it('should display confirm dialog when creating check-in on draft objective', () => {
overviewPage.addObjective()
.fillObjectiveTitle('draft objective title')
Expand Down
7 changes: 1 addition & 6 deletions frontend/cypress/e2e/login.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ describe('okr login', () => {
});

it('should login and logout', () => {
cy.title()
.should('equal', 'Puzzle OKR');
cy.getByTestId('user-options')
.click();
cy.getByTestId('logout')
.click();
cy.logout();
cy.origin(Cypress.env('LOGIN_URL'), () => {
cy.url()
.should('include', Cypress.env('LOGIN_URL'));
Expand Down
15 changes: 15 additions & 0 deletions frontend/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ Cypress.Commands.add('loginAsUser', (user: any) => {
overviewIsLoaded();
});

Cypress.Commands.add('logout', () => {
cy.title()
.should('equal', 'Puzzle OKR');
cy.getByTestId('user-options')
.as('userOptions');
cy.get('@userOptions')
.click();

cy.getByTestId('logout')
.as('logoutButton');
cy.get('@logoutButton')
.click();
});


Cypress.Commands.add('getByTestId', (testId: string, text?: string): Chainable => {
const selector = `[data-testId=${testId}]`;

Expand Down
1 change: 1 addition & 0 deletions frontend/cypress/support/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ declare global {
export namespace Cypress {
interface Chainable {
loginAsUser(user: any): Chainable;
logout(): void;
getByTestId(testsId: string, text?: string): Chainable;
findByTestId(testId: string, text?: string): Chainable;
pressUntilContains(text: string, key: keyof typeof keyCodeDefinitions): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export default class CheckInDialog extends Dialog {
override submit() {
cy.getByTestId('submit-check-in')
.click();
// return new CheckInHistoryDialog();
}

getPage(): Chainable {
Expand Down
6 changes: 6 additions & 0 deletions frontend/cypress/support/helper/dom-helper/dialogs/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ export default abstract class Dialog extends PageObjectMapperBase {
this.validatePage();
}

checkOnDialog(check: () => void) {
this.getPage()
.within(() => check());
return this;
}

override validatePage() {
this.getPage()
.should('exist');
Expand Down

0 comments on commit 2264b6f

Please sign in to comment.