16029: Merge branch 'master' into 16029-cypress-testing
[arvados-workbench2.git] / cypress / support / commands.js
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 // ***********************************************
6 // This example commands.js shows you how to
7 // create various custom commands and overwrite
8 // existing commands.
9 //
10 // For more comprehensive examples of custom
11 // commands please read more here:
12 // https://on.cypress.io/custom-commands
13 // ***********************************************
14 //
15 //
16 // -- This is a parent command --
17 // Cypress.Commands.add("login", (email, password) => { ... })
18 //
19 //
20 // -- This is a child command --
21 // Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
22 //
23 //
24 // -- This is a dual command --
25 // Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
26 //
27 //
28 // -- This will overwrite an existing command --
29 // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
30
31 const YAML = require('yamljs');
32 const arvadosFixturesDir = Cypress.env('fixtures');
33 const controllerURL = Cypress.env('controller_url');
34 const systemToken = Cypress.env('system_token');
35
36 Cypress.Commands.add(
37     "arvadosFixture", (name) => {
38         return cy.readFile(arvadosFixturesDir+'/'+name+'.yml').then(
39             function (str) {
40                 return YAML.parse(str);
41             }
42         )
43     }
44 )
45
46 Cypress.Commands.add(
47     "resetDB", () => {
48         cy.request('POST', `${controllerURL}/database/reset?api_token=${systemToken}`);
49     }
50 )