|
9 | 9 | // *********************************************** |
10 | 10 | // |
11 | 11 | // |
12 | | -// -- This is a parent command -- |
| 12 | +// -- This is a parent command -- |
13 | 13 | // Cypress.Commands.add('login', (email, password) => { ... }) |
14 | 14 | // |
15 | 15 | // |
|
23 | 23 | // |
24 | 24 | // -- This will overwrite an existing command -- |
25 | 25 | // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) |
| 26 | + |
| 27 | + |
| 28 | +import * as CONST from "../../src/cypress.constants" |
| 29 | +const email = Cypress.env('COLLABORATOR_USER') |
| 30 | +const password = Cypress.env('COLLABORATOR_PASSWORD') |
| 31 | +const team = Cypress.env('TEAM_NAME') |
| 32 | + |
| 33 | + |
| 34 | +/** user login function */ |
| 35 | +Cypress.Commands.add('userLogin', () => { |
| 36 | + cy.get('#loginTab').click() |
| 37 | + cy.get('#email').type(email).trigger('change'); |
| 38 | + cy.get('#password').type(password).trigger('change'); |
| 39 | + cy.get('#btn-login').click() |
| 40 | + cy.wait(5000) |
| 41 | +}); |
| 42 | + |
| 43 | +/** select a team */ |
| 44 | +Cypress.Commands.add('selectTeam', () => { |
| 45 | + cy.get(`#${team}`).click() |
| 46 | + cy.location().should((loc) => { |
| 47 | + expect(loc.pathname).to.eq(`/${team}`) |
| 48 | + }) |
| 49 | +}) |
| 50 | + |
| 51 | +/** check if in correct data product */ |
| 52 | +Cypress.Commands.add('inCorrectDataProduct', (dataProduct) => { |
| 53 | + cy.location().should((loc) => { |
| 54 | + expect(loc.pathname).to.eq(`/${team}/${dataProduct}`) |
| 55 | + }) |
| 56 | +}) |
| 57 | + |
| 58 | +/** create a data product */ |
| 59 | +Cypress.Commands.add('newDataProduct', (dataProduct) => { |
| 60 | + cy.get(`button[data-cy=${CONST.NEW_DATA_PRODUCT_BUTTON_ID}]`).click() |
| 61 | + cy.get(`input[data-cy=${CONST.NEW_DATA_PRODUCT_ID}]`).type(dataProduct) |
| 62 | + cy.get(`input[data-cy=${CONST.NEW_DATA_PRODUCT_NAME}]`).type(dataProduct) |
| 63 | + cy.get(`textarea[data-cy=${CONST.NEW_DATA_PRODUCT_DESC}]`).type(dataProduct) |
| 64 | + cy.get(`button[data-cy=${CONST.CREATE_NEW_DATA_PRODUCT_BUTTON_ID}]`).click() |
| 65 | + cy.inCorrectDataProduct(dataProduct) |
| 66 | +}) |
| 67 | + |
| 68 | +/** delete a data product */ |
| 69 | +Cypress.Commands.add('deleteDataProduct', (dataProduct) => { |
| 70 | + cy.get(`button[data-cy=${CONST.HOME_DELETE_DATAPRODUCT_BUTTON_ID}]`).click() |
| 71 | + cy.get('.modal-dialog').should('be.visible') |
| 72 | + cy.get(`input[data-cy=${CONST.DELETE_DATA_PRODUCT_ID}]`).type(dataProduct) |
| 73 | + cy.get(`button[data-cy=${CONST.DELETE_DATAPRODUCT_BUTTON_ID}]`).click() |
| 74 | + cy.get(`#${dataProduct}`).should('not.exist'); |
| 75 | +}) |
| 76 | + |
| 77 | +/** logout */ |
| 78 | +Cypress.Commands.add('logout', () => { |
| 79 | + cy.get('#profile_menu_arrow').click() |
| 80 | + cy.get('#logout').click() |
| 81 | + cy.get('h1.hero-banner__heading').should('have.text', 'SIGN UP') |
| 82 | +}) |
| 83 | + |
0 commit comments