-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #239 from signadot/cypress-e2e-tests
Cypress E2E Tests
- Loading branch information
Showing
8 changed files
with
2,115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: cypress | ||
spec: | ||
cluster: "@{cluster}" | ||
labels: | ||
env: "@{env}" | ||
namespace: signadot-tests | ||
image: cypress/included:latest | ||
jobTimeout: 30m | ||
scaling: | ||
manual: | ||
desiredPods: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
spec: | ||
namePrefix: hotrod-cypress-e2e | ||
runnerGroup: cypress | ||
script: | | ||
#!/bin/bash | ||
set -e | ||
# Clone the git repo | ||
echo "Cloning signadot repo" | ||
git clone --single-branch -b $TARGET_BRANCH \ | ||
https://github.com/signadot/hotrod.git | ||
# Run the cypress e2e tests | ||
cd hotrod | ||
export CYPRESS_HOTROD_NAMESPACE=$HOTROD_NAMESPACE | ||
export CYPRESS_FRONTEND_SANDBOX_NAME=$FRONTEND_SANDBOX_NAME | ||
export CYPRESS_LOCATION_SANDBOX_NAME=$LOCATION_SANDBOX_NAME | ||
export CYPRESS_ROUTE_SANDBOX_NAME=$ROUTE_SANDBOX_NAME | ||
export CYPRESS_DRIVER_SANDBOX_NAME=$DRIVER_SANDBOX_NAME | ||
npx cypress run | ||
env: | ||
- name: TARGET_BRANCH | ||
value: "@{branch}" | ||
- name: HOTROD_NAMESPACE | ||
value: "@{namespace}" | ||
- name: FRONTEND_SANDBOX_NAME | ||
value: "@{frontend_sandbox_name}" | ||
- name: LOCATION_SANDBOX_NAME | ||
value: "@{location_sandbox_name}" | ||
- name: ROUTE_SANDBOX_NAME | ||
value: "@{route_sandbox_name}" | ||
- name: DRIVER_SANDBOX_NAME | ||
value: "@{driver_sandbox_name}" | ||
routingContext: | ||
sandbox: "@{sandbox}" | ||
uploadArtifact: | ||
- path: hotrod/cypress/videos/hotrod.cy.js.mp4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const { defineConfig } = require("cypress"); | ||
|
||
module.exports = defineConfig({ | ||
e2e: { | ||
video: true, | ||
experimentalStudio: true, | ||
env: { | ||
HOTROD_NAMESPACE: 'hotrod', | ||
SIGNADOT_ROUTING_KEY: '', | ||
FRONTEND_SANDBOX_NAME: '', | ||
LOCATION_SANDBOX_NAME: '', | ||
ROUTE_SANDBOX_NAME: '', | ||
DRIVER_SANDBOX_NAME: '', | ||
}, | ||
setupNodeEvents(on, config) { | ||
// implement node event listeners here | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
describe('hotrod spec', () => { | ||
it('request ride', | ||
() => { | ||
var frontendURL = 'http://frontend.' + Cypress.env('HOTROD_NAMESPACE') + ':8080'; | ||
// inject routing key | ||
cy.intercept(frontendURL + '/*', (req) => { | ||
req.headers['baggage'] += ',sd-routing-key=' + Cypress.env('SIGNADOT_ROUTING_KEY'); | ||
}) | ||
|
||
cy.visit(frontendURL); | ||
cy.get('#requestRide').click(); | ||
cy.get(':nth-child(1) > .col').click(); | ||
cy.get(':nth-child(7) > .col > .text-success').click(); | ||
cy.get(':nth-child(7) > .col > .text-success').contains(/Driver (.*) arriving in (.*)./); | ||
|
||
// check routing context | ||
var frontendSandboxName = Cypress.env('FRONTEND_SANDBOX_NAME'); | ||
if (frontendSandboxName === "") { | ||
cy.get(':nth-child(3) > .col > .frontend').should('have.text', 'frontend (baseline)'); | ||
} else { | ||
cy.get(':nth-child(3) > .col > .frontend').should('have.text', 'frontend (sandbox=' + frontendSandboxName + ')'); | ||
} | ||
var locationSandboxName = Cypress.env('LOCATION_SANDBOX_NAME'); | ||
if (locationSandboxName === "") { | ||
cy.get(':nth-child(4) > .col > .location').should('have.text', 'location (baseline)'); | ||
} else { | ||
cy.get(':nth-child(4) > .col > .location').should('have.text', 'location (sandbox=' + locationSandboxName + ')'); | ||
} | ||
var routeSandboxName = Cypress.env('ROUTE_SANDBOX_NAME'); | ||
if (routeSandboxName === "") { | ||
cy.get(':nth-child(6) > .col > .route').should('have.text', 'route (baseline)'); | ||
} else { | ||
cy.get(':nth-child(6) > .col > .route').should('have.text', 'route (sandbox=' + routeSandboxName + ')'); | ||
} | ||
var driverSandboxName = Cypress.env('DRIVER_SANDBOX_NAME'); | ||
if (driverSandboxName === "") { | ||
cy.get(':nth-child(7) > .col > .driver').should('have.text', 'driver (baseline)'); | ||
} else { | ||
cy.get(':nth-child(7) > .col > .driver').should('have.text', 'driver (sandbox=' + driverSandboxName + ')'); | ||
} | ||
}); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// *********************************************** | ||
// This example commands.js shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add('login', (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// *********************************************************** | ||
// This example support/e2e.js is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands' | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |
Oops, something went wrong.