Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
test(headerbar): update functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
varl committed Nov 29, 2019
1 parent bb4a7cf commit 0c1ad2c
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import '../common/index'
import { Then } from 'cypress-cucumber-preprocessor/steps'

Then('contains a link to the user account', () => {
cy.get('[data-test-id="headerbar-profile-menu-link-account"]').should(
'be.visible'
)
cy.get('[data-test-id="headerbar-profile-menu"] > li').should(lis => {
expect(lis.eq(1)).to.be.visible()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import '../common/index'
import { Then } from 'cypress-cucumber-preprocessor/steps'

Then('contains a link to the About DHIS2 page', () => {
cy.get('[data-test-id="headerbar-profile-menu-link-about"]').should(
'be.visible'
)
cy.get('[data-test-id="headerbar-profile-menu"] > li').should(lis => {
expect(lis.eq(3)).to.be.visible()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import '../common/index'
import { Then } from 'cypress-cucumber-preprocessor/steps'

Then('contains a link to the help page', () => {
cy.get('[data-test-id="headerbar-profile-menu-link-help"]').should(
'be.visible'
)
cy.get('[data-test-id="headerbar-profile-menu"] > li').should(lis => {
expect(lis.eq(2)).to.be.visible()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import '../common/index'
import { Then } from 'cypress-cucumber-preprocessor/steps'

Then('contains a link to the settings', () => {
cy.get('[data-test-id="headerbar-profile-menu-link-settings"]').should(
'be.visible'
)
cy.get('[data-test-id="headerbar-profile-menu"] > li').should(lis => {
expect(lis.eq(0)).to.be.visible()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import '../common/index'
import { Then } from 'cypress-cucumber-preprocessor/steps'

Then('contains a link to log out the user', () => {
cy.get('[data-test-id="headerbar-profile-menu-link-logout"]').should(
'be.visible'
)
cy.get('[data-test-id="headerbar-profile-menu"] > li').should(lis => {
expect(lis.eq(4)).to.be.visible()
})
})
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"lint:text": "d2-style text check",
"format": "yarn format:js && yarn format:text",
"format:js": "d2-style js apply",
"format:text": "d2-style text apply"
"format:text": "d2-style text apply",
"format:staged": "yarn format:js --staged && yarn format:text --staged"
},
"devDependencies": {
"@babel/cli": "^7.7.4",
Expand Down
29 changes: 10 additions & 19 deletions src/HeaderBar/Profile/ProfileMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@ const list = [
label: i18n.t('Settings'),
value: 'settings',
link: `/dhis-web-user-profile/#/settings`,
dataTestId: 'headerbar-profile-menu-link-settings',
},
{
icon: <Account className={iconStyle.className} />,
label: i18n.t('Account'),
value: 'account',
link: `/dhis-web-user-profile/#/account`,
dataTestId: 'headerbar-profile-menu-link-account',
},
{
icon: <Help className={iconStyle.className} />,
Expand All @@ -44,21 +42,18 @@ const list = [
link:
'https://docs.dhis2.org/master/en/user/html/dhis2_user_manual_en.html',
nobase: true,
dataTestId: 'headerbar-profile-menu-link-help',
},
{
icon: <Info className={iconStyle.className} />,
label: i18n.t('About DHIS2'),
value: 'about',
link: `/dhis-web-user-profile/#/aboutPage`,
dataTestId: 'headerbar-profile-menu-link-about',
},
{
icon: <Exit className={iconStyle.className} />,
label: i18n.t('Logout'),
value: 'logout',
link: `/dhis-web-commons-security/logout.action`,
dataTestId: 'headerbar-profile-menu-link-logout',
},
]

Expand All @@ -72,20 +67,16 @@ const ProfileContents = ({ name, email, avatar, contextPath }) => (
contextPath={contextPath}
/>
<Divider margin="13px 0 7px 0" />
<ul>
{list.map(
({ label, value, icon, link, nobase, dataTestId }) => (
<span key={`h-p-${value}`} data-test-id={dataTestId}>
<MenuItem
href={nobase ? link : `${contextPath}${link}`}
key={`h-mi-${value}`}
label={label}
value={value}
icon={icon}
/>
</span>
)
)}
<ul data-test-id="headerbar-profile-menu">
{list.map(({ label, value, icon, link, nobase }) => (
<MenuItem
href={nobase ? link : `${contextPath}${link}`}
key={`h-mi-${value}`}
label={label}
value={value}
icon={icon}
/>
))}
</ul>
</div>

Expand Down

0 comments on commit 0c1ad2c

Please sign in to comment.