Skip to content
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

feat: custom calculations (DHIS2-13871) #2232

Merged
merged 49 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
79b6593
fix: include expression in nested field
martinkrulltott Jan 31, 2023
80f62f0
fix: include dataElementDimensions in baseFields (might not be needed)
martinkrulltott Jan 31, 2023
c03ffa3
chore: en.pot updates
martinkrulltott Jan 31, 2023
ffd9558
chore: dedupe ui in yarn.lock
martinkrulltott Jan 31, 2023
c3875f1
fix: save metadata on calculation save
martinkrulltott Jan 31, 2023
790f4f7
chore: update snapshot
martinkrulltott Jan 31, 2023
6c31fee
test: initial draft for calculation tests
martinkrulltott Feb 8, 2023
da8f7ce
test: minor test updates
martinkrulltott Feb 10, 2023
3102617
Merge branch 'master' into feat/DHIS2-13871-custom-calculations
martinkrulltott Feb 15, 2023
06755b8
fix: extract metadata from /visualizations response for calculations
martinkrulltott Feb 20, 2023
f6788ac
fix: fallback when dataDimensionItems aren't available
martinkrulltott Feb 20, 2023
ed193b6
fix: add dimensionItemType and expression to metadata
martinkrulltott Feb 22, 2023
c45e27b
fix: include metadata in SET_CURRENT_FROM_UI dx items
martinkrulltott Feb 23, 2023
04d6584
chore: add default state for tests to pass
martinkrulltott Feb 23, 2023
62d93ea
fix: map expression to metadata
martinkrulltott Feb 28, 2023
277f24e
fix: revert the metadata changes
martinkrulltott Feb 28, 2023
a16d705
Merge branch 'dev' into feat/DHIS2-13871-custom-calculations
martinkrulltott Mar 1, 2023
b4ef170
fix: add correct metadata needed for edi_cache + refactor the use of …
martinkrulltott Mar 2, 2023
7262838
test: adapt jest tests to the new reducer input format
martinkrulltott Mar 2, 2023
bc74527
fix: add id to default metadata items
martinkrulltott Mar 2, 2023
4f0705d
Merge branch 'dev' into feat/DHIS2-13871-custom-calculations
martinkrulltott Mar 2, 2023
7a1d45d
fix: include calculation in the indicator error message
martinkrulltott Mar 7, 2023
0464981
Merge branch 'dev' into feat/DHIS2-13871-custom-calculations
martinkrulltott Mar 10, 2023
293d0e4
Merge branch 'dev' into feat/DHIS2-13871-custom-calculations
martinkrulltott Mar 13, 2023
d6f4391
Merge branch 'dev' into feat/DHIS2-13871-custom-calculations
martinkrulltott Mar 17, 2023
f4cc3e4
Merge branch 'dev' into feat/DHIS2-13871-custom-calculations
martinkrulltott Mar 27, 2023
28792d7
Merge branch 'dev' into feat/DHIS2-13871-custom-calculations
martinkrulltott Apr 3, 2023
d0176bb
Merge branch 'dev' into feat/DHIS2-13871-custom-calculations
martinkrulltott Apr 3, 2023
d430f64
fix: pass access prop for dimension items (DHIS2-15047)
martinkrulltott Apr 12, 2023
82d5cc6
Merge branch 'dev' into feat/DHIS2-13871-custom-calculations
martinkrulltott Apr 17, 2023
56a317b
v0.0.0-2023-04-17T13-48-48
martinkrulltott Apr 17, 2023
fbbd9de
v0.0.0-2023-04-17T13-59-33
martinkrulltott Apr 17, 2023
e09b0d9
v0.0.0-2023-04-17T15-05-21
martinkrulltott Apr 17, 2023
c3ed05c
v0.0.0-2023-04-17T15-13-17
martinkrulltott Apr 17, 2023
80e62cf
v0.0.0-2023-04-17T15-27-05
martinkrulltott Apr 17, 2023
d3adb67
fix: prevent error when dimension has no items (DHIS2-15133)
martinkrulltott Apr 18, 2023
19da80e
Merge branch 'dev' into feat/DHIS2-13871-custom-calculations
martinkrulltott Apr 20, 2023
2ba442b
Merge branch 'dev' into feat/DHIS2-13871-custom-calculations
martinkrulltott Apr 21, 2023
4e2af60
chore: bump analytics to latest
martinkrulltott Apr 24, 2023
f34447d
test: refactor tests to use a single it
martinkrulltott Apr 24, 2023
f1c4600
test: save, load, delete an EDI
martinkrulltott Apr 25, 2023
4b64295
test: data elements - scroll, search, filter, switch type
martinkrulltott Apr 26, 2023
bb0d875
test: save button is disabled and has tooltip when no name is entered
martinkrulltott Apr 26, 2023
770b977
test: add/remove data elements and math operators
martinkrulltott Apr 26, 2023
f4b46d9
test: verify name (metadata) of items in formula field
martinkrulltott Apr 26, 2023
933f6ab
test: formula validation
martinkrulltott Apr 27, 2023
936e3ba
test: remove only
martinkrulltott Apr 27, 2023
50250f6
test: refactor to remove expectCalculationsModalTitleToContain that w…
martinkrulltott Apr 27, 2023
b1a2d37
Merge branch 'dev' into feat/DHIS2-13871-custom-calculations
martinkrulltott Apr 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions cypress/elements/calculationsModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import { typeInput } from './common.js'

const calculationModalEl = 'calculation-modal'
const formulaFieldEl = 'formula-field'
const dimensionsListEl = 'dimension-list'

const saveButton = () =>
cy.getBySel(calculationModalEl).find('button').contains('Save calculation')

export const clickNewCalculationButton = () =>
cy
.getBySel('data-dimension-transfer-leftfooter')
.containsExact('Calculation')
.click()

export const expectCalculationsModalToBeVisible = () =>
cy.getBySel(calculationModalEl).should('be.visible')

export const expectDimensionsListToHaveLength = (length) => {
cy.getBySelLike(dimensionsListEl)
.findBySelLike('data-element-option')
.should('have.length', length)
}

export const expectFormulaFieldToContainItem = (item) =>
cy.getBySel(formulaFieldEl).contains(item).should('exist')

export const expectFormulaFieldToNotContainItem = (item) =>
cy.getBySel(formulaFieldEl).contains(item).should('not.exist')

export const selectItemFromDimensionsListByDoubleClick = (item) => {
cy.getBySelLike(dimensionsListEl)
.findBySelLike('data-element-option')
.should('have.length.least', 1)
.contains(item)
.dblclick()
}

export const selectOperatorFromListByDoubleClick = (item) => {
cy.getBySelLike('operators-list').contains(item).dblclick()
}

export const removeItemFromFormulaFieldByDoubleClick = (item) =>
cy
.getBySel('formula-field')
.findBySelLike('formula-item')
.contains(item)
.dblclick()

export const inputCalculationLabel = (label) =>
typeInput('calculation-label', label)

export const clickSaveButton = () => saveButton().click()

export const clickCancelButton = () =>
cy.getBySel(calculationModalEl).find('button').contains('Cancel').click()

export const clickDeleteButton = () =>
cy
.getBySel(calculationModalEl)
.find('button')
.contains('Delete calculation')
.click()

export const clickConfirmDeleteButton = () =>
cy
.getBySel('calculation-delete-modal')
.find('button')
.contains('Yes, delete')
.click()

export const clickCheckFormulaButton = () =>
cy
.getBySel(calculationModalEl)
.find('button')
.contains('Check formula')
.click()

export const expectSaveButtonToBeEnabled = () => {
saveButton().should('not.have.attr', 'disabled')
saveButton().parent().should('not.have.css', 'cursor', 'not-allowed')
}

export const expectSaveButtonToBeDisabled = () => {
saveButton().should('have.attr', 'disabled')
saveButton().parent().should('have.css', 'cursor', 'not-allowed')
}

export const expectSaveButtonToHaveTooltip = (tooltip) => {
saveButton().trigger('mouseover', { force: true }) // use force as the button is disabled
cy.getBySelLike('tooltip-content').contains(tooltip)
saveButton().trigger('mouseout', { force: true })
}

export const expectSaveButtonToNotHaveTooltip = () => {
saveButton().trigger('mouseover')
cy.getBySelLike('tooltip-content').should('not.exist')
saveButton().trigger('mouseout')
}

export const typeInNumberField = (id, value) =>
cy
.getBySel(formulaFieldEl)
.findBySel(`formula-item-EXPRESSION_TYPE_NUMBER-${id}`)
.find('input')
.type(value)

export const expectFormulaToNotBeValidated = () => {
cy.getBySel('validation-message').should('be.empty')
}

export const expectFormulaToBeValid = () => {
cy.getBySel('validation-message').containsExact('Valid')
}

export const expectFormulaToBeInvalid = (message) => {
cy.getBySel('validation-message').containsExact(message)
}
8 changes: 8 additions & 0 deletions cypress/elements/dimensionModal/dataDimension.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ export const expectEmptySourceMessageToBe = (message) => {
cy.getBySel(emptySourceEl).should('contain', message)
}

export const clickEDIEditButton = (item) =>
cy
.getBySel(optionContentEl)
.contains(item)
.parent()
.findBySel('data-dimension-transfer-option-edit-button')
.click()

/* TODO: Find a way to use random items
export const replaceDataItemsWithRandomDataElements = amount => {
expectDataDimensionModalToBeVisible()
Expand Down
1 change: 1 addition & 0 deletions cypress/elements/dimensionModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export {
expectSubGroupSelectToBeVisible,
expectSubGroupSelectToBe,
switchSubGroupTo,
clickEDIEditButton,
} from './dataDimension.js'

export {
Expand Down
4 changes: 3 additions & 1 deletion cypress/elements/fileMenu/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export const saveNewAO = (name, description) => {
clickFileMenuButton(FILE_MENU_BUTTON_SAVE_NEW)
clearInput(saveModalNameEl)
typeInput(saveModalNameEl, name)
cy.getBySel(saveModalDescriptionEl).find('textarea').type(description)
if (description) {
cy.getBySel(saveModalDescriptionEl).find('textarea').type(description)
}
cy.getBySel(saveModalSaveButtonEl).click()
}

Expand Down
Loading