From fdc49f52d9b59907192bb6b06ca2558556d7281c Mon Sep 17 00:00:00 2001 From: wojteknowacki <124166231+wojteknowacki@users.noreply.github.com> Date: Wed, 27 Sep 2023 15:06:13 +0200 Subject: [PATCH] change env var name CYPRESS_baseurl to BASE_URL (#4262) --- .changeset/tame-llamas-crash.md | 5 ++ .github/actions/e2e/action.yml | 2 +- .github/workflows/cypress-repeat.yml | 19 +++--- .github/workflows/deploy-and-run-cypress.yml | 2 +- .github/workflows/e2e.yml | 70 ++++++++++---------- .github/workflows/tests-nightly.yml | 2 +- cypress.config.js | 2 +- cypress/plugins/index.js | 2 +- playwright.config.ts | 2 +- playwright/pages/login-page.ts | 9 +-- 10 files changed, 57 insertions(+), 58 deletions(-) create mode 100644 .changeset/tame-llamas-crash.md diff --git a/.changeset/tame-llamas-crash.md b/.changeset/tame-llamas-crash.md new file mode 100644 index 00000000000..e548f8765e9 --- /dev/null +++ b/.changeset/tame-llamas-crash.md @@ -0,0 +1,5 @@ +--- +"saleor-dashboard": patch +--- + +change env var name CYPRESS_baseurl to BASE_URL diff --git a/.github/actions/e2e/action.yml b/.github/actions/e2e/action.yml index c7be458b780..68fc60de97f 100644 --- a/.github/actions/e2e/action.yml +++ b/.github/actions/e2e/action.yml @@ -60,7 +60,7 @@ runs: env: API_URI: ${{inputs.apiUrl}} APP_MOUNT_URI: ${{ inputs.appMountUri }} - CYPRESS_baseUrl: ${{inputs.baseUrl}} + BASE_URL: ${{inputs.baseUrl}} CYPRESS_USER_NAME: ${{ inputs.userName }} CYPRESS_SECOND_USER_NAME: ${{ inputs.secondUserName }} CYPRESS_USER_PASSWORD: ${{ inputs.userPassword }} diff --git a/.github/workflows/cypress-repeat.yml b/.github/workflows/cypress-repeat.yml index 633084a24c8..e9fdb0ad8a3 100644 --- a/.github/workflows/cypress-repeat.yml +++ b/.github/workflows/cypress-repeat.yml @@ -5,17 +5,17 @@ on: inputs: spec: required: false - description: 'Spec to run. Leave empty if you prefer to filter tests using grep' + description: "Spec to run. Leave empty if you prefer to filter tests using grep" grep: required: false - description: 'Run all tests which titles contain text. Leave empty if you prefer to filter tests using spec.' + description: "Run all tests which titles contain text. Leave empty if you prefer to filter tests using spec." dashboard_url: required: true - default: 'https://automation-dashboard.staging.saleor.cloud/dashboard' + default: "https://automation-dashboard.staging.saleor.cloud/dashboard" description: "Dashboard url" API_url: required: true - default: 'https://automation-dashboard.staging.saleor.cloud/graphql/' + default: "https://automation-dashboard.staging.saleor.cloud/graphql/" description: "API url" repeat: required: true @@ -23,7 +23,6 @@ on: description: "How many times run tests" jobs: - run-tests: if: ${{ github.event.inputs.spec }} || ${{ github.event.inputs.grep }} ## Do not run if spec or grep not provided runs-on: ubuntu-latest @@ -35,10 +34,10 @@ jobs: uses: actions/setup-node@v3 with: node-version-file: ".nvmrc" - + - name: Package run: npm ci - + - name: Install cypress-repeat run: npm i -D cypress-repeat @@ -48,7 +47,7 @@ jobs: env: API_URI: ${{ github.event.inputs.API_url}} APP_MOUNT_URI: ${{ secrets.APP_MOUNT_URI }} - CYPRESS_baseUrl: ${{ github.event.inputs.dashboard_url}} + BASE_URL: ${{ github.event.inputs.dashboard_url}} CYPRESS_USER_NAME: ${{ secrets.CYPRESS_USER_NAME }} CYPRESS_SECOND_USER_NAME: ${{ secrets.CYPRESS_SECOND_USER_NAME }} CYPRESS_USER_PASSWORD: ${{ secrets.CYPRESS_USER_PASSWORD }} @@ -62,8 +61,8 @@ jobs: STRIPE_PUBLIC_KEY: ${{ secrets.STRIPE_PUBLIC_KEY }} with: parallel: true - group: 'UI - Chrome' + group: "UI - Chrome" record: true tag: Repeat spec: ${{ github.event.inputs.spec }} - command: npx cypress-repeat -n ${{ github.event.inputs.repeat}} \ No newline at end of file + command: npx cypress-repeat -n ${{ github.event.inputs.repeat}} diff --git a/.github/workflows/deploy-and-run-cypress.yml b/.github/workflows/deploy-and-run-cypress.yml index d2d85a5f8ab..5acc93a5773 100644 --- a/.github/workflows/deploy-and-run-cypress.yml +++ b/.github/workflows/deploy-and-run-cypress.yml @@ -110,7 +110,7 @@ jobs: env: API_URI: ${{github.event.inputs.api_url}} APP_MOUNT_URI: ${{ secrets.APP_MOUNT_URI }} - CYPRESS_baseUrl: https://${{needs.deploy.outputs.base_URL}} + BASE_URL: https://${{needs.deploy.outputs.base_URL}} CYPRESS_USER_NAME: ${{ secrets.CYPRESS_USER_NAME }} CYPRESS_SECOND_USER_NAME: ${{ secrets.CYPRESS_SECOND_USER_NAME }} CYPRESS_USER_PASSWORD: ${{ secrets.CYPRESS_USER_PASSWORD }} diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 0b2133dc2fa..f6170b20fce 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -5,9 +5,8 @@ on: types: [edited, labeled] jobs: - get-selected-tags-and-containers: - if: ${{ contains(github.event.pull_request.labels.*.name, 'run e2e') }} + if: ${{ contains(github.event.pull_request.labels.*.name, 'run e2e') }} runs-on: ubuntu-latest outputs: tags: ${{steps.get_tags.outputs.result}} @@ -17,26 +16,26 @@ jobs: - name: Get tags id: get_tags uses: actions/github-script@v6 - env: + env: pullRequestBody: ${{ github.event.pull_request.body }} with: result-encoding: string script: | - const { pullRequestBody } = process.env - const tags = ["@critical"]; - try{ - const removedPullRequestBodyBeforeTests = pullRequestBody.split(`### Do you want to run more stable tests?`); - const removedPullRequestBodyAfterTests = removedPullRequestBodyBeforeTests[1].split(`CONTAINERS`); - let tagsInString = removedPullRequestBodyAfterTests[0]; - tagsInString = tagsInString.split('\n'); - tagsInString.forEach(line => { - if (line.includes('[x]')) tags.push(line.replace(/[0-9]+\. \[x\] /, "@stable+@")) - }); - const tagsToReturn = tags.join(",").toString(); - return tagsToReturn.replace(/\r/g, '') - }catch{ - return '@critical' - } + const { pullRequestBody } = process.env + const tags = ["@critical"]; + try{ + const removedPullRequestBodyBeforeTests = pullRequestBody.split(`### Do you want to run more stable tests?`); + const removedPullRequestBodyAfterTests = removedPullRequestBodyBeforeTests[1].split(`CONTAINERS`); + let tagsInString = removedPullRequestBodyAfterTests[0]; + tagsInString = tagsInString.split('\n'); + tagsInString.forEach(line => { + if (line.includes('[x]')) tags.push(line.replace(/[0-9]+\. \[x\] /, "@stable+@")) + }); + const tagsToReturn = tags.join(",").toString(); + return tagsToReturn.replace(/\r/g, '') + }catch{ + return '@critical' + } - name: get-containers id: get_containers uses: actions/github-script@v6 @@ -44,27 +43,26 @@ jobs: pullRequestBody: ${{ github.event.pull_request.body }} with: script: | - const { pullRequestBody } = process.env - const containers = []; - const numberOfContainersRegex = /CONTAINERS=(\d*)/ - const numberOfContainers = pullRequestBody.match(numberOfContainersRegex); - for(let i=1; i<=numberOfContainers[1]; i++){ - containers.push(i) - } - return {"containers": containers} + const { pullRequestBody } = process.env + const containers = []; + const numberOfContainersRegex = /CONTAINERS=(\d*)/ + const numberOfContainers = pullRequestBody.match(numberOfContainersRegex); + for(let i=1; i<=numberOfContainers[1]; i++){ + containers.push(i) + } + return {"containers": containers} install-cypress: needs: get-selected-tags-and-containers runs-on: ubuntu-latest steps: - - name: Checkout uses: actions/checkout@v2 - name: Setup Node uses: actions/setup-node@v3 with: - node-version-file: '.nvmrc' - + node-version-file: ".nvmrc" + - name: Wait for Deploy and tests uses: lewagon/wait-on-check-action@v1.0.0 with: @@ -79,20 +77,20 @@ jobs: with: # Disable running of tests within install job runTests: false - + run-tests-in-parallel-on-label: needs: [get-selected-tags-and-containers, install-cypress] runs-on: ubuntu-latest env: - NODE_OPTIONS: "--max_old_space_size=4096" + NODE_OPTIONS: "--max_old_space_size=4096" container: cypress/browsers:node18.12.0-chrome106-ff106 strategy: fail-fast: false max-parallel: 10 - matrix: ${{ fromJson(needs.get-selected-tags-and-containers.outputs.containers) }} + matrix: + ${{ fromJson(needs.get-selected-tags-and-containers.outputs.containers) }} # run copies of the current job in parallel steps: - - uses: rlespinasse/github-slug-action@3.1.0 - name: Set domain @@ -117,7 +115,7 @@ jobs: env: API_URI: ${{ steps.api_uri.outputs.custom_api_uri }} APP_MOUNT_URI: ${{ secrets.APP_MOUNT_URI }} - CYPRESS_baseUrl: https://${{ steps.set-domain.outputs.domain }}/ + BASE_URL: https://${{ steps.set-domain.outputs.domain }}/ CYPRESS_USER_NAME: ${{ secrets.CYPRESS_USER_NAME }} CYPRESS_SECOND_USER_NAME: ${{ secrets.CYPRESS_SECOND_USER_NAME }} CYPRESS_USER_PASSWORD: ${{ secrets.CYPRESS_USER_PASSWORD }} @@ -126,9 +124,9 @@ jobs: CYPRESS_mailHogUrl: ${{ secrets.CYPRESS_MAILHOG }} COMMIT_INFO_MESSAGE: ${{ needs.get-selected-tags-and-containers.outputs.tags }} tests triggered on PR - https://github.com/${{ github.repository }}/pull/${{ github.ref_name }} CYPRESS_grepTags: ${{ needs.get-selected-tags-and-containers.outputs.tags }} - CYPRESS_MAILPITURL: ${{ secrets.CYPRESS_MAILPITURL }} + CYPRESS_MAILPITURL: ${{ secrets.CYPRESS_MAILPITURL }} with: parallel: true - group: 'UI - Chrome' + group: "UI - Chrome" record: true tag: e2eTestsOnPR diff --git a/.github/workflows/tests-nightly.yml b/.github/workflows/tests-nightly.yml index b0a641712d1..423df6e1757 100644 --- a/.github/workflows/tests-nightly.yml +++ b/.github/workflows/tests-nightly.yml @@ -312,7 +312,7 @@ jobs: env: API_URI: ${{ needs.get-environment-variables.outputs.url }}graphql/ APP_MOUNT_URI: ${{ secrets.APP_MOUNT_URI }} - CYPRESS_baseUrl: ${{ needs.get-environment-variables.outputs.url }}dashboard/ + BASE_URL: ${{ needs.get-environment-variables.outputs.url }}dashboard/ CYPRESS_USER_NAME: ${{ secrets.CYPRESS_USER_NAME }} CYPRESS_SECOND_USER_NAME: ${{ secrets.CYPRESS_SECOND_USER_NAME }} CYPRESS_USER_PASSWORD: ${{ secrets.CYPRESS_USER_PASSWORD }} diff --git a/cypress.config.js b/cypress.config.js index 5266348343c..eff2c428187 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -28,7 +28,7 @@ module.exports = defineConfig({ numTestsKeptInMemory: 10, experimentalMemoryManagement: true, }, - baseUrl: process.env.CYPRESS_baseUrl, + baseUrl: process.env.BASE_URL, async setupNodeEvents(on, config) { config = require("./cypress/support/cypress-grep/plugin")(config); config = await require("./cypress/plugins/index.js")(on, config); diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js index 29d87bcb3ee..1c73490b057 100644 --- a/cypress/plugins/index.js +++ b/cypress/plugins/index.js @@ -37,7 +37,7 @@ module.exports = async (on, config) => { process.env.CYPRESS_PERMISSIONS_USERS_PASSWORD; config.env.MAILPITURL = process.env.CYPRESS_MAILPITURL; config.env.grepTags = process.env.CYPRESS_grepTags; - config.baseUrl = process.env.CYPRESS_baseUrl; + config.baseUrl = process.env.BASE_URL; on("before:browser:launch", (_browser = {}, launchOptions) => { launchOptions.args.push("--proxy-bypass-list=<-loopback>"); diff --git a/playwright.config.ts b/playwright.config.ts index 7dc832b462b..3b5931657f3 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -18,7 +18,7 @@ export default defineConfig({ // }, /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { - baseURL: process.env.CYPRESS_baseUrl, + baseURL: process.env.BASE_URL, trace: "on-first-retry", screenshot: "only-on-failure", testIdAttribute: "data-test-id", diff --git a/playwright/pages/login-page.ts b/playwright/pages/login-page.ts index 89850080016..2628c055649 100644 --- a/playwright/pages/login-page.ts +++ b/playwright/pages/login-page.ts @@ -1,7 +1,4 @@ -import type { - Locator, - Page, -} from "@playwright/test"; +import type { Locator, Page } from "@playwright/test"; export class LoginPage { readonly page: Page; @@ -24,9 +21,9 @@ export class LoginPage { await this.signInButton.click(); } async goto() { - const CYPRESS_baseUrl = process.env.CYPRESS_baseUrl; + const BASE_URL = process.env.BASE_URL; const loginPageUrl = - CYPRESS_baseUrl === "http://localhost:9000/" + BASE_URL === "http://localhost:9000/" ? "http://localhost:9000/" : "/dashboard"; await this.page.goto(loginPageUrl);