}
@@ -322,7 +325,7 @@ const SuccessContent = ({ data, dataSubmitted }) => {
SuccessContent.propTypes = {
data: PropTypes.object,
- dataSubmitted: PropTypes.submitted,
+ dataSubmitted: PropTypes.string,
}
export { SuccessContent }
diff --git a/src/pages/addItem.js b/src/pages/addItem.js
index 1995d4a..db3610d 100644
--- a/src/pages/addItem.js
+++ b/src/pages/addItem.js
@@ -14,7 +14,7 @@ const defaultExchange = {
export const AddItem = () => {
const { canAddExchange } = useUserContext()
if (!canAddExchange) {
- ;
+ return
}
return
}
diff --git a/src/pages/data.test.js b/src/pages/data.test.js
index 02c1e6b..49358b7 100644
--- a/src/pages/data.test.js
+++ b/src/pages/data.test.js
@@ -1,20 +1,27 @@
import '@testing-library/jest-dom'
-import {act, configure, fireEvent, render, within} from '@testing-library/react'
+import { CustomDataProvider } from '@dhis2/app-runtime'
+import { configure, render, waitFor, within } from '@testing-library/react'
import React from 'react'
-import {testDataExchange, testDataExchangeSourceData, testRequest, testUserContext} from '../utils/builders.js'
-import {QueryParamProvider} from "use-query-params";
-import {AppContext, UserContext} from '../context/index.js'
-import {DataPage} from "./data";
-import {CustomDataProvider} from "@dhis2/app-runtime";
-import {MemoryRouter, Route} from "react-router-dom";
-import {ReactRouter6Adapter} from "use-query-params/adapters/react-router-6";
-import {getRelativeTimeDifference} from "../components/view/data-workspace/title-bar";
-import {formatData} from "../components/view/data-workspace/requests-display";
-import {getReportText} from "../components/view/submit-modal/submit-modal";
-
-const lastAnalyticsTableSuccess = "2024-07-07T21:47:58.383"
-const serverDate = "2024-07-18T17:36:38.164"
-const contextPath = "debug.dhis2.org/dev"
+import { MemoryRouter, Route } from 'react-router-dom'
+import { QueryParamProvider } from 'use-query-params'
+import { ReactRouter6Adapter } from 'use-query-params/adapters/react-router-6'
+import { formatData } from '../components/view/data-workspace/requests-display'
+import { getRelativeTimeDifference } from '../components/view/data-workspace/title-bar'
+import { getReportText } from '../components/view/submit-modal/submit-modal'
+import { AppContext, UserContext } from '../context'
+import {
+ testDataExchange,
+ testDataExchangeSourceData,
+ testImportSummary,
+ testRequest,
+ testUserContext,
+} from '../utils/builders.js'
+import { DataPage } from './data'
+
+const lastAnalyticsTableSuccess = '2024-07-07T21:47:58.383'
+const serverDate = '2024-07-18T17:36:38.164'
+const contextPath = 'debug.dhis2.org/dev'
+let mockImportSummariesResponse = {}
jest.mock('@dhis2/app-runtime', () => ({
...jest.requireActual('@dhis2/app-runtime'),
@@ -24,34 +31,42 @@ jest.mock('@dhis2/app-runtime', () => ({
systemInfo: {
lastAnalyticsTableSuccess,
serverDate,
- serverTimeZoneId: "Etc/UTC",
- contextPath: `https://${contextPath}`
- }
+ serverTimeZoneId: 'Etc/UTC',
+ contextPath: `https://${contextPath}`,
+ },
+ }),
+ useDataEngine: jest.fn().mockReturnValue({
+ mutate: () => {
+ return mockImportSummariesResponse
+ },
}),
}))
-
const setUp = (
ui,
{
aggregateDataExchanges = [testDataExchange(), testDataExchange()],
exchangeId = null,
exchangeData = testDataExchangeSourceData(),
- loadExchangeDataForever = false
+ loadExchangeDataForever = false,
+ importSummaryResponse = { importSummaries: [testImportSummary()] },
} = {}
) => {
+ mockImportSummariesResponse = importSummaryResponse
const routerParams = exchangeId ? `?exchangeId=${exchangeId}` : ''
- const aggregateDataExchangesData = exchangeId && aggregateDataExchanges.find(exchange => exchange.id === exchangeId)
+ const aggregateDataExchangesData =
+ exchangeId &&
+ aggregateDataExchanges.find((exchange) => exchange.id === exchangeId)
const customerProviderData = aggregateDataExchangesData
? {
- aggregateDataExchanges: (_, params) => {
- return params.id === exchangeId
- ? Promise.resolve(aggregateDataExchangesData)
- : Promise.resolve([exchangeData])
- }
- } : {}
-
+ aggregateDataExchanges: (_, params) => {
+ return params.id === exchangeId
+ ? Promise.resolve(aggregateDataExchangesData)
+ : Promise.resolve([exchangeData])
+ },
+ }
+ : {}
const screen = render(
-
+
{
- }
+ aggregateDataExchanges,
+ refetchExchanges: () => {},
}}
>
@@ -76,242 +94,334 @@ const setUp = (
)
-
- return {screen, aggregateDataExchanges}
+ return { screen, aggregateDataExchanges }
}
beforeEach(() => {
configure({
testIdAttribute: 'data-test',
})
-
})
describe('
', () => {
-
it('should display a drop down to select an exchange', async () => {
const exchanges = [testDataExchange(), testDataExchange()]
- const {screen, aggregateDataExchanges} = setUp(
-
, {aggregateDataExchanges: exchanges})
+ const { screen, aggregateDataExchanges } = setUp(
, {
+ aggregateDataExchanges: exchanges,
+ })
screen.getByTestId('dhis2-ui-selectorbaritem').click()
const menuItems = await screen.findAllByTestId('dhis2-uicore-menuitem')
expect(menuItems).toHaveLength(2)
menuItems.map((menuItem, i) => {
- expect(menuItem).toHaveTextContent(
- exchanges[i].displayName
- )
+ expect(menuItem).toHaveTextContent(exchanges[i].displayName)
})
})
it('should display a genera message when no exchange is selected ', async () => {
- const {screen, aggregateDataExchanges} = setUp(
-
)
+ const { screen, aggregateDataExchanges } = setUp(
)
- expect(screen.getByTestId('entry-screen-message')).toBeInTheDocument();
+ expect(screen.getByTestId('entry-screen-message')).toBeInTheDocument()
})
it('should select and clear the selected exchange', async () => {
- const anExchange = testDataExchange();
+ const anExchange = testDataExchange()
const exchanges = [anExchange, testDataExchange()]
- const {screen, router} = setUp(
-
, {aggregateDataExchanges: exchanges})
+ const { screen, router } = setUp(
, {
+ aggregateDataExchanges: exchanges,
+ })
screen.getByTestId('dhis2-ui-selectorbaritem').click()
const menuItems = await screen.findAllByTestId('dhis2-uicore-menuitem')
within(menuItems[0]).queryByText(anExchange.displayName).click()
- expect(screen.getByTestId('data-exchange-selector')).toHaveTextContent(anExchange.displayName)
+ expect(screen.getByTestId('data-exchange-selector')).toHaveTextContent(
+ anExchange.displayName
+ )
const headerBar = screen.getByTestId('dhis2-ui-selectorbar')
- within(headerBar).queryByRole('button', {name: 'Clear selections'}).click()
- expect(screen.getByTestId('data-exchange-selector')).toHaveTextContent('Choose a data exchange')
-
+ within(headerBar)
+ .queryByRole('button', { name: 'Clear selections' })
+ .click()
+ expect(screen.getByTestId('data-exchange-selector')).toHaveTextContent(
+ 'Choose a data exchange'
+ )
})
it('should display the correct exchange specified in url if the param is present', async () => {
- const anExchange = testDataExchange();
+ const anExchange = testDataExchange()
const exchanges = [anExchange, testDataExchange()]
- const {screen, router} = setUp(
-
, {aggregateDataExchanges: exchanges, exchangeId: anExchange.id})
-
- expect(screen.getByTestId('data-exchange-selector')).toHaveTextContent(anExchange.displayName)
+ const { screen, router } = setUp(
, {
+ aggregateDataExchanges: exchanges,
+ exchangeId: anExchange.id,
+ })
+ expect(screen.getByTestId('data-exchange-selector')).toHaveTextContent(
+ anExchange.displayName
+ )
})
it('should display a preview table once an exchange id selected', async () => {
- const anExchange = testDataExchange();
+ const anExchange = testDataExchange()
const exchanges = [anExchange]
const exchangeData = testDataExchangeSourceData()
- const {screen, router} = setUp(
-
, {
- aggregateDataExchanges: exchanges,
- exchangeId: anExchange.id,
- exchangeData
- })
+ const { screen, router } = setUp(
, {
+ aggregateDataExchanges: exchanges,
+ exchangeId: anExchange.id,
+ exchangeData,
+ })
const titleBar = await screen.findByTestId('title-bar')
expect(titleBar).toHaveTextContent(anExchange.displayName)
- expect(titleBar).toHaveTextContent(`${anExchange.source.requests.length} data report`)
+ expect(titleBar).toHaveTextContent(
+ `${anExchange.source.requests.length} data report`
+ )
const timeDifference = getRelativeTimeDifference({
startTimestamp: lastAnalyticsTableSuccess,
endTimestamp: serverDate,
})
- expect(titleBar).toHaveTextContent(`Source data was generated ${timeDifference} ago`)
-
+ expect(titleBar).toHaveTextContent(
+ `Source data was generated ${timeDifference} ago`
+ )
const tabBar = await screen.findByTestId('dhis2-uicore-tabbar')
- expect(within(tabBar).getAllByTestId('dhis2-uicore-tab')).toHaveLength(anExchange.source.requests.length)
- anExchange.source.requests.map(request => {
+ expect(within(tabBar).getAllByTestId('dhis2-uicore-tab')).toHaveLength(
+ anExchange.source.requests.length
+ )
+ anExchange.source.requests.map((request) => {
expect(tabBar).toHaveTextContent(request.name)
})
const dataTable = await screen.findByTestId('dhis2-uicore-datatable')
const formattedData = formatData(exchangeData)[0]
expect(dataTable).toBeInTheDocument()
- expect(within(dataTable).getByTestId('dhis2-uicore-tablehead')).toHaveTextContent(formattedData.title)
- expect(within(dataTable).getByTestId('dhis2-uicore-tablehead')).toHaveTextContent(formattedData.title)
- const tableRows = within(dataTable).getAllByTestId('dhis2-uicore-datatablerow');
+ expect(
+ within(dataTable).getByTestId('dhis2-uicore-tablehead')
+ ).toHaveTextContent(formattedData.title)
+ expect(
+ within(dataTable).getByTestId('dhis2-uicore-tablehead')
+ ).toHaveTextContent(formattedData.title)
+ const tableRows = within(dataTable).getAllByTestId(
+ 'dhis2-uicore-datatablerow'
+ )
expect(tableRows).toHaveLength(3)
- formattedData.headers.map(tableHeader => expect(tableRows[0]).toHaveTextContent(tableHeader.name))
- formattedData.rows[0].map(firstRowCell => expect(tableRows[1]).toHaveTextContent(firstRowCell))
- formattedData.rows[1].map(secondRowCell => expect(tableRows[2]).toHaveTextContent(secondRowCell))
+ formattedData.headers.map((tableHeader) =>
+ expect(tableRows[0]).toHaveTextContent(tableHeader.name)
+ )
+ formattedData.rows[0].map((firstRowCell) =>
+ expect(tableRows[1]).toHaveTextContent(firstRowCell)
+ )
+ formattedData.rows[1].map((secondRowCell) =>
+ expect(tableRows[2]).toHaveTextContent(secondRowCell)
+ )
})
it('should show a submit modal for internal exchange when the user clicks on the submit data button', async () => {
const anExchangeRequest = testRequest()
const anExchange = testDataExchange({
targetType: 'INTERNAL',
- requests: [anExchangeRequest]
- });
+ requests: [anExchangeRequest],
+ })
const exchanges = [anExchange]
const exchangeData = testDataExchangeSourceData()
- const {screen, router} = setUp(
-
, {
- aggregateDataExchanges: exchanges,
- exchangeId: anExchange.id,
- exchangeData
- })
+ const { screen, router } = setUp(
, {
+ aggregateDataExchanges: exchanges,
+ exchangeId: anExchange.id,
+ exchangeData,
+ })
const bottomBar = await screen.findByTestId('bottom-bar')
- within(bottomBar).getByRole('button', {name: 'Submit data'}).click()
+ within(bottomBar).getByRole('button', { name: 'Submit data' }).click()
const submitModal = await screen.findByTestId('dhis2-uicore-card')
expect(submitModal).toBeInTheDocument()
- expect(submitModal).toHaveTextContent(`1 report to ${anExchange.displayName} internally at ${contextPath}`)
- expect(submitModal).toHaveTextContent(getReportText({
- name: anExchangeRequest.name,
- orgUnits: exchangeData.metaData.dimensions.ou,
- periods: exchangeData.metaData.dimensions.pe.map(
- (period) => exchangeData.metaData?.items[period]?.name
- ),
- }))
+ expect(submitModal).toHaveTextContent(
+ `1 report to ${anExchange.displayName} internally at ${contextPath}`
+ )
+ expect(submitModal).toHaveTextContent(
+ getReportText({
+ name: anExchangeRequest.name,
+ orgUnits: exchangeData.metaData.dimensions.ou,
+ periods: exchangeData.metaData.dimensions.pe.map(
+ (period) => exchangeData.metaData?.items[period]?.name
+ ),
+ })
+ )
})
-
it('should show a submit modal for external exchange when the user clicks on the submit data button', async () => {
- const externalURL = 'a/url';
+ const externalURL = 'a/url'
const anExchangeRequest = testRequest()
const anExchange = testDataExchange({
targetType: 'EXTERNAL',
externalURL: externalURL,
- requests: [anExchangeRequest]
- });
+ requests: [anExchangeRequest],
+ })
const exchanges = [anExchange]
const exchangeData = testDataExchangeSourceData()
- const {screen, router} = setUp(
-
, {
- aggregateDataExchanges: exchanges,
- exchangeId: anExchange.id,
- exchangeData
- })
+ const { screen, router } = setUp(
, {
+ aggregateDataExchanges: exchanges,
+ exchangeId: anExchange.id,
+ exchangeData,
+ })
const bottomBar = await screen.findByTestId('bottom-bar')
- within(bottomBar).getByRole('button', {name: 'Submit data'}).click()
+ within(bottomBar).getByRole('button', { name: 'Submit data' }).click()
const submitModal = await screen.findByTestId('dhis2-uicore-card')
expect(submitModal).toBeInTheDocument()
- expect(submitModal).toHaveTextContent(`1 report to ${anExchange.displayName} at ${externalURL}`)
- expect(submitModal).toHaveTextContent(getReportText({
- name: anExchangeRequest.name,
- orgUnits: exchangeData.metaData.dimensions.ou,
- periods: exchangeData.metaData.dimensions.pe.map(
- (period) => exchangeData.metaData?.items[period]?.name
- ),
- }))
+ expect(submitModal).toHaveTextContent(
+ `1 report to ${anExchange.displayName} at ${externalURL}`
+ )
+ expect(submitModal).toHaveTextContent(
+ getReportText({
+ name: anExchangeRequest.name,
+ orgUnits: exchangeData.metaData.dimensions.ou,
+ periods: exchangeData.metaData.dimensions.pe.map(
+ (period) => exchangeData.metaData?.items[period]?.name
+ ),
+ })
+ )
})
- xit('submit an exchange data request', async () => {
- const anExchangeRequest = testRequest()
+ it('show the results when a exchange data is submitted successfully', async () => {
+ const importSummaries = [testImportSummary(), testImportSummary()]
const anExchange = testDataExchange({
- targetType: 'INTERNAL',
- requests: [anExchangeRequest]
- });
+ requests: [testRequest(), testRequest()],
+ })
const exchanges = [anExchange]
- const exchangeData = testDataExchangeSourceData()
- const {screen, router} = setUp(
-
, {
- aggregateDataExchanges: exchanges,
- exchangeId: anExchange.id,
- exchangeData
- })
+ const { screen, router } = setUp(
, {
+ aggregateDataExchanges: exchanges,
+ exchangeId: anExchange.id,
+ importSummaryResponse: { importSummaries },
+ })
const bottomBar = await screen.findByTestId('bottom-bar')
- within(bottomBar).getByRole('button', {name: 'Submit data'}).click()
- const submitModal = await screen.findByTestId('dhis2-uicore-card')
- act(() => {
- within(submitModal).getByTestId('confirm-submission-button').click();
- });
+ const submitButton = within(bottomBar).getByRole('button', {
+ name: 'Submit data',
+ })
+ submitButton.click()
+ const submitModal = await screen.findByTestId('dhis2-uicore-card')
+ within(submitModal).getByTestId('confirm-submission-button').click()
- const successTag = await screen.findByTestId('dhis2-uicore-tag');
+ waitFor(() => expect(submitButton).toBeDisabled())
+ const successTag = await screen.findByTestId('dhis2-uicore-tag')
expect(successTag).toBeInTheDocument()
+ const summaryBoxes = screen.getAllByTestId('summary-box')
+ expect(summaryBoxes).toHaveLength(3)
+ expect(summaryBoxes[0]).toHaveTextContent(
+ `${
+ importSummaries[0].importCount.imported +
+ importSummaries[1].importCount.imported
+ }imported`
+ )
+ expect(summaryBoxes[1]).toHaveTextContent(
+ `${
+ importSummaries[0].importCount.updated +
+ importSummaries[1].importCount.updated
+ }updated`
+ )
+ expect(summaryBoxes[2]).toHaveTextContent(
+ `${
+ importSummaries[0].importCount.ignored +
+ importSummaries[1].importCount.ignored
+ }ignored`
+ )
+
+ const summariesRows = within(submitModal).getAllByTestId(
+ 'dhis2-uicore-datatablerow'
+ )
+ expect(summariesRows).toHaveLength(3)
+ expect(summariesRows[1]).toHaveTextContent(
+ anExchange.source.requests[0].name
+ )
+ expect(summariesRows[1]).toHaveTextContent(
+ importSummaries[0].importCount.imported
+ )
+ expect(summariesRows[1]).toHaveTextContent(
+ importSummaries[0].importCount.updated
+ )
+ expect(summariesRows[1]).toHaveTextContent(
+ importSummaries[0].importCount.ignored
+ )
+
+ expect(summariesRows[2]).toHaveTextContent(
+ anExchange.source.requests[1].name
+ )
+ expect(summariesRows[2]).toHaveTextContent(
+ importSummaries[1].importCount.imported
+ )
+ expect(summariesRows[2]).toHaveTextContent(
+ importSummaries[1].importCount.updated
+ )
+ expect(summariesRows[2]).toHaveTextContent(
+ importSummaries[1].importCount.ignored
+ )
})
- it('should show a progress bar when loading content', async () => {
- const anExchange = testDataExchange()
+ it('show an error when a exchange data is submitted un-successfully', async () => {
+ const importSummariesWithError = [
+ testImportSummary(),
+ testImportSummary({ status: 'ERROR' }),
+ ]
+ const anExchange = testDataExchange({
+ requests: [testRequest(), testRequest()],
+ })
+
const exchanges = [anExchange]
+ const { screen, router } = setUp(
, {
+ aggregateDataExchanges: exchanges,
+ exchangeId: anExchange.id,
+ importSummaryResponse: {
+ importSummaries: importSummariesWithError,
+ status: 'ERROR',
+ },
+ })
- const {screen, router} = setUp(
-
, {
- aggregateDataExchanges: exchanges,
- exchangeId: anExchange.id,
- loadExchangeDataForever: true
- })
+ const bottomBar = await screen.findByTestId('bottom-bar')
- const loader = await screen.findByTestId('dhis2-uicore-circularloader')
- expect(loader).toBeInTheDocument()
- })
+ const submitButton = within(bottomBar).getByRole('button', {
+ name: 'Submit data',
+ })
+ submitButton.click()
+ const submitModal = await screen.findByTestId('dhis2-uicore-card')
+ within(submitModal).getByTestId('confirm-submission-button').click()
- it('should display a warning if there are no requests', async () => {
- const anExchange = testDataExchange({requests: null});
- const exchanges = [anExchange, testDataExchange()]
- const {screen, router} = setUp(
-
, {aggregateDataExchanges: exchanges, exchangeId: anExchange.id})
+ waitFor(() => expect(submitButton).toBeDisabled())
+ const warning = await screen.findByTestId('warning')
+ expect(warning).toBeInTheDocument()
+ expect(warning).toHaveTextContent('There was a problem submitting data')
+ })
+ it('should show a progress bar when loading content', async () => {
+ const anExchange = testDataExchange()
+ const exchanges = [anExchange]
- expect(await screen.findByTestId('no-exchange-data-warning')).toBeInTheDocument()
+ const { screen, router } = setUp(
, {
+ aggregateDataExchanges: exchanges,
+ exchangeId: anExchange.id,
+ loadExchangeDataForever: true,
+ })
+ const loader = await screen.findByTestId('dhis2-uicore-circularloader')
+ expect(loader).toBeInTheDocument()
})
- xit('should display a warning if there are no exchange data', async () => {
- const anExchange = testDataExchange();
+ it('should display a warning if there are no requests', async () => {
+ const anExchange = testDataExchange({ requests: null })
const exchanges = [anExchange, testDataExchange()]
- const {screen, router} = setUp(
-
,
- {
- aggregateDataExchanges: exchanges,
- exchangeId: anExchange.id,
- exchangeData: null
- })
-
+ const { screen, router } = setUp(
, {
+ aggregateDataExchanges: exchanges,
+ exchangeId: anExchange.id,
+ })
- expect(await screen.findByTestId('no-report-data-warning')).toBeInTheDocument()
+ expect(
+ await screen.findByTestId('no-exchange-data-warning')
+ ).toBeInTheDocument()
})
})
-
-
diff --git a/src/pages/editOverview.test.js b/src/pages/editOverview.test.js
index b422a2b..4cdd18a 100644
--- a/src/pages/editOverview.test.js
+++ b/src/pages/editOverview.test.js
@@ -52,10 +52,9 @@ beforeEach(() => {
describe('
', () => {
it('should display every data exchange', () => {
- const { screen, aggregateDataExchanges } = setUp(
,
- {
- aggregateDataExchanges: [testDataExchange(), testDataExchange()],
- })
+ const { screen, aggregateDataExchanges } = setUp(
, {
+ aggregateDataExchanges: [testDataExchange(), testDataExchange()],
+ })
const exchangeCards = screen.queryAllByTestId('data-exchange-card')
expect(exchangeCards).toHaveLength(2)
diff --git a/src/utils/builders.js b/src/utils/builders.js
index e478b9f..26be0f8 100644
--- a/src/utils/builders.js
+++ b/src/utils/builders.js
@@ -6,9 +6,7 @@ const randomValueIn = (list) =>
export const randomDhis2Id = () =>
faker.helpers.fromRegExp(/[a-zA-Z]{1}[a-zA-Z0-9]{10}/)
-export const testRequest = ({
- name = faker.word.noun(),
- } = {}) => ({
+export const testRequest = ({ name = faker.word.noun() } = {}) => ({
name,
})
@@ -27,7 +25,7 @@ export const testDataExchange = ({
id,
displayName,
source: { requests },
- target: { type: targetType, api: {url: externalURL}},
+ target: { type: targetType, api: { url: externalURL } },
access: {
write: writeMetadataAccess,
read: readMetadataAccess,
@@ -50,80 +48,116 @@ export const testUserContext = ({
keyUiLocale,
})
-const testHeaders = [{
- name: "dx",
- column: "Data",
- valueType: "TEXT",
- type: "java.lang.String",
- hidden: false,
- meta: true
-}, {
- name: "pe",
- column: "Period",
- valueType: "TEXT",
- type: "java.lang.String",
- hidden: false,
- meta: true
-}, {
- name: "ou",
- column: "Organisation unit",
- valueType: "TEXT",
- type: "java.lang.String",
- hidden: false,
- meta: true
-}, {
- name: "value",
- column: "Value",
- valueType: "NUMBER",
- type: "java.lang.Double",
- hidden: false,
- meta: false
-}]
+const testHeaders = [
+ {
+ name: 'dx',
+ column: 'Data',
+ valueType: 'TEXT',
+ type: 'java.lang.String',
+ hidden: false,
+ meta: true,
+ },
+ {
+ name: 'pe',
+ column: 'Period',
+ valueType: 'TEXT',
+ type: 'java.lang.String',
+ hidden: false,
+ meta: true,
+ },
+ {
+ name: 'ou',
+ column: 'Organisation unit',
+ valueType: 'TEXT',
+ type: 'java.lang.String',
+ hidden: false,
+ meta: true,
+ },
+ {
+ name: 'value',
+ column: 'Value',
+ valueType: 'NUMBER',
+ type: 'java.lang.Double',
+ hidden: false,
+ meta: false,
+ },
+]
const testItems = {
- 202307: {name: "July 2023"},
- 202308: {name: "August 2023"},
- 202309: {name: "September 2023"},
- MAs88nJc9nL: {name: "Private Clinic"},
- LAST_12_MONTHS: {name: "Last 12 months"},
- ImspTQPwCqd: {name: "Sierra Leone"},
- dx: {name: "Data"},
- pq2XI5kz2BY: {name: "Fixed"},
- PT59n8BQbqM: {name: "Outreach"},
- ou: {name: "Organisation unit"},
- fbfJHSPpUQD: {name: "ANC 1st visit"},
- pe: {name: "Period"},
- cYeuwXTCPkU: {name: "ANC 2nd visit"},
- oRVt7g429ZO: {name: "Public facilities"},
- Bpx0589u8y0: {name: "Facility Ownership"}
+ 202307: { name: 'July 2023' },
+ 202308: { name: 'August 2023' },
+ 202309: { name: 'September 2023' },
+ MAs88nJc9nL: { name: 'Private Clinic' },
+ LAST_12_MONTHS: { name: 'Last 12 months' },
+ ImspTQPwCqd: { name: 'Sierra Leone' },
+ dx: { name: 'Data' },
+ pq2XI5kz2BY: { name: 'Fixed' },
+ PT59n8BQbqM: { name: 'Outreach' },
+ ou: { name: 'Organisation unit' },
+ fbfJHSPpUQD: { name: 'ANC 1st visit' },
+ pe: { name: 'Period' },
+ cYeuwXTCPkU: { name: 'ANC 2nd visit' },
+ oRVt7g429ZO: { name: 'Public facilities' },
+ Bpx0589u8y0: { name: 'Facility Ownership' },
}
const testDimensions = {
- dx: ["fbfJHSPpUQD", "cYeuwXTCPkU"],
- pe: ["202307", "202308", "202309"],
- ou: ["ImspTQPwCqd"],
- co: ["pq2XI5kz2BY", "PT59n8BQbqM"],
- Bpx0589u8y0: ["oRVt7g429ZO", "MAs88nJc9nL"]
+ dx: ['fbfJHSPpUQD', 'cYeuwXTCPkU'],
+ pe: ['202307', '202308', '202309'],
+ ou: ['ImspTQPwCqd'],
+ co: ['pq2XI5kz2BY', 'PT59n8BQbqM'],
+ Bpx0589u8y0: ['oRVt7g429ZO', 'MAs88nJc9nL'],
}
-const testRows = [ ["fbfJHSPpUQD", "202308", "ImspTQPwCqd", "21050"],["cYeuwXTCPkU", "202308", "ImspTQPwCqd", "19638"],
- ["fbfJHSPpUQD", "202307", "ImspTQPwCqd", "21438"], ["cYeuwXTCPkU", "202307", "ImspTQPwCqd", "21438"],
- ["fbfJHSPpUQD", "202309", "ImspTQPwCqd", "21476"], ["cYeuwXTCPkU", "202309", "ImspTQPwCqd", "21476"] ]
+const testRows = [
+ ['fbfJHSPpUQD', '202308', 'ImspTQPwCqd', '21050'],
+ ['cYeuwXTCPkU', '202308', 'ImspTQPwCqd', '19638'],
+ ['fbfJHSPpUQD', '202307', 'ImspTQPwCqd', '21438'],
+ ['cYeuwXTCPkU', '202307', 'ImspTQPwCqd', '21438'],
+ ['fbfJHSPpUQD', '202309', 'ImspTQPwCqd', '21476'],
+ ['cYeuwXTCPkU', '202309', 'ImspTQPwCqd', '21476'],
+]
export const testDataExchangeSourceData = ({
- headers = testHeaders,
- items = testItems,
- dimensions = testDimensions,
- rows = testRows
- } = {}) => ({
+ headers = testHeaders,
+ items = testItems,
+ dimensions = testDimensions,
+ rows = testRows,
+} = {}) => ({
headers,
metaData: {
items,
- dimensions
+ dimensions,
},
rowContext: {},
width: 4,
rows,
height: 36,
- headerWidth: 4
+ headerWidth: 4,
+})
+
+export const testAttribute = ({
+ id = randomDhis2Id(),
+ displayName = faker.word.adjective(),
+} = {}) => ({
+ displayName,
+ id,
+})
+
+export const testImportSummary = ({
+ imported = faker.number.int(),
+ updated = faker.number.int(),
+ ignored = faker.number.int(),
+ deleted = faker.number.int(),
+ status = 'SUCCESS',
+ conflicts = [],
+} = {}) => ({
+ importCount: {
+ imported,
+ updated,
+ ignored,
+ deleted,
+ },
+ conflicts,
+ status,
})