Skip to content

Commit

Permalink
change env var name CYPRESS_baseurl to BASE_URL (#4262)
Browse files Browse the repository at this point in the history
  • Loading branch information
wojteknowacki authored Sep 27, 2023
1 parent d42076f commit fdc49f5
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 58 deletions.
5 changes: 5 additions & 0 deletions .changeset/tame-llamas-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

change env var name CYPRESS_baseurl to BASE_URL
2 changes: 1 addition & 1 deletion .github/actions/e2e/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
19 changes: 9 additions & 10 deletions .github/workflows/cypress-repeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@ 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
default: "10"
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
Expand All @@ -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

Expand All @@ -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 }}
Expand All @@ -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}}
command: npx cypress-repeat -n ${{ github.event.inputs.repeat}}
2 changes: 1 addition & 1 deletion .github/workflows/deploy-and-run-cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
70 changes: 34 additions & 36 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand All @@ -17,54 +16,53 @@ 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
env:
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:
Expand All @@ -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
Expand All @@ -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 }}
Expand All @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/tests-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>");
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 3 additions & 6 deletions playwright/pages/login-page.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import type {
Locator,
Page,
} from "@playwright/test";
import type { Locator, Page } from "@playwright/test";

export class LoginPage {
readonly page: Page;
Expand All @@ -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);
Expand Down

0 comments on commit fdc49f5

Please sign in to comment.