1 // ***********************************************
2 // This example commands.js shows you how to
3 // create various custom commands and overwrite
6 // For more comprehensive examples of custom
7 // commands please read more here:
8 // https://on.cypress.io/custom-commands
9 // ***********************************************
12 // -- This is a parent command --
13 // Cypress.Commands.add('login', (email, password) => { ... })
16 // -- This is a child command --
17 // Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
20 // -- This is a dual command --
21 // Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
24 // -- This will overwrite an existing command --
25 // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
27 function get_fallback_login_value(param) {
29 var env_var = param == 'username' ? 'KOHA_USER' : 'KOHA_PASS';
31 return typeof Cypress.env(env_var) === 'undefined' ? 'koha' : Cypress.env(env_var);
34 Cypress.Commands.add('login', (username, password) => {
35 var user = typeof username === 'undefined' ? get_fallback_login_value('username') : username;
36 var pass = typeof password === 'undefined' ? get_fallback_login_value('password') : password;
37 cy.visit('/cgi-bin/koha/mainpage.pl?logout.x=1')
38 cy.get("#userid").type(user)
39 cy.get("#password").type(pass)
40 cy.get("#submit-button").click()
43 Cypress.Commands.add('left_menu_active_item_is', (label) => {
44 cy.get("#navmenulist a.current:not(.disabled)").should('have.length',1).contains(label);
47 cy.get_title = () => {
49 access_type: "access type",
51 coverage_depth: "coverage depth",
52 date_first_issue_online: "date first",
53 date_last_issue_online: "date last",
54 date_monograph_published_online: "date mono online",
55 date_monograph_published_print: "date mono print",
56 embargo_info: "embargo info",
58 first_author: "first author",
59 first_editor: "first editor",
60 monograph_edition: "monograph edition",
61 monograph_volume: "monograph volume",
63 num_first_issue_online: "num first issue",
64 num_first_vol_online: "num first vol",
65 num_last_issue_online: "num last issue",
66 num_last_vol_online: "num last vol",
67 online_identifier: "online identifier",
68 parent_publication_title_id: "parent id",
69 preceeding_publication_title_id: "preceeding id",
70 print_identifier: "print identifier",
71 publication_title: "publication title",
72 publication_type: "journal",
73 publisher_name: "publication name",
80 name: "first package name"
92 title_url: "title url"
96 cy.get_agreements_to_relate = () => {
100 description: "a second agreement",
101 name: "second agreement name"
105 description: "a third agreement",
106 name: "third agreement name"
110 description: "a fourth agreement",
111 name: "fourth agreement name"