From afa8aae60ef961c6b562dcb9996a13eb7305d1d0 Mon Sep 17 00:00:00 2001 From: jasquat Date: Wed, 9 Nov 2022 10:12:13 -0500 Subject: [PATCH] process model cypress tests are passing --- .../cypress/e2e/process_models.cy.js | 45 ++++++++----------- .../cypress/support/commands.js | 3 +- spiffworkflow-frontend/src/helpers.tsx | 17 +++---- .../src/routes/ProcessInstanceList.tsx | 6 ++- .../src/routes/ProcessModelEditDiagram.tsx | 6 +-- .../src/routes/ProcessModelShow.tsx | 4 +- .../src/routes/ReactFormEditor.tsx | 25 ++++++----- 7 files changed, 52 insertions(+), 54 deletions(-) diff --git a/spiffworkflow-frontend/cypress/e2e/process_models.cy.js b/spiffworkflow-frontend/cypress/e2e/process_models.cy.js index 22eb8b7ab..cc4ef606f 100644 --- a/spiffworkflow-frontend/cypress/e2e/process_models.cy.js +++ b/spiffworkflow-frontend/cypress/e2e/process_models.cy.js @@ -16,20 +16,14 @@ describe('process-models', () => { const modelId = `test-model-2-${id}`; cy.contains(groupDisplayName).click(); cy.createModel(groupId, modelId, modelDisplayName); - cy.contains(`Process Group: ${groupId}`).click(); - cy.contains(modelId); - - cy.contains(modelId).click(); - cy.url().should('include', `process-models/${groupId}/${modelId}`); - cy.contains(`Process Model: ${modelId}`); + cy.url().should('include', `process-models/${groupId}:${modelId}`); + cy.contains(`Process Model: ${modelDisplayName}`); cy.contains('Edit process model').click(); cy.get('input[name=display_name]').clear().type(newModelDisplayName); cy.contains('Submit').click(); - const modifiedModelId = cy.modifyProcessModelPath(modelId); - cy.contains(`Process Model: ${modifiedModelId}`); - - cy.contains('Edit process model').click(); + cy.contains(`Process Model: ${groupId}/${modelId}`); + cy.contains('Submit').click(); cy.get('input[name=display_name]').should( 'have.value', newModelDisplayName @@ -37,7 +31,7 @@ describe('process-models', () => { cy.contains('Delete').click(); cy.contains('Are you sure'); - cy.contains('OK').click(); + cy.getBySel('modal-confirmation-dialog').find('.cds--btn--danger').click(); cy.url().should('include', `process-groups/${groupId}`); cy.contains(modelId).should('not.exist'); }); @@ -57,8 +51,6 @@ describe('process-models', () => { cy.contains(groupDisplayName).click(); cy.createModel(groupId, modelId, modelDisplayName); cy.contains(groupId).click(); - cy.contains(modelId); - cy.contains(modelId).click(); cy.url().should('include', `process-models/${groupId}:${modelId}`); cy.contains(`Process Model: ${modelDisplayName}`); @@ -117,7 +109,7 @@ describe('process-models', () => { cy.contains('Edit process model').click(); cy.contains('Delete').click(); cy.contains('Are you sure'); - cy.contains('OK').click(); + cy.getBySel('modal-confirmation-dialog').find('.cds--btn--danger').click(); cy.url().should('include', `process-groups/${groupId}`); cy.contains(modelId).should('not.exist'); }); @@ -133,36 +125,35 @@ describe('process-models', () => { cy.contains(groupDisplayName).click(); cy.createModel(groupId, modelId, modelDisplayName); - // seeing if getBySel works better, because we are seeing tests fail in CI - // when looking for the "Add a process model" link, so it seems like the - // click on the breadcrumb element must have failed. - cy.getBySel('process-group-breadcrumb-link').click(); - // cy.contains(`Process Group: ${groupId}`).click(); - + cy.contains(`${groupId}`).click(); cy.contains('Add a process model'); - cy.contains(modelId).click(); - cy.url().should('include', `process-models/${groupId}/${modelId}`); - cy.contains(`Process Model: ${modelId}`); + cy.url().should('include', `process-models/${groupId}:${modelId}`); + cy.contains(`Process Model: ${modelDisplayName}`); - cy.get('input[type=file]').selectFile( + cy.getBySel('files-accordion').click(); + cy.getBySel('upload-file-button').click(); + cy.contains('Add file').selectFile( 'cypress/fixtures/test_bpmn_file_upload.bpmn' ); - cy.contains('Submit').click(); + cy.getBySel('modal-upload-file-dialog') + .find('.cds--btn--primary') + .contains('Upload') + .click(); cy.runPrimaryBpmnFile(); cy.getBySel('process-instance-list-link').click(); cy.getBySel('process-instance-show-link').click(); cy.contains('Delete').click(); cy.contains('Are you sure'); - cy.contains('OK').click(); + cy.getBySel('modal-confirmation-dialog').find('.cds--btn--danger').click(); cy.contains(`Process Instances for: ${groupId}/${modelId}`); cy.contains(modelId).click(); cy.contains('Edit process model').click(); cy.contains('Delete').click(); cy.contains('Are you sure'); - cy.contains('OK').click(); + cy.getBySel('modal-confirmation-dialog').find('.cds--btn--danger').click(); cy.url().should('include', `process-groups/${groupId}`); cy.contains(modelId).should('not.exist'); }); diff --git a/spiffworkflow-frontend/cypress/support/commands.js b/spiffworkflow-frontend/cypress/support/commands.js index 8602b572f..c6518917a 100644 --- a/spiffworkflow-frontend/cypress/support/commands.js +++ b/spiffworkflow-frontend/cypress/support/commands.js @@ -122,5 +122,6 @@ Cypress.Commands.add('assertNoItemInPaginatedResults', () => { }); Cypress.Commands.add('modifyProcessModelPath', (path) => { - return path.replace('/', ':') || ''; + path.replace('/', ':'); + return path; }); diff --git a/spiffworkflow-frontend/src/helpers.tsx b/spiffworkflow-frontend/src/helpers.tsx index 89521a3ab..adb28e731 100644 --- a/spiffworkflow-frontend/src/helpers.tsx +++ b/spiffworkflow-frontend/src/helpers.tsx @@ -95,13 +95,10 @@ export const getProcessModelFullIdentifierFromSearchParams = ( searchParams: any ) => { let processModelFullIdentifier = null; - if ( - searchParams.get('process_model_identifier') && - searchParams.get('process_group_identifier') - ) { + if (searchParams.get('process_model_identifier')) { processModelFullIdentifier = `${searchParams.get( - 'process_group_identifier' - )}/${searchParams.get('process_model_identifier')}`; + 'process_model_identifier' + )}`; } return processModelFullIdentifier; }; @@ -116,19 +113,19 @@ export const truncateString = (text: string, len: number) => { // Because of limitations in the way openapi defines parameters, we have to modify process models ids // which are basically paths to the models -export const modifyProcessModelPath = (path: String) => { +export const modifyProcessModelPath = (path: string) => { return path.replace('/', ':') || ''; }; -export const unModifyProcessModelPath = (path: String) => { +export const unModifyProcessModelPath = (path: string) => { return path.replace(':', '/') || ''; }; -export const getGroupFromModifiedModelId = (modifiedId: String) => { +export const getGroupFromModifiedModelId = (modifiedId: string) => { const finalSplitIndex = modifiedId.lastIndexOf(':'); return modifiedId.slice(0, finalSplitIndex); }; -export const splitProcessModelId = (processModelId: String) => { +export const splitProcessModelId = (processModelId: string) => { return processModelId.split('/'); }; diff --git a/spiffworkflow-frontend/src/routes/ProcessInstanceList.tsx b/spiffworkflow-frontend/src/routes/ProcessInstanceList.tsx index a515dfdd4..32b58ac32 100644 --- a/spiffworkflow-frontend/src/routes/ProcessInstanceList.tsx +++ b/spiffworkflow-frontend/src/routes/ProcessInstanceList.tsx @@ -461,7 +461,11 @@ export default function ProcessInstanceList() { return (

Process Instances for:{' '} - + {processModelFullIdentifier}

diff --git a/spiffworkflow-frontend/src/routes/ProcessModelEditDiagram.tsx b/spiffworkflow-frontend/src/routes/ProcessModelEditDiagram.tsx index 85dfc4822..ede6d85ce 100644 --- a/spiffworkflow-frontend/src/routes/ProcessModelEditDiagram.tsx +++ b/spiffworkflow-frontend/src/routes/ProcessModelEditDiagram.tsx @@ -776,9 +776,7 @@ export default function ProcessModelEditDiagram() { // if a file name is not given then this is a new model and the ReactDiagramEditor component will handle it if ((bpmnXmlForDiagramRendering || !params.file_name) && processModel) { - const processModelFileName = processModelFile - ? `: ${processModelFile.name}` - : ''; + const processModelFileName = processModelFile ? processModelFile.name : ''; return ( <>

- Process Model File + Process Model File{processModelFile ? ': ' : ''} {processModelFileName}

{appropriateEditor()} diff --git a/spiffworkflow-frontend/src/routes/ProcessModelShow.tsx b/spiffworkflow-frontend/src/routes/ProcessModelShow.tsx index cd8647423..7294112b7 100644 --- a/spiffworkflow-frontend/src/routes/ProcessModelShow.tsx +++ b/spiffworkflow-frontend/src/routes/ProcessModelShow.tsx @@ -400,13 +400,14 @@ export default function ProcessModelShow() { httpMethod: 'POST', postBody: formData, }); - setShowFileUploadModal(false); } + setShowFileUploadModal(false); }; const fileUploadModal = () => { return (