From bbb2296b3db70f3d4ecae6af14a844f18a10871e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Fri, 5 Jul 2024 16:52:12 +0200 Subject: [PATCH] ci: Make pinning e2e test work locally (no-changelog) (#9954) Signed-off-by: Oleg Ivaniv Co-authored-by: Oleg Ivaniv --- .github/workflows/e2e-reusable.yml | 2 -- cypress/cypress.config.js | 5 ----- cypress/e2e/13-pinning.cy.ts | 7 ++++++- cypress/scripts/run-e2e.js | 1 - cypress/support/index.ts | 1 + packages/editor-ui/src/composables/usePinnedData.ts | 8 ++++++-- packages/editor-ui/src/constants.ts | 4 +--- packages/editor-ui/src/shims.d.ts | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/e2e-reusable.yml b/.github/workflows/e2e-reusable.yml index b7dadc4173..beea3bca27 100644 --- a/.github/workflows/e2e-reusable.yml +++ b/.github/workflows/e2e-reusable.yml @@ -99,8 +99,6 @@ jobs: runTests: false install: false build: pnpm build - env: - VUE_APP_MAX_PINNED_DATA_SIZE: 16384 - name: Cypress install working-directory: cypress diff --git a/cypress/cypress.config.js b/cypress/cypress.config.js index c82f039994..63913af7f8 100644 --- a/cypress/cypress.config.js +++ b/cypress/cypress.config.js @@ -25,9 +25,4 @@ module.exports = defineConfig({ screenshotsFolder: 'screenshots', videosFolder: 'videos', }, - env: { - MAX_PINNED_DATA_SIZE: process.env.VUE_APP_MAX_PINNED_DATA_SIZE - ? parseInt(process.env.VUE_APP_MAX_PINNED_DATA_SIZE, 10) - : 16 * 1024, - }, }); diff --git a/cypress/e2e/13-pinning.cy.ts b/cypress/e2e/13-pinning.cy.ts index 468e73276a..4558c44bca 100644 --- a/cypress/e2e/13-pinning.cy.ts +++ b/cypress/e2e/13-pinning.cy.ts @@ -12,8 +12,13 @@ const workflowPage = new WorkflowPage(); const ndv = new NDV(); describe('Data pinning', () => { + const maxPinnedDataSize = 16384; + beforeEach(() => { workflowPage.actions.visit(); + cy.window().then((win) => { + win.maxPinnedDataSize = maxPinnedDataSize; + }); }); it('Should be able to pin node output', () => { @@ -139,7 +144,7 @@ describe('Data pinning', () => { ndv.actions.pastePinnedData([ { - test: '1'.repeat(Cypress.env('MAX_PINNED_DATA_SIZE') as number), + test: '1'.repeat(maxPinnedDataSize), }, ]); errorToast().should('contain', 'Workflow has reached the maximum allowed pinned data size'); diff --git a/cypress/scripts/run-e2e.js b/cypress/scripts/run-e2e.js index 05ddae1a9f..8096a70caf 100755 --- a/cypress/scripts/run-e2e.js +++ b/cypress/scripts/run-e2e.js @@ -13,7 +13,6 @@ function runTests(options) { process.env.N8N_USER_FOLDER = userFolder; process.env.E2E_TESTS = 'true'; process.env.NODE_OPTIONS = '--dns-result-order=ipv4first'; - process.env.VUE_APP_MAX_PINNED_DATA_SIZE = `${16 * 1024}`; if (options.customEnv) { Object.keys(options.customEnv).forEach((key) => { diff --git a/cypress/support/index.ts b/cypress/support/index.ts index cb0f42bdce..9819e7c3a1 100644 --- a/cypress/support/index.ts +++ b/cypress/support/index.ts @@ -64,6 +64,7 @@ declare global { innerWidth: number; innerHeight: number; preventNodeViewBeforeUnload?: boolean; + maxPinnedDataSize?: number; featureFlags: { override: (feature: string, value: unknown) => void; }; diff --git a/packages/editor-ui/src/composables/usePinnedData.ts b/packages/editor-ui/src/composables/usePinnedData.ts index b1b725aa2b..2ee0d046b5 100644 --- a/packages/editor-ui/src/composables/usePinnedData.ts +++ b/packages/editor-ui/src/composables/usePinnedData.ts @@ -140,6 +140,10 @@ export function usePinnedData( } } + function getMaxPinnedDataSize() { + return window.maxPinnedDataSize ?? MAX_PINNED_DATA_SIZE; + } + function isValidSize(data: string | object): boolean { const targetNode = unref(node); if (!targetNode) { @@ -154,13 +158,13 @@ export function usePinnedData( const newPinData = { ...currentPinData, [targetNode.name]: data }; const newPinDataSize = workflowsStore.getPinDataSize(newPinData); - if (newPinDataSize > MAX_PINNED_DATA_SIZE) { + if (newPinDataSize > getMaxPinnedDataSize()) { toast.showError( new Error( i18n.baseText('ndv.pinData.error.tooLarge.description', { interpolate: { size: toMegaBytes(newPinDataSize), - limit: toMegaBytes(MAX_PINNED_DATA_SIZE), + limit: toMegaBytes(getMaxPinnedDataSize()), }, }), ), diff --git a/packages/editor-ui/src/constants.ts b/packages/editor-ui/src/constants.ts index 074b87a420..845448f61b 100644 --- a/packages/editor-ui/src/constants.ts +++ b/packages/editor-ui/src/constants.ts @@ -9,9 +9,7 @@ import type { InjectionKey } from 'vue'; export const MAX_WORKFLOW_SIZE = 1024 * 1024 * 16; // Workflow size limit in bytes export const MAX_EXPECTED_REQUEST_SIZE = 2048; // Expected maximum workflow request metadata (i.e. headers) size in bytes -export const MAX_PINNED_DATA_SIZE = import.meta.env.VUE_APP_MAX_PINNED_DATA_SIZE - ? parseInt(import.meta.env.VUE_APP_MAX_PINNED_DATA_SIZE, 10) - : 1024 * 1024 * 12; // 12 MB; Workflow pinned data size limit in bytes +export const MAX_PINNED_DATA_SIZE = 1024 * 1024 * 12; // 12 MB; Workflow pinned data size limit in bytes export const MAX_DISPLAY_DATA_SIZE = 1024 * 1024; // 1 MB export const MAX_DISPLAY_DATA_SIZE_SCHEMA_VIEW = 1024 * 1024 * 4; // 4 MB export const MAX_DISPLAY_ITEMS_AUTO_ALL = 250; diff --git a/packages/editor-ui/src/shims.d.ts b/packages/editor-ui/src/shims.d.ts index 8121b15d89..e0a9a886af 100644 --- a/packages/editor-ui/src/shims.d.ts +++ b/packages/editor-ui/src/shims.d.ts @@ -11,7 +11,6 @@ declare global { PROD: boolean; NODE_ENV: 'development' | 'production'; VUE_APP_URL_BASE_API: string; - VUE_APP_MAX_PINNED_DATA_SIZE: string; }; } @@ -20,6 +19,7 @@ declare global { REST_ENDPOINT: string; n8nExternalHooks?: PartialDeep; preventNodeViewBeforeUnload?: boolean; + maxPinnedDataSize?: number; } namespace JSX {