diff --git a/spiffworkflow-frontend/cypress.config.js b/spiffworkflow-frontend/cypress.config.js index 3ad774c86..f7f7b48c7 100644 --- a/spiffworkflow-frontend/cypress.config.js +++ b/spiffworkflow-frontend/cypress.config.js @@ -24,13 +24,19 @@ const deleteVideosOnSuccess = (on) => { }) } +let spiffWorkflowFrontendUrl = `http://localhost:${process.env.SPIFFWORKFLOW_FRONTEND_PORT || 7001}` + +if (process.env.SPIFFWORKFLOW_FRONTEND_URL) { + spiffWorkflowFrontendUrl = process.env.SPIFFWORKFLOW_FRONTEND_URL +} + const cypressConfig = { projectId: 'crax1q', videoUploadOnPasses: false, chromeWebSecurity: false, e2e: { - baseUrl: `http://localhost:${process.env.SPIFFWORKFLOW_FRONTEND_PORT || 7001}`, + baseUrl: spiffWorkflowFrontendUrl, setupNodeEvents(on, config) { deleteVideosOnSuccess(on) require('@cypress/grep/src/plugin')(config); diff --git a/spiffworkflow-frontend/cypress/e2e/pp1.cy.js b/spiffworkflow-frontend/cypress/e2e/pp1.cy.js new file mode 100644 index 000000000..05f1974a4 --- /dev/null +++ b/spiffworkflow-frontend/cypress/e2e/pp1.cy.js @@ -0,0 +1,111 @@ +const submitInputIntoFormField = (taskName, fieldKey, fieldValue) => { + cy.contains(`Task: ${taskName}`, { timeout: 10000 }); + cy.get(fieldKey).clear().type(fieldValue); + cy.contains('Submit').click(); +}; + +const checkFormFieldIsReadOnly = (formName, fieldKey) => { + cy.contains(`Task: ${formName}`); + cy.get(fieldKey).invoke('attr', 'disabled').should('exist'); +}; + +const checkTaskHasClass = (taskName, className) => { + cy.get(`g[data-element-id=${taskName}]`).should('have.class', className); +}; + +const kickOffModelWithForm = () => { + cy.navigateToProcessModel( + 'Acceptance Tests Group One', + 'Acceptance Tests Model 2' + ); + cy.runPrimaryBpmnFile(true); +}; + +describe('tasks', () => { + it.only('can run PP1', () => { + cy.login('core5.contributor', 'core5.contributor'); + cy.visit('/'); + cy.contains('Start New +').click(); + cy.contains('Raise New Demand Request'); + cy.runPrimaryBpmnFile(true); + + // const groupDisplayName = 'Acceptance Tests Group One'; + // const modelDisplayName = `Acceptance Tests Model 2`; + // const completedTaskClassName = 'completed-task-highlight'; + // const activeTaskClassName = 'active-task-highlight'; + // + // cy.navigateToProcessModel(groupDisplayName, modelDisplayName); + // + // submitInputIntoFormField( + // 'get_user_generated_number_one', + // '#root_user_generated_number_1', + // 2 + // ); + // submitInputIntoFormField( + // 'get_user_generated_number_two', + // '#root_user_generated_number_2', + // 3 + // ); + // + // cy.contains('Task: get_user_generated_number_three'); + // cy.getBySel('form-nav-form2').click(); + // checkFormFieldIsReadOnly( + // 'get_user_generated_number_two', + // '#root_user_generated_number_2' + // ); + // cy.getBySel('form-nav-form1').click(); + // checkFormFieldIsReadOnly( + // 'get_user_generated_number_one', + // '#root_user_generated_number_1' + // ); + // + // cy.getBySel('form-nav-form3').click(); + // submitInputIntoFormField( + // 'get_user_generated_number_three', + // '#root_user_generated_number_3', + // 4 + // ); + // + // cy.contains('Task: get_user_generated_number_four'); + // cy.navigateToProcessModel(groupDisplayName, modelDisplayName); + // cy.getBySel('process-instance-list-link').click(); + // cy.assertAtLeastOneItemInPaginatedResults(); + // + // // This should get the first one which should be the one we just completed + // cy.getBySel('process-instance-show-link').first().click(); + // cy.contains('Process Instance Id: '); + // + // cy.get(`g[data-element-id=form3]`).click(); + // cy.contains('"user_generated_number_1": 2'); + // cy.contains('"user_generated_number_2": 3'); + // cy.contains('"user_generated_number_3": 4'); + // cy.contains('"user_generated_number_4": 5').should('not.exist'); + // checkTaskHasClass('form1', completedTaskClassName); + // checkTaskHasClass('form2', completedTaskClassName); + // checkTaskHasClass('form3', completedTaskClassName); + // checkTaskHasClass('form4', activeTaskClassName); + // cy.get('.is-visible .cds--modal-close').click(); + // + // cy.navigateToHome(); + // cy.contains('Tasks').should('exist'); + // + // // FIXME: this will probably need a better way to link to the proper form that we want + // cy.contains('Go').click(); + // + // submitInputIntoFormField( + // 'get_user_generated_number_four', + // '#root_user_generated_number_4', + // 5 + // ); + // cy.url().should('include', '/tasks'); + // + // cy.navigateToProcessModel(groupDisplayName, modelDisplayName); + // cy.getBySel('process-instance-list-link').click(); + // cy.assertAtLeastOneItemInPaginatedResults(); + // + // // This should get the first one which should be the one we just completed + // cy.getBySel('process-instance-show-link').first().click(); + // cy.contains('Process Instance Id: '); + // cy.contains('Status: complete'); + }); +}); diff --git a/spiffworkflow-frontend/cypress/support/commands.js b/spiffworkflow-frontend/cypress/support/commands.js index adf3623c7..cb47e2c87 100644 --- a/spiffworkflow-frontend/cypress/support/commands.js +++ b/spiffworkflow-frontend/cypress/support/commands.js @@ -41,10 +41,15 @@ Cypress.Commands.add('navigateToAdmin', () => { cy.visit('/admin'); }); -Cypress.Commands.add('login', (selector, ...args) => { +Cypress.Commands.add('login', (username, password) => { + // Cypress.Commands.add('login', (selector, ...args) => { cy.visit('/admin'); - const username = Cypress.env('SPIFFWORKFLOW_FRONTEND_USERNAME') || 'ciadmin1'; - const password = Cypress.env('SPIFFWORKFLOW_FRONTEND_PASSWORD') || 'ciadmin1'; + if (!username) { + const username = + Cypress.env('SPIFFWORKFLOW_FRONTEND_USERNAME') || 'ciadmin1'; + const password = + Cypress.env('SPIFFWORKFLOW_FRONTEND_PASSWORD') || 'ciadmin1'; + } cy.get('#username').type(username); cy.get('#password').type(password); if (Cypress.env('SPIFFWORKFLOW_FRONTEND_AUTH_WITH_KEYCLOAK') === true) { @@ -97,7 +102,8 @@ Cypress.Commands.add('createModel', (groupId, modelId, modelDisplayName) => { Cypress.Commands.add( 'runPrimaryBpmnFile', (expectAutoRedirectToHumanTask = false) => { - cy.contains('Start').click(); + cy.getBySel('start-process-instance').click(); + // cy.contains('Start').click(); if (expectAutoRedirectToHumanTask) { // the url changes immediately, so also make sure we get some content from the next page, "Task:", or else when we try to interact with the page, it'll re-render and we'll get an error with cypress. cy.url().should('include', `/tasks/`); diff --git a/spiffworkflow-frontend/src/components/ProcessInstanceRun.tsx b/spiffworkflow-frontend/src/components/ProcessInstanceRun.tsx index 37261d70d..b4ad4eeff 100644 --- a/spiffworkflow-frontend/src/components/ProcessInstanceRun.tsx +++ b/spiffworkflow-frontend/src/components/ProcessInstanceRun.tsx @@ -126,7 +126,11 @@ export default function ProcessInstanceRun({ if (checkPermissions) { return ( -