From d31a651440fb28ff5b240b41bf9f3f12b4f9ceaa Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Mon, 22 Jul 2024 07:07:50 -0400 Subject: [PATCH 01/10] update e2e testing to run optimization for all flowsheets --- .../ui/cypress/e2e/FlowsheetTesting.cy.js | 102 +++++++++--------- electron/ui/cypress/e2e/Flowsheets.js | 46 ++++++++ electron/ui/cypress/support/commands.js | 24 ++++- 3 files changed, 116 insertions(+), 56 deletions(-) create mode 100644 electron/ui/cypress/e2e/Flowsheets.js diff --git a/electron/ui/cypress/e2e/FlowsheetTesting.cy.js b/electron/ui/cypress/e2e/FlowsheetTesting.cy.js index 0e236153..956cee70 100644 --- a/electron/ui/cypress/e2e/FlowsheetTesting.cy.js +++ b/electron/ui/cypress/e2e/FlowsheetTesting.cy.js @@ -1,4 +1,4 @@ - +import { flowsheets } from "./Flowsheets" describe('WaterTAP UI Testing', () => { it('tests flowsheets-list page', () => { cy.load_flowsheets_list() @@ -14,61 +14,60 @@ describe('WaterTAP UI Testing', () => { }) - it('tests individual optimization', () => { - cy.load_flowsheets_list() - cy.screenshot('loaded flowsheet list page') - - cy.load_ro_flowsheet() - cy.screenshot('loaded RO flowsheet'); - - cy.set_ro_flowrate('0.96') - cy.set_ro_flowrate('0.96') - cy.screenshot('set flowrate to 0.96') - - - cy.set_ro_flowrate('0.96') - cy.set_ro_flowrate('0.96') - cy.screenshot('set flowrate to 0.96') - - - cy.solve_flowsheet() - cy.screenshot("solved flowshet") - - - // Click save configuration button - cy.findByRole('button', {name: /save configuration/i}).click() - cy.wait(1000) - cy.screenshot('pre saveConfig') - - - // Clear preset name and enter new name - cy.wait(1000) - cy.get('.MuiInput-input').should('be.visible') - cy.get('.MuiInput-input', {timeout: 10000}).clear({force: true}) - cy.get('.MuiInput-input', {timeout: 10000}).type('new_test_configuration', {force: true}) - cy.screenshot('saveConfig') - - - // Click on save (config) and wait for api response - cy.save_configuration() - cy.screenshot('saved config') - - - // Click compare tab - cy.findByRole('tab', {name: /compare/i}).click() - cy.wait(5000) - - // Verify that new name is shown in comparison table - cy.findAllByRole('tabpanel', {name: /compare/i}) - - cy.screenshot('end-solve-test') + flowsheets.forEach((flowsheet) => { + it('tests optimization for '+flowsheet.name, () => { + cy.load_flowsheets_list() + cy.wait(2000) + cy.screenshot('loaded flowsheet list page') + + cy.load_flowsheet(flowsheet.name) + cy.screenshot('loaded '+flowsheet.name); + + if (flowsheet.buildRequired) { + cy.build_flowsheet() + cy.screenshot("built "+flowsheet.name) + } + + cy.solve_flowsheet() + cy.screenshot("solved "+flowsheet.name) + + + // Click save configuration button + cy.findByRole('button', {name: /save configuration/i}).click() + cy.wait(1000) + cy.screenshot('pre saveConfig for '+flowsheet.name) + + + // Clear preset name and enter new name + cy.wait(1000) + cy.get('.MuiInput-input').should('be.visible') + cy.get('.MuiInput-input', {timeout: 10000}).clear({force: true}) + cy.get('.MuiInput-input', {timeout: 10000}).type('new_test_configuration', {force: true}) + cy.screenshot('saveConfig') + + + // Click on save (config) and wait for api response + cy.save_configuration() + cy.screenshot('saved config for '+flowsheet.name) + + + // Click compare tab + cy.findByRole('tab', {name: /compare/i}).click() + cy.wait(5000) + + // Verify that new name is shown in comparison table + cy.findAllByRole('tabpanel', {name: /compare/i}) + + cy.screenshot('end-solve-'+flowsheet.name) + }) }) + it('tests invalid inputs', () => { cy.load_flowsheets_list() cy.screenshot('loaded flowsheet list page') - cy.load_ro_flowsheet() + cy.load_flowsheet("RO with energy recovery flowsheet") cy.screenshot('loaded RO flowsheet'); cy.set_ro_flowrate('dfas'); @@ -92,6 +91,7 @@ describe('WaterTAP UI Testing', () => { it('tests logging panel', () => { cy.load_flowsheets_list() + cy.wait(2000) cy.screenshot('loaded flowsheet list page') cy.open_logging_panel() @@ -146,7 +146,7 @@ describe('WaterTAP UI Testing', () => { cy.load_flowsheets_list() cy.screenshot('loaded flowsheet list page') - cy.load_ro_flowsheet() + cy.load_flowsheet("RO with energy recovery flowsheet") cy.screenshot('loaded RO flowsheet') // set solve type to sweep diff --git a/electron/ui/cypress/e2e/Flowsheets.js b/electron/ui/cypress/e2e/Flowsheets.js new file mode 100644 index 00000000..cc9e44fa --- /dev/null +++ b/electron/ui/cypress/e2e/Flowsheets.js @@ -0,0 +1,46 @@ +export const flowsheets = [ + { + name: 'NF-DSPM-DE flowsheet', + buildRequired: true, + }, + { + name: 'BSM2 flowsheet', + buildRequired: false, + }, + { + name: 'BSM2_P_extension flowsheet', + buildRequired: false, + }, + { + name: 'Dye Desalination flowsheet', + buildRequired: false, + }, + { + name: 'Mechanical vapor compression flowsheet', + buildRequired: false, + }, + { + name: 'RO with energy recovery flowsheet', + buildRequired: false, + }, + { + name: 'OARO flowsheet', + buildRequired: true, + }, + { + name: 'Granular Activated Carbon (GAC) flowsheet', + buildRequired: true, + }, + { + name: 'Electrodialysis with concentrate recirculation flowsheet', + buildRequired: false, + }, + { + name: 'LSRRO flowsheet', + buildRequired: true, + }, + { + name: 'Generic treatment train flowsheet', + buildRequired: false, + }, +] \ No newline at end of file diff --git a/electron/ui/cypress/support/commands.js b/electron/ui/cypress/support/commands.js index 8caeed4d..93b31d6f 100644 --- a/electron/ui/cypress/support/commands.js +++ b/electron/ui/cypress/support/commands.js @@ -14,18 +14,32 @@ Cypress.Commands.add('load_flowsheets_list', () => { }) /** - * Load the RO with energy recovery flowsheet + * Load flowsheet * * From page: flowsheet list */ -Cypress.Commands.add('load_ro_flowsheet', () => { - const flowsheet_name = 'RO with energy recovery flowsheet'; +Cypress.Commands.add('load_flowsheet', (flowsheet_name) => { + // const flowsheet_name = 'RO with energy recovery flowsheet'; cy.intercept({ method: 'GET', url: 'http://localhost:8001/flowsheets/**', }).as('loadFlowsheet'); cy.findByText(flowsheet_name).click(); - cy.wait('@loadFlowsheet'); + cy.wait('@loadFlowsheet', {timeout: 45000}); +}) + +/** + * Build flowsheet + * + * From page: flowsheet + */ +Cypress.Commands.add('build_flowsheet', () => { + cy.intercept({ + method: 'GET', + url: 'http://localhost:8001/flowsheets/**', + }).as('buildFlowsheet'); + cy.findAllByRole('button', {name: /build flowsheet/i}).eq(0).click(); + cy.wait('@buildFlowsheet', {timeout: 45000}); }) /** @@ -53,7 +67,7 @@ Cypress.Commands.add('solve_flowsheet', () => { url: 'http://localhost:8001/flowsheets/**', }).as('run'); cy.findAllByRole('button', {name: /run/i}).eq(0).click(); - cy.wait('@run'); + cy.wait('@run', {timeout: 45000}); }) /** From 0620b7b74f8ce2fa69e2881414cf69999a4cfcdf Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Mon, 22 Jul 2024 11:16:16 -0400 Subject: [PATCH 02/10] add parameter sweep test for each flowsheet --- .../ui/cypress/e2e/FlowsheetTesting.cy.js | 53 ++++++++++--------- electron/ui/cypress/e2e/Flowsheets.js | 22 ++++++++ 2 files changed, 49 insertions(+), 26 deletions(-) diff --git a/electron/ui/cypress/e2e/FlowsheetTesting.cy.js b/electron/ui/cypress/e2e/FlowsheetTesting.cy.js index 956cee70..ed7ed77c 100644 --- a/electron/ui/cypress/e2e/FlowsheetTesting.cy.js +++ b/electron/ui/cypress/e2e/FlowsheetTesting.cy.js @@ -141,37 +141,38 @@ describe('WaterTAP UI Testing', () => { cy.screenshot('end-new-flowsheet-test') }) + flowsheets.forEach((flowsheet) => { + it('tests parameter sweep '+flowsheet.name, () => { + cy.load_flowsheets_list() + cy.screenshot('loaded flowsheet list page') + + cy.load_flowsheet(flowsheet.name) + cy.screenshot('loaded '+flowsheet.name) - it('tests parameter sweep', () => { - cy.load_flowsheets_list() - cy.screenshot('loaded flowsheet list page') - - cy.load_flowsheet("RO with energy recovery flowsheet") - cy.screenshot('loaded RO flowsheet') - - // set solve type to sweep - cy.get('#solve-sweep-select').click() - cy.wait(100) - cy.get('#sweep-option').click() - cy.wait(1000) + // set solve type to sweep + cy.get('#solve-sweep-select').click() + cy.wait(100) + cy.get('#sweep-option').click() + cy.wait(1000) - // set sweep variable - cy.get('.Watermassflowrate_fixed-free-select').click() - cy.wait(100) - cy.findByRole('option', { name: /sweep/i }).click() - cy.wait(100) + // set sweep variable + cy.get('.'+flowsheet.sweepVariable+'_fixed-free-select').click() + cy.wait(100) + cy.findByRole('option', { name: /sweep/i }).click() + cy.wait(100) - // enter lower and upper bounds - cy.enter_text('class', 'Watermassflowrate_lower_input', '0.7') - cy.enter_text('class', 'Watermassflowrate_upper_input', '0.8') + // enter lower and upper bounds + cy.enter_text('class', flowsheet.sweepVariable+'_lower_input', flowsheet.sweepValues[0]) + cy.enter_text('class', flowsheet.sweepVariable+'_upper_input', flowsheet.sweepValues[1]) - // run sweep - cy.solve_flowsheet() - cy.wait(5000) - cy.screenshot("ran parameter sweep") + // run sweep + cy.solve_flowsheet() + cy.wait(5000) + cy.screenshot('ran parameter sweep '+flowsheet.name) - //test that sweep was successful - cy.get('.parameter-sweep-output-table').should('be.visible') + //test that sweep was successful + cy.get('.parameter-sweep-output-table').should('be.visible') + }) }) }) \ No newline at end of file diff --git a/electron/ui/cypress/e2e/Flowsheets.js b/electron/ui/cypress/e2e/Flowsheets.js index cc9e44fa..a3b6861c 100644 --- a/electron/ui/cypress/e2e/Flowsheets.js +++ b/electron/ui/cypress/e2e/Flowsheets.js @@ -2,45 +2,67 @@ export const flowsheets = [ { name: 'NF-DSPM-DE flowsheet', buildRequired: true, + sweepVariable: 'Volumetricflowrate', + sweepValues: [] }, { name: 'BSM2 flowsheet', buildRequired: false, + sweepVariable: 'Watermassflowrate', + sweepValues: [], }, { name: 'BSM2_P_extension flowsheet', buildRequired: false, + sweepVariable: 'Feedvolumetricflowrate', + sweepValues: ['20000', '21000'], }, { name: 'Dye Desalination flowsheet', buildRequired: false, + sweepVariable: 'Volumetricflowrate', + sweepValues: ['270', '290'], }, { name: 'Mechanical vapor compression flowsheet', buildRequired: false, + sweepVariable: 'Feedmassflow', + sweepValues: ['35','45'], }, { name: 'RO with energy recovery flowsheet', buildRequired: false, + sweepVariable: 'Watermassflowrate', + sweepValues: ['0.7','0.8'], }, { name: 'OARO flowsheet', buildRequired: true, + sweepVariable: 'Watermassflowrate', + sweepValues: ['5','6'], }, { name: 'Granular Activated Carbon (GAC) flowsheet', buildRequired: true, + sweepVariable: 'MW', + sweepValues: ['75','85'], }, { name: 'Electrodialysis with concentrate recirculation flowsheet', buildRequired: false, + sweepVariable: 'Feedsolutionvolumeflowrate', + sweepValues: ['0.001,0.002'], }, { name: 'LSRRO flowsheet', buildRequired: true, + sweepVariable: 'Pump1outletpressure', + sweepValues: ['80','90'], }, { name: 'Generic treatment train flowsheet', buildRequired: false, + sweepVariable: 'Desal1waterrecovery', + sweepValues: ['80','90'], }, ] \ No newline at end of file From 28883aa2e5b541778d1096a9d0a841be33fe162a Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Mon, 22 Jul 2024 11:17:11 -0400 Subject: [PATCH 03/10] increase max wait time for build and solve to 90 seconds --- electron/ui/cypress/support/commands.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/electron/ui/cypress/support/commands.js b/electron/ui/cypress/support/commands.js index 93b31d6f..9d81bc0f 100644 --- a/electron/ui/cypress/support/commands.js +++ b/electron/ui/cypress/support/commands.js @@ -25,7 +25,7 @@ Cypress.Commands.add('load_flowsheet', (flowsheet_name) => { url: 'http://localhost:8001/flowsheets/**', }).as('loadFlowsheet'); cy.findByText(flowsheet_name).click(); - cy.wait('@loadFlowsheet', {timeout: 45000}); + cy.wait('@loadFlowsheet', {timeout: 90000}); }) /** @@ -39,7 +39,7 @@ Cypress.Commands.add('build_flowsheet', () => { url: 'http://localhost:8001/flowsheets/**', }).as('buildFlowsheet'); cy.findAllByRole('button', {name: /build flowsheet/i}).eq(0).click(); - cy.wait('@buildFlowsheet', {timeout: 45000}); + cy.wait('@buildFlowsheet', {timeout: 90000}); }) /** @@ -67,7 +67,7 @@ Cypress.Commands.add('solve_flowsheet', () => { url: 'http://localhost:8001/flowsheets/**', }).as('run'); cy.findAllByRole('button', {name: /run/i}).eq(0).click(); - cy.wait('@run', {timeout: 45000}); + cy.wait('@run', {timeout: 90000}); }) /** From eee502d9f770c4195f1b64ada5c21c10877b22dc Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Mon, 22 Jul 2024 13:00:27 -0400 Subject: [PATCH 04/10] increase timeout time for e2e tests; reorder tests --- .github/workflows/main.yml | 2 +- .../ui/cypress/e2e/FlowsheetTesting.cy.js | 99 +++++++++---------- 2 files changed, 50 insertions(+), 51 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ee709d5d..ff5c3ed5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -77,7 +77,7 @@ jobs: - name: Cypress e2e tests working-directory: electron/ui - timeout-minutes: 15 + timeout-minutes: 45 run: npx cypress run - name: Upload artifact for screenshots & videos diff --git a/electron/ui/cypress/e2e/FlowsheetTesting.cy.js b/electron/ui/cypress/e2e/FlowsheetTesting.cy.js index ed7ed77c..fcdee6de 100644 --- a/electron/ui/cypress/e2e/FlowsheetTesting.cy.js +++ b/electron/ui/cypress/e2e/FlowsheetTesting.cy.js @@ -14,55 +14,6 @@ describe('WaterTAP UI Testing', () => { }) - flowsheets.forEach((flowsheet) => { - it('tests optimization for '+flowsheet.name, () => { - cy.load_flowsheets_list() - cy.wait(2000) - cy.screenshot('loaded flowsheet list page') - - cy.load_flowsheet(flowsheet.name) - cy.screenshot('loaded '+flowsheet.name); - - if (flowsheet.buildRequired) { - cy.build_flowsheet() - cy.screenshot("built "+flowsheet.name) - } - - cy.solve_flowsheet() - cy.screenshot("solved "+flowsheet.name) - - - // Click save configuration button - cy.findByRole('button', {name: /save configuration/i}).click() - cy.wait(1000) - cy.screenshot('pre saveConfig for '+flowsheet.name) - - - // Clear preset name and enter new name - cy.wait(1000) - cy.get('.MuiInput-input').should('be.visible') - cy.get('.MuiInput-input', {timeout: 10000}).clear({force: true}) - cy.get('.MuiInput-input', {timeout: 10000}).type('new_test_configuration', {force: true}) - cy.screenshot('saveConfig') - - - // Click on save (config) and wait for api response - cy.save_configuration() - cy.screenshot('saved config for '+flowsheet.name) - - - // Click compare tab - cy.findByRole('tab', {name: /compare/i}).click() - cy.wait(5000) - - // Verify that new name is shown in comparison table - cy.findAllByRole('tabpanel', {name: /compare/i}) - - cy.screenshot('end-solve-'+flowsheet.name) - }) - }) - - it('tests invalid inputs', () => { cy.load_flowsheets_list() cy.screenshot('loaded flowsheet list page') @@ -86,7 +37,6 @@ describe('WaterTAP UI Testing', () => { cy.get('.error-message').should('be.visible') cy.screenshot('end-invalid-input-test'); - }) it('tests logging panel', () => { @@ -141,6 +91,55 @@ describe('WaterTAP UI Testing', () => { cy.screenshot('end-new-flowsheet-test') }) + + flowsheets.forEach((flowsheet) => { + it('tests optimization for '+flowsheet.name, () => { + cy.load_flowsheets_list() + cy.wait(2000) + cy.screenshot('loaded flowsheet list page') + + cy.load_flowsheet(flowsheet.name) + cy.screenshot('loaded '+flowsheet.name); + + if (flowsheet.buildRequired) { + cy.build_flowsheet() + cy.screenshot("built "+flowsheet.name) + } + + cy.solve_flowsheet() + cy.screenshot("solved "+flowsheet.name) + + + // Click save configuration button + cy.findByRole('button', {name: /save configuration/i}).click() + cy.wait(1000) + cy.screenshot('pre saveConfig for '+flowsheet.name) + + + // Clear preset name and enter new name + cy.wait(1000) + cy.get('.MuiInput-input').should('be.visible') + cy.get('.MuiInput-input', {timeout: 10000}).clear({force: true}) + cy.get('.MuiInput-input', {timeout: 10000}).type('new_test_configuration', {force: true}) + cy.screenshot('saveConfig') + + + // Click on save (config) and wait for api response + cy.save_configuration() + cy.screenshot('saved config for '+flowsheet.name) + + + // Click compare tab + cy.findByRole('tab', {name: /compare/i}).click() + cy.wait(5000) + + // Verify that new name is shown in comparison table + cy.findAllByRole('tabpanel', {name: /compare/i}) + + cy.screenshot('end-solve-'+flowsheet.name) + }) + }) + flowsheets.forEach((flowsheet) => { it('tests parameter sweep '+flowsheet.name, () => { cy.load_flowsheets_list() From cff229ebd70ef6eb77bcac9cf0d4ea65f71d25e3 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Mon, 22 Jul 2024 13:31:06 -0400 Subject: [PATCH 05/10] add id for build flowsheet button; fix parameter sweep for remaining flowsheets --- electron/ui/cypress/e2e/Flowsheets.js | 10 +++++----- electron/ui/cypress/support/commands.js | 2 +- .../ui/src/components/BuildOptions/BuildOptions.js | 10 +++++++++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/electron/ui/cypress/e2e/Flowsheets.js b/electron/ui/cypress/e2e/Flowsheets.js index a3b6861c..e884c03b 100644 --- a/electron/ui/cypress/e2e/Flowsheets.js +++ b/electron/ui/cypress/e2e/Flowsheets.js @@ -3,13 +3,13 @@ export const flowsheets = [ name: 'NF-DSPM-DE flowsheet', buildRequired: true, sweepVariable: 'Volumetricflowrate', - sweepValues: [] + sweepValues: ['3500', '3600'] }, { name: 'BSM2 flowsheet', buildRequired: false, sweepVariable: 'Watermassflowrate', - sweepValues: [], + sweepValues: ['20000', '21000'], }, { name: 'BSM2_P_extension flowsheet', @@ -44,14 +44,14 @@ export const flowsheets = [ { name: 'Granular Activated Carbon (GAC) flowsheet', buildRequired: true, - sweepVariable: 'MW', - sweepValues: ['75','85'], + sweepVariable: 'Apparentdensity', + sweepValues: ['700','800'], }, { name: 'Electrodialysis with concentrate recirculation flowsheet', buildRequired: false, sweepVariable: 'Feedsolutionvolumeflowrate', - sweepValues: ['0.001,0.002'], + sweepValues: ['0.001','0.002'], }, { name: 'LSRRO flowsheet', diff --git a/electron/ui/cypress/support/commands.js b/electron/ui/cypress/support/commands.js index 9d81bc0f..dd5821c6 100644 --- a/electron/ui/cypress/support/commands.js +++ b/electron/ui/cypress/support/commands.js @@ -38,7 +38,7 @@ Cypress.Commands.add('build_flowsheet', () => { method: 'GET', url: 'http://localhost:8001/flowsheets/**', }).as('buildFlowsheet'); - cy.findAllByRole('button', {name: /build flowsheet/i}).eq(0).click(); + cy.get('#build-flowsheet-button').click() cy.wait('@buildFlowsheet', {timeout: 90000}); }) diff --git a/electron/ui/src/components/BuildOptions/BuildOptions.js b/electron/ui/src/components/BuildOptions/BuildOptions.js index 819cc52c..e85c0b34 100644 --- a/electron/ui/src/components/BuildOptions/BuildOptions.js +++ b/electron/ui/src/components/BuildOptions/BuildOptions.js @@ -61,7 +61,15 @@ export default function BuildOptions(props) { ))}
-
From 14ff1f22e28edb7dae7686ba040a51ca18876296 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Tue, 23 Jul 2024 08:54:19 -0400 Subject: [PATCH 06/10] increase timeout amount --- electron/ui/cypress/support/commands.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/electron/ui/cypress/support/commands.js b/electron/ui/cypress/support/commands.js index dd5821c6..6fd8a07a 100644 --- a/electron/ui/cypress/support/commands.js +++ b/electron/ui/cypress/support/commands.js @@ -25,7 +25,7 @@ Cypress.Commands.add('load_flowsheet', (flowsheet_name) => { url: 'http://localhost:8001/flowsheets/**', }).as('loadFlowsheet'); cy.findByText(flowsheet_name).click(); - cy.wait('@loadFlowsheet', {timeout: 90000}); + cy.wait('@loadFlowsheet', {timeout: 180000}); }) /** @@ -39,7 +39,7 @@ Cypress.Commands.add('build_flowsheet', () => { url: 'http://localhost:8001/flowsheets/**', }).as('buildFlowsheet'); cy.get('#build-flowsheet-button').click() - cy.wait('@buildFlowsheet', {timeout: 90000}); + cy.wait('@buildFlowsheet', {timeout: 180000}); }) /** @@ -67,7 +67,7 @@ Cypress.Commands.add('solve_flowsheet', () => { url: 'http://localhost:8001/flowsheets/**', }).as('run'); cy.findAllByRole('button', {name: /run/i}).eq(0).click(); - cy.wait('@run', {timeout: 90000}); + cy.wait('@run', {timeout: 180000}); }) /** From afe41746b6386d67e1dd3dca7bb15693760a381a Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Tue, 23 Jul 2024 09:10:37 -0400 Subject: [PATCH 07/10] fix sweep variable name for bsm2; reset RO flowsheet after using invalid input --- electron/ui/cypress/e2e/FlowsheetTesting.cy.js | 2 ++ electron/ui/cypress/e2e/Flowsheets.js | 2 +- electron/ui/cypress/support/commands.js | 14 ++++++++++++++ .../FlowsheetConfig/ConfigInput/ConfigInput.js | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/electron/ui/cypress/e2e/FlowsheetTesting.cy.js b/electron/ui/cypress/e2e/FlowsheetTesting.cy.js index fcdee6de..b6532e79 100644 --- a/electron/ui/cypress/e2e/FlowsheetTesting.cy.js +++ b/electron/ui/cypress/e2e/FlowsheetTesting.cy.js @@ -37,6 +37,8 @@ describe('WaterTAP UI Testing', () => { cy.get('.error-message').should('be.visible') cy.screenshot('end-invalid-input-test'); + + cy.reset_flowsheet() }) it('tests logging panel', () => { diff --git a/electron/ui/cypress/e2e/Flowsheets.js b/electron/ui/cypress/e2e/Flowsheets.js index e884c03b..8a27279e 100644 --- a/electron/ui/cypress/e2e/Flowsheets.js +++ b/electron/ui/cypress/e2e/Flowsheets.js @@ -8,7 +8,7 @@ export const flowsheets = [ { name: 'BSM2 flowsheet', buildRequired: false, - sweepVariable: 'Watermassflowrate', + sweepVariable: 'Feedvolumetricflowrate', sweepValues: ['20000', '21000'], }, { diff --git a/electron/ui/cypress/support/commands.js b/electron/ui/cypress/support/commands.js index 6fd8a07a..740aa368 100644 --- a/electron/ui/cypress/support/commands.js +++ b/electron/ui/cypress/support/commands.js @@ -42,6 +42,20 @@ Cypress.Commands.add('build_flowsheet', () => { cy.wait('@buildFlowsheet', {timeout: 180000}); }) +/** + * Reset flowsheet + * + * From page: flowsheet + */ +Cypress.Commands.add('reset_flowsheet', () => { + cy.intercept({ + method: 'GET', + url: 'http://localhost:8001/flowsheets/**', + }).as('resetFlowsheet'); + cy.get('#reset-flowsheet-button').click() + cy.wait('@resetFlowsheet', {timeout: 180000}); +}) + /** * Set the water mass flowrate [input] to the given value * diff --git a/electron/ui/src/views/FlowsheetConfig/ConfigInput/ConfigInput.js b/electron/ui/src/views/FlowsheetConfig/ConfigInput/ConfigInput.js index b1bf5155..9bb983f2 100644 --- a/electron/ui/src/views/FlowsheetConfig/ConfigInput/ConfigInput.js +++ b/electron/ui/src/views/FlowsheetConfig/ConfigInput/ConfigInput.js @@ -340,7 +340,7 @@ export default function ConfigInput(props) {
-
Date: Tue, 23 Jul 2024 09:51:17 -0400 Subject: [PATCH 08/10] cleanup --- .../ui/cypress/e2e/FlowsheetTesting.cy.js | 43 ++++++++----------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/electron/ui/cypress/e2e/FlowsheetTesting.cy.js b/electron/ui/cypress/e2e/FlowsheetTesting.cy.js index b6532e79..a8c242a6 100644 --- a/electron/ui/cypress/e2e/FlowsheetTesting.cy.js +++ b/electron/ui/cypress/e2e/FlowsheetTesting.cy.js @@ -4,41 +4,35 @@ describe('WaterTAP UI Testing', () => { cy.load_flowsheets_list() cy.screenshot('loaded flowsheet list page') - //locate heading + // verify that heading and table headers are present cy.findByRole('heading', { name: /flowsheets/i}) - - //locate table headers cy.findByRole('columnheader', { name: /flowsheet name/i}) cy.findByRole('columnheader', { name: /last run/i}) - cy.screenshot('end-list-page-test') - + cy.screenshot('end-list-page-test') }) it('tests invalid inputs', () => { cy.load_flowsheets_list() cy.screenshot('loaded flowsheet list page') + // load flowsheet cy.load_flowsheet("RO with energy recovery flowsheet") cy.screenshot('loaded RO flowsheet'); + // set invalid text input cy.set_ro_flowrate('dfas'); cy.screenshot('invalid-text-input'); + // solve flowsheet cy.solve_flowsheet() - cy.screenshot('error-message'); - cy.get('.error-message').should('be.visible') - - cy.set_ro_flowrate('-10'); - cy.screenshot('invalid-negative-input'); - cy.solve_flowsheet() + // verify that error message is there cy.screenshot('error-message'); - cy.get('.error-message').should('be.visible') - cy.screenshot('end-invalid-input-test'); - + // reset flowsheet cy.reset_flowsheet() + cy.screenshot('end-invalid-input-test'); }) it('tests logging panel', () => { @@ -46,13 +40,13 @@ describe('WaterTAP UI Testing', () => { cy.wait(2000) cy.screenshot('loaded flowsheet list page') + // open logging panel cy.open_logging_panel() cy.screenshot('opened_logs') - // check that a log line of type info, warning, are present + // verify that a log line of type info and warning are present cy.get('.log-line').contains('INFO') cy.get('.log-line').contains('WARNING') - cy.screenshot('end-logging-test') }) @@ -66,9 +60,9 @@ describe('WaterTAP UI Testing', () => { cy.downloadFile(modelFile,'cypress/downloads','testModelFile.py') cy.downloadFile(exportFile,'cypress/downloads','testModelFile_ui.py') + // click new flowsheet button cy.findByRole('button', {name: /new flowsheet +/i}).click() cy.wait(500) - cy.screenshot("clicked new flowsheet") // select both files @@ -80,15 +74,15 @@ describe('WaterTAP UI Testing', () => { action: 'drag-drop', force: true }) - cy.wait(500) cy.screenshot("dragged and dropped files") + // click upload cy.get('.upload-flowsheet-button').click() - cy.wait(1000) cy.screenshot("uploaded files") + // verify that flowsheet is now in list cy.get('.flowsheet-name').contains(/test custom flowsheet/i) cy.screenshot('end-new-flowsheet-test') @@ -100,36 +94,35 @@ describe('WaterTAP UI Testing', () => { cy.wait(2000) cy.screenshot('loaded flowsheet list page') + // load flowsheet cy.load_flowsheet(flowsheet.name) cy.screenshot('loaded '+flowsheet.name); + // if model has build options, it must be manually built if (flowsheet.buildRequired) { cy.build_flowsheet() cy.screenshot("built "+flowsheet.name) } + // solve flowsheet cy.solve_flowsheet() cy.screenshot("solved "+flowsheet.name) - // Click save configuration button cy.findByRole('button', {name: /save configuration/i}).click() cy.wait(1000) cy.screenshot('pre saveConfig for '+flowsheet.name) - // Clear preset name and enter new name cy.wait(1000) cy.get('.MuiInput-input').should('be.visible') cy.get('.MuiInput-input', {timeout: 10000}).clear({force: true}) cy.get('.MuiInput-input', {timeout: 10000}).type('new_test_configuration', {force: true}) cy.screenshot('saveConfig') - // Click on save (config) and wait for api response cy.save_configuration() cy.screenshot('saved config for '+flowsheet.name) - // Click compare tab cy.findByRole('tab', {name: /compare/i}).click() @@ -137,7 +130,6 @@ describe('WaterTAP UI Testing', () => { // Verify that new name is shown in comparison table cy.findAllByRole('tabpanel', {name: /compare/i}) - cy.screenshot('end-solve-'+flowsheet.name) }) }) @@ -147,6 +139,7 @@ describe('WaterTAP UI Testing', () => { cy.load_flowsheets_list() cy.screenshot('loaded flowsheet list page') + // load flowsheet cy.load_flowsheet(flowsheet.name) cy.screenshot('loaded '+flowsheet.name) @@ -171,7 +164,7 @@ describe('WaterTAP UI Testing', () => { cy.wait(5000) cy.screenshot('ran parameter sweep '+flowsheet.name) - //test that sweep was successful + // verify that sweep was successful cy.get('.parameter-sweep-output-table').should('be.visible') }) From 914622c5fa58973ecef229a423e1897cd77cdb6e Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Tue, 23 Jul 2024 10:26:25 -0400 Subject: [PATCH 09/10] double down on invalid input text --- electron/ui/cypress/e2e/FlowsheetTesting.cy.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/electron/ui/cypress/e2e/FlowsheetTesting.cy.js b/electron/ui/cypress/e2e/FlowsheetTesting.cy.js index a8c242a6..7bbd0ddb 100644 --- a/electron/ui/cypress/e2e/FlowsheetTesting.cy.js +++ b/electron/ui/cypress/e2e/FlowsheetTesting.cy.js @@ -19,8 +19,11 @@ describe('WaterTAP UI Testing', () => { cy.load_flowsheet("RO with energy recovery flowsheet") cy.screenshot('loaded RO flowsheet'); - // set invalid text input + // set invalid text input. do it twice to ensure it registers in slow windows runner cy.set_ro_flowrate('dfas'); + cy.wait(1000) + cy.set_ro_flowrate('dfas'); + cy.wait(1000) cy.screenshot('invalid-text-input'); // solve flowsheet From b8c20a450c3093aae12a19b85336c11228179654 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Wed, 31 Jul 2024 07:06:22 -0500 Subject: [PATCH 10/10] turn video off for cypress --- electron/ui/cypress.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/electron/ui/cypress.config.js b/electron/ui/cypress.config.js index 701b3df0..1bd369ed 100644 --- a/electron/ui/cypress.config.js +++ b/electron/ui/cypress.config.js @@ -8,6 +8,6 @@ module.exports = defineConfig({ on('task', {downloadFile}); }, baseUrl: 'http://localhost:3000', - video: true + video: false }, }); \ No newline at end of file