Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate existing Cypress tests to Cypress + Cucumber #56970

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
699eea4
chore: move gitignore to the cypress directory
mdelapenya Feb 3, 2020
70930c0
chore: ignore more test files
mdelapenya Feb 3, 2020
dc5e03b
fix: do not check the Loading Message
mdelapenya Feb 3, 2020
2205b6d
chore: use cypres + webpack + cucumber scaffolding
mdelapenya Feb 3, 2020
d75e0ef
chore: add eslint and prettier for code linting
mdelapenya Feb 3, 2020
4050a76
feat: convert existing Cypress test into BDD style
mdelapenya Feb 4, 2020
0a65007
feat: add support for using proper Node version in MacOSX
mdelapenya Feb 4, 2020
7d9fcbf
chore: use tslint
mdelapenya Feb 4, 2020
687b796
chore: use old layout
mdelapenya Feb 4, 2020
5e39f14
chore: remove prelint script meanwhile we fix TS lint
mdelapenya Feb 4, 2020
f781eb5
chore: move test results to a specific directory
mdelapenya Feb 4, 2020
7eec1dc
chore: rename variable following old code
mdelapenya Feb 4, 2020
dfd1cbc
chore: remove non-needed lints, as we are going to use kibana build
mdelapenya Feb 6, 2020
7d4b9d6
chore: import snapshot function from cypress
mdelapenya Feb 6, 2020
446c9e6
chore: add readFile utils back from a bad removal
mdelapenya Feb 6, 2020
6cfadf1
chore: change format of JSON spec file
mdelapenya Feb 6, 2020
e35d28e
chore: move CI directory to the proper layout in order for Jenkins to…
mdelapenya Feb 6, 2020
cffc9be
chore: store test-results from proper dir on Jenkins
mdelapenya Feb 6, 2020
8f1deee
chore: store artifacts properly on Jenkins
mdelapenya Feb 6, 2020
db14dba
Merge branch 'master' into cypress-cucumber
elasticmachine Feb 6, 2020
03442fd
Fix type issues
dgieselaar Feb 7, 2020
031910e
Merge branch 'master' into cypress-cucumber
elasticmachine Feb 7, 2020
f7b5871
Merge branch 'master' into cypress-cucumber
mdelapenya Feb 10, 2020
53fd242
chore: move APM UI tests dependencies to x-pack dir
mdelapenya Feb 10, 2020
ef117c8
Merge branch 'master' into cypress-cucumber
elasticmachine Feb 10, 2020
46777c0
Merge branch 'master' into cypress-cucumber
mdelapenya Feb 10, 2020
90ae2ad
fix: Remove duplicated dependency
mdelapenya Feb 10, 2020
6eb7776
chore: update yarn.lock
mdelapenya Feb 10, 2020
eff893f
fix: update renovate.json5
mdelapenya Feb 10, 2020
6d7a878
Merge branch 'master' into cypress-cucumber
elasticmachine Feb 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .ci/end2end.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ pipeline {
post {
always {
dir("${BASE_DIR}"){
archiveArtifacts(allowEmptyArchive: false, artifacts: "${CYPRESS_DIR}/screenshots/**,${CYPRESS_DIR}/videos/**,${CYPRESS_DIR}/*e2e-tests.xml")
junit(allowEmptyResults: true, testResults: "${CYPRESS_DIR}/*e2e-tests.xml")
archiveArtifacts(allowEmptyArchive: false, artifacts: "${CYPRESS_DIR}/**/screenshots/**,${CYPRESS_DIR}/**/videos/**,${CYPRESS_DIR}/**/test-results/*e2e-tests.xml")
junit(allowEmptyResults: true, testResults: "${CYPRESS_DIR}/**/test-results/*e2e-tests.xml")
}
dir("${APM_ITS}"){
sh 'docker-compose logs > apm-its.log || true'
Expand Down
2 changes: 1 addition & 1 deletion src/dev/ci_setup/setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,4 @@ if [[ -d "$ES_DIR" && -f "$ES_JAVA_PROP_PATH" ]]; then
export JAVA_HOME=$HOME/.java/$ES_BUILD_JAVA
fi

export CI_ENV_SETUP=true
export CI_ENV_SETUP=true
4 changes: 4 additions & 0 deletions x-pack/legacy/plugins/apm/cypress/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cypress/ingest-data/events.json
cypress/screenshots/*

cypress/test-results
17 changes: 9 additions & 8 deletions x-pack/legacy/plugins/apm/cypress/cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
"video": false,
"trashAssetsBeforeRuns": false,
"fileServerFolder": "../",
"fixturesFolder": "./fixtures",
"integrationFolder": "./integration",
"pluginsFile": "./plugins/index.js",
"screenshotsFolder": "./screenshots",
"supportFile": "./support/index.ts",
"videosFolder": "./videos",
"fixturesFolder": "./cypress/fixtures",
"integrationFolder": "./cypress/integration",
"pluginsFile": "./cypress/plugins/index.js",
"screenshotsFolder": "./cypress/screenshots",
"supportFile": "./cypress/support/index.js",
"videosFolder": "./cypress/videos",
"useRelativeSnapshots": true,
"reporter": "junit",
"reporterOptions": {
"mochaFile": "[hash]-e2e-tests.xml",
"mochaFile": "./cypress/test-results/[hash]-e2e-tests.xml",
"toConsole": false
}
},
"testFiles": "**/*.{feature,features}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Feature: APM

Background:
Given a user browses the APM UI application
When the user inspects the opbeans-go service

Scenario: Transaction duration charts
Then should redirect to correct path with correct params
And should have correct y-axis ticks
Comment on lines +1 to +9
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @MadameSheema, I'd would love to get your insights about this spec 🙏 😊

Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,12 @@ module.exports = {
}
}
},
"__version": "3.4.1"
"__version": "3.8.3",
"APM": {
"Transaction duration charts": {
"1": "3.7 min",
"2": "1.8 min",
"3": "0.0 min"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,8 @@ const wp = require('@cypress/webpack-preprocessor');
const fs = require('fs');

module.exports = on => {
// add typescript support
const options = {
webpackOptions: {
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: { transpileOnly: true }
}
]
}
}
webpackOptions: require('../webpack.config.js')
};
on('file:preprocessor', wp(options));

Expand Down
31 changes: 31 additions & 0 deletions x-pack/legacy/plugins/apm/cypress/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

// ***********************************************
// 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 is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
/// <reference types="Cypress" />

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

// typically custom commands are added in this support folder
// so it makes sense to put their TypeScript definitions here
// from the JavaScript specs loads this file using
// the triple slash "reference" comment like this:
//
// /// <reference path="../support/index.d.ts" />

declare namespace Cypress {
interface Chainable<Subject> {
snapshot: () => {};
Expand Down
31 changes: 31 additions & 0 deletions x-pack/legacy/plugins/apm/cypress/cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

// ***********************************************************
// This example support/index.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')

// @ts-ignore
import { register } from '@cypress/snapshot';

register();
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/// <reference types="Cypress" />

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { loginAndWaitForPage } from '../../integration/helpers';

const { Given, When, Then } = require('cypress-cucumber-preprocessor/steps');

Given(`a user browses the APM UI application`, () => {
// open service overview page
loginAndWaitForPage(`/app/apm#/services`);
});

When(`the user inspects the opbeans-go service`, () => {
// click opbeans-go service
cy.get(':contains(opbeans-go)')
.last()
.click({ force: true });
});

Then(`should redirect to correct path with correct params`, () => {
cy.url().should('contain', `/app/apm#/services/opbeans-go/transactions`);
cy.url().should('contain', `transactionType=request`);
});

Then(`should have correct y-axis ticks`, () => {
const yAxisTick =
'[data-cy=transaction-duration-charts] .rv-xy-plot__axis--vertical .rv-xy-plot__axis__tick__text';

cy.get(yAxisTick)
.eq(2)
.invoke('text')
.snapshot();

cy.get(yAxisTick)
.eq(1)
.invoke('text')
.snapshot();

cy.get(yAxisTick)
.eq(0)
.invoke('text')
.snapshot();
});
41 changes: 41 additions & 0 deletions x-pack/legacy/plugins/apm/cypress/cypress/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

module.exports = {
resolve: {
extensions: ['.ts', '.js']
},
node: { fs: 'empty', child_process: 'empty', readline: 'empty' },
module: {
rules: [
{
test: /\.ts$/,
exclude: [/node_modules/],
use: [
{
loader: 'ts-loader'
}
]
},
{
test: /\.feature$/,
use: [
{
loader: 'cypress-cucumber-preprocessor/loader'
}
]
},
{
test: /\.features$/,
use: [
{
loader: 'cypress-cucumber-preprocessor/lib/featuresLoader'
}
]
}
]
}
};
53 changes: 0 additions & 53 deletions x-pack/legacy/plugins/apm/cypress/integration/apm.spec.ts

This file was deleted.

6 changes: 4 additions & 2 deletions x-pack/legacy/plugins/apm/cypress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@
"license": "MIT",
"scripts": {
"cypress:open": "cypress open",
"cypress:run": "cypress run"
"cypress:run": "cypress run --spec **/*.feature"
},
"dependencies": {
"@cypress/snapshot": "^2.1.3",
"@cypress/webpack-preprocessor": "^4.1.0",
"@types/js-yaml": "^3.12.1",
"@types/node": "^10.12.11",
"cypress": "^3.5.0",
"cypress-cucumber-preprocessor": "^2.0.1",
"js-yaml": "^3.13.1",
"p-limit": "^2.2.1",
"ts-loader": "^6.1.0",
"typescript": "3.7.2",
"typescript": "3.7.5",
"webpack": "^4.40.2"
}
}
1 change: 0 additions & 1 deletion x-pack/legacy/plugins/apm/cypress/screenshots/.gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions x-pack/legacy/plugins/apm/cypress/snapshots.js

This file was deleted.

10 changes: 0 additions & 10 deletions x-pack/legacy/plugins/apm/cypress/support/index.ts

This file was deleted.

Loading