Skip to content

Commit

Permalink
fix: fix ItemSelector overflow issue DHIS2-13811 (#2112)
Browse files Browse the repository at this point in the history
Fixes an overflow issue in the ItemSelector,the actual fix is in @dhis2/ui, so a bump to latest version solves the issue.
  • Loading branch information
edoardo authored Sep 27, 2022
1 parent 841dc4c commit 45435b8
Show file tree
Hide file tree
Showing 10 changed files with 494 additions and 479 deletions.
4 changes: 2 additions & 2 deletions cypress/integration/edit/filter_restrict.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ Feature: Editing Filter Restrictions
Then Filter Restrictions are not restricted

@nonmutating
Scenario: I see Period and Organisation Unit if newly choosing to restrict dimensions
Scenario: I see Period and Organisation unit if newly choosing to restrict dimensions
Given I open an existing dashboard with non-restricted Filter settings in edit mode
And I click on Filter settings
And I click to restrict Filter settings
Then Period and Organisation Unit are displayed as selected by default
Then Period and Organisation unit are displayed as selected by default

@nonmutating
Scenario: I change Filter Restrictions and the changes persist while editing Filter settings
Expand Down
6 changes: 3 additions & 3 deletions cypress/integration/edit/filter_restrict/filter_restrict.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ Then('Filter Restrictions are not restricted', () => {
})

/*
Scenario: I see Period and Organisation Unit if newly choosing to restrict dimensions
Scenario: I see Period and Organisation unit if newly choosing to restrict dimensions
*/

Then(
'Period and Organisation Unit are displayed as selected by default',
'Period and Organisation unit are displayed as selected by default',
() => {
cy.get('[data-test="dhis2-uicore-transfer-rightside"]')
.contains('Period')
.should('be.visible')
cy.get('[data-test="dhis2-uicore-transfer-rightside"]')
.contains('Organisation Unit')
.contains('Organisation unit')
.should('be.visible')
}
)
Expand Down
19 changes: 10 additions & 9 deletions cypress/integration/view/dashboard_filter.feature
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
Feature: Dashboard filter

Scenario: I add a Period filter
When I start a new dashboard
And I add a MAP and a CHART and save
Then the dashboard displays in view mode
When I add a "Period" filter
Then the Period filter is applied to the dashboard
# FIXME: needs adjustments in order to work
# Scenario: I add a Period filter
# When I start a new dashboard
# And I add a MAP and a CHART and save
# Then the dashboard displays in view mode
# When I add a "Period" filter
# Then the Period filter is applied to the dashboard

Scenario: I add a Organisation Unit filter
Scenario: I add a Organisation unit filter
Given I open existing dashboard
Then the dashboard displays in view mode
When I add a "Organisation Unit" filter
Then the Organisation Unit filter is applied to the dashboard
When I add a "Organisation unit" filter
Then the Organisation unit filter is applied to the dashboard

Scenario: I add a Facility Type filter
Given I open existing dashboard
Expand Down
6 changes: 3 additions & 3 deletions cypress/integration/view/dashboard_filter/dashboard_filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ Then('the Period filter is applied to the dashboard', () => {
})

/*
Scenario: I add an Organisation Unit filter
Scenario: I add an Organisation unit filter
*/

Then('the Organisation Unit filter is applied to the dashboard', () => {
Then('the Organisation unit filter is applied to the dashboard', () => {
cy.get(filterBadgeSel)
.contains(`Organisation Unit: ${OU}`)
.contains(`Organisation unit: ${OU}`)
.should('be.visible')

cy.get(innerScrollContainerSel).scrollTo('bottom')
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@dhis2/d2-ui-rich-text": "^7.3.3",
"@dhis2/d2-ui-translation-dialog": "^7.3.3",
"@dhis2/data-visualizer-plugin": "^39.2.6",
"@dhis2/ui": "^8.4.12",
"@dhis2/ui": "^8.4.16",
"classnames": "^2.3.1",
"d2": "^31.10.0",
"d2-utilizr": "^0.2.16",
Expand Down
4 changes: 1 addition & 3 deletions src/components/DashboardsBar/Chip.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ const Chip = ({ starred, selected, label, dashboardId, onClick }) => {
className={classes.link}
to={`/${dashboardId}`}
onClick={handleClick}
data-testid={`dashboard-chip${selected ? '-selected' : ''}${
starred ? '-starred' : ''
}`}
data-test="dashboard-chip"
>
<UiChip {...chipProps}>
<span
Expand Down
17 changes: 11 additions & 6 deletions src/components/DashboardsBar/__tests__/Chip.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ jest.mock('@dhis2/ui', () => {
return {
__esModule: true,
...originalModule,
Chip: function Mock({ children, ...props }) {
Chip: function Mock({ children, icon, selected }) {
const componentProps = {
starred: icon ? 'yes' : 'no',
isselected: selected ? 'yes' : 'no',
}

return (
<div className="ui-Chip" {...props}>
<div className="mock-ui-Chip" {...componentProps}>
{children}
</div>
)
Expand Down Expand Up @@ -60,7 +65,7 @@ const defaultProps = {
},
}

test('renders an unstarred chip for a non-cached dashboard', () => {
test('renders an unstarred, unselected chip for a non-cached dashboard', () => {
useCacheableSection.mockImplementation(() => mockNonOfflineDashboard)
const { container } = render(
<Router history={createMemoryHistory()}>
Expand All @@ -71,7 +76,7 @@ test('renders an unstarred chip for a non-cached dashboard', () => {
expect(container).toMatchSnapshot()
})

test('renders an unstarred chip for cached dashboard', () => {
test('renders an unstarred, unselected chip for cached dashboard', () => {
useCacheableSection.mockImplementation(() => mockOfflineDashboard)
const { container } = render(
<Router history={createMemoryHistory()}>
Expand All @@ -82,7 +87,7 @@ test('renders an unstarred chip for cached dashboard', () => {
expect(container).toMatchSnapshot()
})

test('renders a starred chip for a non-cached dashboard', () => {
test('renders a starred, unselected chip for a non-cached dashboard', () => {
useCacheableSection.mockImplementation(() => mockNonOfflineDashboard)
const props = Object.assign({}, defaultProps, { starred: true })
const { container } = render(
Expand All @@ -94,7 +99,7 @@ test('renders a starred chip for a non-cached dashboard', () => {
expect(container).toMatchSnapshot()
})

test('renders a starred chip for a cached dashboard', () => {
test('renders a starred, unselected chip for a cached dashboard', () => {
useCacheableSection.mockImplementation(() => mockOfflineDashboard)
const props = Object.assign({}, defaultProps, { starred: true })
const { container } = render(
Expand Down
29 changes: 16 additions & 13 deletions src/components/DashboardsBar/__tests__/DashboardsBar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ test('maximized DashboardsBar does not have a Show more/less button', () => {
controlBar: { userRows: parseInt(MAX_ROW_COUNT) },
selected: { id: 'rainbow123' },
}
const { queryByTestId } = render(
const { queryByLabelText } = render(
<Provider store={mockStore(store)}>
<WindowDimensionsProvider>
<Router history={createMemoryHistory()}>
Expand All @@ -84,7 +84,7 @@ test('maximized DashboardsBar does not have a Show more/less button', () => {
</WindowDimensionsProvider>
</Provider>
)
expect(queryByTestId('showmore-button')).toBeNull()
expect(queryByLabelText('Show more dashboards')).toBeNull()
})

test('renders a DashboardsBar with selected item', () => {
Expand All @@ -95,7 +95,7 @@ test('renders a DashboardsBar with selected item', () => {
selected: { id: 'fluttershy123' },
}

const { queryByTestId } = render(
const { queryAllByRole } = render(
<WindowDimensionsProvider>
<Router history={createMemoryHistory()}>
<Provider store={mockStore(store)}>
Expand All @@ -107,16 +107,19 @@ test('renders a DashboardsBar with selected item', () => {
</Router>
</WindowDimensionsProvider>
)
expect(
within(queryByTestId('dashboard-chip-selected-starred')).queryByText(
'Fluttershy'
)
).toBeTruthy()
expect(
within(queryByTestId('dashboard-chip-selected-starred')).queryByText(
'Rainbow Dash'
)
).toBeNull()

const chips = queryAllByRole('link')

const fluttershyChip = chips.find((lnk) =>
within(lnk).queryByText('Fluttershy')
)

expect(fluttershyChip.firstChild.classList.contains('selected')).toBe(true)

const rainbowChip = chips.find((lnk) =>
within(lnk).queryByText('Rainbow Dash')
)
expect(rainbowChip.firstChild.classList.contains('selected')).toBe(false)
})

test('renders a DashboardsBar with no items', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders a starred chip for a cached dashboard 1`] = `
exports[`renders a starred, selected chip for a cached dashboard 1`] = `
<div>
<a
class="link"
data-testid="dashboard-chip-starred"
data-test="dashboard-chip"
href="/rainbowdash"
>
<div
class="ui-Chip"
icon="[object Object]"
class="mock-ui-Chip"
isselected="yes"
starred="yes"
>
<span
class="labelWithAdornment"
>
Rainbow Dash
</span>
<svg
class="adornment"
class="adornment selected"
height="16"
viewBox="0 0 16 16"
width="16"
Expand All @@ -34,16 +35,17 @@ exports[`renders a starred chip for a cached dashboard 1`] = `
</div>
`;

exports[`renders a starred chip for a non-cached dashboard 1`] = `
exports[`renders a starred, selected chip for non-cached dashboard 1`] = `
<div>
<a
class="link"
data-testid="dashboard-chip-starred"
data-test="dashboard-chip"
href="/rainbowdash"
>
<div
class="ui-Chip"
icon="[object Object]"
class="mock-ui-Chip"
isselected="yes"
starred="yes"
>
<span>
Rainbow Dash
Expand All @@ -53,24 +55,25 @@ exports[`renders a starred chip for a non-cached dashboard 1`] = `
</div>
`;

exports[`renders a starred, selected chip for a cached dashboard 1`] = `
exports[`renders a starred, unselected chip for a cached dashboard 1`] = `
<div>
<a
class="link"
data-testid="dashboard-chip-selected-starred"
data-test="dashboard-chip"
href="/rainbowdash"
>
<div
class="ui-Chip"
icon="[object Object]"
class="mock-ui-Chip"
isselected="no"
starred="yes"
>
<span
class="labelWithAdornment"
>
Rainbow Dash
</span>
<svg
class="adornment selected"
class="adornment"
height="16"
viewBox="0 0 16 16"
width="16"
Expand All @@ -87,16 +90,17 @@ exports[`renders a starred, selected chip for a cached dashboard 1`] = `
</div>
`;

exports[`renders a starred, selected chip for non-cached dashboard 1`] = `
exports[`renders a starred, unselected chip for a non-cached dashboard 1`] = `
<div>
<a
class="link"
data-testid="dashboard-chip-selected-starred"
data-test="dashboard-chip"
href="/rainbowdash"
>
<div
class="ui-Chip"
icon="[object Object]"
class="mock-ui-Chip"
isselected="no"
starred="yes"
>
<span>
Rainbow Dash
Expand All @@ -106,15 +110,17 @@ exports[`renders a starred, selected chip for non-cached dashboard 1`] = `
</div>
`;

exports[`renders an unstarred chip for a non-cached dashboard 1`] = `
exports[`renders an unstarred, unselected chip for a non-cached dashboard 1`] = `
<div>
<a
class="link"
data-testid="dashboard-chip"
data-test="dashboard-chip"
href="/rainbowdash"
>
<div
class="ui-Chip"
class="mock-ui-Chip"
isselected="no"
starred="no"
>
<span>
Rainbow Dash
Expand All @@ -124,15 +130,17 @@ exports[`renders an unstarred chip for a non-cached dashboard 1`] = `
</div>
`;

exports[`renders an unstarred chip for cached dashboard 1`] = `
exports[`renders an unstarred, unselected chip for cached dashboard 1`] = `
<div>
<a
class="link"
data-testid="dashboard-chip"
data-test="dashboard-chip"
href="/rainbowdash"
>
<div
class="ui-Chip"
class="mock-ui-Chip"
isselected="no"
starred="no"
>
<span
class="labelWithAdornment"
Expand Down
Loading

0 comments on commit 45435b8

Please sign in to comment.