-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: dashboard filter modal should not be available in small screen #1567
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3916c76
fix: render a separate filterbadge for small screen
jenniferarnesen 14fc534
fix: add cypress test for both large and small screen
jenniferarnesen 7431644
fix: use the visible element instead of class
jenniferarnesen 56267ff
fix: missing newline
jenniferarnesen 2333908
Merge branch 'master' into fix/no-filter-modal-in-portrait
martinkrulltott File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { When } from 'cypress-cucumber-preprocessor/steps' | ||
import { | ||
filterBadgeSel, | ||
unselectedItemsSel, | ||
filterDimensionsPanelSel, | ||
dimensionsModalSel, | ||
orgUnitCheckboxesSel, | ||
} from '../../selectors/dashboardFilter' | ||
import { EXTENDED_TIMEOUT } from '../../support/utils' | ||
|
||
const PERIOD = 'Last 6 months' | ||
const OU = 'Sierra Leone' | ||
const FACILITY_TYPE = 'Clinic' | ||
|
||
When('I add a {string} filter', dimensionType => { | ||
cy.contains('Add filter').click() | ||
|
||
// open the dimensions modal | ||
cy.get(filterDimensionsPanelSel).contains(dimensionType).click() | ||
|
||
// select an item in the modal | ||
if (dimensionType === 'Period') { | ||
cy.get(unselectedItemsSel).contains(PERIOD).dblclick() | ||
} else if (dimensionType === 'Organisation Unit') { | ||
cy.get(dimensionsModalSel, EXTENDED_TIMEOUT).find('.arrow').click() | ||
cy.get(dimensionsModalSel, EXTENDED_TIMEOUT) | ||
.find(orgUnitCheckboxesSel, EXTENDED_TIMEOUT) | ||
.contains(OU, EXTENDED_TIMEOUT) | ||
.click() | ||
} else { | ||
cy.get(unselectedItemsSel).contains(FACILITY_TYPE).dblclick() | ||
} | ||
|
||
// confirm to apply the filter | ||
cy.get('button').contains('Confirm').click() | ||
}) | ||
|
||
When('I click on the {string} filter badge', filterName => { | ||
cy.get(filterBadgeSel).find('span:visible').contains(filterName).click() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
export const filterBadgeSel = '[data-test="dashboard-filter-badge"]' | ||
|
||
export const filterDimensionsPanelSel = '[data-test="dashboard-filter-popover"]' | ||
|
||
export const unselectedItemsSel = | ||
'[data-test="dhis2-uicore-transfer-sourceoptions"]' | ||
export const orgUnitHierarchySel = '[data-test="ou-dimension-modal"]' | ||
|
||
export const orgUnitCheckboxesSel = '*[role="button"]' | ||
|
||
export const dimensionsModalSel = '[data-test="dimension-modal"]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react' | ||
import { render } from '@testing-library/react' | ||
import { Provider } from 'react-redux' | ||
import configureMockStore from 'redux-mock-store' | ||
import FilterBadge from '../FilterBadge' | ||
|
||
const mockStore = configureMockStore() | ||
|
||
test('Filter Badge displays badge containing number of items in filter', () => { | ||
const filter = { | ||
id: 'ponies', | ||
name: 'Ponies', | ||
values: [{ name: 'Rainbow Dash' }, { name: 'Twilight Sparkle' }], | ||
} | ||
const { container } = render( | ||
<Provider store={mockStore({})}> | ||
<FilterBadge | ||
filter={filter} | ||
openFilterModal={jest.fn()} | ||
removeFilter={jest.fn} | ||
/> | ||
</Provider> | ||
) | ||
expect(container).toMatchSnapshot() | ||
}) | ||
|
||
test('FilterBadge displays badge with filter item name when only one filter item', () => { | ||
const filter = { | ||
id: 'ponies', | ||
name: 'Ponies', | ||
values: [{ name: 'Twilight Sparkle' }], | ||
} | ||
|
||
const { container } = render( | ||
<Provider store={mockStore({})}> | ||
<FilterBadge | ||
filter={filter} | ||
openFilterModal={jest.fn()} | ||
removeFilter={jest.fn} | ||
/> | ||
</Provider> | ||
) | ||
expect(container).toMatchSnapshot() | ||
}) |
51 changes: 51 additions & 0 deletions
51
src/components/FilterBar/__tests__/__snapshots__/FilterBadge.spec.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Filter Badge displays badge containing number of items in filter 1`] = ` | ||
<div> | ||
<div | ||
class="container" | ||
data-test="dashboard-filter-badge" | ||
> | ||
<span | ||
class="badge" | ||
> | ||
Ponies: 2 selected | ||
</span> | ||
<span | ||
class="badgeSmall" | ||
> | ||
Ponies: 2 selected | ||
</span> | ||
<span | ||
class="removeButton" | ||
> | ||
Remove | ||
</span> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`FilterBadge displays badge with filter item name when only one filter item 1`] = ` | ||
<div> | ||
<div | ||
class="container" | ||
data-test="dashboard-filter-badge" | ||
> | ||
<span | ||
class="badge" | ||
> | ||
Ponies: Twilight Sparkle | ||
</span> | ||
<span | ||
class="badgeSmall" | ||
> | ||
Ponies: Twilight Sparkle | ||
</span> | ||
<span | ||
class="removeButton" | ||
> | ||
Remove | ||
</span> | ||
</div> | ||
</div> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I finally know who added all of the my little pony names to DV 🦄 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🦄