Skip to content

Commit

Permalink
test(Dashboard): correct test behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
LamaEats committed Nov 22, 2024
1 parent 06b207a commit 81b6da5
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cypress/e2e/dashboard.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ describe('Dashboard', () => {
});

beforeEach(() => {
cy.interceptWhatsNew();
cy.signInViaEmail();
cy.wait('@whatsnew.check');
});

it('filters are active by default', () => {
Expand Down Expand Up @@ -72,7 +74,9 @@ describe('User dashboard', () => {
});

beforeEach(() => {
cy.interceptWhatsNew();
cy.signInViaEmail(testUser);
cy.wait('@whatsnew.check');
});

describe('User have own project', () => {
Expand Down Expand Up @@ -142,6 +146,7 @@ describe('User dashboard', () => {
});

it('User cannot see self goal which assigned in not own project if filter contains next quarter', () => {
cy.hideEmptyProjectOnGoalLists();
cy.get(appliedFiltersPanelEstimate.query).click();
cy.get(estimateQuarterTrigger.query).children().find(':button:contains(@next)').click();
cy.get(appliedFiltersPanelEstimate.query).focus().realPress('{esc}');
Expand Down
2 changes: 2 additions & 0 deletions cypress/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ declare global {
interface Chainable {
logout(): Chainable<void>;
signInViaEmail(fields?: SignInFields): Chainable<void>;
interceptWhatsNew(): Chainable<void>;
hideEmptyProjectOnGoalLists(): Chainable<void>;
createProject(fields: ProjectCreate): Chainable<ProjectCreateReturnType>;
createGoal(projectTitle: string, fields: GoalCommon): Chainable<GoalCreateReturnType>;
updateGoal(shortId: string, filelds: GoalUpdate): Chainable<GoalUpdateReturnType>;
Expand Down
30 changes: 30 additions & 0 deletions cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ import {
userSettingsLogoutButton,
commentFormDescription,
pageContent,
sortPanelDropdownTrigger,
sortPanel,
sortPanelEmptyProjectsCheckbox,
} from '../../src/utils/domObjects';
import { keyPredictor } from '../../src/utils/keyPredictor';
import { SignInFields } from '..';
Expand All @@ -54,6 +57,23 @@ Cypress.Commands.addAll({
cy.reload(true);
},

interceptWhatsNew: () => {
cy.intercept('api/trpc/*whatsnew.check*', (req) =>
req.on('response', (res) => {
if (Array.isArray(res.body)) {
for (let i = 0; i < res.body.length; i += 1) {
const current = res.body[i];
if ('version' in current.result.data) {
res.body[i].result.data = null;
}
}
}

res.send();
}),
).as('whatsnew.check');
},

signInViaEmail: (fields?: SignInFields) => {
cy.intercept('/api/auth/session', (req) => {
req.on('after:response', (res) => {
Expand Down Expand Up @@ -268,6 +288,16 @@ Cypress.Commands.addAll({

return cy.wrap(values);
},
hideEmptyProjectOnGoalLists: () => {
cy.get(sortPanelDropdownTrigger.query).should('exist').click();
cy.get(sortPanel.query).should('exist').and('be.visible');

cy.get(sortPanel.query)
.get(sortPanelEmptyProjectsCheckbox.query)
.should('be.checked')
.click()
.should('not.be.checked');
},
});

/**
Expand Down

0 comments on commit 81b6da5

Please sign in to comment.