Skip to content

Commit 2d81d9f

Browse files
committed
smoke tests: init of cypress
* NSPIR-3137
1 parent ff9c4d4 commit 2d81d9f

File tree

13 files changed

+1521
-6
lines changed

13 files changed

+1521
-6
lines changed

.circleci/config.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@ version: 2
22
jobs:
33
e2e:
44
machine: true
5-
65
working_directory: ~/inspirehep
7-
86
steps:
97
- checkout
10-
- run: sudo chown -R 999 e2e
8+
- run: sudo chown -R 999 e2e
119
- run: sh run-e2e.sh
12-
1310
workflows:
1411
version: 2
1512
workflow:
1613
jobs:
17-
- e2e
14+
- e2e

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,17 @@ $ yarn test # in ui folder
220220
$ ./run-e2e.sh
221221
```
222222

223+
### script tests
224+
225+
For script tests we're using cypress https://docs.cypress.io/
226+
227+
```bash
228+
$ cd smoke-tests
229+
$ yarn install
230+
$ yarn run cypress:open # UI
231+
$ yarn run cypress:run # cmd interface
232+
```
233+
223234
---
224235

225236
## How to import records

build-and-deploy.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
TAG="${TRAVIS_TAG:-$(git describe --always --tags)}"
1010

11+
LATEST_COMMIT=$(git rev-parse HEAD)
12+
LATEST_COMMIT_IN_SMOKE_TESTS=$(git log -1 --format=format:%H --full-diff smoke-tests)
13+
1114
retry() {
1215
"${@}" || "${@}" || exit 2
1316
}
@@ -30,7 +33,7 @@ buildPush() {
3033
-t "${image}:build-stage" \
3134
"${context}" \
3235
--cache-from "${image}:build-stage" \
33-
--target "build-stage"
36+
--target "build-stage"
3437
retry docker push "${image}:build-stage"
3538
retry docker build \
3639
--build-arg VERSION="${TAG}" \
@@ -79,13 +82,32 @@ sentryQA() {
7982
sentry-cli releases set-commits --auto ${TAG}
8083
}
8184

85+
maybeBuildSmokeTests() {
86+
if [ $LATEST_COMMIT = $LATEST_COMMIT_IN_SMOKE_TESTS ]; then
87+
buildPush "smoke-tests" "inspirehep/smoke-tests"
88+
else
89+
echo "Nothing changed on smoke-tests/"
90+
fi
91+
}
92+
93+
maybeDeploySmokeTestsQA() {
94+
if [ $LATEST_COMMIT = $LATEST_COMMIT_IN_SMOKE_TESTS ]; then
95+
# FIXME: smoke tests will replace e2e tests
96+
deployQA "e2e"
97+
else
98+
echo "Nothing changed on smoke-tests/"
99+
fi
100+
}
101+
82102
main() {
83103
login
84104
buildPush "ui" "inspirehep/ui"
85105
buildPush "backend" "inspirehep/hep"
106+
maybeBuildSmokeTests
86107
logout
87108
deployQA "ui"
88109
deployQA "hep"
89110
sentryQA
111+
maybeDeploySmokeTestsQA
90112
}
91113
main

smoke-tests/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# dependencies
2+
**/node_modules
3+
**/__image_snapshots__/__diff_output__
4+
5+
# misc
6+
.DS_Store
7+
.env.local
8+
.env.development.local
9+
.env.test.local
10+
.env.production.local
11+
12+
yarn-debug.log*
13+
yarn-error.log*

smoke-tests/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM cypress/included:3.2.0
2+
3+
WORKDIR /e2e
4+
5+
COPY . .
6+
7+
ENTRYPOINT [ "cypress" ]

smoke-tests/cypress.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"projectId": "439or1",
3+
"env": {
4+
"inspirehep_url": "http://localhost:3000",
5+
"email": "[email protected]",
6+
"password": "123456",
7+
"viewport_width": 1920,
8+
"viewport_height": 1080
9+
}
10+
}

smoke-tests/cypress/fixtures/.gitkeep

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
describe('home page', function() {
2+
it('does an empty search on literature collection', function() {
3+
cy.viewport(Cypress.env('viewport_width'), Cypress.env('viewport_height'));
4+
cy.visit(Cypress.env('inspirehep_url'));
5+
cy
6+
.get(
7+
'.ant-row > .ant-col > .ant-input-search > .ant-input-wrapper > .ant-input'
8+
)
9+
.type(' ');
10+
cy
11+
.get(
12+
'.ant-col > .ant-input-search > .ant-input-wrapper > .ant-input-group-addon > .ant-btn'
13+
)
14+
.click();
15+
});
16+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/// <reference types="cypress" />
2+
// ***********************************************************
3+
// This example plugins/index.js can be used to load plugins
4+
//
5+
// You can change the location of this file or turn off loading
6+
// the plugins file with the 'pluginsFile' configuration option.
7+
//
8+
// You can read more here:
9+
// https://on.cypress.io/plugins-guide
10+
// ***********************************************************
11+
12+
// This function is called when a project is opened or re-opened (e.g. due to
13+
// the project's config changing)
14+
15+
/**
16+
* @type {Cypress.PluginConfig}
17+
*/
18+
module.exports = (on, config) => {
19+
// `on` is used to hook into various events Cypress emits
20+
// `config` is the resolved Cypress config
21+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// ***********************************************
2+
// This example commands.js shows you how to
3+
// create various custom commands and overwrite
4+
// existing commands.
5+
//
6+
// For more comprehensive examples of custom
7+
// commands please read more here:
8+
// https://on.cypress.io/custom-commands
9+
// ***********************************************
10+
//
11+
//
12+
// -- This is a parent command --
13+
// Cypress.Commands.add("login", (email, password) => { ... })
14+
//
15+
//
16+
// -- This is a child command --
17+
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
18+
//
19+
//
20+
// -- This is a dual command --
21+
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
22+
//
23+
//
24+
// -- This will overwrite an existing command --
25+
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

0 commit comments

Comments
 (0)