n8n/cypress/e2e/9-expression-editor-modal.cy.ts

66 lines
2.5 KiB
TypeScript
Raw Normal View History

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
import { WorkflowPage as WorkflowPageClass } from '../pages/workflow';
const WorkflowPage = new WorkflowPageClass();
describe('Expression editor modal', () => {
before(() => {
cy.task('reset');
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
cy.skipSetup();
});
beforeEach(() => {
WorkflowPage.actions.visit();
WorkflowPage.actions.addInitialNodeToCanvas('Manual Trigger');
WorkflowPage.actions.addNodeToCanvas('Hacker News');
WorkflowPage.actions.openNodeNdv('Hacker News');
WorkflowPage.actions.openExpressionEditor();
});
it('should resolve primitive resolvables', () => {
WorkflowPage.getters.expressionModalInput().type('{{');
WorkflowPage.getters.expressionModalInput().type('1 + 2');
WorkflowPage.getters.expressionModalOutput().contains(/^3$/);
WorkflowPage.getters.expressionModalInput().clear();
WorkflowPage.getters.expressionModalInput().type('{{');
WorkflowPage.getters.expressionModalInput().type('"ab" + "cd"');
WorkflowPage.getters.expressionModalOutput().contains(/^abcd$/);
WorkflowPage.getters.expressionModalInput().clear();
WorkflowPage.getters.expressionModalInput().type('{{');
WorkflowPage.getters.expressionModalInput().type('true && false');
WorkflowPage.getters.expressionModalOutput().contains(/^false$/);
});
it('should resolve object resolvables', () => {
WorkflowPage.getters.expressionModalInput().type('{{');
WorkflowPage.getters.expressionModalInput().type('{{} a: 1');
WorkflowPage.getters.expressionModalOutput().contains(/^\[Object: \{"a":1\}\]$/);
WorkflowPage.getters.expressionModalInput().clear();
WorkflowPage.getters.expressionModalInput().type('{{');
WorkflowPage.getters.expressionModalInput().type('{{} a: 1 }.a{del}{del}');
WorkflowPage.getters.expressionModalOutput().contains(/^1$/);
});
it('should resolve array resolvables', () => {
WorkflowPage.getters.expressionModalInput().type('{{');
WorkflowPage.getters.expressionModalInput().type('[1, 2, 3]');
WorkflowPage.getters.expressionModalOutput().contains(/^\[Array: \[1,2,3\]\]$/);
WorkflowPage.getters.expressionModalInput().clear();
WorkflowPage.getters.expressionModalInput().type('{{');
WorkflowPage.getters.expressionModalInput().type('[1, 2, 3][0]');
WorkflowPage.getters.expressionModalOutput().contains(/^1$/);
});
it('should resolve $parameter[]', () => {
WorkflowPage.getters.expressionModalInput().type('{{');
WorkflowPage.getters.expressionModalInput().type('$parameter["operation"]');
WorkflowPage.getters.expressionModalOutput().contains(/^get$/);
});
});