2022-06-24 15:18:25 -04:00
|
|
|
import { DATE_FORMAT, PROCESS_STATUSES } from '../../src/config';
|
|
|
|
import { format } from 'date-fns';
|
|
|
|
|
2022-06-17 14:28:47 -04:00
|
|
|
describe('process-instances', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.visit('/');
|
2022-06-20 14:45:15 -04:00
|
|
|
cy.contains('acceptance-tests-group-one').click();
|
|
|
|
cy.contains('acceptance-tests-model-1').click();
|
2022-06-17 14:28:47 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('can create a new instance and can modify', () => {
|
2022-06-17 17:03:20 -04:00
|
|
|
const originalDmnOutputForKevin = "Very wonderful";
|
|
|
|
const newDmnOutputForKevin = "The new wonderful";
|
|
|
|
const dmnOutputForDan = "pretty wonderful";
|
|
|
|
|
|
|
|
const originalPythonScript = 'person = "Kevin"';
|
|
|
|
const newPythonScript = 'person = "Dan"';
|
|
|
|
|
2022-06-17 14:28:47 -04:00
|
|
|
const dmnFile = "awesome_decision.dmn";
|
|
|
|
const bpmnFile = "process_model_one.bpmn";
|
|
|
|
|
2022-06-17 17:03:20 -04:00
|
|
|
cy.contains(originalDmnOutputForKevin).should('not.exist');;
|
2022-06-20 16:43:47 -04:00
|
|
|
cy.runPrimaryBpmnFile(originalDmnOutputForKevin);
|
2022-06-17 17:03:20 -04:00
|
|
|
|
|
|
|
// Change dmn
|
|
|
|
cy.contains(dmnFile).click();
|
|
|
|
cy.contains(`Process Model File: ${dmnFile}`);
|
|
|
|
updateDmnText(originalDmnOutputForKevin, newDmnOutputForKevin);
|
2022-06-17 14:28:47 -04:00
|
|
|
|
2022-06-17 17:03:20 -04:00
|
|
|
cy.contains('acceptance-tests-model-1').click();
|
2022-06-20 16:43:47 -04:00
|
|
|
cy.runPrimaryBpmnFile(newDmnOutputForKevin);
|
2022-06-17 17:03:20 -04:00
|
|
|
|
|
|
|
cy.contains(dmnFile).click();
|
|
|
|
cy.contains(`Process Model File: ${dmnFile}`);
|
|
|
|
updateDmnText(newDmnOutputForKevin, originalDmnOutputForKevin);
|
|
|
|
cy.contains('acceptance-tests-model-1').click();
|
2022-06-20 16:43:47 -04:00
|
|
|
cy.runPrimaryBpmnFile(originalDmnOutputForKevin);
|
2022-06-17 14:28:47 -04:00
|
|
|
|
|
|
|
// Change bpmn
|
|
|
|
cy.contains(bpmnFile).click();
|
|
|
|
cy.contains(`Process Model File: ${bpmnFile}`);
|
2022-06-24 11:04:10 -04:00
|
|
|
updateBpmnPythonScript(newPythonScript);
|
2022-06-17 17:03:20 -04:00
|
|
|
cy.contains('acceptance-tests-model-1').click();
|
2022-06-20 16:43:47 -04:00
|
|
|
cy.runPrimaryBpmnFile(dmnOutputForDan);
|
2022-06-17 14:28:47 -04:00
|
|
|
|
2022-06-17 17:03:20 -04:00
|
|
|
cy.contains(bpmnFile).click();
|
|
|
|
cy.contains(`Process Model File: ${bpmnFile}`);
|
2022-06-24 11:04:10 -04:00
|
|
|
updateBpmnPythonScript(originalPythonScript);
|
2022-06-17 17:03:20 -04:00
|
|
|
cy.contains('acceptance-tests-model-1').click();
|
2022-06-20 16:43:47 -04:00
|
|
|
cy.runPrimaryBpmnFile(originalDmnOutputForKevin);
|
2022-06-17 14:28:47 -04:00
|
|
|
});
|
|
|
|
|
2022-06-20 14:45:15 -04:00
|
|
|
it('can create a new instance and can modify with monaco text editor', () => {
|
|
|
|
const dmnOutputForKevin = "Very wonderful";
|
|
|
|
const dmnOutputForMike = "Powerful wonderful";
|
|
|
|
const originalPythonScript = 'person = "Kevin"';
|
|
|
|
const newPythonScript = 'person = "Mike"';
|
|
|
|
const bpmnFile = "process_model_one.bpmn";
|
|
|
|
|
|
|
|
// Change bpmn
|
|
|
|
cy.contains(bpmnFile).click();
|
|
|
|
cy.contains(`Process Model File: ${bpmnFile}`);
|
|
|
|
updateBpmnPythonScriptWithMonaco(newPythonScript, bpmnFile);
|
|
|
|
cy.contains('acceptance-tests-model-1').click();
|
2022-06-20 16:43:47 -04:00
|
|
|
cy.runPrimaryBpmnFile(dmnOutputForMike);
|
2022-06-20 14:45:15 -04:00
|
|
|
|
|
|
|
cy.contains(bpmnFile).click();
|
|
|
|
cy.contains(`Process Model File: ${bpmnFile}`);
|
|
|
|
updateBpmnPythonScriptWithMonaco(originalPythonScript, bpmnFile);
|
|
|
|
cy.contains('acceptance-tests-model-1').click();
|
2022-06-20 16:43:47 -04:00
|
|
|
cy.runPrimaryBpmnFile(dmnOutputForKevin);
|
2022-06-20 14:45:15 -04:00
|
|
|
});
|
|
|
|
|
2022-06-24 16:07:55 -04:00
|
|
|
it('can paginate items', () => {
|
2022-06-20 14:45:15 -04:00
|
|
|
// make sure we have some process instances
|
2022-06-20 16:43:47 -04:00
|
|
|
cy.runPrimaryBpmnFile('Very wonderful');
|
|
|
|
cy.runPrimaryBpmnFile('Very wonderful');
|
|
|
|
cy.runPrimaryBpmnFile('Very wonderful');
|
|
|
|
cy.runPrimaryBpmnFile('Very wonderful');
|
|
|
|
cy.runPrimaryBpmnFile('Very wonderful');
|
2022-06-20 14:45:15 -04:00
|
|
|
|
|
|
|
cy.contains('Process Instances').click();
|
|
|
|
cy.basicPaginationTest();
|
2022-06-24 11:04:10 -04:00
|
|
|
});
|
|
|
|
|
2022-06-24 15:50:00 -04:00
|
|
|
it('can filter', () => {
|
2022-06-24 11:04:10 -04:00
|
|
|
cy.contains('Process Instances').click();
|
2022-06-24 12:30:59 -04:00
|
|
|
assertAtLeastOneItemInPaginatedResults();
|
2022-06-24 15:18:25 -04:00
|
|
|
|
|
|
|
for (const processStatus of PROCESS_STATUSES) {
|
|
|
|
if (processStatus === "all"){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
cy.getBySel("process-status-dropdown")
|
|
|
|
.type("typing_to_open_dropdown_box....FIXME")
|
|
|
|
.find('.dropdown-item')
|
|
|
|
.contains(new RegExp(`^${processStatus}$`))
|
|
|
|
.click();
|
|
|
|
cy.contains('Filter').click();
|
|
|
|
assertAtLeastOneItemInPaginatedResults();
|
|
|
|
cy.getBySel("process-instance-status").first().contains(processStatus);
|
|
|
|
}
|
2022-06-24 11:04:10 -04:00
|
|
|
cy.getBySel("process-status-dropdown")
|
|
|
|
.type("typing_to_open_dropdown_box....FIXME")
|
|
|
|
.find('.dropdown-item')
|
2022-06-24 15:18:25 -04:00
|
|
|
.contains("all")
|
2022-06-24 11:04:10 -04:00
|
|
|
.click();
|
2022-06-24 15:18:25 -04:00
|
|
|
|
|
|
|
let date = new Date();
|
|
|
|
date.setHours(date.getHours() - 1);
|
|
|
|
filterByDate(date);
|
|
|
|
assertAtLeastOneItemInPaginatedResults();
|
2022-06-24 16:07:55 -04:00
|
|
|
|
|
|
|
// make sure we are at the bottom of the page
|
|
|
|
cy.scrollTo(0, 1000)
|
2022-06-24 15:18:25 -04:00
|
|
|
cy.getBySel("process-instance-status").contains("not_started");
|
|
|
|
|
|
|
|
date.setHours(date.getHours() + 2);
|
|
|
|
filterByDate(date);
|
|
|
|
assertNoItemInPaginatedResults();
|
|
|
|
cy.getBySel("process-instance-status").should('not.exist');
|
2022-06-24 11:04:10 -04:00
|
|
|
});
|
2022-06-17 14:28:47 -04:00
|
|
|
})
|
|
|
|
|
2022-06-24 15:18:25 -04:00
|
|
|
const filterByDate = ((fromDate) => {
|
|
|
|
cy.get("#date-picker-start-from").clear().type(format(fromDate, DATE_FORMAT));
|
|
|
|
cy.contains('Start Range').click();
|
|
|
|
cy.get("#date-picker-end-from").clear().type(format(fromDate, DATE_FORMAT));
|
|
|
|
cy.contains('Start Range').click();
|
|
|
|
cy.contains('Filter').click();
|
|
|
|
});
|
|
|
|
|
2022-06-24 12:30:59 -04:00
|
|
|
const assertAtLeastOneItemInPaginatedResults = (() => {
|
2022-06-24 15:18:25 -04:00
|
|
|
cy.getBySel('total-paginated-items')
|
2022-06-24 12:30:59 -04:00
|
|
|
.invoke('text')
|
|
|
|
.then(parseFloat)
|
|
|
|
.should('be.gt', 0)
|
|
|
|
});
|
|
|
|
|
2022-06-24 15:18:25 -04:00
|
|
|
const assertNoItemInPaginatedResults = (() => {
|
|
|
|
cy.getBySel('total-paginated-items').contains('0')
|
|
|
|
});
|
|
|
|
|
2022-06-24 12:30:59 -04:00
|
|
|
const updateDmnText = ((oldText, newText, elementId="wonderful_process") => {
|
2022-06-17 14:28:47 -04:00
|
|
|
// this will break if there are more elements added to the drd
|
2022-06-17 17:03:20 -04:00
|
|
|
cy.get(`g[data-element-id=${elementId}]`).click().should('exist');
|
2022-06-17 14:28:47 -04:00
|
|
|
cy.get('.dmn-icon-decision-table').click();
|
|
|
|
cy.contains(oldText).clear().type(`"${newText}"`);
|
|
|
|
|
2022-06-20 10:57:08 -04:00
|
|
|
// wait for a little bit for the xml to get set before saving
|
|
|
|
cy.wait(500);
|
2022-06-17 14:28:47 -04:00
|
|
|
cy.contains('Save').click();
|
2022-06-24 12:30:59 -04:00
|
|
|
});
|
2022-06-20 09:21:35 -04:00
|
|
|
|
2022-06-24 12:30:59 -04:00
|
|
|
const updateBpmnPythonScript = ((pythonScript, elementId="process_script") => {
|
2022-06-17 17:03:20 -04:00
|
|
|
cy.get(`g[data-element-id=${elementId}]`).click().should('exist');
|
|
|
|
cy.contains('SpiffWorkflow Properties').click();
|
|
|
|
cy.get('#bio-properties-panel-pythonScript').clear().type(pythonScript);
|
2022-06-20 10:57:08 -04:00
|
|
|
|
|
|
|
// wait for a little bit for the xml to get set before saving
|
|
|
|
cy.wait(500);
|
2022-06-17 17:03:20 -04:00
|
|
|
cy.contains('Save').click();
|
2022-06-24 12:30:59 -04:00
|
|
|
});
|
2022-06-20 14:45:15 -04:00
|
|
|
|
2022-06-24 12:30:59 -04:00
|
|
|
const updateBpmnPythonScriptWithMonaco = ((pythonScript, bpmnFile, elementId="process_script") => {
|
2022-06-20 14:45:15 -04:00
|
|
|
cy.get(`g[data-element-id=${elementId}]`).click().should('exist');
|
|
|
|
cy.contains('SpiffWorkflow Properties').click();
|
|
|
|
cy.contains('Launch Editor').click();
|
|
|
|
cy.contains("Loading...").should('not.exist');
|
|
|
|
cy.get('.monaco-editor textarea:first')
|
|
|
|
.click()
|
|
|
|
.focused() // change subject to currently focused element
|
|
|
|
.type('{ctrl}a')
|
|
|
|
.type(pythonScript)
|
|
|
|
|
|
|
|
cy.contains('Close').click();
|
|
|
|
// wait for a little bit for the xml to get set before saving
|
|
|
|
cy.wait(500);
|
|
|
|
cy.contains('Save').click();
|
2022-06-24 12:30:59 -04:00
|
|
|
});
|