2022-10-12 14:21:49 +00:00
|
|
|
import { format } from 'date-fns';
|
|
|
|
import { DATE_FORMAT, PROCESS_STATUSES } from '../../src/config';
|
2023-04-28 15:56:52 +00:00
|
|
|
import { titleizeString } from '../../src/helpers';
|
2022-10-12 14:21:49 +00:00
|
|
|
|
|
|
|
const filterByDate = (fromDate) => {
|
2023-05-10 18:05:07 +00:00
|
|
|
cy.get('#date-picker-start-from').clear();
|
|
|
|
cy.get('#date-picker-start-from').type(format(fromDate, DATE_FORMAT));
|
2022-11-21 20:16:54 +00:00
|
|
|
cy.contains('Start date to').click();
|
2023-05-10 18:05:07 +00:00
|
|
|
cy.get('#date-picker-end-from').clear();
|
|
|
|
cy.get('#date-picker-end-from').type(format(fromDate, DATE_FORMAT));
|
2022-11-21 20:16:54 +00:00
|
|
|
cy.contains('End date to').click();
|
2022-11-09 17:33:43 +00:00
|
|
|
cy.getBySel('filter-button').click();
|
2022-10-12 14:21:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const updateDmnText = (oldText, newText, elementId = 'wonderful_process') => {
|
|
|
|
// this will break if there are more elements added to the drd
|
2023-05-10 18:05:07 +00:00
|
|
|
cy.get(`g[data-element-id=${elementId}]`).click();
|
2022-10-12 14:21:49 +00:00
|
|
|
cy.get('.dmn-icon-decision-table').click();
|
2024-01-09 19:00:53 +00:00
|
|
|
|
|
|
|
// We used to use the line:
|
|
|
|
// cy.contains(oldText).clear().type(`"${newText}"`);
|
|
|
|
// but it broke when we upgraded dmn-js to v15 so after clearing it could not type in the cell.
|
|
|
|
// Clicking outside the cell seems to allow it to type it in it again so try that.
|
|
|
|
const item = cy.contains(oldText);
|
|
|
|
item.clear();
|
|
|
|
cy.contains('Process Model File:').click();
|
|
|
|
item.type(`"${newText}"`);
|
2022-10-12 14:21:49 +00:00
|
|
|
|
|
|
|
// wait for a little bit for the xml to get set before saving
|
|
|
|
// FIXME: gray out save button or add spinner while xml is loading
|
|
|
|
cy.wait(500);
|
|
|
|
cy.contains('Save').click();
|
|
|
|
};
|
|
|
|
|
|
|
|
const updateBpmnPythonScript = (pythonScript, elementId = 'process_script') => {
|
2023-05-10 18:05:07 +00:00
|
|
|
cy.get(`g[data-element-id=${elementId}]`).click();
|
2022-10-12 14:21:49 +00:00
|
|
|
cy.contains(/^Script$/).click();
|
2023-05-10 18:05:07 +00:00
|
|
|
cy.get('textarea[name="pythonScript_bpmn:script"]').clear();
|
|
|
|
cy.get('textarea[name="pythonScript_bpmn:script"]').type(pythonScript);
|
2022-10-12 14:21:49 +00:00
|
|
|
|
|
|
|
// wait for a little bit for the xml to get set before saving
|
|
|
|
cy.wait(500);
|
|
|
|
cy.contains('Save').click();
|
|
|
|
};
|
|
|
|
|
2023-09-07 16:41:50 +00:00
|
|
|
// NOTE: anytime the status dropdown box is clicked on, click off of it
|
|
|
|
// by going to a completely different element like the page header.
|
|
|
|
const clickOnHeaderToMakeSureMultiSelectComponentStateIsStable = () => {
|
|
|
|
cy.contains('All Process Instances').click();
|
|
|
|
};
|
|
|
|
|
2023-05-10 18:05:07 +00:00
|
|
|
// const updateBpmnPythonScriptWithMonaco = (
|
|
|
|
// pythonScript,
|
|
|
|
// elementId = 'process_script'
|
|
|
|
// ) => {
|
|
|
|
// cy.get(`g[data-element-id=${elementId}]`).click();
|
|
|
|
// // sometimes, we click on the script task and panel doesn't update to include script task stuff. not sure why.
|
|
|
|
// cy.contains(/^Script$/).click();
|
|
|
|
// cy.contains('Launch Editor').click();
|
|
|
|
// // sometimes, Loading... appears for more than 4 seconds. not sure why.
|
|
|
|
// cy.contains('Loading...').should('not.exist');
|
|
|
|
//
|
|
|
|
// // the delay 30 is because, at some point, monaco started automatically
|
|
|
|
// // adding a second double quote when we type a double quote. when it does
|
|
|
|
// // that, there is a race condition where it sometimes gets in more text
|
|
|
|
// // before the second double quote appears because the robot is typing faster
|
|
|
|
// // than a human being could, so we artificially slow it down to make it more
|
|
|
|
// // human.
|
|
|
|
// cy.get('.monaco-editor textarea:first').click();
|
|
|
|
// cy.get('.monaco-editor textarea:first').focused(); // change subject to currently focused element
|
|
|
|
// cy.get('.monaco-editor textarea:first').clear();
|
|
|
|
// // long delay to ensure cypress isn't competing with monaco auto complete stuff
|
|
|
|
// cy.get('.monaco-editor textarea:first').type(pythonScript, { delay: 120 });
|
|
|
|
//
|
|
|
|
// 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-10-12 14:21:49 +00:00
|
|
|
|
|
|
|
describe('process-instances', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.login();
|
|
|
|
cy.navigateToProcessModel(
|
|
|
|
'Acceptance Tests Group One',
|
2022-12-27 20:42:22 +00:00
|
|
|
'Acceptance Tests Model 1'
|
2022-10-12 14:21:49 +00:00
|
|
|
);
|
|
|
|
});
|
|
|
|
afterEach(() => {
|
|
|
|
cy.logout();
|
|
|
|
});
|
|
|
|
|
2022-11-08 22:20:17 +00:00
|
|
|
it('can create a new instance and can modify', () => {
|
2022-10-12 14:21:49 +00:00
|
|
|
const originalDmnOutputForKevin = 'Very wonderful';
|
|
|
|
const newDmnOutputForKevin = 'The new wonderful';
|
2022-12-27 20:42:22 +00:00
|
|
|
const acceptanceTestOneDisplayName = 'Acceptance Tests Model 1';
|
2022-10-12 14:21:49 +00:00
|
|
|
|
|
|
|
const originalPythonScript = 'person = "Kevin"';
|
|
|
|
const newPythonScript = 'person = "Dan"';
|
|
|
|
|
|
|
|
const dmnFile = 'awesome_decision.dmn';
|
|
|
|
const bpmnFile = 'process_model_one.bpmn';
|
|
|
|
|
|
|
|
cy.contains(originalDmnOutputForKevin).should('not.exist');
|
|
|
|
cy.runPrimaryBpmnFile();
|
|
|
|
|
|
|
|
// Change dmn
|
2023-09-26 14:30:11 +00:00
|
|
|
cy.getBySel('process-model-files').click();
|
2022-11-08 22:20:17 +00:00
|
|
|
cy.getBySel(`edit-file-${dmnFile.replace('.', '-')}`).click();
|
2022-10-12 14:21:49 +00:00
|
|
|
updateDmnText(originalDmnOutputForKevin, newDmnOutputForKevin);
|
|
|
|
|
2022-12-27 20:42:22 +00:00
|
|
|
cy.contains(acceptanceTestOneDisplayName).click();
|
2022-10-12 14:21:49 +00:00
|
|
|
cy.runPrimaryBpmnFile();
|
|
|
|
|
2023-09-26 14:30:11 +00:00
|
|
|
cy.getBySel('process-model-files').click();
|
2022-11-08 22:20:17 +00:00
|
|
|
cy.getBySel(`edit-file-${dmnFile.replace('.', '-')}`).click();
|
2022-10-12 14:21:49 +00:00
|
|
|
updateDmnText(newDmnOutputForKevin, originalDmnOutputForKevin);
|
2022-12-27 20:42:22 +00:00
|
|
|
cy.contains(acceptanceTestOneDisplayName).click();
|
2022-10-12 14:21:49 +00:00
|
|
|
cy.runPrimaryBpmnFile();
|
|
|
|
|
|
|
|
// Change bpmn
|
2023-09-26 14:30:11 +00:00
|
|
|
cy.getBySel('process-model-files').click();
|
2022-11-08 22:20:17 +00:00
|
|
|
cy.getBySel(`edit-file-${bpmnFile.replace('.', '-')}`).click();
|
2022-10-12 14:21:49 +00:00
|
|
|
cy.contains(`Process Model File: ${bpmnFile}`);
|
|
|
|
updateBpmnPythonScript(newPythonScript);
|
2022-12-27 20:42:22 +00:00
|
|
|
cy.contains(acceptanceTestOneDisplayName).click();
|
2022-10-12 14:21:49 +00:00
|
|
|
cy.runPrimaryBpmnFile();
|
|
|
|
|
2023-09-26 14:30:11 +00:00
|
|
|
cy.getBySel('process-model-files').click();
|
2022-11-08 22:20:17 +00:00
|
|
|
cy.getBySel(`edit-file-${bpmnFile.replace('.', '-')}`).click();
|
2022-10-12 14:21:49 +00:00
|
|
|
updateBpmnPythonScript(originalPythonScript);
|
2022-12-27 20:42:22 +00:00
|
|
|
cy.contains(acceptanceTestOneDisplayName).click();
|
2022-10-12 14:21:49 +00:00
|
|
|
cy.runPrimaryBpmnFile();
|
|
|
|
});
|
|
|
|
|
2022-11-21 20:16:54 +00:00
|
|
|
// it('can create a new instance and can modify with monaco text editor', () => {
|
|
|
|
// // leave off the ending double quote since manco adds it
|
|
|
|
// const originalPythonScript = 'person = "Kevin';
|
|
|
|
// const newPythonScript = 'person = "Mike';
|
|
|
|
//
|
|
|
|
// const bpmnFile = 'process_model_one.bpmn';
|
|
|
|
//
|
|
|
|
// // Change bpmn
|
2023-09-26 14:30:11 +00:00
|
|
|
// cy.getBySel('process-model-files').click();
|
2022-11-21 20:16:54 +00:00
|
|
|
// cy.getBySel(`edit-file-${bpmnFile.replace('.', '-')}`).click();
|
|
|
|
// cy.contains(`Process Model File: ${bpmnFile}`);
|
|
|
|
// updateBpmnPythonScriptWithMonaco(newPythonScript);
|
|
|
|
// cy.contains('acceptance-tests-model-1').click();
|
|
|
|
// cy.runPrimaryBpmnFile();
|
|
|
|
//
|
2023-09-26 14:30:11 +00:00
|
|
|
// cy.getBySel('process-model-files').click();
|
2022-11-21 20:16:54 +00:00
|
|
|
// cy.getBySel(`edit-file-${bpmnFile.replace('.', '-')}`).click();
|
|
|
|
// cy.contains(`Process Model File: ${bpmnFile}`);
|
|
|
|
// updateBpmnPythonScriptWithMonaco(originalPythonScript);
|
|
|
|
// cy.contains('acceptance-tests-model-1').click();
|
|
|
|
// cy.runPrimaryBpmnFile();
|
|
|
|
// });
|
2022-10-12 14:21:49 +00:00
|
|
|
|
|
|
|
it('can paginate items', () => {
|
|
|
|
// make sure we have some process instances
|
|
|
|
cy.runPrimaryBpmnFile();
|
|
|
|
cy.runPrimaryBpmnFile();
|
|
|
|
cy.runPrimaryBpmnFile();
|
|
|
|
cy.runPrimaryBpmnFile();
|
|
|
|
cy.runPrimaryBpmnFile();
|
|
|
|
|
|
|
|
cy.getBySel('process-instance-list-link').click();
|
|
|
|
cy.basicPaginationTest();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('can display logs', () => {
|
|
|
|
// make sure we have some process instances
|
|
|
|
cy.runPrimaryBpmnFile();
|
|
|
|
cy.getBySel('process-instance-list-link').click();
|
2023-03-10 17:56:37 +00:00
|
|
|
cy.getBySel('process-instance-show-link-id').first().click();
|
2023-07-10 18:06:55 +00:00
|
|
|
cy.contains('Events').click();
|
2022-10-12 14:21:49 +00:00
|
|
|
cy.contains('process_model_one');
|
2023-03-23 21:34:08 +00:00
|
|
|
cy.contains('task_completed');
|
2023-07-10 18:06:55 +00:00
|
|
|
cy.basicPaginationTest(undefined, 'pagination-options-events');
|
2022-10-12 14:21:49 +00:00
|
|
|
});
|
|
|
|
|
2022-11-09 22:30:33 +00:00
|
|
|
it('can filter', () => {
|
2023-09-25 20:03:46 +00:00
|
|
|
cy.visit('/process-instances/all');
|
2022-12-28 17:27:37 +00:00
|
|
|
cy.contains('All Process Instances');
|
2023-07-10 18:06:55 +00:00
|
|
|
cy.get('.process-instance-list-row-variant-all');
|
2022-10-12 14:21:49 +00:00
|
|
|
cy.assertAtLeastOneItemInPaginatedResults();
|
2023-09-07 19:31:31 +00:00
|
|
|
cy.getBySel('filter-section-expand-toggle').click();
|
2022-10-12 14:21:49 +00:00
|
|
|
|
2022-11-12 03:15:39 +00:00
|
|
|
const statusSelect = '#process-instance-status-select';
|
2022-11-09 19:51:22 +00:00
|
|
|
PROCESS_STATUSES.forEach((processStatus) => {
|
|
|
|
if (!['all', 'waiting'].includes(processStatus)) {
|
2022-11-12 03:15:39 +00:00
|
|
|
cy.get(statusSelect).click();
|
2023-04-28 15:56:52 +00:00
|
|
|
cy.get(statusSelect).contains(titleizeString(processStatus)).click();
|
2023-09-07 16:41:50 +00:00
|
|
|
clickOnHeaderToMakeSureMultiSelectComponentStateIsStable();
|
2022-11-09 19:51:22 +00:00
|
|
|
cy.getBySel('filter-button').click();
|
2023-04-28 15:56:52 +00:00
|
|
|
|
|
|
|
// make sure that there is 1 status item selected in the multiselect
|
|
|
|
cy.get(`${statusSelect} .cds--tag`).contains('1');
|
|
|
|
|
2022-11-09 19:51:22 +00:00
|
|
|
cy.assertAtLeastOneItemInPaginatedResults();
|
2022-11-21 20:16:54 +00:00
|
|
|
cy.getBySel(`process-instance-status-${processStatus}`);
|
2023-03-24 15:10:04 +00:00
|
|
|
|
2023-07-10 18:06:55 +00:00
|
|
|
// we tried 500 as well to try to make this work consistently
|
2023-03-24 15:10:04 +00:00
|
|
|
cy.wait(1000);
|
2023-07-10 18:06:55 +00:00
|
|
|
|
2022-11-09 19:51:22 +00:00
|
|
|
// there should really only be one, but in CI there are sometimes more
|
2023-09-07 16:41:50 +00:00
|
|
|
clickOnHeaderToMakeSureMultiSelectComponentStateIsStable();
|
2022-11-09 19:51:22 +00:00
|
|
|
cy.get('div[aria-label="Clear all selected items"]:first').click();
|
2023-03-06 16:59:33 +00:00
|
|
|
cy.get('div[aria-label="Clear all selected items"]').should(
|
|
|
|
'not.exist'
|
|
|
|
);
|
2023-09-07 16:41:50 +00:00
|
|
|
clickOnHeaderToMakeSureMultiSelectComponentStateIsStable();
|
2022-11-09 19:51:22 +00:00
|
|
|
}
|
|
|
|
});
|
2022-10-12 14:21:49 +00:00
|
|
|
|
|
|
|
const date = new Date();
|
|
|
|
date.setHours(date.getHours() - 1);
|
|
|
|
filterByDate(date);
|
|
|
|
cy.assertAtLeastOneItemInPaginatedResults();
|
|
|
|
|
2022-11-09 19:51:22 +00:00
|
|
|
date.setHours(date.getHours() + 26);
|
2022-10-12 14:21:49 +00:00
|
|
|
filterByDate(date);
|
|
|
|
cy.assertNoItemInPaginatedResults();
|
|
|
|
});
|
|
|
|
});
|