refactor: Set up Cypress as pnpm workspace (no-changelog) (#6049)

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
Iván Ovejero
2024-06-10 15:49:50 +02:00
committed by GitHub
parent bc3dcf706f
commit af3ac2db28
79 changed files with 435 additions and 315 deletions

View File

@@ -1,6 +1,6 @@
import { META_KEY } from '../constants';
import { BasePage } from './base';
import { getVisibleSelect } from '../utils';
import { BasePage } from './base';
import { NodeCreator } from './features/node-creator';
type CyGetOptions = Parameters<(typeof cy)['get']>[1];
@@ -8,6 +8,7 @@ type CyGetOptions = Parameters<(typeof cy)['get']>[1];
const nodeCreator = new NodeCreator();
export class WorkflowPage extends BasePage {
url = '/workflow/new';
getters = {
workflowNameInputContainer: () => cy.getByTestId('workflow-name-input', { timeout: 5000 }),
workflowNameInput: () =>
@@ -134,12 +135,12 @@ export class WorkflowPage extends BasePage {
colors: () => cy.getByTestId('color'),
contextMenuAction: (action: string) => cy.getByTestId(`context-menu-item-${action}`),
};
actions = {
visit: (preventNodeViewUnload = true) => {
cy.visit(this.url);
cy.waitForLoad();
cy.window().then((win) => {
// @ts-ignore
win.preventNodeViewBeforeUnload = preventNodeViewUnload;
});
},
@@ -329,15 +330,17 @@ export class WorkflowPage extends BasePage {
cy.getByTestId('zoom-to-fit').click();
},
pinchToZoom: (steps: number, mode: 'zoomIn' | 'zoomOut' = 'zoomIn') => {
// Pinch-to-zoom simulates a 'wheel' event with ctrlKey: true (same as zooming by scrolling)
this.getters.nodeViewBackground().trigger('wheel', {
force: true,
bubbles: true,
ctrlKey: true,
pageX: cy.window().innerWidth / 2,
pageY: cy.window().innerHeight / 2,
deltaMode: 1,
deltaY: mode === 'zoomOut' ? steps : -steps,
cy.window().then((win) => {
// Pinch-to-zoom simulates a 'wheel' event with ctrlKey: true (same as zooming by scrolling)
this.getters.nodeViewBackground().trigger('wheel', {
force: true,
bubbles: true,
ctrlKey: true,
pageX: win.innerWidth / 2,
pageY: win.innerHeight / 2,
deltaMode: 1,
deltaY: mode === 'zoomOut' ? steps : -steps,
});
});
},
hitUndo: () => {
@@ -388,11 +391,7 @@ export class WorkflowPage extends BasePage {
this.actions.addNodeToCanvas(newNodeName, false, false, action);
},
deleteNodeBetweenNodes: (
sourceNodeName: string,
targetNodeName: string,
newNodeName: string,
) => {
deleteNodeBetweenNodes: (sourceNodeName: string, targetNodeName: string) => {
this.getters.getConnectionBetweenNodes(sourceNodeName, targetNodeName).first().realHover();
this.getters
.getConnectionActionsBetweenNodes(sourceNodeName, targetNodeName)
@@ -415,7 +414,7 @@ export class WorkflowPage extends BasePage {
.find('[data-test-id="change-sticky-color"]')
.click({ force: true });
},
pickColor: (index: number) => {
pickColor: () => {
this.getters.colors().eq(1).click();
},
editSticky: (content: string) => {