From 5c5973fc5c64ec4c3767aff4e979a4e3be351af6 Mon Sep 17 00:00:00 2001 From: Jen Jones Arnesen Date: Mon, 6 Sep 2021 09:05:27 +0200 Subject: [PATCH] fix: several backports to [v37] (#1935) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: bump analytics and ui to latest (#1927) * feat: use the new SharingDialog with cascading sharing (#1913) * fix: reenable cypress tests for offline (#1928) * fix: readd missing offlinejs file (#1929) * fix: disable dirty check on exit (DHIS2-11701) (#1930) Removing the "dirty" check which would display the "Discard changes?" modal when "Exit without saving" was clicked after making changes to the title/description. * fix: bump cli-app-scripts to solve issues with z-index and Modals (#1931) Solves issues with ui Modals and z-index. Various Modals opened under the edit mode toolbar. Co-authored-by: Jen Jones Arnesen * fix: upgrade d2-ui 7.3.3 (#1932) This upgrade fixes the broken interpretations component Co-authored-by: Martin Co-authored-by: Edoardo Sabadelli Co-authored-by: Jan Henrik Ă˜verland --- .../integration/edit/edit_dashboard.feature | 48 ++++---- .../integration/edit/filter_restrict.feature | 2 +- .../view/dashboard_filter/dashboard_filter.js | 84 -------------- .../view/item_context_menu.feature | 10 +- .../item_context_menu/show_interpretations.js | 2 +- cypress/integration/view/offline.feature | 70 ++++++++++++ cypress/integration/view/offline/offline.js | 29 ++--- package.json | 16 +-- src/pages/edit/ActionsBar.js | 12 +- src/pages/view/TitleBar/ActionsBar.js | 20 ++-- yarn.lock | 107 ++++++++++-------- 11 files changed, 201 insertions(+), 199 deletions(-) delete mode 100644 cypress/integration/view/dashboard_filter/dashboard_filter.js create mode 100644 cypress/integration/view/offline.feature diff --git a/cypress/integration/edit/edit_dashboard.feature b/cypress/integration/edit/edit_dashboard.feature index 1fec9ad92..bc83e3a39 100644 --- a/cypress/integration/edit/edit_dashboard.feature +++ b/cypress/integration/edit/edit_dashboard.feature @@ -17,14 +17,14 @@ Feature: Creating, editing and deleting dashboard And I click Exit without saving Then the dashboard displays in view mode - @mutating - Scenario: I cancel exit without saving when name changed - Given I open existing dashboard - When I choose to edit dashboard - And dashboard title is added - And I click Exit without saving - And I decide to continue editing - Then the dashboard displays in edit mode + # @mutating + # Scenario: I cancel exit without saving when name changed + # Given I open existing dashboard + # When I choose to edit dashboard + # And dashboard title is added + # And I click Exit without saving + # And I decide to continue editing + # Then the dashboard displays in edit mode # @mutating # Scenario: I cancel exit without saving when item added @@ -42,17 +42,17 @@ Feature: Creating, editing and deleting dashboard When I choose to edit dashboard And dashboard title is added And I click Exit without saving - And I confirm I want to discard changes + # And I confirm I want to discard changes Then the dashboard displays in view mode - # @mutating - # Scenario: I star the dashboard - # Given I open existing dashboard - # And the dashboard is not starred - # When I click to star the dashboard - # Then the dashboard is starred - # When I click to unstar the dashboard - # Then the dashboard is not starred + @mutating + Scenario: I star the dashboard + Given I open existing dashboard + And the dashboard is not starred + When I click to star the dashboard + Then the dashboard is starred + When I click to unstar the dashboard + Then the dashboard is not starred @mutating @@ -88,13 +88,13 @@ Feature: Creating, editing and deleting dashboard # And I click Exit without saving # Then Norwegian title and description are displayed - @mutating - Scenario: I change sharing settings of a dashboard - Given I open existing dashboard - When I change sharing settings - And I choose to edit dashboard - And dashboard is saved - Then the new sharing settings should be preserved + # @mutating + # Scenario: I change sharing settings of a dashboard + # Given I open existing dashboard + # When I change sharing settings + # And I choose to edit dashboard + # And dashboard is saved + # Then the new sharing settings should be preserved @mutating Scenario: I save a starred dashboard diff --git a/cypress/integration/edit/filter_restrict.feature b/cypress/integration/edit/filter_restrict.feature index dfa3da0f4..29711c3cb 100644 --- a/cypress/integration/edit/filter_restrict.feature +++ b/cypress/integration/edit/filter_restrict.feature @@ -52,7 +52,7 @@ Feature: Editing Filter Restrictions And I add Facility Ownership to selected filters And I click Confirm And I click Exit without saving - And I confirm I want to discard changes + # And I confirm I want to discard changes Then the dashboard displays in view mode When I choose to edit dashboard And I click on Filter settings diff --git a/cypress/integration/view/dashboard_filter/dashboard_filter.js b/cypress/integration/view/dashboard_filter/dashboard_filter.js deleted file mode 100644 index d0f278438..000000000 --- a/cypress/integration/view/dashboard_filter/dashboard_filter.js +++ /dev/null @@ -1,84 +0,0 @@ -import { Then } from 'cypress-cucumber-preprocessor/steps' -import { - filterBadgeSel, - dimensionsModalSel, -} from '../../../elements/dashboardFilter' -import { - gridItemSel, - mapLegendButtonSel, - mapLegendContentSel, - chartSubtitleSel, - chartXAxisLabelSel, -} from '../../../elements/dashboardItem' -import { innerScrollContainerSel } from '../../../elements/viewDashboard' -import { EXTENDED_TIMEOUT } from '../../../support/utils' - -const PERIOD = 'Last 6 months' -const OU = 'Sierra Leone' -const FACILITY_TYPE = 'Clinic' - -/* -Scenario: I add a Period filter -*/ - -Then('the Period filter is applied to the dashboard', () => { - cy.get(filterBadgeSel).contains(`Period: ${PERIOD}`).should('be.visible') - - // check the CHART - cy.get(`${gridItemSel}.CHART`) - .find(chartSubtitleSel, EXTENDED_TIMEOUT) - .scrollIntoView() - .contains(PERIOD, EXTENDED_TIMEOUT) - .should('be.visible') - - cy.get(innerScrollContainerSel).scrollTo('top') - // check the MAP - cy.get('.dhis2-map-legend-button', EXTENDED_TIMEOUT).trigger('mouseover') - cy.get('.dhis2-map-legend-period', EXTENDED_TIMEOUT) - .contains(PERIOD) - .should('be.visible') -}) - -/* -Scenario: I add an Organisation Unit filter -*/ - -Then('the Organisation Unit filter is applied to the dashboard', () => { - cy.get(filterBadgeSel) - .contains(`Organisation Unit: ${OU}`) - .should('be.visible') - - cy.get(innerScrollContainerSel).scrollTo('bottom') - cy.get(`${gridItemSel}.CHART`) - .find(chartXAxisLabelSel, EXTENDED_TIMEOUT) - .scrollIntoView() - .contains(OU, EXTENDED_TIMEOUT) - .should('be.visible') -}) - -/* -Scenario: I add a Facility Type filter -*/ -Then('the Facility Type filter is applied to the dashboard', () => { - cy.get(filterBadgeSel) - .contains(`Facility Type: ${FACILITY_TYPE}`) - .should('be.visible') - - cy.get(innerScrollContainerSel).scrollTo('top') - cy.get(`${gridItemSel}.CHART`) - .find(chartSubtitleSel, EXTENDED_TIMEOUT) - .scrollIntoView() - .contains(FACILITY_TYPE, EXTENDED_TIMEOUT) - .should('be.visible') - - cy.get(innerScrollContainerSel).scrollTo('top') - cy.get(mapLegendButtonSel, EXTENDED_TIMEOUT).trigger('mouseover') - cy.get(mapLegendContentSel, EXTENDED_TIMEOUT) - .find('div') - .contains(`Facility Type: ${FACILITY_TYPE}`) - .should('be.visible') -}) - -Then('the filter modal is opened', () => { - cy.get(dimensionsModalSel, EXTENDED_TIMEOUT).should('be.visible') -}) diff --git a/cypress/integration/view/item_context_menu.feature b/cypress/integration/view/item_context_menu.feature index 0702bcea1..d6d9821d4 100644 --- a/cypress/integration/view/item_context_menu.feature +++ b/cypress/integration/view/item_context_menu.feature @@ -30,11 +30,11 @@ Feature: Item context menu When I click Open in Data Visualizer app on a chart dashboard item Then the chart is opened in the Data Visualizer app - # @nonmutating - # Scenario: Open the interpretations panel - # Given I open the "Delivery" dashboard - # When I click Show details and interpretations on a chart dashboard item - # Then the interpretations panel is displayed + @nonmutating + Scenario: Open the interpretations panel + Given I open the "Delivery" dashboard + When I click Show details and interpretations on a chart dashboard item + Then the interpretations panel is displayed @nonmutating Scenario: Text item does not have a context menu diff --git a/cypress/integration/view/item_context_menu/show_interpretations.js b/cypress/integration/view/item_context_menu/show_interpretations.js index bcc4dc5f4..26819c861 100644 --- a/cypress/integration/view/item_context_menu/show_interpretations.js +++ b/cypress/integration/view/item_context_menu/show_interpretations.js @@ -23,7 +23,7 @@ When( Then('the interpretations panel is displayed', () => { getDashboardItem(chartItemUid) .find(itemDetailsSel) - .contains('Chart details') + .contains('Visualization details') .scrollIntoView() .should('be.visible') diff --git a/cypress/integration/view/offline.feature b/cypress/integration/view/offline.feature new file mode 100644 index 000000000..7ef930560 --- /dev/null +++ b/cypress/integration/view/offline.feature @@ -0,0 +1,70 @@ +Feature: Offline dashboard + + Scenario: I cache an uncached dashboard + Given I create two dashboards + When I cache one of the dashboards + Then the cached dashboard has a Last Updated time and chip icon + And the uncached dashboard does not have a Last Updated time and no chip icon + + Scenario: I am online with an uncached dashboard when I lose connectivity + Given I open an uncached dashboard + When connectivity is turned off + Then all actions for "uncached" dashboard requiring connectivity are disabled + + Scenario: I am online with a cached dashboard when I lose connectivity + Given I open a cached dashboard + Then the cached dashboard options are available + When connectivity is turned off + Then all actions for "cached" dashboard requiring connectivity are disabled + + Scenario: I am offline and switch from a cached dashboard to an uncached dashboard + Given I open a cached dashboard + And connectivity is turned off + When I click to open an uncached dashboard when offline + Then the dashboard is not available and offline message is displayed + + Scenario: I am offline and switch to a cached dashboard + Given I open an uncached dashboard + And connectivity is turned off + When I click to open a cached dashboard when offline + Then the cached dashboard is loaded and displayed in view mode + + Scenario: I am offline and switch to an uncached dashboard and then connectivity is restored + Given I open a cached dashboard + And connectivity is turned off + When I click to open an uncached dashboard when offline + Then the dashboard is not available and offline message is displayed + When connectivity is turned on + Then the uncached dashboard is loaded and displayed in view mode + + Scenario: I am in edit mode on an uncached dashboard when I lose connectivity and then I exit without saving and then connectivity is restored + Given I open an uncached dashboard in edit mode + When connectivity is turned off + Then all edit actions requiring connectivity are disabled + When I click Exit without saving + Then the dashboard is not available and offline message is displayed + When connectivity is turned on + Then the uncached dashboard is loaded and displayed in view mode + + Scenario: I am in edit mode on a cached dashboard when I lose connectivity and then I exit without saving + Given I open a cached dashboard in edit mode + When connectivity is turned off + Then all edit actions requiring connectivity are disabled + When I click Exit without saving + Then the cached dashboard is loaded and displayed in view mode + + # Scenario: The sharing dialog is open when connectivity is lost + # Given I open a cached dashboard + # When I open sharing settings + # And connectivity is turned off + # Then it is not possible to change sharing settings + + Scenario: The interpretations panel is open when connectivity is lost + Given I open a cached dashboard + And I open the interpretations panel + When connectivity is turned off + Then it is not possible to interact with interpretations + + + Scenario: I delete the cached and uncached dashboard + Given I delete the cached and uncached dashboard \ No newline at end of file diff --git a/cypress/integration/view/offline/offline.js b/cypress/integration/view/offline/offline.js index f530430e7..3494961f6 100644 --- a/cypress/integration/view/offline/offline.js +++ b/cypress/integration/view/offline/offline.js @@ -34,7 +34,7 @@ const CACHED_DASHBOARD_TITLE = 'aa ca' + new Date().toUTCString().slice(-12, -4) const createDashboard = cacheState => { const cachedDashboard = cacheState === CACHED - cy.get(newButtonSel).click() + cy.get(newButtonSel, EXTENDED_TIMEOUT).click() cy.get(titleInputSel, EXTENDED_TIMEOUT).should('be.visible') const title = cachedDashboard @@ -54,9 +54,6 @@ const createDashboard = cacheState => { closeMenu() clickEditActionButton('Save changes') cy.get(dashboardTitleSel, EXTENDED_TIMEOUT).should('be.visible') - if (cachedDashboard) { - cacheDashboard() - } } const openDashboard = title => { @@ -73,12 +70,6 @@ const enterEditMode = () => { cy.get(titleInputSel, EXTENDED_TIMEOUT).should('be.visible') } -const cacheDashboard = () => { - clickViewActionButton('More') - cy.contains(MAKE_AVAILABLE_OFFLINE_TEXT).click() - cy.contains(OFFLINE_DATA_LAST_UPDATED_TEXT).should('be.visible') -} - const checkCorrectMoreOptions = cacheState => { clickViewActionButton('More') if (cacheState === CACHED) { @@ -127,14 +118,24 @@ const deleteDashboard = dashboardTitle => { // Scenario: I cache an uncached dashboard -Given('I create a cached and uncached dashboard', () => { - createDashboard(CACHED) +Given('I create two dashboards', () => { + cy.log('create the uncached dashboard') createDashboard(UNCACHED) + createDashboard(CACHED) }) -Then('the cached dashboard has a Last Updated time and chip icon', () => { +When('I cache one of the dashboards', () => { openDashboard(CACHED_DASHBOARD_TITLE) - cy.contains(OFFLINE_DATA_LAST_UPDATED_TEXT).should('be.visible') + clickViewActionButton('More') + cy.contains(MAKE_AVAILABLE_OFFLINE_TEXT, EXTENDED_TIMEOUT).click() + cy.contains(OFFLINE_DATA_LAST_UPDATED_TEXT, EXTENDED_TIMEOUT).should( + 'be.visible' + ) +}) + +Then('the cached dashboard has a Last Updated time and chip icon', () => { + // openDashboard(CACHED_DASHBOARD_TITLE) + // cy.contains(OFFLINE_DATA_LAST_UPDATED_TEXT).should('be.visible') // check that the chip has the icon cy.get(dashboardChipSel) diff --git a/package.json b/package.json index c845f45c6..cfb0c854d 100644 --- a/package.json +++ b/package.json @@ -9,12 +9,11 @@ "@dhis2/app-runtime": "^2.11.0", "@dhis2/app-runtime-adapter-d2": "^1.1.0", "@dhis2/d2-i18n": "^1.1.0", - "@dhis2/d2-ui-core": "^7.3.2", - "@dhis2/d2-ui-interpretations": "^7.3.2", - "@dhis2/d2-ui-mentions-wrapper": "^7.3.2", - "@dhis2/d2-ui-rich-text": "^7.3.2", - "@dhis2/d2-ui-sharing-dialog": "^7.3.2", - "@dhis2/d2-ui-translation-dialog": "^7.3.2", + "@dhis2/d2-ui-core": "^7.3.3", + "@dhis2/d2-ui-interpretations": "^7.3.3", + "@dhis2/d2-ui-mentions-wrapper": "^7.3.3", + "@dhis2/d2-ui-rich-text": "^7.3.3", + "@dhis2/d2-ui-translation-dialog": "^7.3.3", "@dhis2/data-visualizer-plugin": "^38.0.1", "@dhis2/ui": "^6.20.0", "classnames": "^2.3.1", @@ -50,8 +49,11 @@ "cy:run-stub": "cypress_dhis2_api_stub_mode=STUB d2-utils-cypress run --tags '@nonmutating' --appStart 'yarn cypress:start' --record", "cy:capture": "cypress_dhis2_api_stub_mode=CAPTURE yarn d2-utils-cypress run --appStart 'yarn cypress:start'" }, + "resolutions": { + "@dhis2/ui": "6.20.0" + }, "devDependencies": { - "@dhis2/cli-app-scripts": "^7.6.0", + "@dhis2/cli-app-scripts": "^7.6.2", "@dhis2/cli-style": "^9.1.0", "@dhis2/cli-utils-cypress": "^7.0.1", "@dhis2/cypress-commands": "^7.0.1", diff --git a/src/pages/edit/ActionsBar.js b/src/pages/edit/ActionsBar.js index d8d659109..052c6a8a6 100644 --- a/src/pages/edit/ActionsBar.js +++ b/src/pages/edit/ActionsBar.js @@ -98,11 +98,13 @@ const EditBar = ({ dashboard, ...props }) => { } const onConfirmDiscard = () => { - if (props.isDirty) { - setConfirmDiscardDlgIsOpen(true) - } else { - onDiscardConfirmed() - } + // disabling dirty check in 2.37 + + // if (props.isDirty) { + // setConfirmDiscardDlgIsOpen(true) + // } else { + onDiscardConfirmed() + // } } const onDiscardConfirmed = () => { diff --git a/src/pages/view/TitleBar/ActionsBar.js b/src/pages/view/TitleBar/ActionsBar.js index b1195df25..c322ce8e1 100644 --- a/src/pages/view/TitleBar/ActionsBar.js +++ b/src/pages/view/TitleBar/ActionsBar.js @@ -4,10 +4,14 @@ import { useOnlineStatus, useCacheableSection, } from '@dhis2/app-runtime' -import { useD2 } from '@dhis2/app-runtime-adapter-d2' import i18n from '@dhis2/d2-i18n' -import SharingDialog from '@dhis2/d2-ui-sharing-dialog' -import { Button, FlyoutMenu, colors, IconMore24 } from '@dhis2/ui' +import { + Button, + FlyoutMenu, + colors, + IconMore24, + SharingDialog, +} from '@dhis2/ui' import PropTypes from 'prop-types' import React, { useState } from 'react' import { connect } from 'react-redux' @@ -48,7 +52,6 @@ const ViewActions = ({ const [confirmCacheDialogIsOpen, setConfirmCacheDialogIsOpen] = useState(false) const [redirectUrl, setRedirectUrl] = useState(null) - const { d2 } = useD2() const dataEngine = useDataEngine() const { offline } = useOnlineStatus() const { lastUpdated, isCached, startRecording, remove } = @@ -239,16 +242,11 @@ const ViewActions = ({ {getMoreButton(classes.moreButtonSmall, true)} - {id && ( + {id && sharingDialogIsOpen && ( )}