Skip to content

Commit

Permalink
731 cypress failures (#735)
Browse files Browse the repository at this point in the history
* record javascript console logs in Cypress test

* fix calls to cy.spy()

* add more logging to Profiler

* add another wait() command after profiler starts

* try running parallel

* creating env variable for Cypress run

* move environment variable

* define env in yaml

* test hard coded run id

* remove parallel flag from Cypress run

* use setup-demo-data in create-statistics tests

* update eyeHeight fixtures

* reset scroll position to top of dialog on close

* update add-statistics-dialog.cy.js to use Teacher Survey Data

* add wait for statistic to be created, before opening the dialog

* turn off Cypress record

* use Setup Demo Data for more tests

* remove hard-coded value from test code
  • Loading branch information
ekraffmiller committed Feb 9, 2023
1 parent bba0760 commit 12756e1
Show file tree
Hide file tree
Showing 13 changed files with 326 additions and 245 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export AZURE_LOGGING=False
export AZURE_INSTRUMENTATION_KEY=

export VUE_APP_ADOBE_PDF_CLIENT_ID=
export GITHUB_RUN_ID=$RANDOM
2 changes: 2 additions & 0 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
- name: Archive Cypress test results
if: ${{ always() }}
uses: actions/upload-artifact@v2
env:
GITHUB_RUN_ID: test12345
with:
name: cypress-videos
path: client/cypress/videos
Expand Down
4 changes: 4 additions & 0 deletions client/cypress/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ ENV WAIT_TIMEOUT=60
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.9.0/wait /wait
RUN chmod +x /wait

ENV GITHUB_RUN_ID=$RANDOM

## Launch the wait tool and then Cypress
## (The server to wait for is set as an environment variable)

# turn Cypress record for now
# CMD /wait && cypress run --config-file cypress_github_ci.config.js --record --key 0a9658f9-4279-488b-8f65-29a6ca0c2d76
CMD /wait && cypress run --config-file cypress_github_ci.config.js --record --key 0a9658f9-4279-488b-8f65-29a6ca0c2d76
38 changes: 25 additions & 13 deletions client/cypress/e2e/add-statistics-dialog.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,18 @@
console.log('runnable', runnable)
return false
})
cy.login('dev_admin', 'admin')
cy.request('/cypress-tests/clear-test-data/').then((resp) => {
console.log('CLEAR RESP: ' + JSON.stringify(resp))
})
cy.request('/cypress-tests/setup-demo-data/').then(() => {
cy.logout()
cy.login('dp_analyst', 'Test-for-2022')
cy.visit('/my-data')
cy.get('[data-test="continueWorkflow"]').click({force: true})

cy.setupStatisticsPageFixtures('datasetInfoStep600.json', 'analysisPlanStep700.json')

})
})


Expand All @@ -28,24 +37,26 @@

// The Create Statistics Button should be enabled after entering histogram edges
cy.get('[data-test="Histogram"]').click({force: true});
cy.get('[data-test="Trial"]').click({force: true})
cy.get('[data-test="selfesteem"]').click({force: true})
cy.get('[data-test="Fixed value"]').type('22')
cy.get('[data-test="binEdges"]').click({force: true})
cy.get('[data-test="histogramBinEdges"]').type("2,6,", {force: true})
cy.get('[data-test="histogramBinEdges"]').type("12,16,", {force: true})
cy.get('[data-test="Create Statistic Button"]').should('be.enabled')
cy.get('[data-test="Create Statistic Button"]').click({force: true})
cy.get('[data-test="Create Statistics Title').should('be.visible')
cy.get('[data-test="Add Statistic"]').should('be.visible')

// wait until the vuex store is updated before adding the next statistic
cy.vuex().its('state.dataset.analysisPlan.dpStatistics.length').should('be.equal', 1)
cy.get('[data-test="Add Statistic"]').should('be.visible')
cy.get('[data-test="Add Statistic"]').click({force: true});
cy.get('[data-test="AddStatisticDialog"]').should('be.visible')

// The second time through, the Create Statistics button should still be enabled
cy.get('[data-test="Histogram"]').click({force: true});
cy.get('[data-test="Trial"]').click({force: true})
cy.get('[data-test="age"]').click({force: true})
cy.get('[data-test="Fixed value"]').type('33')
cy.get('[data-test="binEdges"]').click({force: true})
cy.get('[data-test="histogramBinEdges"]').type("4,8,", {force: true})
cy.get('[data-test="histogramBinEdges"]').type("20,40,", {force: true})
cy.get('[data-test="Create Statistic Button"]').should('be.enabled')
cy.get('[data-test="Create Statistic Button"]').click({force: true})

Expand All @@ -55,25 +66,26 @@
cy.get('h1').should('contain', 'Create Statistics')
cy.get('[data-test="Add Statistic"]').click({force: true});
cy.get('[data-test="AddStatisticDialog"]').should('be.visible')
cy.get('[data-test="Subject"]').should('be.enabled')
cy.get('[data-test="Language"]').should('be.enabled')
cy.get('[data-test="sex"]').should('be.enabled')
cy.get('[data-test="maritalstatus"]').should('be.enabled')

// After clicking Mean, the non-numeric variables should not be visible
cy.get('[data-test="Mean"]').click({force: true})
cy.get('[data-test="Subject"]').should('not.exist')
cy.get('[data-test="Language"]').should('not.exist')
cy.get('[data-test="Trial"]').click({force: true})
cy.get('[data-test="sex"]').should('not.exist')
cy.get('[data-test="maritalstatus"]').should('not.exist')
cy.get('[data-test="age"]').click({force: true})

cy.get('[data-test="Fixed value"]').type('22')
cy.get('[data-test="Create Statistic Button"]').click({force: true})
cy.get('[data-test="Create Statistics Title').should('be.visible')
cy.vuex().its('state.dataset.analysisPlan.dpStatistics.length').should('be.equal', 1)
cy.get('[data-test="Add Statistic"]').should('be.visible')

cy.get('[data-test="Add Statistic"]').click({force: true});
cy.get('[data-test="AddStatisticDialog"]').should('be.visible')
// The non-numeric fields should be visible when re-opening the Dialog
cy.get('[data-test="Subject"]').should('be.enabled')
cy.get('[data-test="Language"]').should('be.enabled')
cy.get('[data-test="sex"]').should('be.enabled')
cy.get('[data-test="maritalstatus"]').should('be.enabled')


})
Expand Down
33 changes: 18 additions & 15 deletions client/cypress/e2e/confirm-variables.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
})
// cy.clearData()
// cy.createAccount('oscar', 'oscar@sesame.com', 'oscar123!')

cy.clearDatasetsOnly()
cy.pause()
/*
let testfile = 'cypress/fixtures/Fatigue_data.csv'
cy.uploadFile(testfile)
Expand All @@ -28,6 +26,10 @@
console.log('runnable', runnable)
return false
})
cy.on("window:before:load", (win) => {
cy.spy(win.console, "log");
cy.spy(win.console, "error")
})
cy.clearData()
let testfile = 'cypress/fixtures/Fatigue_data.csv'
cy.createAccount('oscar', 'oscar@sesame.com', 'oscar123!')
Expand All @@ -51,21 +53,22 @@
cy.createAccount('oscar', 'oscar@sesame.com', 'oscar123!')
cy.uploadFile(testfile)
cy.fixture('variables').then((varsFixture) => {
cy.goToConfirmVariables(varsFixture)
cy.pause()
for (const key in varsFixture) {
cy.get('table').contains('td', varsFixture[key].name).should('be.visible')
cy.get('table').contains('tr', varsFixture[key].name).should('contain', varsFixture[key].type)
}
const label = 'Subject'
const name = 'subject'
const catInput = label + ':categories'
const catDataTest = '[data-test="' + catInput + '"]'
cy.get(catDataTest).type(varsFixture[name].categories, {force: true})
varsFixture[name].categoryChips.forEach(category => {
cy.get('[data-test="categoryChip"]').should('contain', category)
cy.goToConfirmVariables(varsFixture).then(() => {
for (const key in varsFixture) {
cy.get('table').contains('td', varsFixture[key].name).should('be.visible')
cy.get('table').contains('tr', varsFixture[key].name).should('contain', varsFixture[key].type)
}
const label = 'Subject'
const name = 'subject'
const catInput = label + ':categories'
const catDataTest = '[data-test="' + catInput + '"]'
cy.get(catDataTest).type(varsFixture[name].categories, {force: true})
varsFixture[name].categoryChips.forEach(category => {
cy.get('[data-test="categoryChip"]').should('contain', category)
})
})


})
})

Expand Down
69 changes: 21 additions & 48 deletions client/cypress/e2e/create-statistics-spec2.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,81 +7,54 @@
return false
})
cy.clearData()
cy.createAccount('oscar', 'oscar@sesame.com', 'oscar123!')
cy.logout()

})
beforeEach(() => {
cy.on('uncaught:exception', (e, runnable) => {
console.log('error', e)
console.log('runnable', runnable)
return false
})
cy.clearDatasetsOnly()
cy.login('oscar', 'oscar123!')
let testfile = 'cypress/fixtures/Fatigue_data.csv'
cy.uploadFile(testfile)


cy.loadTeacherSurveyDemo()
})
afterEach(() => {
cy.logout()
})
it('Saves Histogram Options Correctly', () => {
const demoDatafile = 'EyeDemoStatsTest.json'
cy.fixture(demoDatafile).then((demoData) => {
cy.goToConfirmVariables(demoData.variables)
// select the variables we will use
cy.selectVariable(demoData.variables)
// Continue to Set Epsilon Step
cy.epsilonStep()
//go to Create Statistics Step
cy.get('[data-test="wizardContinueButton"]').last().click({force: true});
cy.get('h1').should('contain', 'Create Statistics').should('be.visible')


cy.get('h1').should('contain', 'Create Statistics').should('be.visible')

// Add all a Histogram statistic and test the options
cy.get('[data-test="Add Statistic"]').click({force: true});
cy.get('[data-test="AddStatisticDialog"]').should('be.visible')

cy.get('[data-test="Histogram"]').click({force: true});
const varDataTest = '[data-test="Trial"]'
cy.get(varDataTest).click({force: true})
cy.get('[data-test="Fixed value"]').type('5')
cy.get('[data-test="onePerValue"]').click({force: true})
const varDataTest = '[data-test="age"]'
cy.get(varDataTest).click({force: true})
cy.get('[data-test="Fixed value"]').type('35')
cy.get('[data-test="onePerValue"]').click({force: true})
cy.get('[data-test="Create Statistic Button"]').should('be.enabled')
cy.get('[data-test="equalRanges"]').click({force: true})
cy.get('[data-test="histogramNumberOfBins"]').type('11')
cy.get('div').should('contain', 'Value must').should('be.visible')
cy.get('[data-test="equalRanges"]').click({force: true})
cy.get('[data-test="histogramNumberOfBins"]').type('110')
cy.get('div').should('contain', 'Value must').should('be.visible')

cy.get('[data-test="histogramNumberOfBins"]').clear().type('3')
cy.get('div').should('contain', 'Equal range bins: [0, 4],[5, 10],uncategorized')
cy.get('[data-test="Create Statistic Button"]').click({force: true})
cy.get('[data-test="histogramNumberOfBins"]').clear().type('3')
cy.get('div').should('contain', 'Equal range bins: [20, 47],[48, 75],uncategorized')
cy.get('[data-test="Create Statistic Button"]').click({force: true})
cy.get('tr').first().get('td').should('contain', "Histogram")

})

})
it('Validates Correctly after epsilon changes', () => {
const demoDatafile = 'EyeDemoStatsTest.json'

cy.fixture(demoDatafile).then((demoData) => {
cy.goToConfirmVariables(demoData.variables)
// select the variables we will use
cy.selectVariable(demoData.variables)

// Continue to Set Epsilon Step
cy.epsilonStep()
const statsData = {
"datasetName": "Eye-typing experiment",
"datasetName": "Teacher Survey",
"statistics": [
{
"statistic": "Mean",
"variable": "Trial",
"fixedValue": "3",
"roundedAccuracy": "0.164"
"variable": "age",
"fixedValue": "35",
"roundedAccuracy": "0.0235"
}
]
}
const newAccuracy = "1.64"
const newAccuracy = ".235"
cy.createStatistics(statsData)
cy.get('tr').first().get('td').should('contain', statsData.statistics[0].statistic)
cy.get('table').contains('td', statsData.statistics[0].statistic).should('be.visible');
Expand All @@ -105,7 +78,7 @@
cy.get('[data-test=editParamsSave]').click();
cy.get('table').contains('td', statsData.statistics[0].roundedAccuracy).should('be.visible')

})

})


Expand Down
76 changes: 21 additions & 55 deletions client/cypress/e2e/create-statistics-spec3.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,61 +12,28 @@

})
beforeEach(() => {
cy.on('uncaught:exception', (e, runnable) => {
console.log('error', e)
console.log('runnable', runnable)
return false
})
cy.clearDatasetsOnly()
cy.login('oscar', 'oscar123!')
let testfile = 'cypress/fixtures/Fatigue_data.csv'
cy.uploadFile(testfile)


cy.loadTeacherSurveyDemo()
})
afterEach(() => {
cy.logout()
})

it('Updated dpStatistics Correctly', () => {
const demoDatafile = 'EyeDemoStatsTest.json'
cy.fixture(demoDatafile).then((demoData) => {
cy.goToConfirmVariables(demoData.variables)
// select the variables we will use
cy.selectVariable(demoData.variables)
// Continue to Set Epsilon Step
cy.epsilonStep()
// Add all the statistics in the Create Statistics Step
cy.createStatistics(demoData)
})
})
it('Displays Fixed Value Input Correctly', () => {
const demoDatafile = 'EyeDemoStatsTest.json'

cy.fixture(demoDatafile).then((demoData) => {
cy.goToConfirmVariables(demoData.variables)
// select the variables we will use
let variables = {
"Trial": {
"name": "Trial",
"label": "",
"type": "Integer",
"min": "0",
"max": "10"
},
}
cy.selectVariable(variables)

// Continue to Set Epsilon Step
cy.epsilonStep()

cy.get('[data-test="wizardContinueButton"]').last().click({force: true});
cy.get('[data-test="Add Statistic"]').click({force: true});
cy.get('[data-test="AddStatisticDialog"]').should('be.visible')
// The fixed input field should be visible after switching from Count to Mean
cy.get('[data-test="Count"]').click({force: true});
cy.get('[data-test="Trial"]').click({force: true})
cy.get('[data-test="Fixed value"]').should('not.exist')
let variables = {
"age": {
"name": "age",
"label": "age",
"type": "Integer",
"min": "20",
"max": "75"
},
}
cy.get('[data-test="Add Statistic"]').click({force: true});
cy.get('[data-test="AddStatisticDialog"]').should('be.visible')
// The fixed input field should be visible after switching from Count to Mean
cy.get('[data-test="Count"]').click({force: true});
cy.get('[data-test="age"]').click({force: true})
cy.get('[data-test="Fixed value"]').should('not.exist')
cy.get('[data-test="Mean"]').click({force: true});
cy.get('[data-test="Fixed value"]').should('exist')
cy.get('[data-test="Count"]').click({force: true});
Expand All @@ -79,19 +46,18 @@
cy.get('[data-test="Add Statistic"]').click({force: true});
cy.get('[data-test="AddStatisticDialog"]').should('be.visible')
cy.get('[data-test="Mean"]').click({force: true});
cy.get('[data-test="Fixed value"]').should('be.visible')
cy.get('[data-test="Trial"]').click({force: true})
cy.get('[data-test="Fixed value"]').should('be.visible')
cy.get('[data-test="age"]').click({force: true})

// The fixed input should be required to Create the Statistic if it's visible
cy.get('[data-test="Create Statistic Button"]').should('be.disabled')
cy.get('[data-test="Fixed value"]').type('5')
cy.get('[data-test="Create Statistic Button"]').should('be.enabled')
cy.get('[data-test="Create Statistic Button"]').should('be.disabled')
cy.get('[data-test="Fixed value"]').type('35')
cy.get('[data-test="Create Statistic Button"]').should('be.enabled')
cy.get('[data-test="Create Statistic Button"]').click({force: true})
// The statistic should have been created
cy.get('tr').first().get('td').should('contain', "Mean")


})
})


Expand Down
Loading

0 comments on commit 12756e1

Please sign in to comment.