16029: Adds support for reading YAML fixtures and receive config data.
[arvados-workbench2.git] / cypress / support / commands.js
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