spiff-arena/spiffworkflow-frontend/cypress/support/commands.js

133 lines
4.2 KiB
JavaScript
Raw Normal View History

import { string } from 'prop-types';
// ***********************************************
// 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-04 21:14:48 +00:00
cy.get('button[aria-label="Open menu"]').click();
cy.getBySel('side-nav-items').contains('Home').click();
// cy.getBySel('nav-home').click();
});
Cypress.Commands.add('navigateToAdmin', () => {
cy.visit('/admin');
});
Cypress.Commands.add('login', (selector, ...args) => {
cy.visit('/admin');
cy.get('#username').type('ciadmin1');
cy.get('#password').type('ciadmin1');
cy.get('#kc-login').click();
});
Cypress.Commands.add('logout', (selector, ...args) => {
cy.getBySel('logout-button').click();
// otherwise we can click logout, quickly load the next page, and the javascript
// doesn't have time to actually sign you out
cy.contains('Sign in to your account');
});
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();
cy.url().should('include', `process-models/${groupId}:${modelId}`);
cy.contains(`Process Model: ${modelDisplayName}`);
});
Cypress.Commands.add('runPrimaryBpmnFile', (reload = true) => {
cy.contains('Run').click();
cy.contains(/Process Instance.*kicked off/);
if (reload) {
cy.reload(true);
cy.contains(/Process Instance.*kicked off/).should('not.exist');
}
});
Cypress.Commands.add(
'navigateToProcessModel',
(groupDisplayName, modelDisplayName, modelIdentifier) => {
cy.navigateToAdmin();
cy.contains(groupDisplayName).click();
cy.contains(`Process Group: ${groupDisplayName}`);
// https://stackoverflow.com/q/51254946/6090676
cy.getBySel('process-model-show-link').contains(modelIdentifier).click();
cy.contains(`Process Model: ${modelDisplayName}`);
}
);
Cypress.Commands.add('basicPaginationTest', () => {
cy.getBySel('pagination-options').scrollIntoView();
cy.get('.cds--select__item-count').find('.cds--select-input').select('2');
// NOTE: this is a em dash instead of en dash
cy.contains(/\b12 of \d+/);
cy.get('.cds--pagination__button--forward').click();
cy.contains(/\b34 of \d+/);
cy.get('.cds--pagination__button--backward').click();
cy.contains(/\b12 of \d+/);
});
Cypress.Commands.add('assertAtLeastOneItemInPaginatedResults', () => {
cy.contains(/\b[1-9]\d*[1-9]\d* of [1-9]\d*/);
});
Cypress.Commands.add('assertNoItemInPaginatedResults', () => {
cy.contains(/\b00 of 0 items/);
});
Cypress.Commands.add('modifyProcessModelPath', (path) => {
path.replace('/', ':');
return path;
});
Squashed 'spiffworkflow-frontend/' changes from cdae31a57..2149f03f5 2149f03f5 fix breadcrumb 4106c5aac Merge pull request #28 from sartography/bug/browser_lock_on_dmn_selection d9f04b932 one instance test left for cypress w/ burnettk db4ff9019 kill a few consoles 8fd0cbafc fixing up routes for launching editor. Also some fixes in the bpmn-js-spiffworkflow to avoid locking up the browser if no files are available. 063fc1e0c process model cypress tests are passing a1de9eca1 camelcase 67116e6ac fix process model create and a couple tests, docker build refactor 6dbdbffad fixed lint issue w/ burnettk cullerton 441e300c6 merged in main and resolved conflicts w/ burnettk cullerton 8c29bc3f6 fixed some acceptance tests w/ burnettk cullerton cf9af691e updated breadcrumbs to work with new process models ids w/ burnettk cullerton 23ff4e816 made a process model form w/ burnettk dbe0b9c71 Merge branch 'main' into feature/nested-groups 099ce24bb lint da1bd979d return next task when running an instance w/ burnettk ee76c5c81 More frontend changes ff0e4c762 process model show page lists files as accordion with action icons w/ burnettk a8cf19162 Merge remote-tracking branch 'origin/main' into feature/carbon_process_model_show 0b334f08d some minor chnages to prepare for chnaging actions dropdown to buttons 4e7d4733f First pass at custom report/perspective for Process Instance List (#23) 381cd4578 change action dropdown direction based on if it is the last one or not ec72afceb add back run and edit and add actions menu 331c079e1 added a table for files w/ burnettk 65874023b updated process modal show page to use accordion component w/ burnettk d50d23f14 First stab at fixing routes and urls d26b67865 Merge remote-tracking branch 'origin/main' into feature/carbon_process_model_show 6d8fee5eb Merge commit '44e49e6ae6a1f644162489a27618c39194f4628d' into main 01218b3ca update gitignore. ee11c1c2f updated the breadcrumb component and added a test for buttons in file dropdown git-subtree-dir: spiffworkflow-frontend git-subtree-split: 2149f03f5d352ba2f40b4dc41e9435cfb396d0e5
2022-11-09 20:02:22 +00:00
Cypress.Commands.add('modifyProcessModelPath', (path) => {
path.replace('/', ':');
return path;
});