From ecbe70f5dcfa99e2b58f4470a1c9a24491c5c01c Mon Sep 17 00:00:00 2001 From: Biswajeet Das Date: Mon, 29 Jan 2024 16:48:12 +0530 Subject: [PATCH 1/3] feat: add file upload support for cypress --- .source | 2 +- apps/web/cypress/fixtures/translation.json | 19 +++++++ apps/web/cypress/support/commands.ts | 1 + .../translations/translation-group.spec-ee.ts | 56 ++++++++++++------- apps/web/package.json | 9 +-- pnpm-lock.yaml | 31 ++++++---- 6 files changed, 84 insertions(+), 34 deletions(-) create mode 100644 apps/web/cypress/fixtures/translation.json diff --git a/.source b/.source index 89b8fab26bf..ec6ad1589d4 160000 --- a/.source +++ b/.source @@ -1 +1 @@ -Subproject commit 89b8fab26bfd2df4c021c928bc18be74debffb3d +Subproject commit ec6ad1589d410122cdba6fb7c6ac07ed19bb4925 diff --git a/apps/web/cypress/fixtures/translation.json b/apps/web/cypress/fixtures/translation.json new file mode 100644 index 00000000000..63b42eb37ee --- /dev/null +++ b/apps/web/cypress/fixtures/translation.json @@ -0,0 +1,19 @@ +{ + "key": "value", + "keyDeep": { + "inner": "value" + }, + "keyNesting": "reuse $t(keyDeep.inner)", + "keyInterpolate": "replace this {{value}}", + "keyInterpolateUnescaped": "replace this {{- value}}", + "keyContext_male": "the male variant", + "keyContext_female": "the female variant", + "keyPluralSimple": "the singular", + "keyPluralSimple_plural": "the plural", + "keyPluralMultipleEgArabic_0": "the plural form 0", + "keyPluralMultipleEgArabic_1": "the plural form 1", + "keyPluralMultipleEgArabic_2": "the plural form 2", + "keyPluralMultipleEgArabic_3": "the plural form 3", + "keyPluralMultipleEgArabic_11": "the plural form 4", + "keyPluralMultipleEgArabic_100": "the plural form 5" +} diff --git a/apps/web/cypress/support/commands.ts b/apps/web/cypress/support/commands.ts index 766c9f46d4f..f025214544f 100644 --- a/apps/web/cypress/support/commands.ts +++ b/apps/web/cypress/support/commands.ts @@ -3,6 +3,7 @@ import { MemberRoleEnum, MemberStatusEnum } from '@novu/shared'; import 'cypress-wait-until'; +import 'cypress-file-upload'; Cypress.Commands.add('getByTestId', (selector, ...args) => { return cy.get(`[data-test-id=${selector}]`, ...args); diff --git a/apps/web/cypress/tests/translations/translation-group.spec-ee.ts b/apps/web/cypress/tests/translations/translation-group.spec-ee.ts index 01ee02c7940..ca091ebc181 100644 --- a/apps/web/cypress/tests/translations/translation-group.spec-ee.ts +++ b/apps/web/cypress/tests/translations/translation-group.spec-ee.ts @@ -10,31 +10,49 @@ describe('Translations Group Page', function () { }); it('should add a new translations group', function () { + createTranslationGroup(); cy.visit('/translations'); - cy.waitForNetworkIdle(500); - cy.getByTestId('translation-title').should('have.text', 'Translations'); - cy.getByTestId('add-group-btn').click(); - cy.getByTestId('default-language-select').click(); - cy.get('.mantine-Select-item').first().click(); - cy.getByTestId('default-language-submit-btn').click(); - cy.getByTestId('group-name-input').type('Test Group'); - cy.getByTestId('group-identifier-input').should('have.value', 'test-group'); - cy.getByTestId('add-group-submit-btn').click(); + cy.getByTestId('test-group').click(); + cy.getByTestId('translation-filename').should('have.text', 'Empty...'); + cy.getByTestId('translation-keys-value').should('have.text', ''); }); it('should delete a translations group', function () { - cy.visit('/translations'); - cy.waitForNetworkIdle(500); - cy.getByTestId('translation-title').should('have.text', 'Translations'); - cy.getByTestId('add-group-btn').click(); - cy.getByTestId('default-language-select').click(); - cy.get('.mantine-Select-item').first().click(); - cy.getByTestId('default-language-submit-btn').click(); - cy.getByTestId('group-name-input').type('Test Group'); - cy.getByTestId('group-identifier-input').should('have.value', 'test-group'); - cy.getByTestId('add-group-submit-btn').click(); + createTranslationGroup(); cy.getByTestId('delete-group-btn').click(); cy.getByTestId('delete-group-submit-btn').should('have.text', 'Delete group').click(); cy.getByTestId('add-group-btn').should('exist'); }); + + it('should upload translation file', function () { + createTranslationGroup(); + cy.getByTestId('upload-menu').click(); + cy.getByTestId('upload-files-dropdown-item').find('input').attachFile('translation.json'); + cy.getByTestId('upload-submit-btn').click(); + cy.visit('/translations'); + cy.getByTestId('test-group').click(); + cy.getByTestId('translation-filename').should('have.text', 'translation.json'); + cy.getByTestId('translation-keys-value').should('have.text', 15); + }); }); + +function createTranslationGroup() { + const identifier = 'test-group'; + + cy.visit('/translations'); + cy.waitForNetworkIdle(500); + cy.getByTestId('translation-title').should('have.text', 'Translations'); + cy.getByTestId('add-group-btn').click(); + cy.waitForNetworkIdle(500); + + cy.getByTestId('default-language-select').click().type('Hindi'); + + cy.get('.mantine-Select-item').first().click(); + cy.getByTestId('default-language-submit-btn').click(); + cy.waitForNetworkIdle(500); + + cy.getByTestId('group-name-input').type('Test Group'); + cy.getByTestId('group-identifier-input').should('have.value', identifier); + cy.getByTestId('add-group-submit-btn').click({ force: true }); + cy.waitForNetworkIdle(1000); +} diff --git a/apps/web/package.json b/apps/web/package.json index b3056192352..4f2c43e6cc5 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -52,11 +52,12 @@ "@mantine/notifications": "^5.7.1", "@mantine/prism": "^5.7.1", "@mantine/spotlight": "^5.7.1", + "@monaco-editor/react": "^4.6.0", "@novu/design-system": "^0.22.0", "@novu/notification-center": "^0.22.0", "@novu/shared": "^0.22.0", - "@segment/analytics-next": "^1.48.0", "@novu/shared-web": "^0.22.0", + "@segment/analytics-next": "^1.48.0", "@sentry/react": "^7.40.0", "@sentry/tracing": "^7.40.0", "@storybook/addon-docs": "^7.4.2", @@ -70,8 +71,6 @@ "@types/react": "^17.0.0", "@types/react-dom": "^17.0.0", "@types/react-table": "^7.7.12", - "@monaco-editor/react": "^4.6.0", - "monaco-editor": "^0.45.0", "ace-builds": "^1.4.12", "antd": "^4.10.0", "autoprefixer": "^9.8.6", @@ -93,6 +92,7 @@ "lodash.get": "^4.3.2", "lodash.isequal": "^4.5.0", "lodash.set": "^4.3.2", + "monaco-editor": "^0.45.0", "polished": "^4.1.3", "react": "^17.0.1", "react-ace": "^9.4.3", @@ -108,12 +108,12 @@ "react-helmet-async": "^1.3.0", "react-hook-form": "7.43.9", "react-is": "^18.2.0", + "react-joyride": "^2.5.3", "react-password-strength-bar": "^0.4.1", "react-router-dom": "6.2.2", "react-syntax-highlighter": "^15.4.3", "react-table": "^7.8.0", "react-use-intercom": "^2.0.0", - "react-joyride": "^2.5.3", "rimraf": "^3.0.2", "slugify": "^1.4.6", "storybook-dark-mode": "^3.0.1", @@ -147,6 +147,7 @@ "@types/react": "^17.0.0", "@types/testing-library__jest-dom": "^5.14.5", "cypress": "^13.3.1", + "cypress-file-upload": "^5.0.8", "cypress-localstorage-commands": "^2.2.4", "cypress-network-idle": "^1.14.2", "cypress-wait-until": "^2.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 15ab22569a9..6f139f31a97 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -965,6 +965,9 @@ importers: cypress: specifier: ^13.3.1 version: 13.3.1 + cypress-file-upload: + specifier: ^5.0.8 + version: 5.0.8(cypress@13.3.1) cypress-localstorage-commands: specifier: ^2.2.4 version: 2.2.4(cypress@13.3.1) @@ -32896,6 +32899,15 @@ packages: resolution: {integrity: sha512-NJGVKPS81XejHcLhaLJS7plab0fK3slPh11mESeeDq2W4ZI5kUKK/LRRdVDvjJseojbPB7ZwjnyOybg3Igea/A==} dev: true + /cypress-file-upload@5.0.8(cypress@13.3.1): + resolution: {integrity: sha512-+8VzNabRk3zG6x8f8BWArF/xA/W0VK4IZNx3MV0jFWrJS/qKn8eHfa5nU73P9fOQAgwHFJx7zjg4lwOnljMO8g==} + engines: {node: '>=8.2.1'} + peerDependencies: + cypress: '>3.0.0' + dependencies: + cypress: 13.3.1 + dev: true + /cypress-intellij-reporter@0.0.7: resolution: {integrity: sha512-P4A0BPz5h9TWLZFVhMJsAMktqCEdeKA0+bS+zfTGLohUtM89pmU5kAWLEGFOYRcRlVR39XbUWhyFyTjs8AoFLA==} dependencies: @@ -33195,7 +33207,6 @@ packages: dependencies: ms: 2.1.3 supports-color: 5.5.0 - dev: true /debug@3.2.7(supports-color@8.1.1): resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} @@ -34417,7 +34428,7 @@ packages: /eslint-import-resolver-node@0.3.7: resolution: {integrity: sha512-gozW2blMLJCeFpBwugLTGyvVjNoeo1knonXAcatC6bjPBZitotxdWf7Gimr25N4c0AAOo4eOUfaG82IJPDpqCA==} dependencies: - debug: 3.2.7(supports-color@8.1.1) + debug: 3.2.7(supports-color@5.5.0) is-core-module: 2.13.0 resolve: 1.22.2 transitivePeerDependencies: @@ -34432,7 +34443,7 @@ packages: webpack: '>=1.11.0' dependencies: array.prototype.find: 2.2.2 - debug: 3.2.7(supports-color@8.1.1) + debug: 3.2.7(supports-color@5.5.0) enhanced-resolve: 0.9.1 eslint-plugin-import: 2.28.1(@typescript-eslint/parser@5.58.0)(eslint-import-resolver-webpack@0.13.7)(eslint@8.38.0) find-root: 1.1.0 @@ -34470,7 +34481,7 @@ packages: optional: true dependencies: '@typescript-eslint/parser': 5.58.0(eslint@8.38.0)(typescript@4.9.5) - debug: 3.2.7(supports-color@8.1.1) + debug: 3.2.7(supports-color@5.5.0) eslint: 8.38.0 eslint-import-resolver-node: 0.3.7 eslint-import-resolver-webpack: 0.13.7(eslint-plugin-import@2.28.1)(webpack@5.78.0) @@ -34500,7 +34511,7 @@ packages: optional: true dependencies: '@typescript-eslint/parser': 5.58.0(eslint@8.51.0)(typescript@4.9.5) - debug: 3.2.7(supports-color@8.1.1) + debug: 3.2.7(supports-color@5.5.0) eslint: 8.51.0 eslint-import-resolver-node: 0.3.7 eslint-import-resolver-webpack: 0.13.7(eslint-plugin-import@2.28.1)(webpack@5.78.0) @@ -34581,7 +34592,7 @@ packages: array.prototype.findlastindex: 1.2.3 array.prototype.flat: 1.3.1 array.prototype.flatmap: 1.3.1 - debug: 3.2.7(supports-color@8.1.1) + debug: 3.2.7(supports-color@5.5.0) doctrine: 2.1.0 eslint: 8.38.0 eslint-import-resolver-node: 0.3.7 @@ -34616,7 +34627,7 @@ packages: array.prototype.findlastindex: 1.2.3 array.prototype.flat: 1.3.1 array.prototype.flatmap: 1.3.1 - debug: 3.2.7(supports-color@8.1.1) + debug: 3.2.7(supports-color@5.5.0) doctrine: 2.1.0 eslint: 8.51.0 eslint-import-resolver-node: 0.3.7 @@ -39141,7 +39152,7 @@ packages: pretty-format: 27.5.1 slash: 3.0.0 strip-json-comments: 3.1.1 - ts-node: 10.9.1(@types/node@14.18.42)(typescript@4.9.5) + ts-node: 10.9.1(@types/node@16.11.7)(typescript@4.9.5) transitivePeerDependencies: - bufferutil - canvas @@ -43022,7 +43033,7 @@ packages: hasBin: true requiresBuild: true dependencies: - debug: 3.2.7(supports-color@8.1.1) + debug: 3.2.7(supports-color@5.5.0) iconv-lite: 0.6.3 sax: 1.2.4 transitivePeerDependencies: @@ -45339,7 +45350,7 @@ packages: engines: {node: '>= 0.12.0'} dependencies: async: 2.6.4 - debug: 3.2.7(supports-color@8.1.1) + debug: 3.2.7(supports-color@5.5.0) mkdirp: 0.5.6 transitivePeerDependencies: - supports-color From 776a20503e7fd8e6e8b6c85366fdcd1f10502fec Mon Sep 17 00:00:00 2001 From: Biswajeet Das Date: Mon, 29 Jan 2024 19:21:18 +0530 Subject: [PATCH 2/3] Update apps/web/cypress/tests/translations/translation-group.spec-ee.ts Co-authored-by: ainouzgali --- apps/web/cypress/tests/translations/translation-group.spec-ee.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/web/cypress/tests/translations/translation-group.spec-ee.ts b/apps/web/cypress/tests/translations/translation-group.spec-ee.ts index ca091ebc181..28a1eb088e8 100644 --- a/apps/web/cypress/tests/translations/translation-group.spec-ee.ts +++ b/apps/web/cypress/tests/translations/translation-group.spec-ee.ts @@ -11,7 +11,6 @@ describe('Translations Group Page', function () { it('should add a new translations group', function () { createTranslationGroup(); - cy.visit('/translations'); cy.getByTestId('test-group').click(); cy.getByTestId('translation-filename').should('have.text', 'Empty...'); cy.getByTestId('translation-keys-value').should('have.text', ''); From 67749012ec6beb5a5f8119fccce2112acbd21460 Mon Sep 17 00:00:00 2001 From: Biswajeet Das Date: Mon, 29 Jan 2024 20:02:26 +0530 Subject: [PATCH 3/3] fix: test --- .../web/cypress/tests/translations/translation-group.spec-ee.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/cypress/tests/translations/translation-group.spec-ee.ts b/apps/web/cypress/tests/translations/translation-group.spec-ee.ts index 28a1eb088e8..eff0a40afb7 100644 --- a/apps/web/cypress/tests/translations/translation-group.spec-ee.ts +++ b/apps/web/cypress/tests/translations/translation-group.spec-ee.ts @@ -11,7 +11,7 @@ describe('Translations Group Page', function () { it('should add a new translations group', function () { createTranslationGroup(); - cy.getByTestId('test-group').click(); + cy.getByTestId('test-group').click({ force: true }); cy.getByTestId('translation-filename').should('have.text', 'Empty...'); cy.getByTestId('translation-keys-value').should('have.text', ''); });