Skip to content

Commit

Permalink
fix(deps): bump platform deps to clear sensitive caches and more (#1999)
Browse files Browse the repository at this point in the history
* chore(deps): bump platform deps

* test: fix offline tests by recaching for each test

Co-authored-by: Jen Jones Arnesen <[email protected]>
  • Loading branch information
KaiVandivier and jenniferarnesen authored Oct 1, 2021
1 parent 6593bd4 commit 45a4ca2
Show file tree
Hide file tree
Showing 4 changed files with 498 additions and 485 deletions.
22 changes: 14 additions & 8 deletions cypress/integration/view/offline.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Feature: Offline dashboard

# NB: localStorage is cleared between each test, which causes caches to be
# cleared according to the `clearSensitiveCaches` function from the
# platform. Because of this, dashboards must be cached in each test that
# requires a cached dashboard

Scenario: I cache an uncached dashboard
Given I create two dashboards
When I cache one of the dashboards
Expand All @@ -12,25 +17,26 @@ Feature: Offline dashboard
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
Given I open and cache a 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
Given I open and cache a 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 and cache a 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
Given I open and cache a 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
Expand All @@ -54,21 +60,22 @@ Feature: Offline dashboard
Then the cached dashboard is loaded and displayed in view mode

Scenario: I remove a dashboard from cache while offline
Given I open a cached dashboard
Given I open and cache a dashboard
And connectivity is turned off
When I click to Remove from offline storage
Then the dashboard is not cached
When connectivity is turned on
Then I cache one of the dashboards

# Scenario: The sharing dialog is open when connectivity is lost
# Given I open a cached dashboard
# Given I open and cache a 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
Given I open and cache a dashboard
And I open the interpretations panel
When connectivity is turned off
Then it is not possible to interact with interpretations
Expand All @@ -79,6 +86,5 @@ Feature: Offline dashboard
When I choose Show Description
Then the description is shown along with a warning


Scenario: I delete the cached and uncached dashboard
Given I delete the cached and uncached dashboard
Given I delete the cached and uncached dashboard
22 changes: 13 additions & 9 deletions cypress/integration/view/offline/offline.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ const checkDashboardIsVisible = title => {
cy.get(dashboardTitleSel).contains(title).should('be.visible')
}

const openAndCacheDashboard = title => {
openDashboard(title)
clickViewActionButton('More')
cy.contains(MAKE_AVAILABLE_OFFLINE_TEXT, EXTENDED_TIMEOUT).click()
cy.contains(OFFLINE_DATA_LAST_UPDATED_TEXT, EXTENDED_TIMEOUT).should(
'be.visible'
)
}

const enterEditMode = () => {
clickViewActionButton('Edit')
cy.get(titleInputSel, EXTENDED_TIMEOUT).should('be.visible')
Expand Down Expand Up @@ -129,12 +138,7 @@ Given('I create two dashboards', () => {
})

When('I cache one of the dashboards', () => {
openDashboard(CACHED_DASHBOARD_TITLE)
clickViewActionButton('More')
cy.contains(MAKE_AVAILABLE_OFFLINE_TEXT, EXTENDED_TIMEOUT).click()
cy.contains(OFFLINE_DATA_LAST_UPDATED_TEXT, EXTENDED_TIMEOUT).should(
'be.visible'
)
openAndCacheDashboard(CACHED_DASHBOARD_TITLE)
})

Then('the cached dashboard has a Last Updated time and chip icon', () => {
Expand Down Expand Up @@ -237,8 +241,8 @@ Then('all edit actions requiring connectivity are disabled', () => {
})

// Scenario: I am online with a cached dashboard when I lose connectivity
Given('I open a cached dashboard', () => {
openDashboard(CACHED_DASHBOARD_TITLE)
Given('I open and cache a dashboard', () => {
openAndCacheDashboard(CACHED_DASHBOARD_TITLE)
})

Then('the cached dashboard options are available', () => {
Expand Down Expand Up @@ -296,7 +300,7 @@ Then('the dashboard is not available and offline message is displayed', () => {

// 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', () => {
openDashboard(CACHED_DASHBOARD_TITLE)
openAndCacheDashboard(CACHED_DASHBOARD_TITLE)
enterEditMode()
})

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "BSD-3-Clause",
"dependencies": {
"@dhis2/analytics": "^20.4.10",
"@dhis2/app-runtime": "^2.11.0",
"@dhis2/app-runtime": "^2.12.2",
"@dhis2/app-runtime-adapter-d2": "^1.1.0",
"@dhis2/d2-i18n": "^1.1.0",
"@dhis2/d2-ui-core": "^7.3.3",
Expand All @@ -15,7 +15,7 @@
"@dhis2/d2-ui-rich-text": "^7.3.3",
"@dhis2/d2-ui-translation-dialog": "^7.3.3",
"@dhis2/data-visualizer-plugin": "^38.0.16",
"@dhis2/ui": "^6.23.5",
"@dhis2/ui": "^6.25.0",
"classnames": "^2.3.1",
"d2": "^31.10.0",
"d2-utilizr": "^0.2.16",
Expand Down Expand Up @@ -50,7 +50,7 @@
"cy:capture": "cypress_dhis2_api_stub_mode=CAPTURE yarn d2-utils-cypress run --appStart 'yarn cypress:start'"
},
"devDependencies": {
"@dhis2/cli-app-scripts": "^7.6.5",
"@dhis2/cli-app-scripts": "^7.7.1",
"@dhis2/cli-style": "^9.1.0",
"@dhis2/cli-utils-cypress": "^7.0.1",
"@dhis2/cypress-commands": "^7.0.1",
Expand Down
Loading

0 comments on commit 45a4ca2

Please sign in to comment.