Skip to content

Commit

Permalink
Merge pull request #108 from dhis2/Upstream_changes_widgets
Browse files Browse the repository at this point in the history
Upstream changes widgets
  • Loading branch information
іѕмαу authored May 28, 2020
2 parents b51c689 + 2f11c96 commit fc47e22
Show file tree
Hide file tree
Showing 22 changed files with 661 additions and 273 deletions.
3 changes: 3 additions & 0 deletions cypress/fixtures/HeaderBar/applicationTitle.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"applicationTitle": "Foobar"
}
8 changes: 0 additions & 8 deletions cypress/fixtures/HeaderBar/getModules.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@
"icon": "../icons/dhis-web-interpretation.png",
"description": ""
},
{
"name": "dhis-web-importexport",
"namespace": "/dhis-web-importexport",
"defaultAction": "../dhis-web-importexport/index.action",
"displayName": "Import/Export",
"icon": "../icons/dhis-web-importexport.png",
"description": ""
},
{
"name": "WHO Metadata browser",
"namespace": "WHO Metadata browser",
Expand Down
229 changes: 229 additions & 0 deletions cypress/fixtures/HeaderBar/getModulesWithSpecialChars.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
{
"modules": [
{
"name": "/",
"namespace": "//",
"defaultAction": "..//.action",
"displayName": "A / character",
"icon": "../icons/dhis-web-dashboard.png",
"description": ""
},
{
"name": "-",
"namespace": "/-",
"defaultAction": "../-.action",
"displayName": "A - character",
"icon": "../icons/dhis-web-dashboard.png",
"description": ""
},
{
"name": "(",
"namespace": "/(",
"defaultAction": "../(.action",
"displayName": "A ( character",
"icon": "../icons/dhis-web-data-visualizer.png",
"description": ""
},
{
"name": ")",
"namespace": "/)",
"defaultAction": "../).action",
"displayName": "A ) character",
"icon": "../icons/dhis-web-data-visualizer.png",
"description": ""
},
{
"name": "[",
"namespace": "/[",
"defaultAction": "../[.action",
"displayName": "A [ character",
"icon": "../icons/dhis-web-data-visualizer.png",
"description": ""
},
{
"name": "]",
"namespace": "/]",
"defaultAction": "../].action",
"displayName": "A ] character",
"icon": "../icons/dhis-web-data-visualizer.png",
"description": ""
},
{
"name": "{",
"namespace": "/{",
"defaultAction": "../{.action",
"displayName": "A { character",
"icon": "../icons/dhis-web-data-visualizer.png",
"description": ""
},
{
"name": "}",
"namespace": "/}",
"defaultAction": "../}.action",
"displayName": "A } character",
"icon": "../icons/dhis-web-data-visualizer.png",
"description": ""
},
{
"name": "*",
"namespace": "/*",
"defaultAction": "../*.action",
"displayName": "A * character",
"icon": "../icons/dhis-web-data-visualizer.png",
"description": ""
},
{
"name": "+",
"namespace": "/+",
"defaultAction": "../+.action",
"displayName": "A + character",
"icon": "../icons/dhis-web-data-visualizer.png",
"description": ""
},
{
"name": "?",
"namespace": "/?",
"defaultAction": "../?.action",
"displayName": "A ? character",
"icon": "../icons/dhis-web-data-visualizer.png",
"description": ""
},
{
"name": ".",
"namespace": "/.",
"defaultAction": "../..action",
"displayName": "A . character",
"icon": "../icons/dhis-web-data-visualizer.png",
"description": ""
},
{
"name": ",",
"namespace": "/,",
"defaultAction": "../,.action",
"displayName": "A , character",
"icon": "../icons/dhis-web-data-visualizer.png",
"description": ""
},
{
"name": "^",
"namespace": "/^",
"defaultAction": "../^.action",
"displayName": "A ^ character",
"icon": "../icons/dhis-web-data-visualizer.png",
"description": ""
},
{
"name": "$",
"namespace": "/$",
"defaultAction": "../$.action",
"displayName": "A $ character",
"icon": "../icons/dhis-web-data-visualizer.png",
"description": ""
},
{
"name": "|",
"namespace": "/|",
"defaultAction": "../|.action",
"displayName": "A | character",
"icon": "../icons/dhis-web-data-visualizer.png",
"description": ""
},
{
"name": "#",
"namespace": "/#",
"defaultAction": "../#.action",
"displayName": "A # character",
"icon": "../icons/dhis-web-data-visualizer.png",
"description": ""
},
{
"name": "\\s",
"namespace": "/\\s",
"defaultAction": "../\\s.action",
"displayName": "A \\s character",
"icon": "../icons/dhis-web-data-visualizer.png",
"description": ""
},
{
"name": "\\",
"namespace": "/\\",
"defaultAction": "../\\.action",
"displayName": "A \\ character",
"icon": "../icons/dhis-web-data-visualizer.png",
"description": ""
},

{
"name": "dhis-web-dashboard",
"namespace": "/dhis-web-dashboard",
"defaultAction": "../dhis-web-dashboard/index.action",
"displayName": "Dashboard",
"icon": "../icons/dhis-web-dashboard.png",
"description": ""
},
{
"name": "dhis-web-capture",
"namespace": "/dhis-web-capture",
"defaultAction": "../dhis-web-capture/index.action",
"displayName": "Capture",
"icon": "../icons/dhis-web-capture.png",
"description": ""
},
{
"name": "dhis-web-maintenance",
"namespace": "/dhis-web-maintenance",
"defaultAction": "../dhis-web-maintenance/index.action",
"displayName": "Maintenance",
"icon": "../icons/dhis-web-maintenance.png",
"description": ""
},
{
"name": "dhis-web-maps",
"namespace": "/dhis-web-maps",
"defaultAction": "../dhis-web-maps/index.action",
"displayName": "Maps",
"icon": "../icons/dhis-web-maps.png",
"description": ""
},
{
"name": "dhis-web-event-reports",
"namespace": "/dhis-web-event-reports",
"defaultAction": "../dhis-web-event-reports/index.action",
"displayName": "Event Reports",
"icon": "../icons/dhis-web-event-reports.png",
"description": ""
},
{
"name": "dhis-web-interpretation",
"namespace": "/dhis-web-interpretation",
"defaultAction": "../dhis-web-interpretation/index.action",
"displayName": "Interpretations",
"icon": "../icons/dhis-web-interpretation.png",
"description": ""
},
{
"name": "dhis-web-import-export",
"namespace": "/dhis-web-import-export",
"defaultAction": "../dhis-web-import-export/index.action",
"displayName": "Import/Export",
"icon": "../icons/dhis-web-importexport.png",
"description": ""
},
{
"name": "WHO Metadata browser",
"namespace": "WHO Metadata browser",
"defaultAction": "https://debug.dhis2.org/dev/api/apps/WHO-Metadata-browser/index.html",
"displayName": "",
"icon": "https://debug.dhis2.org/dev/api/apps/WHO-Metadata-browser/icons/medicine-48.png",
"description": ""
},
{
"name": "Dashboard Classic",
"namespace": "Dashboard Classic",
"defaultAction": "https://debug.dhis2.org/dev/api/apps/Dashboard-Classic/index.html",
"displayName": "",
"icon": "https://debug.dhis2.org/dev/api/apps/Dashboard-Classic/icon.png",
"description": "DHIS2 Legacy Dashboard App"
}
]
}
4 changes: 0 additions & 4 deletions cypress/fixtures/HeaderBar/systemInfo.json

This file was deleted.

26 changes: 14 additions & 12 deletions cypress/integration/HeaderBar/common/index.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,52 @@
import { Before, Given } from 'cypress-cucumber-preprocessor/steps'

export const baseUrl = 'https://domain.tld/'
export const webCommons = 'https://domain.tld/dhis-web-commons/'

Before(() => {
cy.fixture('HeaderBar/systemInfo').as('systemInfoFixture')
cy.fixture('HeaderBar/applicationTitle').as('applicationTitleFixture')
cy.fixture('HeaderBar/me').as('meFixture')
cy.fixture('HeaderBar/getModules').as('modulesFixture')
cy.fixture('HeaderBar/dashboard').as('dashboardFixture')
cy.fixture('HeaderBar/logo_banner').as('logoFixture')
})

Given('the HeaderBar loads without an error', () => {
cy.server()

cy.get('@systemInfoFixture').then(fx => {
cy.get('@applicationTitleFixture').then(fx => {
cy.route({
url: 'https://domain.tld/api/system/info',
url: `${baseUrl}/api/systemSettings/applicationTitle`,
response: fx,
}).as('systemInfo')
}).as('applicationTitle')
})

cy.get('@meFixture').then(fx => {
cy.route({
url: 'https://domain.tld/api/me',
url: `${baseUrl}/api/me`,
response: fx,
}).as('systemInfo')
}).as('me')
})

cy.get('@modulesFixture').then(fx => {
cy.route({
url: 'https://domain.tld/dhis-web-commons/menu/getModules.action',
url: `${baseUrl}/dhis-web-commons/menu/getModules.action`,
response: fx,
}).as('modules')
})

cy.get('@dashboardFixture').then(fx => {
cy.route({
url: 'https://domain.tld/api/me/dashboard',
url: `${baseUrl}/api/me/dashboard`,
response: fx,
}).as('dashboard')
})

cy.get('@logoFixture').then(fx => {
cy.route({
url: 'https://domain.tld/api/staticContent/logo_banner',
url: `${baseUrl}/api/staticContent/logo_banner`,
response: fx,
}).as('logo_banner')
})
})

Given('the HeaderBar loads without an error', () => {
cy.visitStory('HeaderBarTesting', 'Default')
})
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import '../common/index.js'
import { webCommons } from '../common/index.js'
import { When, Then, Given } from 'cypress-cucumber-preprocessor/steps'

Given('there are 5 apps available to the user', () => {
cy.fixture('HeaderBar/getModules')
.then(response => ({
...response,
modules: response.modules.slice(0, 5),
}))
.as('modulesFixture')
cy.get('@modulesFixture').then(fx => {
cy.route({
url: `${webCommons}menu/getModules.action`,
response: {
...fx,
modules: fx.modules.slice(0, 5),
},
}).as('modules')
})
})

When('the user clicks on the menu icons', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import '../common/index.js'
import { Then } from 'cypress-cucumber-preprocessor/steps'
import { baseUrl } from '../common/index.js'

Then('the HeaderBar should display the dhis2 logo', () => {
cy.get('[data-test="headerbar-logo"]').should('be.visible')
})

Then('the logo should link to the homepage', () => {
cy.getAll('@systemInfoFixture', '[data-test="headerbar-logo"] a').should(
([{ contextPath }, $a]) => {
expect($a.attr('href')).to.equal(contextPath)
}
)
cy.get('[data-test="headerbar-logo"] a').should($a => {
expect($a.attr('href')).to.equal(baseUrl)
})
})
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import '../common/index'
import { baseUrl } from '../common/index'
import { Then, Given } from 'cypress-cucumber-preprocessor/steps'

Given(
'the custom title is {string} and the app title is "Example!"',
systemName => {
cy.fixture('HeaderBar/systemInfo')
.then(response => ({
...response,
systemName,
}))
.as('systemInfoFixture')
applicationTitle => {
cy.get('@applicationTitleFixture').then(fx => {
cy.route({
url: `${baseUrl}api/systemSettings/applicationTitle`,
response: { ...fx, applicationTitle },
}).as('applicationTitle')
})
}
)

Expand Down
Loading

0 comments on commit fc47e22

Please sign in to comment.