-
Notifications
You must be signed in to change notification settings - Fork 0
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
Cypress cucumber #1
Changes from 12 commits
699eea4
70930c0
dc5e03b
2205b6d
d75e0ef
4050a76
0a65007
7d9fcbf
687b796
5e39f14
f781eb5
7eec1dc
dfd1cbc
7d4b9d6
446c9e6
6cfadf1
e35d28e
cffc9be
8f1deee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
cypress/ingest-data/events.json | ||
cypress/screenshots/* | ||
|
||
cypress/test-results |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Feature: APM | ||
|
||
Background: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Backgrounds are executed before any scenario within this feature file (like a before test method) |
||
Given a user browses the APM UI application | ||
When the user inspects the opbeans-go service | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
||
Scenario: Transaction duration charts | ||
Then should redirect to correct path with correct params | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
And should have correct y-axis ticks | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And works with Given, When or Then it makes a scenario easier to read. Given a thing Reads better than Given a thing |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* 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 = { | ||
'When clicking opbeans-go service': { | ||
'transaction duration charts': { | ||
'should have correct y-axis ticks': { | ||
'1': '3.7 min', | ||
'2': '1.8 min', | ||
'3': '0.0 min' | ||
} | ||
} | ||
}, | ||
__version: '3.4.1' | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,36 +19,10 @@ | |
|
||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
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 } | ||
} | ||
] | ||
} | ||
} | ||
Comment on lines
-27
to
-40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved to |
||
webpackOptions: require('../webpack.config.js') | ||
}; | ||
on('file:preprocessor', wp(options)); | ||
|
||
// readFileMaybe | ||
on('task', { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what it's the purpose of this function, maybe to read the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, it's for the snapshots IIRC. |
||
readFileMaybe(filename) { | ||
if (fs.existsSync(filename)) { | ||
return fs.readFileSync(filename, 'utf8'); | ||
} | ||
|
||
return null; | ||
} | ||
}); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file comes from the scaffolding |
||
* 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: () => {}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the function that is nor defined in the tests 🤷♀ How could we include it in the tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a type def, it's not the actual code. likely we need to include |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file comes from the scaffolding |
||
* 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'; | ||
|
||
mdelapenya marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |
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`, () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no difference using |
||
// open service overview page | ||
loginAndWaitForPage(`/app/apm#/services`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because a |
||
}); | ||
|
||
When(`the user inspects the opbeans-go service`, () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
// click opbeans-go service | ||
cy.get(':contains(opbeans-go)') | ||
.last() | ||
.click({ force: true }); | ||
}); | ||
|
||
Then(`should redirect to correct path with correct params`, () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The traditional |
||
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(); | ||
mdelapenya marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
cy.get(yAxisTick) | ||
.eq(1) | ||
.invoke('text') | ||
.snapshot(); | ||
|
||
cy.get(yAxisTick) | ||
.eq(0) | ||
.invoke('text') | ||
.snapshot(); | ||
}); |
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$/, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Files representing the features/specifications, in the form of |
||
use: [ | ||
{ | ||
loader: 'cypress-cucumber-preprocessor/loader' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the preloader that does the magic accepting Cucumber feature files |
||
} | ||
] | ||
}, | ||
{ | ||
test: /\.features$/, | ||
use: [ | ||
{ | ||
loader: 'cypress-cucumber-preprocessor/lib/featuresLoader' | ||
} | ||
] | ||
} | ||
Comment on lines
+31
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm realising that this could be removed, as hopefully we won't write this kind of files. (TBH, I need to read about the differences) |
||
] | ||
} | ||
}; |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,17 +5,25 @@ | |
"license": "MIT", | ||
"scripts": { | ||
"cypress:open": "cypress open", | ||
"cypress:run": "cypress run" | ||
"cypress:run": "cypress run --spec **/*.feature", | ||
"lint": "tslint --project ./tsconfig.json --fix", | ||
"postlint": "npm run tsc", | ||
"tsc": "tsc --pretty --noEmit" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd need help in this part, because maybe it's already provided by kibana build There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this can all be removed, typescript should be handled by Kibana scripts, see |
||
}, | ||
"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", | ||
"eslint": "^6.8.0", | ||
"eslint-config-prettier": "^6.9.0", | ||
"js-yaml": "^3.13.1", | ||
"p-limit": "^2.2.1", | ||
"ts-loader": "^6.1.0", | ||
"typescript": "3.7.2", | ||
"tslint": "6.0.0", | ||
"typescript": "3.7.5", | ||
"webpack": "^4.40.2" | ||
} | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was already merged in upstream, so we will remove the commit that added it