2022-10-12 14:21:49 +00:00
|
|
|
const submitInputIntoFormField = (taskName, fieldKey, fieldValue) => {
|
2022-11-21 21:47:04 +00:00
|
|
|
cy.contains(`Task: ${taskName}`, { timeout: 10000 });
|
2023-05-01 18:54:11 +00:00
|
|
|
cy.get(fieldKey).clear();
|
|
|
|
cy.get(fieldKey).type(fieldValue);
|
2022-10-12 14:21:49 +00:00
|
|
|
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');
|
|
|
|
// };
|
2022-10-12 14:21:49 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
};
|
|
|
|
|
2022-10-12 14:21:49 +00:00
|
|
|
describe('tasks', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.login();
|
|
|
|
});
|
|
|
|
afterEach(() => {
|
|
|
|
cy.logout();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('can complete and navigate a form', () => {
|
|
|
|
const groupDisplayName = 'Acceptance Tests Group One';
|
2022-11-08 22:20:17 +00:00
|
|
|
const modelDisplayName = `Acceptance Tests Model 2`;
|
2022-10-12 14:21:49 +00:00
|
|
|
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);
|
2022-10-12 14:21:49 +00:00
|
|
|
|
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');
|
|
|
|
submitInputIntoFormField('get_form_num_three', '#root_form_num_3', 4);
|
2022-10-12 14:21:49 +00:00
|
|
|
|
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);
|
2022-10-12 14:21:49 +00:00
|
|
|
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();
|
2022-10-12 14:21:49 +00:00
|
|
|
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');
|
2022-10-12 14:21:49 +00:00
|
|
|
checkTaskHasClass('form1', completedTaskClassName);
|
|
|
|
checkTaskHasClass('form2', completedTaskClassName);
|
|
|
|
checkTaskHasClass('form3', completedTaskClassName);
|
|
|
|
checkTaskHasClass('form4', activeTaskClassName);
|
2022-11-08 22:20:17 +00:00
|
|
|
cy.get('.is-visible .cds--modal-close').click();
|
2022-10-12 14:21:49 +00:00
|
|
|
|
|
|
|
cy.navigateToHome();
|
2023-04-14 14:00:06 +00:00
|
|
|
|
|
|
|
// look for somethig to make sure the homepage has loaded
|
2023-05-16 14:13:29 +00:00
|
|
|
cy.contains('Waiting for me').should('exist');
|
2022-10-12 14:21:49 +00:00
|
|
|
|
|
|
|
// FIXME: this will probably need a better way to link to the proper form that we want
|
2022-12-28 17:27:37 +00:00
|
|
|
cy.contains('Go').click();
|
2022-10-12 14:21:49 +00:00
|
|
|
|
2023-05-01 18:54:11 +00:00
|
|
|
submitInputIntoFormField('get_form_num_four', '#root_form_num_4', 5);
|
2022-10-12 14:21:49 +00:00
|
|
|
cy.url().should('include', '/tasks');
|
|
|
|
|
2022-12-27 20:42:22 +00:00
|
|
|
cy.navigateToProcessModel(groupDisplayName, modelDisplayName);
|
2022-10-12 14:21:49 +00:00
|
|
|
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();
|
2022-10-12 14:21:49 +00:00
|
|
|
cy.contains('Process Instance Id: ');
|
2023-07-10 18:06:55 +00:00
|
|
|
cy.get('.process-instance-status').contains('complete');
|
2022-10-12 14:21:49 +00:00
|
|
|
});
|
2024-03-19 18:52:27 +00:00
|
|
|
});
|
2022-10-12 14:21:49 +00:00
|
|
|
|
2024-03-19 18:52:27 +00:00
|
|
|
describe('public_tasks', () => {
|
|
|
|
it('can start process from message form', () => {
|
|
|
|
// login and log out to ensure permissions are set correctly
|
|
|
|
cy.login();
|
|
|
|
cy.logout();
|
|
|
|
|
|
|
|
cy.visit('public/misc:bounty_start_multiple_forms');
|
|
|
|
cy.get('#root_firstName').type('MyFirstName');
|
|
|
|
cy.contains('Submit').click();
|
|
|
|
cy.get('#root_lastName').type('MyLastName');
|
|
|
|
cy.contains('Submit').click();
|
|
|
|
cy.contains('We hear you. Your name is MyFirstName MyLastName.');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('can complete a guest task', () => {
|
|
|
|
cy.login();
|
|
|
|
const groupDisplayName = 'Shared Resources';
|
|
|
|
const modelDisplayName = 'task-with-guest-form';
|
|
|
|
cy.navigateToProcessModel(groupDisplayName, modelDisplayName);
|
|
|
|
cy.runPrimaryBpmnFile(false, false, false);
|
|
|
|
|
|
|
|
cy.get('[data-qa="metadata-value-first_task_url"] a')
|
|
|
|
.invoke('attr', 'href')
|
|
|
|
.then((hrefValue) => {
|
|
|
|
cy.logout();
|
|
|
|
cy.visit(hrefValue);
|
|
|
|
// form 1
|
|
|
|
cy.contains('Submit').click();
|
|
|
|
// form 2
|
|
|
|
cy.contains('Submit').click();
|
|
|
|
cy.contains('You are done. Yay!');
|
|
|
|
cy.visit(hrefValue);
|
|
|
|
cy.contains('Error retrieving content.');
|
|
|
|
cy.getBySel('public-home-link').click();
|
|
|
|
cy.getBySel('public-sign-out').click();
|
|
|
|
if (Cypress.env('SPIFFWORKFLOW_FRONTEND_AUTH_WITH_KEYCLOAK') === true) {
|
|
|
|
cy.contains('Sign in to your account');
|
|
|
|
} else {
|
|
|
|
cy.get('#spiff-login-button').should('exist');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2022-10-12 14:21:49 +00:00
|
|
|
});
|