Skip to content

Commit

Permalink
fix: e2e tests on dashboard page
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorGoryany committed Sep 12, 2024
1 parent ebe0b3a commit a15dddd
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
40 changes: 23 additions & 17 deletions cypress/e2e/dashboard.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import {
participants,
projectListItem,
watch,
sortPanel,
sortPanelDropdownTrigger,
sortPanelEmptyProjectsCheckbox,
} from '../../src/utils/domObjects';
import { keyPredictor } from '../../src/utils/keyPredictor';
import { getTranslation } from '../support/lang';
Expand All @@ -33,16 +36,10 @@ describe('Dashboard', () => {
cy.signInViaEmail();
});

it('filters are active by default', () => {
cy.get('body')
.should('exist')
.then(($body) => {
if ($body.find(projectListItem.query).length > 0) {
cy.get(projectListItem.query).filter(`:contains(${projectOne})`).should('not.exist');
return;
}
cy.get(projectListItem.query).should('not.exist');
});
it.only('filters are active by default', () => {
cy.get('body').should('exist');

cy.get(projectListItem.query).filter(`:contains(${projectOne})`).should('exist');

cy.get(filtersPanelResetButton.query).should('exist').click().should('not.exist');

Expand Down Expand Up @@ -89,23 +86,32 @@ describe('User dashboard', () => {
}).then((res) => Cypress.env('testUserProject', res));
});

it('user dont see own project without goals with applied filters', () => {
cy.get(projectListItem.query).should('not.exist');
it('user see own project without goals with applied filters', () => {
cy.get(projectListItem.query).should('exist').and('include.text', userProjectTitle);
});

it('user see own project without goals with clear filters', () => {
it("user don't see own project without goals with empty projects filters", () => {
cy.get(projectListItem.query).should('exist');

cy.get(sortPanel.query).should('not.exist');
cy.get(sortPanelDropdownTrigger.query).should('exist').click();
cy.get(sortPanel.query).should('exist');
cy.get(sortPanelEmptyProjectsCheckbox.query)
.should('exist')
.and('be.checked')
.click()
.should('not.checked');

cy.get(projectListItem.query).should('not.exist');
});

it('user see own project without goals with clear filters', () => {
cy.get(filtersPanelResetButton.query).should('exist').click().should('not.exist');

cy.get(projectListItem.query).should('exist').and('include.text', userProjectTitle);
});

it("user can create goal from projects's list", () => {
cy.get(projectListItem.query).should('not.exist');

cy.get(filtersPanelResetButton.query).should('exist').click().should('not.exist');

cy.get(projectListItem.query).find(createGoalInlineControl.query).and('not.include.text');
});

Expand Down
7 changes: 5 additions & 2 deletions src/components/FiltersBar/FiltersBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { nullable } from '@taskany/bricks';

import { PageView } from '../../hooks/useUrlFilterParams';
import { Dropdown, DropdownPanel, DropdownTrigger } from '../Dropdown/Dropdown';
import { sortPanel, sortPanelDropdownTrigger } from '../../utils/domObjects';

import s from './FiltersBar.module.css';
import { tr } from './FiltersBar.i18n';
Expand Down Expand Up @@ -37,14 +38,16 @@ export const FiltersBarLayoutSwitch: FC<FiltersBarLayoutSwitchProps> = ({ value
export const FiltersBarViewDropdown: FC<{ children?: ReactNode }> = ({ children }) => {
return (
<Dropdown>
<DropdownTrigger className={s.FiltersBarViewDropdownDrigger} view="fill">
<DropdownTrigger className={s.FiltersBarViewDropdownDrigger} view="fill" {...sortPanelDropdownTrigger.attr}>
<div className={s.FiltersBarViewDropdownDrigger}>
<IconAdjustHorizontalSolid size="xxs" />
<Text size="s">{tr('View')}</Text>
</div>
</DropdownTrigger>
<DropdownPanel width={335} placement="bottom-start" className={s.FiltersBarDropdownPanel}>
<div className={s.FiltersBarDropdownPanelContainer}>{children}</div>
<div className={s.FiltersBarDropdownPanelContainer} {...sortPanel.attr}>
{children}
</div>
</DropdownPanel>
</Dropdown>
);
Expand Down
2 changes: 2 additions & 0 deletions src/components/FiltersPanel/FiltersPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
appliedFiltersPanel,
appliedFiltersPanelEstimate,
appliedFiltersPanelState,
sortPanelEmptyProjectsCheckbox,
} from '../../utils/domObjects';
import {
FiltersBarViewDropdown,
Expand Down Expand Up @@ -276,6 +277,7 @@ export const FiltersPanel: FC<{
{nullable(enableHideProjectToggle, () => (
<FiltersBarDropdownContent>
<Checkbox
{...sortPanelEmptyProjectsCheckbox.attr}
label={tr('Empty Projects')}
checked={!hideEmptyProjects}
onChange={() => setHideEmptyProjects(!hideEmptyProjects)}
Expand Down
4 changes: 4 additions & 0 deletions src/utils/domObjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export const filtersPanel = DO('filtersPanel');
export const filtersPanelTitle = filtersPanel.add('title');
export const filtersPanelResetButton = filtersPanel.add('resetButton');

export const sortPanel = DO('sortPanel');
export const sortPanelDropdownTrigger = DO('sortPanelDropdownTrigger');
export const sortPanelEmptyProjectsCheckbox = sortPanel.add('emptyProjectsCheckbox');

export const appliedFiltersPanel = DO('appliedFiltersPanel');
export const appliedFiltersPanelEstimate = appliedFiltersPanel.add('estimate');
export const appliedFiltersPanelState = appliedFiltersPanel.add('state');
Expand Down

0 comments on commit a15dddd

Please sign in to comment.