Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ui testing #760

Merged
merged 79 commits into from
Aug 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
5dd0d5b
Merge pull request #304 from hackforla/dev
sellnat77 Feb 27, 2020
8ee3486
Merge pull request #308 from hackforla/dev
brodly Feb 27, 2020
a3fb483
Merge pull request #331 from hackforla/dev
brodly Mar 1, 2020
9c49195
Merge pull request #335 from hackforla/dev
sellnat77 Mar 1, 2020
3468f51
Merge pull request #336 from hackforla/dev
sellnat77 Mar 1, 2020
6195ff5
Merge pull request #340 from hackforla/dev
sellnat77 Mar 2, 2020
944e0e5
Merge pull request #342 from hackforla/dev
sellnat77 Mar 2, 2020
2d09a02
Merge pull request #346 from hackforla/dev
sellnat77 Mar 2, 2020
216142e
Merge pull request #348 from hackforla/dev
sellnat77 Mar 2, 2020
5486a1c
Merge pull request #349 from hackforla/dev
sellnat77 Mar 2, 2020
f221d31
Merge pull request #350 from hackforla/dev
sellnat77 Mar 2, 2020
4b17778
Merge pull request #351 from hackforla/dev
sellnat77 Mar 2, 2020
4fabbc8
Merge pull request #352 from hackforla/dev
sellnat77 Mar 2, 2020
17f95c7
Merge pull request #353 from hackforla/dev
sellnat77 Mar 2, 2020
f5590f4
Merge pull request #354 from hackforla/dev
sellnat77 Mar 2, 2020
8f390c4
Merge pull request #355 from hackforla/dev
sellnat77 Mar 2, 2020
4aa7a47
Merge pull request #356 from hackforla/dev
sellnat77 Mar 2, 2020
403e5de
Merge pull request #368 from hackforla/dev
sellnat77 Mar 4, 2020
3525807
Merge pull request #392 from hackforla/dev
sellnat77 Mar 9, 2020
37b6f72
Merge pull request #400 from hackforla/dev
jmensch1 Mar 11, 2020
df08453
Merge pull request #425 from hackforla/dev
sellnat77 Mar 14, 2020
b03a5f8
Merge pull request #453 from hackforla/dev
sellnat77 Mar 23, 2020
d191dcd
Merge pull request #458 from hackforla/dev
sellnat77 Mar 25, 2020
7718c96
Merge pull request #466 from hackforla/dev
brodly Mar 27, 2020
04a34b7
Merge pull request #468 from hackforla/dev
sellnat77 Mar 27, 2020
8bb225a
Merge pull request #472 from hackforla/dev
brodly Mar 27, 2020
cf473b8
Merge pull request #475 from hackforla/dev
brodly Mar 27, 2020
b875000
Merge pull request #476 from hackforla/dev
brodly Mar 27, 2020
35857a7
Merge pull request #485 from hackforla/dev
sellnat77 Apr 1, 2020
4f14451
Merge pull request #491 from hackforla/dev
brodly Apr 3, 2020
efdd561
Merge pull request #496 from hackforla/dev
johnr54321 Apr 3, 2020
d4caaab
Merge pull request #513 from hackforla/dev
brodly Apr 8, 2020
dc818f1
Merge pull request #522 from hackforla/dev
brodly Apr 10, 2020
4f1d199
Merge pull request #536 from hackforla/dev
jmensch1 Apr 20, 2020
ef1e337
Merge pull request #578 from hackforla/dev
sellnat77 May 6, 2020
9c3909d
Merge pull request #589 from hackforla/dev
jmensch1 May 6, 2020
2a8df09
Merge pull request #617 from hackforla/dev
jmensch1 May 15, 2020
56992c0
Merge pull request #619 from hackforla/dev
adamkendis May 15, 2020
75b5330
Merge branch 'dev' of https://github.com/hackforla/311-data into dev
Jul 17, 2020
e0c1fbe
Adding some UI tests
Jul 17, 2020
b7dbe12
Adding Map and Data Visualization tests
Jul 20, 2020
e1444f9
Adding JSON response test
Jul 20, 2020
ec88695
Adding more JSON response tests
Jul 20, 2020
ca3aeed
Adding default folders that come from initial install
Jul 21, 2020
46ec237
Adding an action workflow to run the tests
Jul 24, 2020
796981e
Cypress seems to need this file?
Jul 24, 2020
51c9b7f
Correcting port
Jul 24, 2020
11220f9
Incrementing version number
Jul 24, 2020
fa2e668
Incrementing version number
Jul 24, 2020
728b8a9
Turning on recording
Jul 24, 2020
d63a6dd
Pointing to DEV instead of localhost
Jul 24, 2020
c4e5dbb
Pointing to DEV instead of localhost
Jul 24, 2020
40b0757
Adding lodash
Jul 24, 2020
1778065
Map filter: when results are more than three places the visual displa…
Jul 25, 2020
47e2a60
For Happy Returns
Jul 27, 2020
bb06dd4
For Happy Returns updated
Jul 27, 2020
abc2aa1
For Happy Returns updated
Jul 27, 2020
70fa7e7
Cleaning up
Jul 29, 2020
d47457a
Adding a secrets
Aug 3, 2020
05d14e9
Adding a secrets
Aug 3, 2020
b4d477b
Adding a more tests and updating
Aug 5, 2020
de32331
Adding context
Aug 5, 2020
c1dcc8d
Removing mailasaurus data
Aug 5, 2020
81d681f
Removing mailasaurus data
Aug 5, 2020
df4f6b4
Moving Cypress into it's own directory
Aug 5, 2020
c06ce81
Updating actions
Aug 5, 2020
04e083f
Updating actions
Aug 5, 2020
25c3452
Moving Cypress back
Aug 5, 2020
18c0adf
Moving Cypress back
Aug 5, 2020
33eba60
Moving Cypress back
Aug 5, 2020
7c53fd3
Moving Cypress back
Aug 5, 2020
b200954
Moving Cypress back
Aug 5, 2020
220fa54
Moving Cypress back
Aug 5, 2020
3f9df14
Moving Cypress back
Aug 5, 2020
88dd664
Getting all tests to run
Aug 5, 2020
f91265e
moved all cypress code and dependencies into /e2e
jmensch1 Aug 7, 2020
a051d7e
adding e2e/package-lock.json to version control
jmensch1 Aug 7, 2020
2c1d35b
Pointing to the http://dev-api.311-data.org instead of http://dev.311…
Aug 8, 2020
875c039
deleted .now files
jmensch1 Aug 8, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/End_To_End_Tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: End-to-end tests
on: [push]
jobs:
cypress-run:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Cypress run
uses: cypress-io/github-action@v2
with:
#build: npm run build
#start: npm start
spec: cypress/integration/map_filter.spec.js,cypress/integration/email.spec.js
wait-on: http://dev.311-data.org/
record: true
working-directory: e2e
env:
# pass the Dashboard record key as an environment variable
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# pass GitHub token to allow accurately detecting a build vs a re-run build
#GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

package-lock.json
/package-lock.json

# config
config.js
Expand Down
2 changes: 2 additions & 0 deletions e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.idea
7 changes: 7 additions & 0 deletions e2e/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"baseUrl": "http://dev.311-data.org/",
"video": false,
"viewportWidth": 1400,
"viewportHeight": 1060,
"projectId": "i733mt"
}
42 changes: 42 additions & 0 deletions e2e/cypress/integration/email.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
describe('311 Data', () => {

const serverId = '';

const testEmail = `fake\@email.com`

context('Contct Us', () => {
it('Contact Us: Sending Email', () => {

cy.server()
cy.route({
method:'POST',
url: '/feedback',
response: [{"success": true}],
onResponse(xhr) {
expect(xhr.status).to.eq(200);
}
}).as('feedbackJSON')

cy.visit('/')
cy.get('.navbar-end > :nth-child(4)').click()
cy.get('#contact-firstname').type('Test')
cy.get('#contact-lastname').type('User')
cy.get('#contact-email').type(testEmail)
cy.get('#contact-message').type('email test')
cy.get('#btn-contact-submit').click()
cy.wait('@feedbackJSON')

cy.get('.contact-success-popup').should('exist')
})

it.skip('Contact Us: Checking email', () => {
cy.mailosaurGetMessage(serverId, {
sentTo: testEmail
}).then(email => {
expect(email.subject).to.equal('Thanks for your feedback');
})
})
})


})
299 changes: 299 additions & 0 deletions e2e/cypress/integration/examples/actions.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,299 @@
/// <reference types="cypress" />

context('Actions', () => {
beforeEach(() => {
cy.visit('https://example.cypress.io/commands/actions')
})

// https://on.cypress.io/interacting-with-elements

it('.type() - type into a DOM element', () => {
// https://on.cypress.io/type
cy.get('.action-email')
.type('[email protected]').should('have.value', '[email protected]')

// .type() with special character sequences
.type('{leftarrow}{rightarrow}{uparrow}{downarrow}')
.type('{del}{selectall}{backspace}')

// .type() with key modifiers
.type('{alt}{option}') //these are equivalent
.type('{ctrl}{control}') //these are equivalent
.type('{meta}{command}{cmd}') //these are equivalent
.type('{shift}')

// Delay each keypress by 0.1 sec
.type('[email protected]', { delay: 100 })
.should('have.value', '[email protected]')

cy.get('.action-disabled')
// Ignore error checking prior to type
// like whether the input is visible or disabled
.type('disabled error checking', { force: true })
.should('have.value', 'disabled error checking')
})

it('.focus() - focus on a DOM element', () => {
// https://on.cypress.io/focus
cy.get('.action-focus').focus()
.should('have.class', 'focus')
.prev().should('have.attr', 'style', 'color: orange;')
})

it('.blur() - blur off a DOM element', () => {
// https://on.cypress.io/blur
cy.get('.action-blur').type('About to blur').blur()
.should('have.class', 'error')
.prev().should('have.attr', 'style', 'color: red;')
})

it('.clear() - clears an input or textarea element', () => {
// https://on.cypress.io/clear
cy.get('.action-clear').type('Clear this text')
.should('have.value', 'Clear this text')
.clear()
.should('have.value', '')
})

it('.submit() - submit a form', () => {
// https://on.cypress.io/submit
cy.get('.action-form')
.find('[type="text"]').type('HALFOFF')

cy.get('.action-form').submit()
.next().should('contain', 'Your form has been submitted!')
})

it('.click() - click on a DOM element', () => {
// https://on.cypress.io/click
cy.get('.action-btn').click()

// You can click on 9 specific positions of an element:
// -----------------------------------
// | topLeft top topRight |
// | |
// | |
// | |
// | left center right |
// | |
// | |
// | |
// | bottomLeft bottom bottomRight |
// -----------------------------------

// clicking in the center of the element is the default
cy.get('#action-canvas').click()

cy.get('#action-canvas').click('topLeft')
cy.get('#action-canvas').click('top')
cy.get('#action-canvas').click('topRight')
cy.get('#action-canvas').click('left')
cy.get('#action-canvas').click('right')
cy.get('#action-canvas').click('bottomLeft')
cy.get('#action-canvas').click('bottom')
cy.get('#action-canvas').click('bottomRight')

// .click() accepts an x and y coordinate
// that controls where the click occurs :)

cy.get('#action-canvas')
.click(80, 75) // click 80px on x coord and 75px on y coord
.click(170, 75)
.click(80, 165)
.click(100, 185)
.click(125, 190)
.click(150, 185)
.click(170, 165)

// click multiple elements by passing multiple: true
cy.get('.action-labels>.label').click({ multiple: true })

// Ignore error checking prior to clicking
cy.get('.action-opacity>.btn').click({ force: true })
})

it('.dblclick() - double click on a DOM element', () => {
// https://on.cypress.io/dblclick

// Our app has a listener on 'dblclick' event in our 'scripts.js'
// that hides the div and shows an input on double click
cy.get('.action-div').dblclick().should('not.be.visible')
cy.get('.action-input-hidden').should('be.visible')
})

it('.rightclick() - right click on a DOM element', () => {
// https://on.cypress.io/rightclick

// Our app has a listener on 'contextmenu' event in our 'scripts.js'
// that hides the div and shows an input on right click
cy.get('.rightclick-action-div').rightclick().should('not.be.visible')
cy.get('.rightclick-action-input-hidden').should('be.visible')
})

it('.check() - check a checkbox or radio element', () => {
// https://on.cypress.io/check

// By default, .check() will check all
// matching checkbox or radio elements in succession, one after another
cy.get('.action-checkboxes [type="checkbox"]').not('[disabled]')
.check().should('be.checked')

cy.get('.action-radios [type="radio"]').not('[disabled]')
.check().should('be.checked')

// .check() accepts a value argument
cy.get('.action-radios [type="radio"]')
.check('radio1').should('be.checked')

// .check() accepts an array of values
cy.get('.action-multiple-checkboxes [type="checkbox"]')
.check(['checkbox1', 'checkbox2']).should('be.checked')

// Ignore error checking prior to checking
cy.get('.action-checkboxes [disabled]')
.check({ force: true }).should('be.checked')

cy.get('.action-radios [type="radio"]')
.check('radio3', { force: true }).should('be.checked')
})

it('.uncheck() - uncheck a checkbox element', () => {
// https://on.cypress.io/uncheck

// By default, .uncheck() will uncheck all matching
// checkbox elements in succession, one after another
cy.get('.action-check [type="checkbox"]')
.not('[disabled]')
.uncheck().should('not.be.checked')

// .uncheck() accepts a value argument
cy.get('.action-check [type="checkbox"]')
.check('checkbox1')
.uncheck('checkbox1').should('not.be.checked')

// .uncheck() accepts an array of values
cy.get('.action-check [type="checkbox"]')
.check(['checkbox1', 'checkbox3'])
.uncheck(['checkbox1', 'checkbox3']).should('not.be.checked')

// Ignore error checking prior to unchecking
cy.get('.action-check [disabled]')
.uncheck({ force: true }).should('not.be.checked')
})

it('.select() - select an option in a <select> element', () => {
// https://on.cypress.io/select

// at first, no option should be selected
cy.get('.action-select')
.should('have.value', '--Select a fruit--')

// Select option(s) with matching text content
cy.get('.action-select').select('apples')
// confirm the apples were selected
// note that each value starts with "fr-" in our HTML
cy.get('.action-select').should('have.value', 'fr-apples')

cy.get('.action-select-multiple')
.select(['apples', 'oranges', 'bananas'])
// when getting multiple values, invoke "val" method first
.invoke('val')
.should('deep.equal', ['fr-apples', 'fr-oranges', 'fr-bananas'])

// Select option(s) with matching value
cy.get('.action-select').select('fr-bananas')
// can attach an assertion right away to the element
.should('have.value', 'fr-bananas')

cy.get('.action-select-multiple')
.select(['fr-apples', 'fr-oranges', 'fr-bananas'])
.invoke('val')
.should('deep.equal', ['fr-apples', 'fr-oranges', 'fr-bananas'])

// assert the selected values include oranges
cy.get('.action-select-multiple')
.invoke('val').should('include', 'fr-oranges')
})

it('.scrollIntoView() - scroll an element into view', () => {
// https://on.cypress.io/scrollintoview

// normally all of these buttons are hidden,
// because they're not within
// the viewable area of their parent
// (we need to scroll to see them)
cy.get('#scroll-horizontal button')
.should('not.be.visible')

// scroll the button into view, as if the user had scrolled
cy.get('#scroll-horizontal button').scrollIntoView()
.should('be.visible')

cy.get('#scroll-vertical button')
.should('not.be.visible')

// Cypress handles the scroll direction needed
cy.get('#scroll-vertical button').scrollIntoView()
.should('be.visible')

cy.get('#scroll-both button')
.should('not.be.visible')

// Cypress knows to scroll to the right and down
cy.get('#scroll-both button').scrollIntoView()
.should('be.visible')
})

it('.trigger() - trigger an event on a DOM element', () => {
// https://on.cypress.io/trigger

// To interact with a range input (slider)
// we need to set its value & trigger the
// event to signal it changed

// Here, we invoke jQuery's val() method to set
// the value and trigger the 'change' event
cy.get('.trigger-input-range')
.invoke('val', 25)
.trigger('change')
.get('input[type=range]').siblings('p')
.should('have.text', '25')
})

it('cy.scrollTo() - scroll the window or element to a position', () => {
// https://on.cypress.io/scrollTo

// You can scroll to 9 specific positions of an element:
// -----------------------------------
// | topLeft top topRight |
// | |
// | |
// | |
// | left center right |
// | |
// | |
// | |
// | bottomLeft bottom bottomRight |
// -----------------------------------

// if you chain .scrollTo() off of cy, we will
// scroll the entire window
cy.scrollTo('bottom')

cy.get('#scrollable-horizontal').scrollTo('right')

// or you can scroll to a specific coordinate:
// (x axis, y axis) in pixels
cy.get('#scrollable-vertical').scrollTo(250, 250)

// or you can scroll to a specific percentage
// of the (width, height) of the element
cy.get('#scrollable-both').scrollTo('75%', '25%')

// control the easing of the scroll (default is 'swing')
cy.get('#scrollable-vertical').scrollTo('center', { easing: 'linear' })

// control the duration of the scroll (in ms)
cy.get('#scrollable-both').scrollTo('center', { duration: 2000 })
})
})
Loading