16029: Adds support for reading YAML fixtures and receive config data.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Sat, 14 Mar 2020 16:21:57 +0000 (13:21 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Sat, 14 Mar 2020 16:21:57 +0000 (13:21 -0300)
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 <lucas@di-pentima.com.ar>

cypress/support/commands.js
package.json
yarn.lock

index a74cbba18f619531ebcd2149516f98f9af394eb8..636bae3ce860ac9c2ed069de281c1443d9fdc5bb 100644 (file)
 //
 // -- 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
index 7e505fcf0b2003f25d567f1a98eff84467bfc36b..bbbd6bf44c835049c4ab28d16536c16f159ad3f3 100644 (file)
@@ -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": {
index 724e9ec5f4db802332b430d986838c4afe2d1e14..1d7ce6efb90db7040f32dadad5ed24614c40bc83 100644 (file)
--- 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"