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

chore(cypress npm scripts): replace scripts with concurrently & wait-on #154

Merged
merged 5 commits into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,29 @@

**[Online docs and demos (latest master
build)](https://d2-ci.github.io/ui-widgets/)**

## Testing

Testing is done with cypress & cucumber.

* Run `yarn cypress:run`<br />
This will run cypress and exit with either 0 or 1

* Run `yarn cypress:open`<br />
This will open the cypress gui, which is useful for writing tests

### Recording videos and taking screenshots

When running `yarn cypress:run`, by default no video is recorded and no
screenshot will be taken.
* Recording videos can be enabled by supplying the
`CYPRESS_VIDEO=true` env var.
* Taking screenshots can be enabled by supplying the
`CYPRESS_SCREENSHOT=true` env var.

### Storybook stories for testing

Sometimes it's required to add stateful stories to test certain behavior.
That's why you can add files with the following file name format: `*.stories.testing.js`
These stories will not be used when generating the docs storybook and can
contain more sophisticated scenarios for testing.
3 changes: 2 additions & 1 deletion cypress.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"testFiles": "**/*.feature"
"testFiles": "**/*.feature",
"video": false
}
9 changes: 9 additions & 0 deletions cypress/assets/unfetch.umd.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/**
* See
*
* * https://github.com/cypress-io/cypress/issues/95
* * https://github.com/cypress-io/cypress-example-recipes/tree/master/examples/stubbing-spying__window-fetch
* * https://github.com/cypress-io/cypress-example-recipes/blob/master/examples/stubbing-spying__window-fetch/cypress/integration/polyfill-fetch-from-tests-spec.js
*
* for an explanation why this is currently necessary...
*/
varl marked this conversation as resolved.
Show resolved Hide resolved
!(function(e, n) {
'object' == typeof exports && 'undefined' != typeof module
? (module.exports = n())
Expand Down
35 changes: 0 additions & 35 deletions cypress/integration/HeaderBar/Interpretations/index.js

This file was deleted.

33 changes: 0 additions & 33 deletions cypress/integration/HeaderBar/Messages/index.js

This file was deleted.

82 changes: 0 additions & 82 deletions cypress/integration/HeaderBar/ProfileMenu/index.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import '../common/index'

Then('the HeaderBar displays a menu icon', () => {
cy.get('[data-test-id="headerbar-apps-icon"]').should('exist')
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import '../common/index'

When('the user opens the menu', () => {
cy.get('[data-test-id="headerbar-apps-icon"]').click()
})

When('the user clicks outside of the menu', () => {
cy.get('[data-test-id="headerbar-title"]').click()
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import '../common/index'
import './common'

Then('the HeaderBar dos not display the app menu', () => {
cy.get('[data-test-id="headerbar-apps-menu"]').should('not.exist')
})
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,6 @@ When('the user clicks on the menu icons', () => {
cy.get('[data-test-id="headerbar-apps-icon"]').click()
})

When('the user opens the menu', () => {
cy.get('[data-test-id="headerbar-apps-icon"]').click()
})

When('the user clicks outside of the menu', () => {
cy.get('[data-test-id="headerbar-title"]').click()
})

Then('the HeaderBar displays a menu icon', () => {
cy.get('[data-test-id="headerbar-apps-icon"]').should('exist')
})

Then('the HeaderBar dos not display the app menu', () => {
cy.get('[data-test-id="headerbar-apps-menu"]').should('not.exist')
})

Then('the menu opens', () => {
cy.get('[data-test-id="headerbar-apps-menu"]').should('be.visible')
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Then('the HeaderBar dos not display the app menu', () => {
cy.get('[data-test-id="headerbar-apps-menu"]').should('not.exist')
})
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,46 @@ Feature: The HeaderBar contains a profile menu
Given the HeaderBar loads without an error
Then the HeaderBar does not display the profile menu

Scenario: The user name and email are displayed
Scenario: The menu opens
Given the HeaderBar loads without an error
When the user clicks on the profile icons
Then the menu opens

Scenario: The user name and email are displayed
Given the HeaderBar loads without an error
When the user opens the menu
And contains the user name
And contains the user email

Scenario: The user can edit his profile
Given the HeaderBar loads without an error
When the user clicks on the profile icons
Then the menu opens
And contains a link to edit the profile
When the user opens the menu
Then contains a link to edit the profile

Scenario: The user can go to the settings
Given the HeaderBar loads without an error
When the user clicks on the profile icons
Then the menu opens
And contains a link to the settings
When the user opens the menu
Then contains a link to the settings

Scenario: The user can go to his account
Given the HeaderBar loads without an error
When the user clicks on the profile icons
Then the menu opens
And contains a link to the user account
When the user opens the menu
Then contains a link to the user account

Scenario: The user can go to the help page
Given the HeaderBar loads without an error
When the user clicks on the profile icons
Then the menu opens
And contains a link to the help page
When the user opens the menu
Then contains a link to the help page

Scenario: The user can go to the About DHIS2 page
Given the HeaderBar loads without an error
When the user clicks on the profile icons
Then the menu opens
And contains a link to the About DHIS2 page
When the user opens the menu
Then contains a link to the About DHIS2 page

Scenario: The user can log out
Given the HeaderBar loads without an error
When the user clicks on the profile icons
Then the menu opens
And contains a link to log out the user
When the user opens the menu
Then contains a link to log out the user

Scenario: The profile menu closes when the user clicks outside
Given the HeaderBar loads without an error
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import '../common/index'

Then('the HeaderBar displays a profile icon', () => {
cy.get(
`
[data-test-id="headerbar-profile-icon-text"],
[data-test-id="headerbar-profile-icon-image"]
`
).should('be.visible')
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import '../common/index'

// all step definitions are shared with other scenarios
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import '../common/index'

When('the user clicks on the profile icons', () => {
cy.get(
`
[data-test-id="headerbar-profile-icon-text"],
[data-test-id="headerbar-profile-icon-image"]
`
).click()
})

Then('the menu opens', () => {
cy.get('[data-test-id="headerbar-profile-menu"]').should('be.visible')
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import '../common/index'

When('the user clicks outside of the menu', () => {
cy.get('[data-test-id="headerbar-title"]').click()
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import '../common/index'

Then('contains a link to edit the profile', () => {
cy.get('[data-test-id="headerbar-profile-edit-profile-link"]').should(
'be.visible'
)
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import '../common/index'

Then('contains a link to the user account', () => {
cy.get('[data-test-id="headerbar-profile-menu-link-account"]').should(
'be.visible'
)
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import '../common/index'

Then('contains a link to the About DHIS2 page', () => {
cy.get('[data-test-id="headerbar-profile-menu-link-about"]').should(
'be.visible'
)
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import '../common/index'

Then('contains a link to the help page', () => {
cy.get('[data-test-id="headerbar-profile-menu-link-help"]').should(
'be.visible'
)
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import '../common/index'

Then('contains a link to the settings', () => {
cy.get('[data-test-id="headerbar-profile-menu-link-settings"]').should(
'be.visible'
)
})