n8n/cypress/pages/workflow.ts

104 lines
4.4 KiB
TypeScript
Raw Normal View History

import { BasePage } from './base';
export class WorkflowPage extends BasePage {
url = '/workflow/new';
getters = {
workflowNameInputContainer: () => cy.getByTestId('workflow-name-input', { timeout: 5000 }),
workflowNameInput: () => this.getters.workflowNameInputContainer().then(($el) => cy.wrap($el.find('input'))),
workflowImportInput: () => cy.getByTestId('workflow-import-input'),
workflowTags: () => cy.getByTestId('workflow-tags'),
workflowTagsContainer: () => cy.getByTestId('workflow-tags-container'),
workflowTagsInput: () => this.getters.workflowTagsContainer().then(($el) => cy.wrap($el.find('input').first())),
workflowTagElements: () => cy.get('[data-test-id="workflow-tags-container"] span.tags > span'),
workflowTagsDropdown: () => cy.getByTestId('workflow-tags-dropdown'),
newTagLink: () => cy.getByTestId('new-tag-link'),
saveButton: () => cy.getByTestId('workflow-save-button'),
nodeCreatorSearchBar: () => cy.getByTestId('node-creator-search-bar'),
nodeCreatorPlusButton: () => cy.getByTestId('node-creator-plus-button'),
canvasPlusButton: () => cy.getByTestId('canvas-plus-button'),
canvasNodes: () => cy.getByTestId('canvas-node'),
canvasNodeByName: (nodeName: string) => this.getters.canvasNodes().filter(`:contains("${nodeName}")`),
ndvParameterInput: (parameterName: string) =>
cy.getByTestId(`parameter-input-${parameterName}`),
ndvOutputPanel: () => cy.getByTestId('output-panel'),
ndvRunDataPaneHeader: () => cy.getByTestId('run-data-pane-header'),
successToast: () => cy.get('.el-notification__title'),
activatorSwitch: () => cy.getByTestId('workflow-activate-switch'),
workflowMenu: () => cy.getByTestId('workflow-menu'),
firstStepButton: () => cy.getByTestId('canvas-add-button'),
isWorkflowSaved: () => this.getters.saveButton().should('match', 'span'), // In Element UI, disabled button turn into spans 🤷‍♂️
isWorkflowActivated: () => this.getters.activatorSwitch().should('have.class', 'is-checked'),
feat(editor): Overhaul expression editor modal (#4631) * feat(editor): Integrate CodeMirror into expression editor modal (#4563) * :sparkles: Initial setup * :shirt: Fix lint * :zap: Extract segments * :zap: Implement var insertion * :shirt: Ignore `.d.cts` * :zap: Refactor to simplify * :sparkles: Add brace handler * :sparkles: Fully replace input and output * feat(editor): Adjust resolved expression to match parameter input hint (#4600) * :sparkles: Initial adjustments * :bug: Prevent empty decorations * :zap: Adjust resolved expression to match param input hint * :pencil2: Improve comment * :shirt: Remove lint rule * :pencil2: Fix typo * :pencil2: Fix closing brace * :zap: Clean up `displayableSegments()` * feat(editor): Apply styling to expression editor modal (#4607) :art: Apply styling * feat(core): Improve errors in evaluated expression (#4619) * :bug: Fix env var access for FE * :fire: Remove excess closing bracket * :construction: Set up TODO * :pencil2: Update copy * :zap: Deny env vars access to FE * :shirt: Remove unneeded lint exception * :blue_book: Remove unneeded typing * feat(editor): Dynamically delay evaluation resolution (#4625) * :pencil2: Update copy * :zap: Dynamically delay evaluation resolution * :fire: Remove unneeded computed property * refactor(editor): Pre-review cleanup (#4627) * :fire: Remove `ExpressionInput` component * :fire: Remove Quill * :pencil2: Rename i18n key * :art: Place border on correct element * :bug: Handle syntax errors * :zap: Add sample autocompletions * :bug: Fix auto-extending behavior * feat(editor): Improve escaping behavior (#4641) * :art: Hide hint on small screen * :zap: Improve escaping * refactor(editor): Apply styling feedback to expression editor modal (#4660) * :art: Restyle hint * :art: Restyle param input hint * :fire: Remove `e.g.` * :zap: Tweak delay * :art: Restyle output * :art: Tweak theme * :pencil2: Tweak copy * refactor(editor): Apply feedback 2022.11.22 (#4697) * :art: Change background color * :zap: Focus on mount * :zap: Account for preexisting braces on injection * :bug: Fix `$workflow` showing as not saved * :pencil2: Tweak copy * :bug: Fix readonly focus * :zap: Focus input on paste * :zap: Sync inputs with modal * :pencil2: Tweak copy * refactor(editor): Apply feedback 2022.11.23 (#4705) * :zap: Allow newlines * :zap: Set cursor at end of content * :zap: Do not defocus on paste on Chrome * :zap: Fix import * :test_tube: Add e2e tests * :zap: Cleanup * :zap: Add telemetry * :fire: Remove log * :zap: Expose error properties * :test_tube: Rename test * :zap: Move `getCurrentWorkflow()` call * :rewind: Revert highlighting removal per feedback * :zap: Add i18n keys * :truck: Move computed property to local state * :art: Use CSS vars * :zap: Update `pnpm-lock.yaml` * :zap: Apply readonly state * :zap: Use prop * :zap: Complete fix
2022-12-01 04:26:22 -08:00
expressionModalInput: () => cy.getByTestId('expression-modal-input'),
expressionModalOutput: () => cy.getByTestId('expression-modal-output'),
nodeViewRoot: () => cy.getByTestId('node-view-root'),
copyPasteInput: () => cy.getByTestId('hidden-copy-paste'),
};
actions = {
visit: () => {
cy.visit(this.url);
cy.getByTestId('node-view-loader', { timeout: 5000 }).should('not.exist');
cy.get('.el-loading-mask', { timeout: 5000 }).should('not.exist');
},
addInitialNodeToCanvas: (nodeDisplayName: string) => {
this.getters.canvasPlusButton().click();
this.getters.nodeCreatorSearchBar().type(nodeDisplayName);
this.getters.nodeCreatorSearchBar().type('{enter}{esc}');
},
addNodeToCanvas: (nodeDisplayName: string) => {
this.getters.nodeCreatorPlusButton().click();
this.getters.nodeCreatorSearchBar().type(nodeDisplayName);
this.getters.nodeCreatorSearchBar().type('{enter}{esc}');
},
openNodeNdv: (nodeTypeName: string) => {
this.getters.canvasNodeByName(nodeTypeName).dblclick();
},
feat(editor): Overhaul expression editor modal (#4631) * feat(editor): Integrate CodeMirror into expression editor modal (#4563) * :sparkles: Initial setup * :shirt: Fix lint * :zap: Extract segments * :zap: Implement var insertion * :shirt: Ignore `.d.cts` * :zap: Refactor to simplify * :sparkles: Add brace handler * :sparkles: Fully replace input and output * feat(editor): Adjust resolved expression to match parameter input hint (#4600) * :sparkles: Initial adjustments * :bug: Prevent empty decorations * :zap: Adjust resolved expression to match param input hint * :pencil2: Improve comment * :shirt: Remove lint rule * :pencil2: Fix typo * :pencil2: Fix closing brace * :zap: Clean up `displayableSegments()` * feat(editor): Apply styling to expression editor modal (#4607) :art: Apply styling * feat(core): Improve errors in evaluated expression (#4619) * :bug: Fix env var access for FE * :fire: Remove excess closing bracket * :construction: Set up TODO * :pencil2: Update copy * :zap: Deny env vars access to FE * :shirt: Remove unneeded lint exception * :blue_book: Remove unneeded typing * feat(editor): Dynamically delay evaluation resolution (#4625) * :pencil2: Update copy * :zap: Dynamically delay evaluation resolution * :fire: Remove unneeded computed property * refactor(editor): Pre-review cleanup (#4627) * :fire: Remove `ExpressionInput` component * :fire: Remove Quill * :pencil2: Rename i18n key * :art: Place border on correct element * :bug: Handle syntax errors * :zap: Add sample autocompletions * :bug: Fix auto-extending behavior * feat(editor): Improve escaping behavior (#4641) * :art: Hide hint on small screen * :zap: Improve escaping * refactor(editor): Apply styling feedback to expression editor modal (#4660) * :art: Restyle hint * :art: Restyle param input hint * :fire: Remove `e.g.` * :zap: Tweak delay * :art: Restyle output * :art: Tweak theme * :pencil2: Tweak copy * refactor(editor): Apply feedback 2022.11.22 (#4697) * :art: Change background color * :zap: Focus on mount * :zap: Account for preexisting braces on injection * :bug: Fix `$workflow` showing as not saved * :pencil2: Tweak copy * :bug: Fix readonly focus * :zap: Focus input on paste * :zap: Sync inputs with modal * :pencil2: Tweak copy * refactor(editor): Apply feedback 2022.11.23 (#4705) * :zap: Allow newlines * :zap: Set cursor at end of content * :zap: Do not defocus on paste on Chrome * :zap: Fix import * :test_tube: Add e2e tests * :zap: Cleanup * :zap: Add telemetry * :fire: Remove log * :zap: Expose error properties * :test_tube: Rename test * :zap: Move `getCurrentWorkflow()` call * :rewind: Revert highlighting removal per feedback * :zap: Add i18n keys * :truck: Move computed property to local state * :art: Use CSS vars * :zap: Update `pnpm-lock.yaml` * :zap: Apply readonly state * :zap: Use prop * :zap: Complete fix
2022-12-01 04:26:22 -08:00
openExpressionEditor: () => {
cy.get('input[value="expression"]').parent('label').click();
},
typeIntoParameterInput: (parameterName: string, content: string) => {
this.getters.ndvParameterInput(parameterName).type(content);
},
selectOptionInParameterDropdown: (parameterName: string, content: string) => {
this.getters
.ndvParameterInput(parameterName)
.find('.option-headline')
.contains(content)
.click();
},
executeNodeFromNdv: () => {
cy.contains('Execute node').click();
},
openWorkflowMenu: () => {
this.getters.workflowMenu().click();
},
saveWorkflowOnButtonClick: () => {
this.getters.saveButton().click();
},
saveWorkflowUsingKeyboardShortcut: () => {
cy.get('body').type('{meta}', { release: false }).type('s');
},
activateWorkflow: () => {
this.getters.activatorSwitch().find('input').first().should('be.enabled');
this.getters.activatorSwitch().click();
cy.get('body').type('{esc}');
},
renameWorkflow: (newName: string) => {
this.getters.workflowNameInputContainer().click();
cy.get('body').type('{selectall}');
cy.get('body').type(newName);
cy.get('body').type('{enter}');
},
addTags: (tags: string[]) => {
tags.forEach(tag => {
this.getters.workflowTagsInput().type(tag);
this.getters.workflowTagsInput().type('{enter}');
});
cy.get('body').type('{enter}');
},
zoomToFit: () => {
cy.getByTestId('zoom-to-fit').click();
},
};
}