2022-11-23 14:38:45 +00:00
|
|
|
|
import { modifyProcessIdentifierForPathParam } from '../../src/helpers';
|
2022-12-14 22:09:43 +00:00
|
|
|
|
import { miscDisplayName } from './helpers';
|
2023-04-06 14:31:24 +00:00
|
|
|
|
import 'cypress-file-upload';
|
2022-10-12 14:21:49 +00:00
|
|
|
|
|
|
|
|
|
// ***********************************************
|
|
|
|
|
// This example commands.js shows you how to
|
|
|
|
|
// create various custom commands and overwrite
|
|
|
|
|
// existing commands.
|
|
|
|
|
//
|
|
|
|
|
// For more comprehensive examples of custom
|
|
|
|
|
// commands please read more here:
|
|
|
|
|
// https://on.cypress.io/custom-commands
|
|
|
|
|
// ***********************************************
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// -- This is a parent command --
|
|
|
|
|
// Cypress.Commands.add('login', (email, password) => { ... })
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// -- This is a child command --
|
|
|
|
|
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// -- This is a dual command --
|
|
|
|
|
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// -- This will overwrite an existing command --
|
|
|
|
|
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('getBySel', (selector, ...args) => {
|
|
|
|
|
return cy.get(`[data-qa=${selector}]`, ...args);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('navigateToHome', () => {
|
2022-11-22 03:09:13 +00:00
|
|
|
|
cy.getBySel('header-menu-expand-button').click();
|
2022-11-04 21:14:48 +00:00
|
|
|
|
cy.getBySel('side-nav-items').contains('Home').click();
|
2022-10-12 14:21:49 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('navigateToAdmin', () => {
|
2022-11-04 19:07:40 +00:00
|
|
|
|
cy.visit('/admin');
|
2022-10-12 14:21:49 +00:00
|
|
|
|
});
|
|
|
|
|
|
2023-03-05 04:48:23 +00:00
|
|
|
|
Cypress.Commands.add('login', (username, password) => {
|
2022-10-12 14:21:49 +00:00
|
|
|
|
cy.visit('/admin');
|
2023-05-10 18:05:07 +00:00
|
|
|
|
let usernameToUse = username;
|
|
|
|
|
let passwordToUse = password;
|
|
|
|
|
if (!usernameToUse) {
|
|
|
|
|
usernameToUse =
|
|
|
|
|
Cypress.env('SPIFFWORKFLOW_FRONTEND_USERNAME') || 'ciadmin1';
|
|
|
|
|
passwordToUse =
|
|
|
|
|
Cypress.env('SPIFFWORKFLOW_FRONTEND_PASSWORD') || 'ciadmin1';
|
2023-03-05 04:48:23 +00:00
|
|
|
|
}
|
2023-05-10 18:05:07 +00:00
|
|
|
|
cy.get('#username').type(usernameToUse);
|
|
|
|
|
cy.get('#password').type(passwordToUse);
|
2023-02-16 18:31:08 +00:00
|
|
|
|
if (Cypress.env('SPIFFWORKFLOW_FRONTEND_AUTH_WITH_KEYCLOAK') === true) {
|
2023-02-16 17:09:44 +00:00
|
|
|
|
cy.get('#kc-login').click();
|
|
|
|
|
} else {
|
|
|
|
|
cy.get('#spiff-login-button').click();
|
|
|
|
|
}
|
2022-10-12 14:21:49 +00:00
|
|
|
|
});
|
|
|
|
|
|
2023-05-10 18:05:07 +00:00
|
|
|
|
Cypress.Commands.add('logout', (_selector, ..._args) => {
|
2023-05-10 19:49:55 +00:00
|
|
|
|
cy.wait(2000);
|
2023-07-10 18:06:55 +00:00
|
|
|
|
// click the profile thingy in the top right
|
|
|
|
|
cy.get('.user-profile-toggletip-button').click();
|
|
|
|
|
|
2023-05-10 18:05:07 +00:00
|
|
|
|
cy.getBySel('logout-button').click();
|
2023-02-16 18:31:08 +00:00
|
|
|
|
if (Cypress.env('SPIFFWORKFLOW_FRONTEND_AUTH_WITH_KEYCLOAK') === true) {
|
2023-02-16 17:09:44 +00:00
|
|
|
|
// otherwise we can click logout, quickly load the next page, and the javascript
|
|
|
|
|
// doesn't have time to actually sign you out
|
2023-05-10 18:05:07 +00:00
|
|
|
|
// cy.wait(4000);
|
2023-02-16 17:09:44 +00:00
|
|
|
|
cy.contains('Sign in to your account');
|
|
|
|
|
} else {
|
|
|
|
|
cy.get('#spiff-login-button').should('exist');
|
|
|
|
|
}
|
2022-10-12 14:21:49 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('createGroup', (groupId, groupDisplayName) => {
|
|
|
|
|
cy.contains(groupId).should('not.exist');
|
|
|
|
|
cy.contains('Add a process group').click();
|
|
|
|
|
cy.get('input[name=display_name]').type(groupDisplayName);
|
|
|
|
|
cy.get('input[name=display_name]').should('have.value', groupDisplayName);
|
|
|
|
|
cy.get('input[name=id]').should('have.value', groupId);
|
|
|
|
|
cy.contains('Submit').click();
|
|
|
|
|
|
|
|
|
|
cy.url().should('include', `process-groups/${groupId}`);
|
|
|
|
|
cy.contains(`Process Group: ${groupDisplayName}`);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('createModel', (groupId, modelId, modelDisplayName) => {
|
|
|
|
|
cy.contains(modelId).should('not.exist');
|
|
|
|
|
|
|
|
|
|
cy.contains('Add a process model').click();
|
|
|
|
|
cy.get('input[name=display_name]').type(modelDisplayName);
|
|
|
|
|
cy.get('input[name=display_name]').should('have.value', modelDisplayName);
|
|
|
|
|
cy.get('input[name=id]').should('have.value', modelId);
|
|
|
|
|
cy.contains('Submit').click();
|
|
|
|
|
|
2022-11-21 20:39:33 +00:00
|
|
|
|
cy.url().should(
|
|
|
|
|
'include',
|
2022-11-23 14:38:45 +00:00
|
|
|
|
`process-models/${modifyProcessIdentifierForPathParam(groupId)}:${modelId}`
|
2022-11-21 20:39:33 +00:00
|
|
|
|
);
|
2022-11-09 03:36:39 +00:00
|
|
|
|
cy.contains(`Process Model: ${modelDisplayName}`);
|
2022-10-12 14:21:49 +00:00
|
|
|
|
});
|
|
|
|
|
|
2023-04-06 15:42:24 +00:00
|
|
|
|
// Intended to be run from the process model show page
|
2022-11-22 03:09:13 +00:00
|
|
|
|
Cypress.Commands.add(
|
|
|
|
|
'runPrimaryBpmnFile',
|
2023-04-24 18:40:42 +00:00
|
|
|
|
(expectAutoRedirectToHumanTask = false, returnToProcessModelShow = true) => {
|
2023-05-10 18:05:07 +00:00
|
|
|
|
cy.getBySel('start-process-instance').click();
|
2022-11-22 03:09:13 +00:00
|
|
|
|
if (expectAutoRedirectToHumanTask) {
|
2023-05-10 18:05:07 +00:00
|
|
|
|
// the url changes immediately, so also make sure we get some content from the next page, "Task:",
|
|
|
|
|
// or else when we try to interact with the page, it'll re-render and we'll get an error with cypress.
|
2022-11-22 03:09:13 +00:00
|
|
|
|
cy.url().should('include', `/tasks/`);
|
2023-03-09 15:59:20 +00:00
|
|
|
|
cy.contains('Task: ', { timeout: 30000 });
|
2022-11-22 03:09:13 +00:00
|
|
|
|
} else {
|
2023-04-24 18:40:42 +00:00
|
|
|
|
cy.url().should('include', `/interstitial`);
|
2023-05-19 15:24:50 +00:00
|
|
|
|
// cy.contains('Status: Completed');
|
|
|
|
|
cy.contains(
|
|
|
|
|
'There are no additional instructions or information for this task.'
|
|
|
|
|
);
|
2023-04-24 18:40:42 +00:00
|
|
|
|
if (returnToProcessModelShow) {
|
|
|
|
|
cy.getBySel('process-model-breadcrumb-link').click();
|
|
|
|
|
cy.getBySel('process-model-show-permissions-loaded').should('exist');
|
|
|
|
|
}
|
2022-11-22 03:09:13 +00:00
|
|
|
|
}
|
2022-10-12 14:21:49 +00:00
|
|
|
|
}
|
2022-11-22 03:09:13 +00:00
|
|
|
|
);
|
2022-10-12 14:21:49 +00:00
|
|
|
|
|
|
|
|
|
Cypress.Commands.add(
|
|
|
|
|
'navigateToProcessModel',
|
2022-12-27 20:42:22 +00:00
|
|
|
|
(groupDisplayName, modelDisplayName) => {
|
2022-10-12 14:21:49 +00:00
|
|
|
|
cy.navigateToAdmin();
|
2022-12-14 22:09:43 +00:00
|
|
|
|
cy.contains(miscDisplayName).click();
|
|
|
|
|
cy.contains(`Process Group: ${miscDisplayName}`, { timeout: 10000 });
|
2022-10-12 14:21:49 +00:00
|
|
|
|
cy.contains(groupDisplayName).click();
|
|
|
|
|
cy.contains(`Process Group: ${groupDisplayName}`);
|
|
|
|
|
// https://stackoverflow.com/q/51254946/6090676
|
2022-11-23 14:38:45 +00:00
|
|
|
|
cy.getBySel('process-model-show-link').contains(modelDisplayName).click();
|
2022-10-12 14:21:49 +00:00
|
|
|
|
cy.contains(`Process Model: ${modelDisplayName}`);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2022-12-30 14:13:03 +00:00
|
|
|
|
Cypress.Commands.add(
|
|
|
|
|
'basicPaginationTest',
|
2023-07-10 18:06:55 +00:00
|
|
|
|
(
|
|
|
|
|
dataQaTagToUseToEnsureTableHasLoaded = 'paginated-entity-id',
|
|
|
|
|
paginationOptionsDataQa = 'pagination-options'
|
|
|
|
|
) => {
|
|
|
|
|
cy.getBySel(paginationOptionsDataQa).scrollIntoView();
|
|
|
|
|
cy.getBySel(paginationOptionsDataQa)
|
|
|
|
|
.find('.cds--select__item-count')
|
|
|
|
|
.find('.cds--select-input')
|
|
|
|
|
.select('2');
|
2022-12-30 14:13:03 +00:00
|
|
|
|
|
|
|
|
|
// NOTE: this is a em dash instead of en dash
|
|
|
|
|
cy.contains(/\b1–2 of \d+/);
|
|
|
|
|
|
|
|
|
|
// ok, trying to ensure that we have everything loaded before we leave this
|
|
|
|
|
// function and try to sign out. Just showing results 1-2 of blah is not good enough,
|
|
|
|
|
// since the ajax request may not have finished yet.
|
|
|
|
|
// to be sure it's finished, grab the log id from page 1. remember it.
|
|
|
|
|
// then use the magical contains command that waits for the element to exist AND
|
|
|
|
|
// for that element to contain the text we're looking for.
|
|
|
|
|
cy.getBySel(dataQaTagToUseToEnsureTableHasLoaded)
|
|
|
|
|
.first()
|
|
|
|
|
.then(($element) => {
|
|
|
|
|
const oldId = $element.text().trim();
|
2023-07-10 18:06:55 +00:00
|
|
|
|
cy.getBySel(paginationOptionsDataQa)
|
|
|
|
|
.find('.cds--pagination__button--forward')
|
|
|
|
|
.click();
|
|
|
|
|
cy.getBySel(paginationOptionsDataQa)
|
|
|
|
|
.contains(`[data-qa=${dataQaTagToUseToEnsureTableHasLoaded}]`, oldId)
|
|
|
|
|
.should('not.exist');
|
|
|
|
|
cy.getBySel(paginationOptionsDataQa).contains(/\b3–4 of \d+/);
|
|
|
|
|
cy.getBySel(paginationOptionsDataQa)
|
|
|
|
|
.find('.cds--pagination__button--backward')
|
|
|
|
|
.click();
|
|
|
|
|
cy.getBySel(paginationOptionsDataQa).contains(/\b1–2 of \d+/);
|
2022-12-30 14:13:03 +00:00
|
|
|
|
cy.contains(`[data-qa=${dataQaTagToUseToEnsureTableHasLoaded}]`, oldId);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
);
|
2022-10-12 14:21:49 +00:00
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('assertAtLeastOneItemInPaginatedResults', () => {
|
2022-11-08 22:20:17 +00:00
|
|
|
|
cy.contains(/\b[1-9]\d*–[1-9]\d* of [1-9]\d*/);
|
2022-10-12 14:21:49 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('assertNoItemInPaginatedResults', () => {
|
2022-11-09 19:51:22 +00:00
|
|
|
|
cy.contains(/\b0–0 of 0 items/);
|
2022-10-12 14:21:49 +00:00
|
|
|
|
});
|
2022-12-15 22:59:01 +00:00
|
|
|
|
|
2023-01-16 17:24:02 +00:00
|
|
|
|
Cypress.Commands.add('deleteProcessModelAndConfirm', (buttonId, groupId) => {
|
|
|
|
|
cy.getBySel(buttonId).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)}`
|
|
|
|
|
);
|
|
|
|
|
});
|