From 12756e1952f220e61f1cbfee99b38be2a7bae0d2 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Thu, 9 Feb 2023 14:32:46 -0500 Subject: [PATCH] 731 cypress failures (#735) * 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 --- .env | 1 + .github/workflows/cypress.yml | 2 + client/cypress/Dockerfile | 4 + .../cypress/e2e/add-statistics-dialog.cy.js | 38 +++-- client/cypress/e2e/confirm-variables.cy.js | 33 ++-- .../cypress/e2e/create-statistics-spec2.cy.js | 69 +++----- .../cypress/e2e/create-statistics-spec3.cy.js | 76 +++------ client/cypress/e2e/create-statistics.cy.js | 151 +++++++----------- .../fixtures/TeacherSurveyVariableInfo.json | 131 +++++++++++++++ .../cypress/fixtures/analysisPlanStep700.json | 3 +- .../cypress/fixtures/datasetInfoStep600.json | 3 + client/cypress/support/commands.js | 49 ++++-- .../CreateStatistics/AddStatisticDialog.vue | 11 +- 13 files changed, 326 insertions(+), 245 deletions(-) create mode 100644 client/cypress/fixtures/TeacherSurveyVariableInfo.json diff --git a/.env b/.env index a2baea72..8d7d4664 100644 --- a/.env +++ b/.env @@ -11,3 +11,4 @@ export AZURE_LOGGING=False export AZURE_INSTRUMENTATION_KEY= export VUE_APP_ADOBE_PDF_CLIENT_ID= +export GITHUB_RUN_ID=$RANDOM \ No newline at end of file diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index ab3a145b..716ffb1b 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -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 diff --git a/client/cypress/Dockerfile b/client/cypress/Dockerfile index d5ac2d17..55a82b45 100644 --- a/client/cypress/Dockerfile +++ b/client/cypress/Dockerfile @@ -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 diff --git a/client/cypress/e2e/add-statistics-dialog.cy.js b/client/cypress/e2e/add-statistics-dialog.cy.js index b4d521a8..8aef0181 100644 --- a/client/cypress/e2e/add-statistics-dialog.cy.js +++ b/client/cypress/e2e/add-statistics-dialog.cy.js @@ -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') + }) }) @@ -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}) @@ -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') }) diff --git a/client/cypress/e2e/confirm-variables.cy.js b/client/cypress/e2e/confirm-variables.cy.js index f0ed6d7d..458a1fa3 100644 --- a/client/cypress/e2e/confirm-variables.cy.js +++ b/client/cypress/e2e/confirm-variables.cy.js @@ -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) @@ -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!') @@ -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) + }) }) + }) }) diff --git a/client/cypress/e2e/create-statistics-spec2.cy.js b/client/cypress/e2e/create-statistics-spec2.cy.js index 3fdf9447..ec21c342 100644 --- a/client/cypress/e2e/create-statistics-spec2.cy.js +++ b/client/cypress/e2e/create-statistics-spec2.cy.js @@ -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'); @@ -105,7 +78,7 @@ cy.get('[data-test=editParamsSave]').click(); cy.get('table').contains('td', statsData.statistics[0].roundedAccuracy).should('be.visible') - }) + }) diff --git a/client/cypress/e2e/create-statistics-spec3.cy.js b/client/cypress/e2e/create-statistics-spec3.cy.js index 219705ca..03ed36bc 100644 --- a/client/cypress/e2e/create-statistics-spec3.cy.js +++ b/client/cypress/e2e/create-statistics-spec3.cy.js @@ -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}); @@ -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") - }) }) diff --git a/client/cypress/e2e/create-statistics.cy.js b/client/cypress/e2e/create-statistics.cy.js index 9b0c31ed..d9b1b4cf 100644 --- a/client/cypress/e2e/create-statistics.cy.js +++ b/client/cypress/e2e/create-statistics.cy.js @@ -6,99 +6,72 @@ console.log('runnable', runnable) 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('Validates fixed value max-min', () => { - 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.createStatistics(statsData) - 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') - - 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((Number(variables.Trial.max) + 1)) - cy.get('div').should('contain', 'Value must be between') - cy.get('[data-test="Fixed value"]').clear() - cy.get('[data-test="Fixed value"]').type((Number(variables.Trial.max) - 1)) - cy.get('div').should('not.contain', 'Value must be between') - - - }) + it('Goes back to the Confirm Variables Page', () => { + const meanAge = { + "statistics": [ + { + "statistic": "Mean", + "variable": "age", + "fixedValue": "35", + "roundedAccuracy": "0.0235", + } + ] + + } + + cy.enterStatsInPopup(meanAge) + cy.get('[data-test="Add Statistic"]').should('be.visible') + cy.get('[data-test="Add Statistic"]').click({force: true}); + cy.get('[data-test="confirmVariablesLink"]').click({force: true}); + cy.get('h1').should('contain', 'Confirm Variables').should('be.visible') + // The checkbox for variable that was used to create a statistic should be disabled + // on the confirm variables page + cy.contains('td', meanAge.statistics[0].variable).parent('tr').children() + .first().children().get(":has(.v-simple-checkbox--disabled)").should('be.visible') }) - it('Displays correct precision', () => { - const demoDatafile = 'EyeDemoData.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) - }) + afterEach(() => { + cy.logout() }) - it('Goes back to the Confirm Variables Page', () => { - const demoDatafile = 'EyeDemoData.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) - cy.get('[data-test="Add Statistic"]').should('be.visible') - cy.get('[data-test="Add Statistic"]').click({force: true}); - cy.get('[data-test="confirmVariablesLink"]').click({force: true}); - cy.get('h1').should('contain', 'Confirm Variables').should('be.visible') - cy.contains('td', demoData.variables[demoData.statistics[0].variable].name).parent('tr').children() - .first().children().get(":has(.v-simple-checkbox--disabled)").should('be.visible') + it('Validates fixed value max-min', () => { + const varMax = 75 + const varMin = 20 + const testMax = Number(varMax + 1) + const testMin = Number(varMin - 1) + const varName = "age" + 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}); + const varDataTest = '[data-test="' + varName + '"]' + cy.get(varDataTest).click({force: true}) + cy.get('[data-test="Fixed value"]').type(testMax) + cy.get('div').should('contain', 'Value must be between') + cy.get('[data-test="Fixed value"]').clear() + cy.get('[data-test="Fixed value"]').type(testMin) + cy.get('div').should('contain', 'Value must be between') + cy.get('[data-test="Fixed value"]').clear() + cy.get('[data-test="Fixed value"]').type(varMax) + cy.get('div').should('not.contain', 'Value must be between') + }) + it('Goes to the correct wizard step', () => { + cy.on('uncaught:exception', (e, runnable) => { + console.log('error', e) + console.log('runnable', runnable) + return false }) + cy.get('h1').should('contain', 'Create Statistics') }) it('Populates Edit Noise Param Dialog', () => { cy.on('uncaught:exception', (e, runnable) => { @@ -106,9 +79,6 @@ console.log('runnable', runnable) return false }) - cy.logout() - cy.login('dev_admin', 'admin') - cy.setupStatisticsPage('datasetInfoStep600.json', 'analysisPlanStep700.json') cy.get('h1').should('contain', 'Create Statistics') cy.get('[data-test="editConfidenceIcon"]').click({force: true}); cy.get('h2').should('contain', 'Are you sure you want to proceed?').should('be.visible') @@ -118,27 +88,13 @@ cy.get('[data-test="editParamsCancel"]').click({force: true}); }) - it('Goes to the correct wizard step', () => { - cy.on('uncaught:exception', (e, runnable) => { - console.log('error', e) - console.log('runnable', runnable) - return false - }) - cy.logout() - cy.login('dev_admin', 'admin') - cy.setupStatisticsPage('datasetInfoStep600.json', 'analysisPlanStep700.json') - cy.get('h1').should('contain', 'Create Statistics') - }) it('Contains correct variables in the Add Statistics dialog ', () => { cy.on('uncaught:exception', (e, runnable) => { console.log('error', e) console.log('runnable', runnable) return false }) - cy.logout() - cy.login('dev_admin', 'admin') - cy.setupStatisticsPage('datasetInfoStep600.json', 'analysisPlanStep700.json') - cy.fixture('analysisPlanStep700').then((analysisFixture) => { + cy.fixture('TeacherSurveyVariableInfo').then((analysisFixture) => { // Create your statistic cy.get('[data-test="Add Statistic"]').click({force: true}); for (const key in analysisFixture.variableInfo) { @@ -161,5 +117,6 @@ }) + }) } \ No newline at end of file diff --git a/client/cypress/fixtures/TeacherSurveyVariableInfo.json b/client/cypress/fixtures/TeacherSurveyVariableInfo.json new file mode 100644 index 00000000..b58d4abc --- /dev/null +++ b/client/cypress/fixtures/TeacherSurveyVariableInfo.json @@ -0,0 +1,131 @@ +{ + "age": { + "max": 75, + "min": 20, + "name": "age", + "type": "Integer", + "label": "age", + "selected": true, + "sortOrder": 1 + }, + "sex": { + "max": 3, + "min": 1, + "name": "sex", + "type": "Categorical", + "label": "sex", + "selected": true, + "sortOrder": 0, + "categories": [ + 1, + 2, + 3 + ] + }, + "smoking": { + "max": 0, + "min": 0, + "name": "smoking", + "type": "Boolean", + "label": "smoking", + "selected": true, + "sortOrder": 6, + "trueValue": 1, + "falseValue": 2 + }, + "optimism": { + "max": 30, + "min": 6, + "name": "optimism", + "type": "Integer", + "label": "optimism", + "selected": true, + "sortOrder": 7, + "categories": [] + }, + "selfesteem": { + "max": 40, + "min": 10, + "name": "selfesteem", + "type": "Integer", + "label": "selfesteem", + "selected": true, + "sortOrder": 9, + "categories": [] + }, + "havingchild": { + "name": "Havingchild", + "type": "Boolean", + "label": "Havingchild", + "selected": true, + "sortOrder": 3, + "trueValue": 1, + "falseValue": 2 + }, + "maritalstatus": { + "max": 8, + "min": 1, + "name": "maritalstatus", + "type": "Categorical", + "label": "maritalstatus", + "selected": true, + "sortOrder": 2, + "categories": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ] + }, + "sourceofstress": { + "max": 9, + "min": 1, + "name": "sourceofstress", + "type": "Categorical", + "label": "sourceofstress", + "selected": true, + "sortOrder": 5, + "categories": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ] + }, + "lifesattisfaction": { + "max": 35, + "min": 5, + "name": "lifesattisfaction", + "type": "Integer", + "label": "lifesattisfaction", + "selected": true, + "sortOrder": 8, + "categories": [] + }, + "highesteducationlevel": { + "max": 6, + "min": 1, + "name": "highesteducationlevel", + "type": "Categorical", + "label": "highesteducationlevel", + "selected": true, + "sortOrder": 4, + "categories": [ + 1, + 2, + 3, + 4, + 5, + 6 + ] + } +} \ No newline at end of file diff --git a/client/cypress/fixtures/analysisPlanStep700.json b/client/cypress/fixtures/analysisPlanStep700.json index 1a4001d9..1ad36286 100644 --- a/client/cypress/fixtures/analysisPlanStep700.json +++ b/client/cypress/fixtures/analysisPlanStep700.json @@ -46,7 +46,8 @@ "eyeHeight": { "name": "EyeHeight", "type": "Float", - "label": "", + "selected": true, + "label": "EyeHeight", "sortOrder": 19 }, "typingSpeed": { diff --git a/client/cypress/fixtures/datasetInfoStep600.json b/client/cypress/fixtures/datasetInfoStep600.json index 0d705ac1..a6963c1b 100644 --- a/client/cypress/fixtures/datasetInfoStep600.json +++ b/client/cypress/fixtures/datasetInfoStep600.json @@ -64,9 +64,12 @@ "sortOrder": 1 }, "eyeHeight": { + "max": 10, + "min": 0, "name": "EyeHeight", "type": "Float", "label": "", + "selected": true, "sortOrder": 19 }, "typingSpeed": { diff --git a/client/cypress/support/commands.js b/client/cypress/support/commands.js index 3e8646cb..20163369 100644 --- a/client/cypress/support/commands.js +++ b/client/cypress/support/commands.js @@ -1,3 +1,23 @@ +Cypress.Commands.add('loadTeacherSurveyDemo', () => { + cy.on('uncaught:exception', (e, runnable) => { + console.log('error', e) + 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}) + + + }) +}) + Cypress.Commands.add('login', (username, password) => { Cypress.Cookies.debug(true) cy.visit('/log-in') @@ -206,21 +226,22 @@ Cypress.Commands.add('goToConfirmVariables', (variableData) => { cy.get('[data-test="notHarmButConfidential"]').check({force: true}) cy.get('[data-test="radioOnlyOneIndividualPerRowYes"]').check({force: true}) cy.intercept('/api/profile/run-async-profile/').as('runAsync') - + cy.intercept('/api/dataset-info/*').as('getDatasetInfo') // click on continue to go to trigger the profiler and go to the Confirm Variables Page cy.get('[data-test="wizardContinueButton"]').last().click({force: true}); - cy.wait('@runAsync').then(() => { - cy.get('h1').should('contain', 'Confirm Variables') - const getStore = () => cy.window().its('app.$store') - getStore().its('state.dataset.profilerStatus').should('deep.equal', true) - - // dataset.profilerStatus - for (const key in variableData) { - const val = variableData[key] - cy.get('table').contains('td', val.name).should('be.visible') - cy.get('table').contains('tr', val.name).should('contain', val.type) - } - }) + cy.wait('@runAsync') + cy.wait('@getDatasetInfo') + + cy.get('h1').should('contain', 'Confirm Variables') + const getStore = () => cy.window().its('app.$store') + getStore().its('state.dataset.profilerStatus').should('deep.equal', true) + + // dataset.profilerStatus + for (const key in variableData) { + const val = variableData[key] + cy.get('table').contains('td', val.name).should('be.visible') + cy.get('table').contains('tr', val.name).should('contain', val.type) + } }) @@ -368,7 +389,7 @@ Cypress.Commands.add('submitStatistics', (demoData) => { expect(releaseInfo.dpRelease.statistics[i].statistic).to.equal(demoData.statistics[i].statistic.toLowerCase()) expect(releaseInfo.dpRelease.statistics[i].accuracy.value).to.equal(demoData.statistics[i].accuracy) if (demoData.statistics[i].result) { - const mean = .59 + const mean = demoData.statistics[i].result expect(releaseInfo.dpRelease.statistics[i].result.value).to.be.lessThan(mean + (demoData.statistics[i].accuracy)) expect(releaseInfo.dpRelease.statistics[i].result.value).to.be.greaterThan(mean - (demoData.statistics[i].accuracy)) } diff --git a/client/src/components/Wizard/Steps/CreateStatistics/AddStatisticDialog.vue b/client/src/components/Wizard/Steps/CreateStatistics/AddStatisticDialog.vue index 1b58a059..a3dcd2a1 100644 --- a/client/src/components/Wizard/Steps/CreateStatistics/AddStatisticDialog.vue +++ b/client/src/components/Wizard/Steps/CreateStatistics/AddStatisticDialog.vue @@ -4,12 +4,12 @@ v-model="dialog" @click:outside="close" > - + mdi-close - +

{{ formTitle }}

@@ -608,6 +608,7 @@ export default { this.validationError = false this.$emit("saveConfirmed", this.editedItemDialog) this.selectedStatistic = null + this.scrollUp() } else { this.validationError = true } @@ -684,12 +685,18 @@ export default { this.close() this.$emit("addVariable") }, + // Reset the Dialog for the next time it is shown + scrollUp() { + this.$refs.addStatTitle.scrollIntoView() + }, close() { this.validationError = false this.validationErrorMsg = "" this.selectedStatistic = null this.resetEditedItemDialog() this.$emit("close"); + this.scrollUp() + }, resetEditedItemDialog() { this.editedItemDialog.statistic = ""