Skip to content

Commit

Permalink
Merge branch 'dev' into chore/useQueryCacheProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
jenniferarnesen authored Sep 28, 2023
2 parents 7ef663c + 51f0760 commit 7461316
Show file tree
Hide file tree
Showing 10 changed files with 345 additions and 23 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/dhis2-verify-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ jobs:
if: |
failure() &&
!cancelled() &&
github.ref == 'refs/heads/master'
github.ref == 'refs/heads/master' &&
contains(github.event.head_commit.message, 'chore(release)')
steps:
- name: Checkout code
uses: actions/checkout@master
Expand All @@ -140,13 +141,13 @@ jobs:
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
payload: |
{
"text": ":small_red_triangle_down: :maps-app: Maps version ${{ steps.extract_version.outputs.version }} release <https://github.com/dhis2/maps-app/actions/workflows/dhis2-verify-app.yml?query=branch%3Amaster+is%3Afailure|failed>",
"text": ":small_red_triangle_down: :maps-app: Maps release <https://github.com/dhis2/maps-app/actions/workflows/dhis2-verify-app.yml?query=branch%3Amaster+is%3Afailure|failed>",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":small_red_triangle_down: :maps-app: Maps version ${{ steps.extract_version.outputs.version }} release <https://github.com/dhis2/maps-app/actions/workflows/dhis2-verify-app.yml?query=branch%3Amaster+is%3Afailure|failed>"
"text": ":small_red_triangle_down: :maps-app: Maps release <https://github.com/dhis2/maps-app/actions/workflows/dhis2-verify-app.yml?query=branch%3Amaster+is%3Afailure|failed>"
}
}
]
Expand All @@ -160,7 +161,8 @@ jobs:
if: |
success() &&
!cancelled() &&
github.ref == 'refs/heads/master'
github.ref == 'refs/heads/master' &&
contains(github.event.head_commit.message, 'chore(release)')
steps:
- name: Checkout code
uses: actions/checkout@master
Expand Down
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# [100.2.0](https://github.com/dhis2/maps-app/compare/v100.1.7...v100.2.0) (2023-09-27)


### Bug Fixes

* **translations:** sync translations from transifex (dev) ([af3183c](https://github.com/dhis2/maps-app/commit/af3183cb28928d5a2f862b13a57c45377d136b8b))
* accept both lowercase and camelCase interpretationId in url([#2937](https://github.com/dhis2/maps-app/issues/2937)) ([c171b3d](https://github.com/dhis2/maps-app/commit/c171b3d26189206e546361911e31f887082ee136))
* **translations:** sync translations from transifex (dev) ([1ec1b5c](https://github.com/dhis2/maps-app/commit/1ec1b5cac53d2f36a80201a258fe99757523ab15))
* **translations:** sync translations from transifex (dev) ([bfff4ab](https://github.com/dhis2/maps-app/commit/bfff4ab2a4036c3afce74bda58e24bc77504edbd))
* **translations:** sync translations from transifex (dev) ([2a77caa](https://github.com/dhis2/maps-app/commit/2a77caafdd6d8ee42db14d35a9ab3034e5e8897a))


### Features

* upgrade toolbar (DHIS2-15667) ([#2936](https://github.com/dhis2/maps-app/issues/2936)) ([e1bda37](https://github.com/dhis2/maps-app/commit/e1bda3702edc5c254bce6bacb573da5dd9f54305))


### Reverts

* "chore: fixed period select refactor ([#2958](https://github.com/dhis2/maps-app/issues/2958))" ([#2984](https://github.com/dhis2/maps-app/issues/2984)) ([f532a81](https://github.com/dhis2/maps-app/commit/f532a81463e1842a3e3aa938497505d290be028a))

## [100.1.7](https://github.com/dhis2/maps-app/compare/v100.1.6...v100.1.7) (2023-09-07)


Expand Down
29 changes: 29 additions & 0 deletions cypress/integration/interpretations.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,33 @@ context('Interpretations', () => {

deleteMap()
})

it('opens and closes the interpretation panel', () => {
cy.intercept({ method: 'POST', url: /dataStatistics/ }).as(
'postDataStatistics'
)
cy.visit(
'/?id=ZBjCfSaLSqD&interpretationId=yKqhXZdeJ6a',
EXTENDED_TIMEOUT
) //ANC: LLITN coverage district and facility

cy.wait('@postDataStatistics')
.its('response.statusCode')
.should('eq', 201)

cy.getByDataTest('interpretation-modal')
.find('h1')
.contains(
'Viewing interpretation: ANC: LLITN coverage district and facility'
)
.should('be.visible')

cy.getByDataTest('interpretation-modal')
.findByDataTest('dhis2-modal-close-button')
.click()

cy.getByDataTest('interpretation-modal').should('not.exist')

cy.getByDataTest('interpretations-list').should('be.visible')
})
})
42 changes: 42 additions & 0 deletions cypress/integration/smoke.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,46 @@ context('Smoke Test', () => {
Layer.validateCardTitle('ANC 1 Coverage')
cy.get('canvas.maplibregl-canvas').should('be.visible')
})

it('loads with map id and interpretationid lowercase', () => {
cy.intercept({ method: 'POST', url: /dataStatistics/ }).as(
'postDataStatistics'
)
cy.visit(
'/?id=ZBjCfSaLSqD&interpretationid=yKqhXZdeJ6a',
EXTENDED_TIMEOUT
) //ANC: LLITN coverage district and facility

cy.wait('@postDataStatistics')
.its('response.statusCode')
.should('eq', 201)

cy.getByDataTest('interpretation-modal')
.find('h1')
.contains(
'Viewing interpretation: ANC: LLITN coverage district and facility'
)
.should('be.visible')
})

it('loads with map id and interpretationId uppercase', () => {
cy.intercept({ method: 'POST', url: /dataStatistics/ }).as(
'postDataStatistics'
)
cy.visit(
'/?id=ZBjCfSaLSqD&interpretationId=yKqhXZdeJ6a',
EXTENDED_TIMEOUT
) //ANC: LLITN coverage district and facility

cy.wait('@postDataStatistics')
.its('response.statusCode')
.should('eq', 201)

cy.getByDataTest('interpretation-modal')
.find('h1')
.contains(
'Viewing interpretation: ANC: LLITN coverage district and facility'
)
.should('be.visible')
})
})
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "maps-app",
"version": "100.1.7",
"version": "100.2.0",
"description": "DHIS2 Maps",
"license": "BSD-3-Clause",
"author": "Bjørn Sandvik",
Expand Down
10 changes: 10 additions & 0 deletions src/components/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CssVariables } from '@dhis2/ui'
import React, { useEffect } from 'react'
import { useDispatch } from 'react-redux'
import { tSetAnalyticalObject } from '../../actions/analyticalObject.js'
import { setInterpretation } from '../../actions/interpretations.js'
import { tOpenMap } from '../../actions/map.js'
import { CURRENT_AO_KEY } from '../../util/analyticalObject.js'
import { getUrlParameter } from '../../util/requests.js'
Expand Down Expand Up @@ -34,6 +35,15 @@ const App = () => {
} else if (getUrlParameter('currentAnalyticalObject') === 'true') {
await dispatch(tSetAnalyticalObject(currentAO))
}

// analytics interpretation component uses camelcase
const interpretationId =
getUrlParameter('interpretationid') ||
getUrlParameter('interpretationId')

if (interpretationId) {
dispatch(setInterpretation(interpretationId))
}
}

fetchData()
Expand Down
11 changes: 4 additions & 7 deletions src/components/app/DetailsPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@ import styles from './styles/DetailsPanel.module.css'
const DetailsPanel = ({ interpretationsRenderCount }) => {
const detailsPanelOpen = useSelector((state) => state.ui.rightPanelOpen)
const viewOrgUnitProfile = useSelector((state) => state.orgUnitProfile)
const interpretationId = useSelector((state) => state.interpretation?.id)

const getContent = () => {
if (!detailsPanelOpen) {
return null
if (interpretationId || (detailsPanelOpen && !viewOrgUnitProfile)) {
return <Interpretations renderCount={interpretationsRenderCount} />
}

return viewOrgUnitProfile ? (
<OrgUnitProfile />
) : (
<Interpretations renderCount={interpretationsRenderCount} />
)
return detailsPanelOpen ? <OrgUnitProfile /> : null
}

return (
Expand Down
142 changes: 142 additions & 0 deletions src/components/app/__tests__/Detailspanel.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import { render } from '@testing-library/react'
import React from 'react'
import { Provider } from 'react-redux'
import configureMockStore from 'redux-mock-store'
import DetailsPanel from '../DetailsPanel.js'

const mockStore = configureMockStore()

jest.mock(
'../../interpretations/Interpretations.js',
() =>
function MockInterpretations() {
return <div>Interpretations</div>
}
)

jest.mock(
'../../orgunits/OrgUnitProfile.js',
() =>
function MockOrgUnitProfile() {
return <div>Org Unit Profile</div>
}
)

describe('DetailsPanel', () => {
test('renders InterpretationsPanel when has interpretationId, has orgUnitProfile and panel is open', () => {
const store = {
interpretation: { id: 'abc123' },
orgUnitProfile: 'xyzpdq',
ui: { rightPanelOpen: true },
}

const { container } = render(
<Provider store={mockStore(store)}>
<DetailsPanel interpretationsRenderCount={1} />
</Provider>
)
expect(container).toMatchSnapshot()
})
test('renders InterpretationsPanel when has interpretationId, has orgUnitProfile and panel is closed', () => {
const store = {
interpretation: { id: 'abc123' },
orgUnitProfile: 'xyzpdq',
ui: { rightPanelOpen: false },
}

const { container } = render(
<Provider store={mockStore(store)}>
<DetailsPanel interpretationsRenderCount={1} />
</Provider>
)
expect(container).toMatchSnapshot()
})
test('renders InterpretationsPanel when has interpretationId, no orgUnitProfile and panel is open', () => {
const store = {
interpretation: { id: 'abc123' },
orgUnitProfile: null,
ui: { rightPanelOpen: true },
}

const { container } = render(
<Provider store={mockStore(store)}>
<DetailsPanel interpretationsRenderCount={1} />
</Provider>
)
expect(container).toMatchSnapshot()
})

test('renders InterpretationsPanel when has interpretationId, no orgUnitProfile and panel is closed', () => {
const store = {
interpretation: { id: 'abc123' },
orgUnitProfile: null,
ui: { rightPanelOpen: false },
}

const { container } = render(
<Provider store={mockStore(store)}>
<DetailsPanel interpretationsRenderCount={1} />
</Provider>
)
expect(container).toMatchSnapshot()
})

test('renders OrgUnitProfile when no interpretationId, has orgUnitProfile and panel is open', () => {
const store = {
interpretation: {},
orgUnitProfile: 'xyzpdq',
ui: { rightPanelOpen: true },
}

const { container } = render(
<Provider store={mockStore(store)}>
<DetailsPanel interpretationsRenderCount={1} />
</Provider>
)
expect(container).toMatchSnapshot()
})

test('renders null when no interpretationId, has orgUnitProfile, and panel closed', () => {
const store = {
interpretation: {},
orgUnitProfile: 'xyzpdq',
ui: { rightPanelOpen: false },
}

const { container } = render(
<Provider store={mockStore(store)}>
<DetailsPanel interpretationsRenderCount={1} />
</Provider>
)
expect(container).toMatchSnapshot()
})
test('renders InterpretationsPanel when no interpretationId, no orgUnitProfile and panel open', () => {
const store = {
interpretation: {},
orgUnitProfile: null,
ui: { rightPanelOpen: true },
}

const { container } = render(
<Provider store={mockStore(store)}>
<DetailsPanel interpretationsRenderCount={1} />
</Provider>
)
expect(container).toMatchSnapshot()
})

test('renders null when no interpretationId, no orgUnitProfile, and panel closed', () => {
const store = {
interpretation: {},
orgUnitProfile: null,
ui: { rightPanelOpen: false },
}

const { container } = render(
<Provider store={mockStore(store)}>
<DetailsPanel interpretationsRenderCount={1} />
</Provider>
)
expect(container).toMatchSnapshot()
})
})
Loading

0 comments on commit 7461316

Please sign in to comment.