IO-2327 converting a job tests

This commit is contained in:
swtmply
2023-06-15 00:22:17 +08:00
parent 8f8fdf7548
commit 76b17cd249
3 changed files with 101 additions and 5 deletions

View File

@@ -0,0 +1,65 @@
describe(
"Check if there are job without RO number",
{
defaultCommandTimeout: 5000,
},
() => {
beforeEach(() => {
cy.visit("/manage");
cy.get("body").then(($body) => {
if ($body.text().includes("Login")) {
// Log in
cy.get('[data-cy="username"]').type("john@imex.dev");
cy.get('[data-cy="password"]').type("john123");
cy.get('[data-cy="sign-in-button"]').click();
}
cy.get(".ant-table-tbody")
.find("tr")
.should("not.have.class", "ant-table-placeholder");
cy.get(".ant-table-row").find("a").contains("N/A").first().click();
});
});
it("shows the error messages of required fields", () => {
// Check if required fields are filled
cy.get('[data-cy="job-convert-button"]').click();
cy.get('[data-cy="convert-button"]').click();
cy.antdFormSelect("", "Insurance Company Name", () => {
cy.contains("Insurance Company Name is required.").should("exist");
});
cy.antdFormSelect("", "Referral Source", () => {
cy.contains("Referral Source is required.").should("exist");
});
cy.antdFormSelect("", "Customer Service Rep.", () => {
cy.contains("Customer Service Rep. is required.").should("exist");
});
cy.antdFormSelect("", "Category", () => {
cy.contains("Category is required.").should("exist");
});
});
it("converts a job and issue an RO number", () => {
cy.get('[data-cy="job-convert-button"]').click();
// Check if fields are present
cy.antdFormSelect("ins_co_nm", "Insurance Company Name");
cy.antdFormSelect("referral_source", "Referral Source", () => {
cy.get('[data-cy="referral_source_extra"]').type("Twitter");
});
cy.antdFormSelect("employee_csr", "Customer Service Rep.");
cy.antdFormSelect("category", "Category");
cy.get("#ca_gst_registrant").should("have.class", "ant-switch").click();
cy.get("#driveable").should("have.class", "ant-switch").click();
cy.get("#towin").should("have.class", "ant-switch").click();
// cy.get('[data-cy="convert-button"]').click();
// cy.get(".ant-notification-notice-message").contains("successfully");
});
}
);

View File

@@ -49,3 +49,26 @@ Cypress.on("uncaught:exception", (err, runnable) => {
// failing the test
return false;
});
Cypress.Commands.add("antdSelect", (selector) => {
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`;
cy.get(dropDownSelector)
.next()
.find(".ant-select-item-option-content")
.first()
.click();
});
});
Cypress.Commands.add("antdFormSelect", (name, text, cb) => {
cy.get(".ant-form-item-required").then(($field) => {
if ($field.text().includes(text)) {
if (name) cy.antdSelect(name);
cb?.();
}
});
});