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

114 lines
3.8 KiB
JavaScript
Raw Normal View History

const submitInputIntoFormField = (taskName, fieldKey, fieldValue) => {
cy.contains(`Task: ${taskName}`, { timeout: 10000 });
2023-05-01 18:54:11 +00:00
cy.get(fieldKey).clear();
cy.get(fieldKey).type(fieldValue);
cy.contains('Submit').click();
};
2023-05-01 18:54:11 +00:00
// const checkFormFieldIsReadOnly = (formName, fieldKey) => {
// cy.contains(`Task: ${formName}`);
// cy.get(fieldKey).invoke('attr', 'disabled').should('exist');
// };
const checkTaskHasClass = (taskName, className) => {
cy.get(`g[data-element-id=${taskName}]`).should('have.class', className);
};
2022-12-27 20:42:22 +00:00
const kickOffModelWithForm = () => {
2022-11-22 03:09:13 +00:00
cy.navigateToProcessModel(
'Acceptance Tests Group One',
2022-12-27 20:42:22 +00:00
'Acceptance Tests Model 2'
2022-11-22 03:09:13 +00:00
);
cy.runPrimaryBpmnFile(true);
};
describe('tasks', () => {
beforeEach(() => {
cy.login();
});
afterEach(() => {
cy.logout();
});
it('can complete and navigate a form', () => {
const groupDisplayName = 'Acceptance Tests Group One';
const modelDisplayName = `Acceptance Tests Model 2`;
const completedTaskClassName = 'completed-task-highlight';
const activeTaskClassName = 'active-task-highlight';
2022-12-27 20:42:22 +00:00
cy.navigateToProcessModel(groupDisplayName, modelDisplayName);
2022-11-22 13:17:17 +00:00
cy.runPrimaryBpmnFile(true);
2023-05-01 18:54:11 +00:00
submitInputIntoFormField('get_form_num_one', '#root_form_num_1', 2);
submitInputIntoFormField('get_form_num_two', '#root_form_num_2', 3);
cy.contains('Task: get_form_num_three');
2023-03-24 13:21:23 +00:00
// TODO: remove this if we decide to completely kill form navigation
// cy.getBySel('form-nav-form2').click();
// checkFormFieldIsReadOnly(
2023-05-01 18:54:11 +00:00
// 'get_form_num_two',
// '#root_form_num_2'
2023-03-24 13:21:23 +00:00
// );
// cy.getBySel('form-nav-form1').click();
// checkFormFieldIsReadOnly(
2023-05-01 18:54:11 +00:00
// 'get_form_num_one',
// '#root_form_num_1'
2023-03-24 13:21:23 +00:00
// );
//
// cy.getBySel('form-nav-form3').click();
2023-05-01 18:54:11 +00:00
submitInputIntoFormField('get_form_num_three', '#root_form_num_3', 4);
2023-05-01 18:54:11 +00:00
cy.contains('Task: get_form_num_four');
2022-12-27 20:42:22 +00:00
cy.navigateToProcessModel(groupDisplayName, modelDisplayName);
cy.getBySel('process-instance-list-link').click();
cy.assertAtLeastOneItemInPaginatedResults();
// This should get the first one which should be the one we just completed
2023-03-10 17:56:37 +00:00
cy.getBySel('process-instance-show-link-id').first().click();
cy.contains('Process Instance Id: ');
cy.get(`g[data-element-id=form3]`).click();
2023-05-01 18:54:11 +00:00
cy.contains('"form_num_1": 2');
cy.contains('"form_num_2": 3');
cy.contains('"form_num_3": 4');
cy.contains('"form_num_4": 5').should('not.exist');
checkTaskHasClass('form1', completedTaskClassName);
checkTaskHasClass('form2', completedTaskClassName);
checkTaskHasClass('form3', completedTaskClassName);
checkTaskHasClass('form4', activeTaskClassName);
cy.get('.is-visible .cds--modal-close').click();
cy.navigateToHome();
2023-04-14 14:00:06 +00:00
// look for somethig to make sure the homepage has loaded
cy.contains('Waiting for me').should('exist');
// FIXME: this will probably need a better way to link to the proper form that we want
cy.contains('Go').click();
2023-05-01 18:54:11 +00:00
submitInputIntoFormField('get_form_num_four', '#root_form_num_4', 5);
cy.url().should('include', '/tasks');
2022-12-27 20:42:22 +00:00
cy.navigateToProcessModel(groupDisplayName, modelDisplayName);
cy.getBySel('process-instance-list-link').click();
cy.assertAtLeastOneItemInPaginatedResults();
// This should get the first one which should be the one we just completed
2023-03-10 17:56:37 +00:00
cy.getBySel('process-instance-show-link-id').first().click();
cy.contains('Process Instance Id: ');
cy.contains('Status: complete');
});
2022-11-22 03:09:13 +00:00
it('can paginate items', () => {
// make sure we have some tasks
kickOffModelWithForm();
kickOffModelWithForm();
kickOffModelWithForm();
kickOffModelWithForm();
kickOffModelWithForm();
cy.navigateToHome();
2023-03-10 17:56:37 +00:00
cy.basicPaginationTest('process-instance-show-link-id');
2022-11-22 03:09:13 +00:00
});
});