From bbeb1b4bc19356e4d826d4915ae091300be97198 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Sat, 14 Mar 2020 13:21:57 -0300 Subject: [PATCH] 16029: Adds support for reading YAML fixtures and receive config data. Also, adds a command to reset the testing database. Config data can be passed in several ways: * Running 'yarn run cypress [open|run] --env fixtures=/a/path,controller_url=...' * Setting environment variables named with the 'CYPRESS_' prefix. * Using Cypress.config() inside the test cases. For now, 3 config items are needed: 1. Arvados fixtures path 2. System root token (defined on arvados-boot's zzzzz.yml config file) so a database reset can be called. 3. Controller's URL Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- cypress/support/commands.js | 21 +++++++++++++++++++++ package.json | 3 ++- yarn.lock | 8 ++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index a74cbba1..636bae3c 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -27,3 +27,24 @@ // // -- This will overwrite an existing command -- // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) + +const YAML = require('yamljs'); +const arvadosFixturesDir = Cypress.env('fixtures'); +const controllerURL = Cypress.env('controller_url'); +const systemToken = Cypress.env('system_token'); + +Cypress.Commands.add( + "arvadosFixture", (name) => { + return cy.readFile(arvadosFixturesDir+'/'+name+'.yml').then( + function (str) { + return YAML.parse(str); + } + ) + } +) + +Cypress.Commands.add( + "resetDB", () => { + cy.request('POST', `${controllerURL}/database/reset?api_token=${systemToken}`); + } +) \ No newline at end of file diff --git a/package.json b/package.json index 7e505fcf..bbbd6bf4 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,8 @@ "node-sass": "4.9.4", "node-sass-chokidar": "1.3.4", "redux-devtools": "3.4.1", - "typescript": "3.1.1" + "typescript": "3.1.1", + "yamljs": "0.3.0" }, "jest": { "moduleNameMapper": { diff --git a/yarn.lock b/yarn.lock index 724e9ec5..1d7ce6ef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11608,6 +11608,14 @@ yallist@^3.0.2: resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== +yamljs@0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/yamljs/-/yamljs-0.3.0.tgz#dc060bf267447b39f7304e9b2bfbe8b5a7ddb03b" + integrity sha512-C/FsVVhht4iPQYXOInoxUM/1ELSf9EsgKH34FofQOp6hwCPrW4vG4w5++TED3xRUo8gD7l0P1J1dLlDYzODsTQ== + dependencies: + argparse "^1.0.7" + glob "^7.0.5" + yargs-parser@^11.1.1: version "11.1.1" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-11.1.1.tgz#879a0865973bca9f6bab5cbdf3b1c67ec7d3bcf4" -- 2.30.2