From 76050f602f0bf37df4bfc19a3558194af3e135c3 Mon Sep 17 00:00:00 2001 From: jasquat Date: Wed, 23 Nov 2022 09:38:45 -0500 Subject: [PATCH] fixed cypress tests --- .../cypress/e2e/process_groups.cy.js | 10 +--- .../cypress/e2e/process_models.cy.js | 57 +++++++++++-------- .../cypress/support/commands.js | 16 ++---- .../src/components/ProcessModelListTiles.tsx | 1 + 4 files changed, 40 insertions(+), 44 deletions(-) diff --git a/spiffworkflow-frontend/cypress/e2e/process_groups.cy.js b/spiffworkflow-frontend/cypress/e2e/process_groups.cy.js index 85ab9b82..bef0e560 100644 --- a/spiffworkflow-frontend/cypress/e2e/process_groups.cy.js +++ b/spiffworkflow-frontend/cypress/e2e/process_groups.cy.js @@ -19,18 +19,12 @@ describe('process-groups', () => { cy.url().should('include', `process-groups/${groupId}`); cy.contains(`Process Group: ${groupDisplayName}`); - cy.contains('Edit process group').click(); + cy.getBySel('edit-process-group-button').click(); cy.get('input[name=display_name]').clear().type(newGroupDisplayName); cy.contains('Submit').click(); cy.contains(`Process Group: ${newGroupDisplayName}`); - cy.contains('Edit process group').click(); - cy.get('input[name=display_name]').should( - 'have.value', - newGroupDisplayName - ); - - cy.contains('Delete').click(); + cy.getBySel('delete-process-group-button').click(); cy.contains('Are you sure'); cy.getBySel('delete-process-group-button-modal-confirmation-dialog') .find('.cds--btn--danger') diff --git a/spiffworkflow-frontend/cypress/e2e/process_models.cy.js b/spiffworkflow-frontend/cypress/e2e/process_models.cy.js index 4bc75ead..4fd1b481 100644 --- a/spiffworkflow-frontend/cypress/e2e/process_models.cy.js +++ b/spiffworkflow-frontend/cypress/e2e/process_models.cy.js @@ -1,4 +1,4 @@ -import { modifyProcessModelPath } from '../../src/helpers'; +import { modifyProcessIdentifierForPathParam } from '../../src/helpers'; describe('process-models', () => { beforeEach(() => { @@ -16,25 +16,22 @@ describe('process-models', () => { const modelDisplayName = `Test Model 2 ${id}`; const modelId = `test-model-2-${id}`; const newModelDisplayName = `${modelDisplayName} edited`; - cy.contains('Misc').click(); + cy.contains('99-Shared Resources').click(); cy.wait(500); cy.contains(groupDisplayName).click(); cy.createModel(groupId, modelId, modelDisplayName); cy.url().should( 'include', - `process-models/${modifyProcessModelPath(groupId)}:${modelId}` + `process-models/${modifyProcessIdentifierForPathParam( + groupId + )}:${modelId}` ); cy.contains(`Process Model: ${modelDisplayName}`); - cy.contains('Edit process model').click(); + cy.getBySel('edit-process-model-button').click(); cy.get('input[name=display_name]').clear().type(newModelDisplayName); cy.contains('Submit').click(); - cy.contains(`Process Model: ${groupId}/${modelId}`); - cy.contains('Submit').click(); - cy.get('input[name=display_name]').should( - 'have.value', - newModelDisplayName - ); + cy.contains(`Process Model: ${newModelDisplayName}`); // go back to process model show by clicking on the breadcrumb cy.contains(modelId).click(); @@ -46,7 +43,7 @@ describe('process-models', () => { .click(); cy.url().should( 'include', - `process-groups/${modifyProcessModelPath(groupId)}` + `process-groups/${modifyProcessIdentifierForPathParam(groupId)}` ); cy.contains(modelId).should('not.exist'); }); @@ -64,15 +61,17 @@ describe('process-models', () => { const dmnFileName = `dmn_test_file_${id}`; const jsonFileName = `json_test_file_${id}`; - cy.contains('Misc').click(); + cy.contains('99-Shared Resources').click(); cy.wait(500); cy.contains(groupDisplayName).click(); cy.createModel(groupId, modelId, modelDisplayName); cy.contains(directParentGroupId).click(); - cy.contains(modelId).click(); + cy.contains(modelDisplayName).click(); cy.url().should( 'include', - `process-models/${modifyProcessModelPath(groupId)}:${modelId}` + `process-models/${modifyProcessIdentifierForPathParam( + groupId + )}:${modelId}` ); cy.contains(`Process Model: ${modelDisplayName}`); cy.contains(`${bpmnFileName}.bpmn`).should('not.exist'); @@ -135,8 +134,12 @@ describe('process-models', () => { cy.getBySel('delete-process-model-button-modal-confirmation-dialog') .find('.cds--btn--danger') .click(); - cy.url().should('include', `process-groups/${modifyProcessModelPath(groupId)}`); + cy.url().should( + 'include', + `process-groups/${modifyProcessIdentifierForPathParam(groupId)}` + ); cy.contains(modelId).should('not.exist'); + cy.contains(modelDisplayName).should('not.exist'); }); it('can upload and run a bpmn file', () => { @@ -148,17 +151,19 @@ describe('process-models', () => { const modelDisplayName = `Test Model 2 ${id}`; const modelId = `test-model-2-${id}`; cy.contains('Add a process group'); - cy.contains('Misc').click(); + cy.contains('99-Shared Resources').click(); cy.wait(500); cy.contains(groupDisplayName).click(); cy.createModel(groupId, modelId, modelDisplayName); cy.contains(`${directParentGroupId}`).click(); cy.contains('Add a process model'); - cy.contains(modelId).click(); + cy.contains(modelDisplayName).click(); cy.url().should( 'include', - `process-models/${modifyProcessModelPath(groupId)}:${modelId}` + `process-models/${modifyProcessIdentifierForPathParam( + groupId + )}:${modelId}` ); cy.contains(`Process Model: ${modelDisplayName}`); @@ -190,17 +195,19 @@ describe('process-models', () => { .click(); cy.url().should( 'include', - `process-groups/${modifyProcessModelPath(groupId)}` + `process-groups/${modifyProcessIdentifierForPathParam(groupId)}` ); cy.contains(modelId).should('not.exist'); + cy.contains(modelDisplayName).should('not.exist'); }); - it('can paginate items', () => { - cy.contains('Misc').click(); - cy.wait(500); - cy.contains('Acceptance Tests Group One').click(); - cy.basicPaginationTest(); - }); + // process models no longer has pagination post-tiles + // it.only('can paginate items', () => { + // cy.contains('99-Shared Resources').click(); + // cy.wait(500); + // cy.contains('Acceptance Tests Group One').click(); + // cy.basicPaginationTest(); + // }); it('can allow searching for model', () => { cy.getBySel('process-model-selection').click().type('model-3'); diff --git a/spiffworkflow-frontend/cypress/support/commands.js b/spiffworkflow-frontend/cypress/support/commands.js index 60ffd791..f0034168 100644 --- a/spiffworkflow-frontend/cypress/support/commands.js +++ b/spiffworkflow-frontend/cypress/support/commands.js @@ -1,5 +1,5 @@ import { string } from 'prop-types'; -import { modifyProcessModelPath } from '../../src/helpers'; +import { modifyProcessIdentifierForPathParam } from '../../src/helpers'; // *********************************************** // This example commands.js shows you how to @@ -78,8 +78,7 @@ Cypress.Commands.add('createModel', (groupId, modelId, modelDisplayName) => { cy.url().should( 'include', - `process-models/${modifyProcessModelPath(groupId)}:${modelId}` - // `process-models/${groupId}:${modelId}` + `process-models/${modifyProcessIdentifierForPathParam(groupId)}:${modelId}` ); cy.contains(`Process Model: ${modelDisplayName}`); }); @@ -104,12 +103,12 @@ Cypress.Commands.add( 'navigateToProcessModel', (groupDisplayName, modelDisplayName, modelIdentifier) => { cy.navigateToAdmin(); - cy.contains('Misc').click(); - cy.contains(`Process Group: 99-Misc`, { timeout: 10000 }); + cy.contains('99-Shared Resources').click(); + cy.contains(`Process Group: 99-Shared Resources`, { timeout: 10000 }); cy.contains(groupDisplayName).click(); cy.contains(`Process Group: ${groupDisplayName}`); // https://stackoverflow.com/q/51254946/6090676 - cy.getBySel('process-model-show-link').contains(modelIdentifier).click(); + cy.getBySel('process-model-show-link').contains(modelDisplayName).click(); cy.contains(`Process Model: ${modelDisplayName}`); } ); @@ -133,8 +132,3 @@ Cypress.Commands.add('assertAtLeastOneItemInPaginatedResults', () => { Cypress.Commands.add('assertNoItemInPaginatedResults', () => { cy.contains(/\b0–0 of 0 items/); }); - -Cypress.Commands.add('modifyProcessModelPath', (path) => { - path.replace('/', ':'); - return path; -}); diff --git a/spiffworkflow-frontend/src/components/ProcessModelListTiles.tsx b/spiffworkflow-frontend/src/components/ProcessModelListTiles.tsx index 3b0292bb..f42a032d 100644 --- a/spiffworkflow-frontend/src/components/ProcessModelListTiles.tsx +++ b/spiffworkflow-frontend/src/components/ProcessModelListTiles.tsx @@ -79,6 +79,7 @@ export default function ProcessModelListTiles({