112 lines
3.2 KiB
JavaScript
112 lines
3.2 KiB
JavaScript
// ***********************************************
|
|
// This example commands.js shows you how to
|
|
// create various custom commands and overwrite
|
|
// existing commands.
|
|
//
|
|
// For more comprehensive examples of custom
|
|
// commands please read more here:
|
|
// https://on.cypress.io/custom-commands
|
|
// ***********************************************
|
|
//
|
|
//
|
|
// -- This is a parent command --
|
|
// Cypress.Commands.add('login', (email, password) => { ... })
|
|
//
|
|
//
|
|
// -- This is a child command --
|
|
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
|
//
|
|
//
|
|
// -- This is a dual command --
|
|
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
//
|
|
//
|
|
// -- This will overwrite an existing command --
|
|
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
|
|
|
Cypress.Commands.add("goToSignInPage", () => {
|
|
cy.visit("/");
|
|
cy.contains("Sign In").click();
|
|
});
|
|
|
|
Cypress.Commands.add("login", (username, password) => {
|
|
cy.goToSignInPage();
|
|
|
|
cy.get('[data-cy="username"]').type(username);
|
|
cy.get('[data-cy="password"]').type(password);
|
|
cy.get('[data-cy="sign-in-button"]', { timeout: 2000 }).click();
|
|
});
|
|
|
|
Cypress.Commands.add("passwordReset", (email) => {
|
|
cy.goToSignInPage();
|
|
cy.get('[data-cy="reset-password"]').click();
|
|
cy.get('[data-cy="reset-password-email-input"]').type(email);
|
|
cy.get('[data-cy="reset-password-button"]').click();
|
|
});
|
|
|
|
Cypress.on("uncaught:exception", (err, runnable) => {
|
|
// returning false here prevents Cypress from
|
|
// failing the test
|
|
return false;
|
|
});
|
|
|
|
Cypress.Commands.add("antdSelect", (selector, filter) => {
|
|
cy.get(`.ant-select-${selector} > .ant-select-selector`).click();
|
|
cy.get(`.ant-select-${selector} .ant-select-selection-search input`)
|
|
.invoke("attr", "id")
|
|
.then((selElm) => {
|
|
const dropDownSelector = `#${selElm}_list`;
|
|
|
|
if (filter) {
|
|
cy.get(dropDownSelector)
|
|
.next()
|
|
.find(".ant-select-item-option-content")
|
|
.not(`:contains("${filter}")`)
|
|
.first()
|
|
.click({ force: true });
|
|
} else {
|
|
cy.get(dropDownSelector)
|
|
.next()
|
|
.find(".ant-select-item-option-content")
|
|
.first()
|
|
.click({ force: true });
|
|
}
|
|
});
|
|
});
|
|
|
|
Cypress.Commands.add(
|
|
"insertAvailableJob",
|
|
({ bodyshopid, job, job_est_data, token }) => {
|
|
const query = `mutation INSERT_AVAILABLE_JOB($job: available_jobs_insert_input!) {
|
|
insert_available_jobs_one(object: $job) {
|
|
id
|
|
}
|
|
}`;
|
|
|
|
cy.request({
|
|
url: "http://localhost:4000/test/query",
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
Authorization: token,
|
|
},
|
|
body: {
|
|
query,
|
|
job: {
|
|
est_data: job_est_data,
|
|
uploaded_by: Cypress.env("uploaded_by_email"),
|
|
cieca_id: job.ciecaid,
|
|
bodyshopid,
|
|
clm_amt: job.clm_total,
|
|
clm_no: job.clm_no,
|
|
ins_co_nm: job.ins_co_nm,
|
|
ownr_name: `${job.owner.data.ownr_fn} ${job.owner.data.ownr_ln}`,
|
|
vehicle_info: `${job.v_model_yr} ${job.v_make_desc} ${job.v_model_desc}`,
|
|
},
|
|
},
|
|
})
|
|
.its("body.insert_available_jobs_one")
|
|
.should("have.property", "id");
|
|
}
|
|
);
|