2023-12-20 03:06:49 -08:00
|
|
|
|
import { META_KEY } from '../constants';
|
2023-04-21 06:37:09 -07:00
|
|
|
|
import { WorkflowPage as WorkflowPageClass } from '../pages/workflow';
|
2023-11-08 05:23:57 -08:00
|
|
|
|
import { getPopper } from '../utils';
|
|
|
|
|
import { Interception } from 'cypress/types/net-stubbing';
|
2023-04-21 06:37:09 -07:00
|
|
|
|
|
|
|
|
|
const workflowPage = new WorkflowPageClass();
|
|
|
|
|
|
2023-07-28 00:51:07 -07:00
|
|
|
|
function checkStickiesStyle(
|
|
|
|
|
top: number,
|
|
|
|
|
left: number,
|
|
|
|
|
height: number,
|
|
|
|
|
width: number,
|
|
|
|
|
zIndex?: number,
|
|
|
|
|
) {
|
2023-04-21 06:37:09 -07:00
|
|
|
|
workflowPage.getters.stickies().should(($el) => {
|
|
|
|
|
expect($el).to.have.css('top', `${top}px`);
|
|
|
|
|
expect($el).to.have.css('left', `${left}px`);
|
|
|
|
|
expect($el).to.have.css('height', `${height}px`);
|
|
|
|
|
expect($el).to.have.css('width', `${width}px`);
|
|
|
|
|
if (zIndex) {
|
|
|
|
|
expect($el).to.have.css('z-index', `${zIndex}`);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
describe('Canvas Actions', () => {
|
2023-05-26 08:15:06 -07:00
|
|
|
|
beforeEach(() => {
|
2023-04-21 06:37:09 -07:00
|
|
|
|
workflowPage.actions.visit();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('adds sticky to canvas with default text and position', () => {
|
|
|
|
|
workflowPage.getters.addStickyButton().should('not.be.visible');
|
|
|
|
|
|
2023-07-28 00:51:07 -07:00
|
|
|
|
addDefaultSticky();
|
2023-11-20 05:37:12 -08:00
|
|
|
|
workflowPage.actions.deselectAll();
|
|
|
|
|
workflowPage.actions.addStickyFromContextMenu();
|
|
|
|
|
workflowPage.actions.hitAddStickyShortcut();
|
|
|
|
|
|
2023-12-20 03:06:49 -08:00
|
|
|
|
workflowPage.getters.stickies().should('have.length', 3);
|
|
|
|
|
|
|
|
|
|
// Should not add a sticky for ctrl+shift+s
|
|
|
|
|
cy.get('body')
|
|
|
|
|
.type(META_KEY, { delay: 500, release: false })
|
|
|
|
|
.type('{shift}', { release: false })
|
|
|
|
|
.type('s');
|
|
|
|
|
|
2023-11-20 05:37:12 -08:00
|
|
|
|
workflowPage.getters.stickies().should('have.length', 3);
|
2023-07-28 00:51:07 -07:00
|
|
|
|
workflowPage.getters
|
|
|
|
|
.stickies()
|
|
|
|
|
.eq(0)
|
2023-04-21 06:37:09 -07:00
|
|
|
|
.should('have.text', 'I’m a note\nDouble click to edit me. Guide\n')
|
2023-07-28 00:51:07 -07:00
|
|
|
|
.find('a')
|
|
|
|
|
.contains('Guide')
|
|
|
|
|
.should('have.attr', 'href');
|
2023-04-21 06:37:09 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('drags sticky around to top left corner', () => {
|
|
|
|
|
// used to caliberate move sticky function
|
|
|
|
|
addDefaultSticky();
|
|
|
|
|
moveSticky({ top: 0, left: 0 });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('drags sticky around and position/size are saved correctly', () => {
|
|
|
|
|
addDefaultSticky();
|
|
|
|
|
moveSticky({ top: 500, left: 500 });
|
|
|
|
|
|
|
|
|
|
workflowPage.actions.saveWorkflowOnButtonClick();
|
|
|
|
|
cy.wait('@createWorkflow');
|
|
|
|
|
|
|
|
|
|
cy.reload();
|
|
|
|
|
cy.waitForLoad();
|
|
|
|
|
|
|
|
|
|
stickyShouldBePositionedCorrectly({ top: 500, left: 500 });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('deletes sticky', () => {
|
|
|
|
|
workflowPage.actions.addSticky();
|
2023-07-28 00:51:07 -07:00
|
|
|
|
workflowPage.getters.stickies().should('have.length', 1);
|
2023-04-21 06:37:09 -07:00
|
|
|
|
|
|
|
|
|
workflowPage.actions.deleteSticky();
|
|
|
|
|
|
2023-07-28 00:51:07 -07:00
|
|
|
|
workflowPage.getters.stickies().should('have.length', 0);
|
2023-04-21 06:37:09 -07:00
|
|
|
|
});
|
|
|
|
|
|
2023-11-08 05:23:57 -08:00
|
|
|
|
it('change sticky color', () => {
|
|
|
|
|
workflowPage.actions.addSticky();
|
|
|
|
|
|
|
|
|
|
workflowPage.getters.stickies().should('have.length', 1);
|
|
|
|
|
|
|
|
|
|
workflowPage.actions.toggleColorPalette();
|
|
|
|
|
|
|
|
|
|
getPopper().should('be.visible');
|
|
|
|
|
|
|
|
|
|
workflowPage.actions.pickColor(2);
|
|
|
|
|
|
|
|
|
|
workflowPage.actions.toggleColorPalette();
|
|
|
|
|
|
|
|
|
|
getPopper().should('not.be.visible');
|
|
|
|
|
|
|
|
|
|
workflowPage.actions.saveWorkflowOnButtonClick();
|
|
|
|
|
|
|
|
|
|
cy.wait('@createWorkflow').then((interception: Interception) => {
|
|
|
|
|
const { request } = interception;
|
|
|
|
|
const color = request.body?.nodes[0]?.parameters?.color;
|
|
|
|
|
expect(color).to.equal(2);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
workflowPage.getters.stickies().should('have.length', 1);
|
|
|
|
|
});
|
|
|
|
|
|
2023-04-21 06:37:09 -07:00
|
|
|
|
it('edits sticky and updates content as markdown', () => {
|
|
|
|
|
workflowPage.actions.addSticky();
|
|
|
|
|
|
2023-07-28 00:51:07 -07:00
|
|
|
|
workflowPage.getters
|
|
|
|
|
.stickies()
|
|
|
|
|
.should('have.text', 'I’m a note\nDouble click to edit me. Guide\n');
|
2023-04-21 06:37:09 -07:00
|
|
|
|
|
|
|
|
|
workflowPage.getters.stickies().dblclick();
|
|
|
|
|
workflowPage.actions.editSticky('# hello world \n ## text text');
|
|
|
|
|
workflowPage.getters.stickies().find('h1').should('have.text', 'hello world');
|
|
|
|
|
workflowPage.getters.stickies().find('h2').should('have.text', 'text text');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('expands/shrinks sticky from the right edge', () => {
|
|
|
|
|
addDefaultSticky();
|
|
|
|
|
|
|
|
|
|
moveSticky({ top: 200, left: 200 });
|
|
|
|
|
|
2023-11-03 07:22:37 -07:00
|
|
|
|
cy.drag('[data-test-id="sticky"] [data-dir="right"]', [100, 100]);
|
|
|
|
|
checkStickiesStyle(100, 20, 160, 346);
|
|
|
|
|
|
|
|
|
|
cy.drag('[data-test-id="sticky"] [data-dir="right"]', [-50, -50]);
|
|
|
|
|
checkStickiesStyle(100, 20, 160, 302);
|
2023-04-21 06:37:09 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('expands/shrinks sticky from the left edge', () => {
|
|
|
|
|
addDefaultSticky();
|
|
|
|
|
|
|
|
|
|
moveSticky({ left: 600, top: 200 });
|
|
|
|
|
cy.drag('[data-test-id="sticky"] [data-dir="left"]', [100, 100]);
|
2023-07-14 06:36:17 -07:00
|
|
|
|
checkStickiesStyle(100, 510, 160, 150);
|
2023-04-21 06:37:09 -07:00
|
|
|
|
|
|
|
|
|
cy.drag('[data-test-id="sticky"] [data-dir="left"]', [-50, -50]);
|
2023-07-14 06:36:17 -07:00
|
|
|
|
checkStickiesStyle(100, 466, 160, 194);
|
2023-04-21 06:37:09 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('expands/shrinks sticky from the top edge', () => {
|
|
|
|
|
workflowPage.actions.addSticky();
|
|
|
|
|
cy.drag('[data-test-id="sticky"]', [100, 100]); // move away from canvas button
|
2023-07-14 06:36:17 -07:00
|
|
|
|
checkStickiesStyle(300, 620, 160, 240);
|
2023-04-21 06:37:09 -07:00
|
|
|
|
|
|
|
|
|
cy.drag('[data-test-id="sticky"] [data-dir="top"]', [100, 100]);
|
2023-07-14 06:36:17 -07:00
|
|
|
|
checkStickiesStyle(380, 620, 80, 240);
|
2023-04-21 06:37:09 -07:00
|
|
|
|
|
|
|
|
|
cy.drag('[data-test-id="sticky"] [data-dir="top"]', [-50, -50]);
|
2023-07-14 06:36:17 -07:00
|
|
|
|
checkStickiesStyle(324, 620, 136, 240);
|
2023-04-21 06:37:09 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('expands/shrinks sticky from the bottom edge', () => {
|
|
|
|
|
workflowPage.actions.addSticky();
|
|
|
|
|
cy.drag('[data-test-id="sticky"]', [100, 100]); // move away from canvas button
|
2023-07-14 06:36:17 -07:00
|
|
|
|
checkStickiesStyle(300, 620, 160, 240);
|
2023-04-21 06:37:09 -07:00
|
|
|
|
|
|
|
|
|
cy.drag('[data-test-id="sticky"] [data-dir="bottom"]', [100, 100]);
|
2023-07-14 06:36:17 -07:00
|
|
|
|
checkStickiesStyle(300, 620, 254, 240);
|
2023-04-21 06:37:09 -07:00
|
|
|
|
|
|
|
|
|
cy.drag('[data-test-id="sticky"] [data-dir="bottom"]', [-50, -50]);
|
2023-07-14 06:36:17 -07:00
|
|
|
|
checkStickiesStyle(300, 620, 198, 240);
|
2023-04-21 06:37:09 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('expands/shrinks sticky from the bottom right edge', () => {
|
|
|
|
|
workflowPage.actions.addSticky();
|
|
|
|
|
cy.drag('[data-test-id="sticky"]', [-100, -100]); // move away from canvas button
|
2023-07-14 06:36:17 -07:00
|
|
|
|
checkStickiesStyle(100, 420, 160, 240);
|
2023-04-21 06:37:09 -07:00
|
|
|
|
|
|
|
|
|
cy.drag('[data-test-id="sticky"] [data-dir="bottomRight"]', [100, 100]);
|
2023-07-14 06:36:17 -07:00
|
|
|
|
checkStickiesStyle(100, 420, 254, 346);
|
2023-04-21 06:37:09 -07:00
|
|
|
|
|
|
|
|
|
cy.drag('[data-test-id="sticky"] [data-dir="bottomRight"]', [-50, -50]);
|
2023-07-14 06:36:17 -07:00
|
|
|
|
checkStickiesStyle(100, 420, 198, 302);
|
2023-04-21 06:37:09 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('expands/shrinks sticky from the top right edge', () => {
|
|
|
|
|
addDefaultSticky();
|
|
|
|
|
|
|
|
|
|
cy.drag('[data-test-id="sticky"] [data-dir="topRight"]', [100, 100]);
|
2023-07-14 06:36:17 -07:00
|
|
|
|
checkStickiesStyle(360, 400, 80, 346);
|
2023-04-21 06:37:09 -07:00
|
|
|
|
|
|
|
|
|
cy.drag('[data-test-id="sticky"] [data-dir="topRight"]', [-50, -50]);
|
2023-07-14 06:36:17 -07:00
|
|
|
|
checkStickiesStyle(304, 400, 136, 302);
|
2023-04-21 06:37:09 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('expands/shrinks sticky from the top left edge, and reach min height/width', () => {
|
|
|
|
|
addDefaultSticky();
|
|
|
|
|
|
|
|
|
|
cy.drag('[data-test-id="sticky"] [data-dir="topLeft"]', [100, 100]);
|
2023-07-14 06:36:17 -07:00
|
|
|
|
checkStickiesStyle(360, 490, 80, 150);
|
2023-04-21 06:37:09 -07:00
|
|
|
|
|
|
|
|
|
cy.drag('[data-test-id="sticky"] [data-dir="topLeft"]', [-150, -150]);
|
2023-07-14 06:36:17 -07:00
|
|
|
|
checkStickiesStyle(204, 346, 236, 294);
|
2023-04-21 06:37:09 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('sets sticky behind node', () => {
|
|
|
|
|
workflowPage.actions.addInitialNodeToCanvas('Manual Trigger');
|
|
|
|
|
addDefaultSticky();
|
|
|
|
|
|
|
|
|
|
cy.drag('[data-test-id="sticky"] [data-dir="topLeft"]', [-150, -150]);
|
2023-07-14 06:36:17 -07:00
|
|
|
|
checkStickiesStyle(124, 256, 316, 384, -121);
|
2023-04-21 06:37:09 -07:00
|
|
|
|
|
2023-07-28 00:51:07 -07:00
|
|
|
|
workflowPage.getters
|
|
|
|
|
.canvasNodes()
|
|
|
|
|
.eq(0)
|
2023-04-21 06:37:09 -07:00
|
|
|
|
.should(($el) => {
|
|
|
|
|
expect($el).to.have.css('z-index', 'auto');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
workflowPage.actions.addSticky();
|
2023-07-28 00:51:07 -07:00
|
|
|
|
workflowPage.getters
|
|
|
|
|
.stickies()
|
|
|
|
|
.eq(0)
|
2023-04-21 06:37:09 -07:00
|
|
|
|
.should(($el) => {
|
|
|
|
|
expect($el).to.have.css('z-index', '-121');
|
|
|
|
|
});
|
2023-07-28 00:51:07 -07:00
|
|
|
|
workflowPage.getters
|
|
|
|
|
.stickies()
|
|
|
|
|
.eq(1)
|
2023-04-21 06:37:09 -07:00
|
|
|
|
.should(($el) => {
|
|
|
|
|
expect($el).to.have.css('z-index', '-38');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
cy.drag('[data-test-id="sticky"] [data-dir="topLeft"]', [-200, -200], { index: 1 });
|
2023-07-28 00:51:07 -07:00
|
|
|
|
workflowPage.getters
|
|
|
|
|
.stickies()
|
|
|
|
|
.eq(0)
|
2023-04-21 06:37:09 -07:00
|
|
|
|
.should(($el) => {
|
|
|
|
|
expect($el).to.have.css('z-index', '-121');
|
|
|
|
|
});
|
|
|
|
|
|
2023-07-28 00:51:07 -07:00
|
|
|
|
workflowPage.getters
|
|
|
|
|
.stickies()
|
|
|
|
|
.eq(1)
|
2023-04-21 06:37:09 -07:00
|
|
|
|
.should(($el) => {
|
|
|
|
|
expect($el).to.have.css('z-index', '-158');
|
|
|
|
|
});
|
|
|
|
|
});
|
2024-04-23 18:56:33 -07:00
|
|
|
|
|
|
|
|
|
it('Empty sticky should not error when activating workflow', () => {
|
|
|
|
|
workflowPage.actions.addSticky();
|
|
|
|
|
|
|
|
|
|
workflowPage.getters.stickies().should('have.length', 1);
|
|
|
|
|
|
|
|
|
|
workflowPage.getters.stickies().dblclick();
|
|
|
|
|
|
|
|
|
|
workflowPage.actions.clearSticky();
|
|
|
|
|
|
|
|
|
|
workflowPage.actions.addNodeToCanvas('Schedule Trigger');
|
|
|
|
|
|
|
|
|
|
workflowPage.actions.activateWorkflow();
|
|
|
|
|
});
|
2023-04-21 06:37:09 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
type Position = {
|
|
|
|
|
top: number;
|
|
|
|
|
left: number;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function shouldHaveOneSticky() {
|
|
|
|
|
workflowPage.getters.stickies().should('have.length', 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function shouldBeInDefaultLocation() {
|
2023-07-28 00:51:07 -07:00
|
|
|
|
workflowPage.getters
|
|
|
|
|
.stickies()
|
|
|
|
|
.eq(0)
|
|
|
|
|
.should(($el) => {
|
|
|
|
|
expect($el).to.have.css('height', '160px');
|
|
|
|
|
expect($el).to.have.css('width', '240px');
|
|
|
|
|
});
|
2023-04-21 06:37:09 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function shouldHaveDefaultSize() {
|
|
|
|
|
workflowPage.getters.stickies().should(($el) => {
|
|
|
|
|
expect($el).to.have.css('height', '160px');
|
|
|
|
|
expect($el).to.have.css('width', '240px');
|
2023-07-28 00:51:07 -07:00
|
|
|
|
});
|
2023-04-21 06:37:09 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addDefaultSticky() {
|
|
|
|
|
workflowPage.actions.addSticky();
|
|
|
|
|
shouldHaveOneSticky();
|
|
|
|
|
shouldHaveDefaultSize();
|
|
|
|
|
shouldBeInDefaultLocation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function stickyShouldBePositionedCorrectly(position: Position) {
|
2023-07-14 06:36:17 -07:00
|
|
|
|
const yOffset = -100;
|
2023-04-21 06:37:09 -07:00
|
|
|
|
const xOffset = -180;
|
2023-07-28 00:51:07 -07:00
|
|
|
|
workflowPage.getters.stickies().should(($el) => {
|
|
|
|
|
expect($el).to.have.css('top', `${yOffset + position.top}px`);
|
|
|
|
|
expect($el).to.have.css('left', `${xOffset + position.left}px`);
|
|
|
|
|
});
|
2023-04-21 06:37:09 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function stickyShouldHaveCorrectSize(size: [number, number]) {
|
|
|
|
|
const yOffset = 0;
|
|
|
|
|
const xOffset = 0;
|
2023-07-28 00:51:07 -07:00
|
|
|
|
workflowPage.getters.stickies().should(($el) => {
|
|
|
|
|
expect($el).to.have.css('height', `${yOffset + size[0]}px`);
|
|
|
|
|
expect($el).to.have.css('width', `${xOffset + size[1]}px`);
|
|
|
|
|
});
|
2023-04-21 06:37:09 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function moveSticky(target: Position) {
|
|
|
|
|
cy.drag('[data-test-id="sticky"]', [target.left, target.top], { abs: true });
|
|
|
|
|
stickyShouldBePositionedCorrectly(target);
|
|
|
|
|
}
|