spiff-arena/spiffworkflow-frontend/cypress/e2e/process_models.cy.js

203 lines
7.8 KiB
JavaScript
Raw Normal View History

2022-11-23 14:38:45 +00:00
import { modifyProcessIdentifierForPathParam } from '../../src/helpers';
2022-12-14 22:09:43 +00:00
import { miscDisplayName } from '../support/helpers';
describe('process-models', () => {
beforeEach(() => {
cy.login();
});
afterEach(() => {
cy.logout();
});
2022-12-15 22:59:01 +00:00
const groupDisplayName = 'Acceptance Tests Group One';
const deleteProcessModelButtonId = 'delete-process-model-button';
const saveChangesButtonText = 'Save Changes';
2023-05-01 18:54:11 +00:00
const fileNameInputSelector = 'input#process_model_file_name';
2022-12-15 22:59:01 +00:00
it('can perform crud operations', () => {
const uuid = () => Cypress._.random(0, 1e6);
const id = uuid();
const groupId = 'misc/acceptance-tests-group-one';
const modelDisplayName = `Test Model 2 ${id}`;
const modelId = `test-model-2-${id}`;
const newModelDisplayName = `${modelDisplayName} edited`;
2022-12-14 22:09:43 +00:00
cy.contains(miscDisplayName).click();
cy.contains(groupDisplayName).click();
cy.createModel(groupId, modelId, modelDisplayName);
cy.url().should(
'include',
2022-11-23 14:38:45 +00:00
`process-models/${modifyProcessIdentifierForPathParam(
groupId
)}:${modelId}`
);
cy.contains(`Process Model: ${modelDisplayName}`);
2022-11-23 14:38:45 +00:00
cy.getBySel('edit-process-model-button').click();
2023-05-01 18:54:11 +00:00
cy.get('input[name=display_name]').clear();
cy.get('input[name=display_name]').type(newModelDisplayName);
cy.contains('Submit').click();
2022-11-23 14:38:45 +00:00
cy.contains(`Process Model: ${newModelDisplayName}`);
2022-12-15 22:59:01 +00:00
cy.deleteProcessModelAndConfirm(deleteProcessModelButtonId, groupId);
2022-11-21 02:28:23 +00:00
cy.contains(modelId).should('not.exist');
cy.contains(modelDisplayName).should('not.exist');
});
2022-12-30 14:30:44 +00:00
it('can create new bpmn and dmn and json files', () => {
const uuid = () => Cypress._.random(0, 1e6);
const id = uuid();
const directParentGroupId = 'acceptance-tests-group-one';
const groupId = `misc/${directParentGroupId}`;
const modelDisplayName = `Test Model 2 ${id}`;
const modelId = `test-model-2-${id}`;
const bpmnFileName = `bpmn_test_file_${id}`;
const dmnFileName = `dmn_test_file_${id}`;
const jsonFileName = `json_test_file_${id}`;
2023-05-01 18:54:11 +00:00
const decisionAcceptanceTestId = `decision_acceptance_test_${id}`;
2022-12-14 22:09:43 +00:00
cy.contains(miscDisplayName).click();
cy.contains(groupDisplayName).click();
cy.createModel(groupId, modelId, modelDisplayName);
cy.contains(groupDisplayName).click();
2022-11-23 14:38:45 +00:00
cy.contains(modelDisplayName).click();
cy.url().should(
'include',
2022-11-23 14:38:45 +00:00
`process-models/${modifyProcessIdentifierForPathParam(
groupId
)}:${modelId}`
);
cy.contains(`Process Model: ${modelDisplayName}`);
cy.contains(`${bpmnFileName}.bpmn`).should('not.exist');
cy.contains(`${dmnFileName}.dmn`).should('not.exist');
cy.contains(`${jsonFileName}.json`).should('not.exist');
// add new bpmn file
cy.getBySel('process-model-add-file').click();
cy.contains('New BPMN File').click();
cy.contains(/^Process Model File$/);
2023-05-01 18:54:11 +00:00
cy.get('g[data-element-id=StartEvent_1]').click();
cy.contains('General').click();
2023-05-01 18:54:11 +00:00
cy.get('#bio-properties-panel-name').clear();
cy.get('#bio-properties-panel-name').type('Start Event Name');
cy.wait(500);
cy.contains('Save').click();
cy.contains('Start Event Name');
cy.get(fileNameInputSelector).type(bpmnFileName);
cy.contains(saveChangesButtonText).click();
cy.contains(`Process Model File: ${bpmnFileName}`);
2022-12-15 22:59:01 +00:00
cy.contains(modelDisplayName).click();
cy.contains(`Process Model: ${modelDisplayName}`);
2022-11-21 02:28:23 +00:00
// cy.getBySel('files-accordion').click();
cy.contains(`${bpmnFileName}.bpmn`).should('exist');
// add new dmn file
cy.getBySel('process-model-add-file').click();
cy.contains('New DMN File').click();
cy.contains(/^Process Model File$/);
2023-05-01 18:54:11 +00:00
cy.get('g[data-element-id=decision_1]').click();
cy.contains('General').click();
2023-05-01 18:54:11 +00:00
cy.get('#bio-properties-panel-id').clear();
cy.get('#bio-properties-panel-id').type(decisionAcceptanceTestId);
2022-11-21 15:31:11 +00:00
cy.contains('General').click();
cy.contains('Save').click();
cy.get(fileNameInputSelector).type(dmnFileName);
cy.contains(saveChangesButtonText).click();
cy.contains(`Process Model File: ${dmnFileName}`);
2022-12-15 22:59:01 +00:00
cy.contains(modelDisplayName).click();
cy.contains(`Process Model: ${modelDisplayName}`);
2022-11-21 02:28:23 +00:00
// cy.getBySel('files-accordion').click();
cy.contains(`${dmnFileName}.dmn`).should('exist');
// add new json file
cy.getBySel('process-model-add-file').click();
cy.contains('New JSON File').click();
cy.contains(/^Process Model File$/);
// Some reason, cypress evals json strings so we have to escape it it with '{{}'
cy.get('.view-line').type('{{} "test_key": "test_value" }');
cy.getBySel('file-save-button').click();
cy.get(fileNameInputSelector).type(jsonFileName);
cy.contains(saveChangesButtonText).click();
cy.contains(`Process Model File: ${jsonFileName}`);
// wait for json to load before clicking away to avoid network errors
cy.wait(500);
2022-12-15 22:59:01 +00:00
cy.contains(modelDisplayName).click();
cy.contains(`Process Model: ${modelDisplayName}`);
2022-11-21 02:28:23 +00:00
// cy.getBySel('files-accordion').click();
cy.contains(`${jsonFileName}.json`).should('exist');
2022-12-15 22:59:01 +00:00
cy.deleteProcessModelAndConfirm(deleteProcessModelButtonId, groupId);
cy.contains(modelId).should('not.exist');
2022-11-23 14:38:45 +00:00
cy.contains(modelDisplayName).should('not.exist');
2022-12-30 14:30:44 +00:00
// we go back to the parent process group after deleting the model
cy.get('.tile-process-group-content-container').should('exist');
});
2023-05-10 18:05:07 +00:00
// FIXME: we currently do not know how to upload files since the new Add File
// component does not support the selectFile method
// it('can upload and run a bpmn file', () => {
// const uuid = () => Cypress._.random(0, 1e6);
// const id = uuid();
// const directParentGroupId = 'acceptance-tests-group-one';
// const groupId = `misc/${directParentGroupId}`;
// const modelDisplayName = `Test Model 2 ${id}`;
// const modelId = `test-model-2-${id}`;
// cy.contains('Add a process group');
// cy.contains(miscDisplayName).click();
// cy.contains(groupDisplayName).click();
// cy.createModel(groupId, modelId, modelDisplayName);
//
// cy.contains(`${groupDisplayName}`).click();
// cy.contains('Add a process model');
// cy.contains(modelDisplayName).click();
// cy.url().should(
// 'include',
// `process-models/${modifyProcessIdentifierForPathParam(
// groupId
// )}:${modelId}`
// );
// cy.contains(`Process Model: ${modelDisplayName}`);
//
// cy.getBySel('upload-file-button').click();
// cy.contains('Add file').selectFile(
// 'cypress/fixtures/test_bpmn_file_upload.bpmn'
// );
// cy.getBySel('modal-upload-file-dialog')
// .find('.cds--btn--primary')
// .contains('Upload')
// .click();
// cy.runPrimaryBpmnFile();
//
// cy.getBySel('process-instance-show-link-id').click();
// cy.getBySel('process-instance-delete').click();
// cy.contains('Are you sure');
// cy.getBySel('process-instance-delete-modal-confirmation-dialog')
// .find('.cds--btn--danger')
// .click();
//
// // in breadcrumb
// cy.contains(modelDisplayName).click();
//
// cy.getBySel(deleteProcessModelButtonId).click();
// cy.contains('Are you sure');
// cy.getBySel('delete-process-model-button-modal-confirmation-dialog')
// .find('.cds--btn--danger')
// .click();
// cy.url().should(
// 'include',
// `process-groups/${modifyProcessIdentifierForPathParam(groupId)}`
// );
// cy.contains(modelId).should('not.exist');
// cy.contains(modelDisplayName).should('not.exist');
// });
it('can allow searching for model', () => {
2023-05-01 18:54:11 +00:00
cy.getBySel('process-model-selection').click();
cy.getBySel('process-model-selection').type('model-3');
cy.contains('acceptance-tests-group-one/acceptance-tests-model-3').click();
cy.contains('Acceptance Tests Model 3');
});
});