Skip to content

Commit

Permalink
Upgrade cypress (#376)
Browse files Browse the repository at this point in the history
* [Cypress:] upgrade to latest

* [Cypress:] use CYPRESS_BROWSER var

* [Cypress:] remove unused tests

* [Cypress:] fix tests for upgrade

* [Cypress:] use latest cypress client image
  • Loading branch information
hgw77 authored Jul 24, 2023
1 parent 44d7435 commit 9d5b3fa
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 196 deletions.
56 changes: 22 additions & 34 deletions ci/pipeline.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -541,19 +541,17 @@ jobs:
inputs:
- name: ui-storybook.git
path: /app/juno
params:
CYPRESS_API_URL: "https://director.cypress.qa-de-1.cloud.sap"
CYPRESS_BROWSER: chrome

run:
path: /bin/sh
args:
- -c
- |
CYPRESS_BROWSER=chrome
cd /app/juno/e2e
CI_BUID_ID="$(date) - CI - ui-components-qa-tests - $CYPRESS_BROWSER $BROWSER_VERSION" && \
CI_BUID_ID="$(date) - CI - ui-components-qa-tests - $CYPRESS_BROWSER" && \
echo $CI_BUID_ID && \
CYPRESS_BASE_URL=https://ui.juno.qa-de-1.cloud.sap cy2 run --record --key 'juno' --parallel --ci-build-id "$CI_BUID_ID" --browser $CYPRESS_BROWSER --spec "cypress/integration/ui-storybook/*"
CYPRESS_BASE_URL=https://ui.juno.qa-de-1.cloud.sap cypress-cloud run --parallel --ci-build-id "$CI_BUID_ID" --browser $CYPRESS_BROWSER --spec "cypress/integration/ui-storybook/*"

# DEPLOY STORYBOOK TO PROD
- name: deploy-storybook-to-s-eu-nl-1
Expand Down Expand Up @@ -605,19 +603,17 @@ jobs:
inputs:
- name: ui-storybook.git
path: /app/juno
params:
CYPRESS_API_URL: "https://director.cypress.qa-de-1.cloud.sap"
CYPRESS_BROWSER: chrome

run:
path: /bin/sh
args:
- -c
- |
CYPRESS_BROWSER=chrome
cd /app/juno/e2e
CI_BUID_ID="$(date) - CI - ui-components-qa-tests - $CYPRESS_BROWSER $BROWSER_VERSION" && \
CI_BUID_ID="$(date) - CI - ui-components-qa-tests - $CYPRESS_BROWSER" && \
echo $CI_BUID_ID && \
CYPRESS_BASE_URL=https://ui.juno.eu-nl-1.cloud.sap cy2 run --record --key 'juno' --parallel --ci-build-id "$CI_BUID_ID" --browser $CYPRESS_BROWSER --spec "cypress/integration/ui-storybook/*"
CYPRESS_BASE_URL=https://ui.juno.eu-nl-1.cloud.sap cypress-cloud run --record --parallel --ci-build-id "$CI_BUID_ID" --browser $CYPRESS_BROWSER --spec "cypress/integration/ui-storybook/*"


############ ASSETS SERVER #########
Expand Down Expand Up @@ -673,19 +669,17 @@ jobs:
inputs:
- name: juno.git
path: /app/juno
params:
CYPRESS_API_URL: "https://director.cypress.qa-de-1.cloud.sap"
CYPRESS_BROWSER: chrome

run:
path: /bin/sh
args:
- -c
- |
CYPRESS_BROWSER=chrome
cd /app/juno/e2e
CI_BUID_ID="$(date) - CI - assets-qa-tests - $CYPRESS_BROWSER $BROWSER_VERSION" && \
CI_BUID_ID="$(date) - CI - assets-qa-tests - $CYPRESS_BROWSER" && \
echo $CI_BUID_ID && \
CYPRESS_BASE_URL=https://assets.juno.qa-de-1.cloud.sap cy2 run --record --key 'juno' --parallel --ci-build-id "$CI_BUID_ID" --browser $CYPRESS_BROWSER --spec "cypress/integration/assets-server/*"
CYPRESS_BASE_URL=https://assets.juno.qa-de-1.cloud.sap cypress-cloud run --record --parallel --ci-build-id "$CI_BUID_ID" --browser $CYPRESS_BROWSER --spec "cypress/integration/assets-server/*"


# PROMOTE TO PROD
Expand Down Expand Up @@ -771,19 +765,17 @@ jobs:
inputs:
- name: juno.git
path: /app/juno
params:
CYPRESS_API_URL: "https://director.cypress.qa-de-1.cloud.sap"
CYPRESS_BROWSER: chrome

run:
path: /bin/sh
args:
- -c
- |
CYPRESS_BROWSER=chrome
cd /app/juno/e2e
CI_BUID_ID="$(date) - CI - assets-qa-tests - $CYPRESS_BROWSER $BROWSER_VERSION" && \
CI_BUID_ID="$(date) - CI - assets-qa-tests - $CYPRESS_BROWSER" && \
echo $CI_BUID_ID && \
CYPRESS_BASE_URL=https://assets.juno.global.cloud.sap cy2 run --record --key 'juno' --parallel --ci-build-id "$CI_BUID_ID" --browser $CYPRESS_BROWSER --spec "cypress/integration/assets-server/*"
CYPRESS_BASE_URL=https://assets.juno.global.cloud.sap cypress-cloud run --record --parallel --ci-build-id "$CI_BUID_ID" --browser $CYPRESS_BROWSER --spec "cypress/integration/assets-server/*"

<% end %>

Expand Down Expand Up @@ -833,22 +825,20 @@ jobs:
inputs:
- name: hosting.git
path: /app/juno
params:
CYPRESS_API_URL: "https://director.cypress.qa-de-1.cloud.sap"
CYPRESS_BROWSER: chrome

run:
path: /bin/sh
args:
- -c
- |
CYPRESS_BROWSER=chrome
cd /app/juno/e2e
CI_BUID_ID="$(date) - CI - dashboard-qa-tests - $CYPRESS_BROWSER $BROWSER_VERSION" && \
CI_BUID_ID="$(date) - CI - dashboard-qa-tests - $CYPRESS_BROWSER" && \
echo $CI_BUID_ID && \
CYPRESS_BASE_URL=https://juno.qa-de-1.cloud.sap cy2 run --record --key 'juno' --parallel --ci-build-id "$CI_BUID_ID" --browser $CYPRESS_BROWSER --spec "cypress/integration/hosting/dashboard*" && \
CI_BUID_ID="$(date) - CI - exampleapp-components-qa-tests - $CYPRESS_BROWSER $BROWSER_VERSION" && \
CYPRESS_BASE_URL=https://juno.qa-de-1.cloud.sap cypress-cloud run --record --parallel --ci-build-id "$CI_BUID_ID" --browser $CYPRESS_BROWSER --spec "cypress/integration/hosting/dashboard*" && \
CI_BUID_ID="$(date) - CI - exampleapp-components-qa-tests - $CYPRESS_BROWSER" && \
echo $CI_BUID_ID && \
CYPRESS_BASE_URL=https://exampleapp.juno.qa-de-1.cloud.sap cy2 run --record --key 'juno' --parallel --ci-build-id "$CI_BUID_ID" --browser $CYPRESS_BROWSER --spec "cypress/integration/hosting/exampleapp*"
CYPRESS_BASE_URL=https://exampleapp.juno.qa-de-1.cloud.sap cypress-cloud run --record --parallel --ci-build-id "$CI_BUID_ID" --browser $CYPRESS_BROWSER --spec "cypress/integration/hosting/exampleapp*"

# DEPLOY HOSTING TO PROD
- name: deploy-hosting-to-s-eu-nl-1
Expand Down Expand Up @@ -896,18 +886,16 @@ jobs:
inputs:
- name: hosting.git
path: /app/juno
params:
CYPRESS_API_URL: "https://director.cypress.qa-de-1.cloud.sap"
CYPRESS_BROWSER: chrome

run:
path: /bin/sh
args:
- -c
- |
CYPRESS_BROWSER=chrome
cd /app/juno/e2e
CI_BUID_ID="$(date) - CI - dashboard-qa-tests - $CYPRESS_BROWSER $BROWSER_VERSION" && \
CI_BUID_ID="$(date) - CI - dashboard-qa-tests - $CYPRESS_BROWSER" && \
echo $CI_BUID_ID && \
CYPRESS_BASE_URL=https://juno.global.cloud.sap cy2 run --record --key 'juno' --parallel --ci-build-id "$CI_BUID_ID" --browser $CYPRESS_BROWSER --spec "cypress/integration/hosting/dashboard*" && \
CYPRESS_BASE_URL=https://ccloud.juno.global.cloud.sap cy2 run --record --key 'juno' --parallel --ci-build-id "$CI_BUID_ID" --browser $CYPRESS_BROWSER --spec "cypress/integration/hosting/dashboard*" && \
CYPRESS_BASE_URL=https://convergedcloud.juno.global.cloud.sap cy2 run --record --key 'juno' --parallel --ci-build-id "$CI_BUID_ID" --browser $CYPRESS_BROWSER --spec "cypress/integration/hosting/dashboard*"
CYPRESS_BASE_URL=https://juno.global.cloud.sap cypress-cloud run --record --parallel --ci-build-id "$CI_BUID_ID" --browser $CYPRESS_BROWSER --spec "cypress/integration/hosting/dashboard*" && \
CYPRESS_BASE_URL=https://ccloud.juno.global.cloud.sap cypress-cloud run --record --parallel --ci-build-id "$CI_BUID_ID" --browser $CYPRESS_BROWSER --spec "cypress/integration/hosting/dashboard*" && \
CYPRESS_BASE_URL=https://convergedcloud.juno.global.cloud.sap cypress-cloud run --record --parallel --ci-build-id "$CI_BUID_ID" --browser $CYPRESS_BROWSER --spec "cypress/integration/hosting/dashboard*"
32 changes: 30 additions & 2 deletions e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,41 @@
## run dashboard e2e tests against localhost

```bash
./run.sh dashboard
./run.sh assets-server
```

## run dashboard e2e tests against remote host

### asset-server

```bash
./run.sh --host https://assets.juno.qa-de-1.cloud.sap assets-server
```

### dashboard

```bash
./run.sh --host https://juno.global.cloud.sap --app hosting dashboard
```

### exampleapp

```bash
./run.sh --host https://juno.global.cloud.sap --app hosting exampleapp
```

### hosting

tests for dashboard and exampleapp at once

```bash
./run.sh --host https://juno.global.cloud.sap --app hosting
```

### storybook

```bash
./run.sh --host https://juno.qa-de-1.cloud.sap dashboard
./run.sh --host https://ui.juno.qa-de-1.cloud.sap --app ui-storybook
```

## run all e2e tests against localhost
Expand Down
5 changes: 5 additions & 0 deletions e2e/currents.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
projectId: "juno",
recordKey: "ui",
cloudServiceUrl: "https://director.cypress.qa-de-1.cloud.sap",
}
26 changes: 26 additions & 0 deletions e2e/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const { defineConfig } = require("cypress")
const { cloudPlugin } = require("cypress-cloud/plugin")

module.exports = defineConfig({
defaultCommandTimeout: 20000,
viewportWidth: 1300,
viewportHeight: 1100,
videoCompression: 20,
includeShadowDom: true,
chromeWebSecurity: false,

e2e: {
setupNodeEvents(on, config) {
on("task", {
log(message) {
console.log(message)

return null
},
})
return cloudPlugin(on, config)
},
supportFile: "cypress/support/index.js", // Path to file to load before spec files load. This file is compiled and bundled. (Pass false to disable)
specPattern: "cypress/integration/**/*.{js,jsx}", // A String or Array of glob patterns of the test files to load.
},
})
8 changes: 0 additions & 8 deletions e2e/cypress.json

This file was deleted.

42 changes: 21 additions & 21 deletions e2e/cypress/integration/assets-server/mount_assets.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,33 @@ describe("mount app", () => {
})
})

afterEach(() => {
cy.wait(DELAY * apps.length).then(() => {
expect(windowErrorSpy).to.not.be.called
expect(windowWarnSpy).to.not.be.called
})
})

it("can mount apps without errors", () => {
apps.forEach(async (app) => {
let appConf = { name: app.name, version: app.version, props: {} }

// if (appConf.name === "dashboard") appConf.name = "blablabla"
if (app.appProps) {
Object.keys(app.appProps).forEach((key) => {
if (app.appProps[key]?.type === "required")
appConf.props[key] = "test"
if (appConf.name === "exampleapp") {
if (app.appProps) {
Object.keys(app.appProps).forEach((key) => {
if (app.appProps[key]?.type === "required")
appConf.props[key] = "test"
})
}
cy.log("mount app: " + JSON.stringify(appConf))
let encodedAppConf = btoa(JSON.stringify(appConf))
// load module file (index.js)
cy.request(app.entryFile).should((response) => {
expect(response.status).to.eq(200)
})
cy.visit("/mount-test.html?config=" + encodedAppConf)
cy.wait(DELAY).then(() => {
cy.get(`[data-juno-app="${app.name}"]`).should("exist") // check if app is mounted)
cy.wait(DELAY).then(() => {
expect(windowErrorSpy).to.not.be.called
expect(windowWarnSpy).to.not.be.called
})
cy.log("\x1b[32mSUCCESS\x1b[37m")
})
}
cy.log("mount app: " + JSON.stringify(appConf))
let encodedAppConf = btoa(JSON.stringify(appConf))
// load module file (index.js)
cy.request(app.entryFile).should((response) => {
expect(response.status).to.eq(200)
})
cy.visit("/mount-test.html?config=" + encodedAppConf)
cy.get(`[data-juno-app="${app.name}"]`).should("exist") // check if app is mounted)
cy.log("\x1b[32mSUCCESS\x1b[37m")
})
})
})
18 changes: 0 additions & 18 deletions e2e/cypress/integration/greenhouse/app.spec.js

This file was deleted.

18 changes: 0 additions & 18 deletions e2e/cypress/integration/heureka/app.spec.js

This file was deleted.

3 changes: 2 additions & 1 deletion e2e/cypress/integration/hosting/dashboard.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe("Dashboard", () => {
before(() => {
beforeEach(() => {
cy.visit("/")
})

Expand All @@ -14,6 +14,7 @@ describe("Dashboard", () => {
})

it("contains login button", () => {
cy.visit("/")
cy.contains("button", "Log in")
})

Expand Down
18 changes: 0 additions & 18 deletions e2e/cypress/integration/volta/app.spec.js

This file was deleted.

18 changes: 0 additions & 18 deletions e2e/cypress/integration/whois/app.spec.js

This file was deleted.

Loading

0 comments on commit 9d5b3fa

Please sign in to comment.