From 82f5221d5dd1acec612852a1a4cd7e36eb7b3d73 Mon Sep 17 00:00:00 2001 From: Tomas Plevko Date: Tue, 7 Jan 2025 10:26:30 +0100 Subject: [PATCH] (e2e): catalog versions e2e weekly tests --- .github/workflows/e2e-tests.yml | 3 + .github/workflows/e2e-weekly.yml | 243 ++++++++++++++++++ .../e2e/catalogVersions/catalogVersions.cy.ts | 66 +++++ .../settings/switchDescriptionId.cy.ts | 2 +- .../flows/camelRoute/catalogConfig.yaml | 25 ++ packages/ui-tests/cypress/support/e2e.ts | 3 + packages/ui-tests/package.json | 4 +- yarn.lock | 64 ++++- 8 files changed, 406 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/e2e-weekly.yml create mode 100644 packages/ui-tests/cypress/e2e/catalogVersions/catalogVersions.cy.ts create mode 100644 packages/ui-tests/cypress/fixtures/flows/camelRoute/catalogConfig.yaml diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index bbef0a99f..f035d1f81 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -105,6 +105,7 @@ jobs: working-directory: packages/ui-tests wait-on: 'http://127.0.0.1:4173' wait-on-timeout: 120 + env: grepTags=-weekly env: CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }} CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} @@ -164,6 +165,7 @@ jobs: working-directory: packages/ui-tests wait-on: 'http://127.0.0.1:4173' wait-on-timeout: 120 + env: grepTags=-weekly env: CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }} CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} @@ -223,6 +225,7 @@ jobs: working-directory: packages/ui-tests wait-on: 'http://127.0.0.1:4173' wait-on-timeout: 120 + env: grepTags=-weekly env: CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }} CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} diff --git a/.github/workflows/e2e-weekly.yml b/.github/workflows/e2e-weekly.yml new file mode 100644 index 000000000..a7ef18399 --- /dev/null +++ b/.github/workflows/e2e-weekly.yml @@ -0,0 +1,243 @@ +name: 🏗️ E2E Weekly Tests (Cypress) + +on: + schedule: + - cron: "0 0 * * 7" + +jobs: + install: + runs-on: ubuntu-latest + + container: + image: cypress/browsers:node-20.13.1-chrome-125.0.6422.60-1-ff-126.0-edge-125.0.2535.51-1 + options: --user 1001 + + steps: + - name: 👷‍♀️ Checkout + uses: actions/checkout@v4 + + - uses: actions/cache@v4 + with: + path: | + **/node_modules + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + cache: 'maven' + + # Install dependencies + - run: yarn install --immutable + + # Build packages excluding @kaoto/camel-catalog since it was build during installing dependencies + - name: Build packages + run: yarn workspaces foreach --verbose --all --topological-dev --exclude @kaoto/camel-catalog run build + + # Build lib + - name: Build @kaoto/kaoto package in lib mode + run: yarn workspace @kaoto/kaoto run build:lib + + - name: 💾 Save build folder + uses: actions/upload-artifact@v4 + with: + name: ui-dist + if-no-files-found: error + path: packages/ui/dist + + - name: 💾 Save catalog build folder + uses: actions/upload-artifact@v4 + with: + name: catalog-dist + if-no-files-found: error + path: packages/catalog-generator/dist/camel-catalog + + test-on-firefox: + needs: install + runs-on: ubuntu-latest + container: + image: cypress/browsers:node-20.13.1-chrome-125.0.6422.60-1-ff-126.0-edge-125.0.2535.51-1 + options: --user 1001 + + steps: + - name: 👷‍♀️ Checkout + uses: actions/checkout@v4 + + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + cache: 'maven' + + - name: 🗄️ Download the UI build folder + uses: actions/download-artifact@v4 + with: + name: ui-dist + path: packages/ui/dist + + - name: 🗄️ Download the catalog build folder + uses: actions/download-artifact@v4 + with: + name: catalog-dist + path: packages/camel-catalog/dist + + - name: 🔨 Cypress run + uses: cypress-io/github-action@v6.7.8 + with: + browser: firefox + # we have already installed all dependencies above + # install: false + start: yarn workspace @kaoto/kaoto run preview --host + config: baseUrl=http://localhost:4173 + working-directory: packages/ui-tests + wait-on: 'http://127.0.0.1:4173' + wait-on-timeout: 120 + env: grepTags=weekly + env: + CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }} + CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: 💾 Save videos + if: failure() + uses: actions/upload-artifact@v4 + with: + name: videos-firefox + path: packages/ui-tests/cypress/videos + + - name: 💾 Save screenshots + if: failure() + uses: actions/upload-artifact@v4 + with: + name: screenshots-firefox + path: packages/ui-tests/cypress/screenshots + + test-on-chrome: + needs: install + runs-on: ubuntu-latest + container: + image: cypress/browsers:node-20.13.1-chrome-125.0.6422.60-1-ff-126.0-edge-125.0.2535.51-1 + options: --user 1001 + + steps: + - name: 👷‍♀️ Checkout + uses: actions/checkout@v4 + + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + cache: 'maven' + + - name: 🗄️ Download the UI build folder + uses: actions/download-artifact@v4 + with: + name: ui-dist + path: packages/ui/dist + + - name: 🗄️ Download the catalog build folder + uses: actions/download-artifact@v4 + with: + name: catalog-dist + path: packages/camel-catalog/dist + + - name: 🔨 Cypress run + uses: cypress-io/github-action@v6.7.8 + with: + browser: chrome + # we have already installed all dependencies above + # install: false + start: yarn workspace @kaoto/kaoto run preview --host + config: baseUrl=http://localhost:4173 + working-directory: packages/ui-tests + wait-on: 'http://127.0.0.1:4173' + wait-on-timeout: 120 + env: grepTags=weekly + env: + CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }} + CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: 💾 Save videos + if: failure() + uses: actions/upload-artifact@v4 + with: + name: videos-chrome + path: packages/ui-tests/cypress/videos + + - name: 💾 Save screenshots + if: failure() + uses: actions/upload-artifact@v4 + with: + name: screenshots-chrome + path: packages/ui-tests/cypress/screenshots + + test-on-edge: + needs: install + runs-on: ubuntu-latest + container: + image: cypress/browsers:node-20.13.1-chrome-125.0.6422.60-1-ff-126.0-edge-125.0.2535.51-1 + options: --user 1001 + + steps: + - name: 👷‍♀️ Checkout + uses: actions/checkout@v4 + + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + cache: 'maven' + + - name: 🗄️ Download the UI build folder + uses: actions/download-artifact@v4 + with: + name: ui-dist + path: packages/ui/dist + + - name: 🗄️ Download the catalog build folder + uses: actions/download-artifact@v4 + with: + name: catalog-dist + path: packages/camel-catalog/dist + + - name: 🔨 Cypress run + uses: cypress-io/github-action@v6.7.8 + with: + browser: edge + # we have already installed all dependencies above + # install: false + start: yarn workspace @kaoto/kaoto run preview --host + config: baseUrl=http://localhost:4173 + working-directory: packages/ui-tests + wait-on: 'http://127.0.0.1:4173' + wait-on-timeout: 120 + env: grepTags=weekly + env: + CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }} + CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: 💾 Save videos + if: failure() + uses: actions/upload-artifact@v4 + with: + name: videos-edge + path: packages/ui-tests/cypress/videos + + - name: 💾 Save screenshots + if: failure() + uses: actions/upload-artifact@v4 + with: + name: screenshots-edge + path: packages/ui-tests/cypress/screenshots diff --git a/packages/ui-tests/cypress/e2e/catalogVersions/catalogVersions.cy.ts b/packages/ui-tests/cypress/e2e/catalogVersions/catalogVersions.cy.ts new file mode 100644 index 000000000..fc6370c32 --- /dev/null +++ b/packages/ui-tests/cypress/e2e/catalogVersions/catalogVersions.cy.ts @@ -0,0 +1,66 @@ +describe('Test for catalog versions', () => { + beforeEach(() => { + cy.openHomePage(); + }); + + const testData = [ + { type: 'Main', version: 'Camel Main 4.9.0' }, + { type: 'Main', version: 'Camel Main 4.4.0.redhat-00046' }, + { type: 'Main', version: 'Camel Main 4.8.0.redhat-00017' }, + { type: 'Main', version: 'Camel Main 4.4.4' }, + { type: 'Main', version: 'Camel Main 4.8.2' }, + { type: 'Quarkus', version: 'Camel Quarkus 3.17.0' }, + { type: 'Quarkus', version: 'Camel Quarkus 3.15.1' }, + { type: 'Quarkus', version: 'Camel Quarkus 3.8.4' }, + { type: 'Quarkus', version: 'Camel Quarkus 3.15.0.redhat-00007' }, + { type: 'Quarkus', version: 'Camel Quarkus 3.8.0.redhat-00018' }, + { type: 'Spring Boot', version: 'Camel Spring Boot 4.4.0.redhat-00039' }, + { type: 'Spring Boot', version: 'Camel Spring Boot 4.8.0.redhat-00022' }, + { type: 'Spring Boot', version: 'Camel Spring Boot 4.4.4' }, + { type: 'Spring Boot', version: 'Camel Spring Boot 4.8.2' }, + { type: 'Spring Boot', version: 'Camel Spring Boot 4.9.0' }, + ]; + testData.forEach((data) => { + it(`Catalog version test for ${data.version}`, { tags: ['weekly'] }, () => { + cy.uploadFixture('flows/camelRoute/catalogConfig.yaml'); + cy.openDesignPage(); + + cy.hoverOnRuntime(data.type); + cy.get(`[data-testid^="runtime-selector-${data.version}"] button.pf-v5-c-menu__item`) + .first() + .click({ force: true }); + cy.get('body').then((body) => { + if (body.find('[testid="loading-schemas"]').length > 0) { + cy.waitSchemasLoading(); + } + }); + + cy.openStepConfigurationTab('timer', 0); + cy.selectFormTab('All'); + // Check the configured fields didn't change in the node + cy.checkConfigInputObject('parameters.timerName', 'testTimerName'); + cy.checkConfigInputObject('parameters.delay', '2000'); + cy.checkConfigInputObject('parameters.period', '2000'); + cy.checkConfigInputObject('parameters.repeatCount', '10'); + + cy.openStepConfigurationTab('setHeader', 0); + cy.selectFormTab('All'); + // Check the configured fields didn't change in the node + cy.checkConfigInputObject('expression', 'testExpression'); + cy.checkConfigInputObject('id', 'testId'); + cy.checkConfigInputObject('name', 'testName'); + + cy.openStepConfigurationTab('log', 0); + cy.selectFormTab('All'); + // Check the configured fields didn't change in the node + cy.checkConfigInputObject('description', 'log'); + cy.checkConfigInputObject('logName', 'testLoggerName'); + cy.contains('button', 'Processor advanced properties').click(); + cy.checkConfigInputObject('marker', 'testMarker'); + + cy.selectPrependNode('log'); + cy.chooseFromCatalog('component', 'amqp'); + cy.checkNodeExist('amqp', 1); + }); + }); +}); diff --git a/packages/ui-tests/cypress/e2e/designer/settings/switchDescriptionId.cy.ts b/packages/ui-tests/cypress/e2e/designer/settings/switchDescriptionId.cy.ts index be330c781..0a702be33 100644 --- a/packages/ui-tests/cypress/e2e/designer/settings/switchDescriptionId.cy.ts +++ b/packages/ui-tests/cypress/e2e/designer/settings/switchDescriptionId.cy.ts @@ -4,7 +4,7 @@ describe('Tests for switching description and ID in settings page', () => { }); // Reset nodeLabel to description - after(() => { + afterEach(() => { cy.openSettings(); cy.selectInTypeaheadField('nodeLabel', 'description'); cy.get('[data-testid="settings-form-save-btn"]').click(); diff --git a/packages/ui-tests/cypress/fixtures/flows/camelRoute/catalogConfig.yaml b/packages/ui-tests/cypress/fixtures/flows/camelRoute/catalogConfig.yaml new file mode 100644 index 000000000..bbfb09496 --- /dev/null +++ b/packages/ui-tests/cypress/fixtures/flows/camelRoute/catalogConfig.yaml @@ -0,0 +1,25 @@ +- route: + id: route-3933 + from: + id: from-3455 + uri: timer + parameters: + delay: "2000" + fixedRate: false + period: "2000" + repeatCount: "10" + timerName: testTimerName + steps: + - setHeader: + id: setHeader-2258 + expression: + simple: + id: testId + expression: testExpression + name: testName + - log: + id: log-3491 + description: log + logName: testLoggerName + marker: testMarker + message: ${body} diff --git a/packages/ui-tests/cypress/support/e2e.ts b/packages/ui-tests/cypress/support/e2e.ts index dd3d80d07..0915e6165 100644 --- a/packages/ui-tests/cypress/support/e2e.ts +++ b/packages/ui-tests/cypress/support/e2e.ts @@ -20,6 +20,9 @@ import './next-commands/nodeConfiguration'; import './next-commands/design'; import './next-commands/metadata'; +import registerCypressGrep from '@cypress/grep/src/support'; +registerCypressGrep(); + Cypress.on('uncaught:exception', (_err, _runnable) => { // returning false here prevents Cypress from // failing the test diff --git a/packages/ui-tests/package.json b/packages/ui-tests/package.json index f9823c263..4d655c898 100644 --- a/packages/ui-tests/package.json +++ b/packages/ui-tests/package.json @@ -12,7 +12,8 @@ "license": "Apache License v2.0", "scripts": { "e2e": "cypress open --config-file=cypress.config.ts", - "e2e:headless": "cypress run", + "e2e:headless": "cypress run --env grepTags=-weekly", + "e2e:headless-weekly": "cypress run --env grepTags=weekly", "e2e-preview": "cypress open --config-file=cypress.config.ts --config baseUrl=http://localhost:4173/", "e2e-preview:headless": "cypress run --config baseUrl=http://localhost:4173/", "lint": "yarn eslint \"cypress/**/*.{ts,tsx}\" \"stories/**/*.{ts,tsx}\"", @@ -22,6 +23,7 @@ "chromatic": "chromatic --build-script-name 'build:storybook' --exit-zero-on-changes --project-token=chpt_7a4940aa65b14ab" }, "devDependencies": { + "@cypress/grep": "^4.1.0", "@eslint/js": "^9.10.0", "@kaoto/kaoto": "workspace:*", "@storybook/addon-essentials": "^8.2.8", diff --git a/yarn.lock b/yarn.lock index b9bcfd9c6..a9a568da5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1823,6 +1823,19 @@ __metadata: languageName: node linkType: hard +"@cypress/grep@npm:^4.1.0": + version: 4.1.0 + resolution: "@cypress/grep@npm:4.1.0" + dependencies: + debug: "npm:^4.3.4" + find-test-names: "npm:^1.28.18" + globby: "npm:^11.0.4" + peerDependencies: + cypress: ">=10" + checksum: 10/15a40991fb3b1ab5738c171b1dcd42c9eb2bde1e2bcb0ec69a058aff624715b92ec3fc860f66ce811dca0d60c3ec6ff4eab86793aaf3f6bc855042c36c0c8d7b + languageName: node + linkType: hard + "@cypress/request@npm:^3.0.0": version: 3.0.1 resolution: "@cypress/request@npm:3.0.1" @@ -2774,6 +2787,7 @@ __metadata: version: 0.0.0-use.local resolution: "@kaoto/kaoto-tests@workspace:packages/ui-tests" dependencies: + "@cypress/grep": "npm:^4.1.0" "@eslint/js": "npm:^9.10.0" "@kaoto/kaoto": "workspace:*" "@storybook/addon-essentials": "npm:^8.2.8" @@ -6871,6 +6885,15 @@ __metadata: languageName: node linkType: hard +"acorn-walk@npm:^8.2.0": + version: 8.3.4 + resolution: "acorn-walk@npm:8.3.4" + dependencies: + acorn: "npm:^8.11.0" + checksum: 10/871386764e1451c637bb8ab9f76f4995d408057e9909be6fb5ad68537ae3375d85e6a6f170b98989f44ab3ff6c74ad120bc2779a3d577606e7a0cd2b4efcaf77 + languageName: node + linkType: hard + "acorn@npm:^7.4.1": version: 7.4.1 resolution: "acorn@npm:7.4.1" @@ -9189,6 +9212,18 @@ __metadata: languageName: node linkType: hard +"debug@npm:^4.3.3": + version: 4.4.0 + resolution: "debug@npm:4.4.0" + dependencies: + ms: "npm:^2.1.3" + peerDependenciesMeta: + supports-color: + optional: true + checksum: 10/1847944c2e3c2c732514b93d11886575625686056cd765336212dc15de2d2b29612b6cd80e1afba767bb8e1803b778caf9973e98169ef1a24a7a7009e1820367 + languageName: node + linkType: hard + "debug@npm:^4.3.6": version: 4.3.6 resolution: "debug@npm:4.3.6" @@ -10618,6 +10653,24 @@ __metadata: languageName: node linkType: hard +"find-test-names@npm:^1.28.18": + version: 1.29.1 + resolution: "find-test-names@npm:1.29.1" + dependencies: + "@babel/parser": "npm:^7.24.7" + "@babel/plugin-syntax-jsx": "npm:^7.24.7" + acorn-walk: "npm:^8.2.0" + debug: "npm:^4.3.3" + globby: "npm:^11.0.4" + simple-bin-help: "npm:^1.8.0" + bin: + find-test-names: bin/find-test-names.js + print-tests: bin/print-tests.js + update-test-count: bin/update-test-count.js + checksum: 10/da5545517d103a99bf37f9f45912880c172a95142e4d7c979dc521f167b33c57d7095aa1bd7fea03c6c7afb0ec05592752889ea5a4e5bc40a73ef794160e88e6 + languageName: node + linkType: hard + "find-up@npm:^3.0.0": version: 3.0.0 resolution: "find-up@npm:3.0.0" @@ -11260,7 +11313,7 @@ __metadata: languageName: node linkType: hard -"globby@npm:^11.1.0": +"globby@npm:^11.0.4, globby@npm:^11.1.0": version: 11.1.0 resolution: "globby@npm:11.1.0" dependencies: @@ -14177,7 +14230,7 @@ __metadata: languageName: node linkType: hard -"ms@npm:2.1.3, ms@npm:^2.1.1": +"ms@npm:2.1.3, ms@npm:^2.1.1, ms@npm:^2.1.3": version: 2.1.3 resolution: "ms@npm:2.1.3" checksum: 10/aa92de608021b242401676e35cfa5aa42dd70cbdc082b916da7fb925c542173e36bce97ea3e804923fe92c0ad991434e4a38327e15a1b5b5f945d66df615ae6d @@ -16827,6 +16880,13 @@ __metadata: languageName: node linkType: hard +"simple-bin-help@npm:^1.8.0": + version: 1.8.0 + resolution: "simple-bin-help@npm:1.8.0" + checksum: 10/2333be11a8863f9ea7c5fbd9824824bcc56bfd91e436ea4364bd117600e9a2971ecdbaf1782924b53d3c16f393200e85ddbdf075a454375f80572481cd0aecd3 + languageName: node + linkType: hard + "simple-git@npm:^3.22.0": version: 3.25.0 resolution: "simple-git@npm:3.25.0"