Skip to content

Commit

Permalink
test for value change. add id for alert box.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sufi Kaur committed Sep 3, 2024
1 parent 04b8c5c commit 504cc5c
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 3 deletions.
57 changes: 56 additions & 1 deletion electron/ui/cypress/e2e/FlowsheetTesting.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,59 @@ describe('WaterTAP UI Testing', () => {

})
})
})

// RO is most kikely the most canonical
// Exclusively run on 'RO with energy recovery flowsheet'
it('input change flag for RO with energy recovery value change', () => {
cy.load_flowsheets_list()
cy.screenshot('loaded flowsheet list page')

const flowsheet_name = 'RO with energy recovery flowsheet'

// load flowsheet
cy.load_flowsheet(flowsheet_name)
cy.screenshot('loaded '+ flowsheet_name)

// solve flowsheet
cy.solve_flowsheet()
cy.screenshot("solved "+flowsheet_name)

// check no flag
cy.get('#inputChangeFlag').should('not.exist');
cy.screenshot('no-input-change-no-flag-'+flowsheet_name)

// go to inputs
cy.findByRole('tab', {name: /input/i}).click();
cy.screenshot('input-tab-click-' + flowsheet_name);
let username;

cy.findByRole('textbox', {name: 'Water mass flowrate'}).invoke('val').then((val) => {
const changed_val = val * 1.02

// change input
cy.enter_text('role' ,'textbox', changed_val, 'Water mass flowrate')

// Take the screenshot after the input has v has been logged
cy.screenshot('input-change-' + flowsheet_name);

});

// go to outputs
cy.findByRole('tab', {name: /output/i}).click()

// check for flag
cy.get('#inputChangeFlag').should('exist');
cy.screenshot('output-flag-after-input-change-flag' + flowsheet_name);

// return to inputs
cy.findByRole('tab', {name: /input/i}).click();

// solve flowsheet
cy.solve_flowsheet()

// check no flag after solving again
cy.get('#inputChangeFlag').should('not.exist');
cy.screenshot("re-solved-after-input-change-no-flag "+flowsheet_name)
})

})
8 changes: 7 additions & 1 deletion electron/ui/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,16 @@ Cypress.Commands.add('enter_text', (identifier, role_or_class, value, name ) =>
input_textbox.click({force:true});
if (identifier === "role") {
input_textbox = cy.findByRole(role_or_class, {name: name});
// input_textbox.clear().type(value)

}
else if (identifier === "class") {
input_textbox = cy.get('.'+role_or_class);
// input_textbox.type('{backspace}{backspace}{backspace}{backspace}' + value);

}
input_textbox.type('{backspace}{backspace}{backspace}{backspace}' + value);
input_textbox.clear().type(value)

// input_textbox.type('{backspace}{backspace}{backspace}{backspace}' + value);
cy.wait(500);
})
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function ConfigOutput(props) {
return (
<Box>
{inputsChanged ?
<Alert color="warning" severity='warning' >
<Alert id = 'inputChangeFlag' color="warning" severity='warning' >
Inputs changed since last run
</Alert> : <></>}
<Grid container spacing={2} alignItems="flex-start">
Expand Down

0 comments on commit 504cc5c

Please sign in to comment.