IO-2327 converting a job tests
This commit is contained in:
65
client/cypress/e2e/job-import/converting.cy.js
Normal file
65
client/cypress/e2e/job-import/converting.cy.js
Normal 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");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
@@ -49,3 +49,26 @@ Cypress.on("uncaught:exception", (err, runnable) => {
|
|||||||
// failing the test
|
// failing the test
|
||||||
return false;
|
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?.();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ export function JobsConvertButton({
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Select>
|
<Select className="ant-select-ins_co_nm">
|
||||||
{bodyshop.md_ins_cos.map((s, i) => (
|
{bodyshop.md_ins_cos.map((s, i) => (
|
||||||
<Select.Option key={i} value={s.name}>
|
<Select.Option key={i} value={s.name}>
|
||||||
{s.name}
|
{s.name}
|
||||||
@@ -127,7 +127,7 @@ export function JobsConvertButton({
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Select>
|
<Select className="ant-select-class">
|
||||||
{bodyshop.md_classes.map((s) => (
|
{bodyshop.md_classes.map((s) => (
|
||||||
<Select.Option key={s} value={s}>
|
<Select.Option key={s} value={s}>
|
||||||
{s}
|
{s}
|
||||||
@@ -148,7 +148,7 @@ export function JobsConvertButton({
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Select>
|
<Select className="ant-select-referral_source">
|
||||||
{bodyshop.md_referral_sources.map((s) => (
|
{bodyshop.md_referral_sources.map((s) => (
|
||||||
<Select.Option key={s} value={s}>
|
<Select.Option key={s} value={s}>
|
||||||
{s}
|
{s}
|
||||||
@@ -157,6 +157,7 @@ export function JobsConvertButton({
|
|||||||
</Select>
|
</Select>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
|
data-cy="referral_source_extra"
|
||||||
label={t("jobs.fields.referral_source_extra")}
|
label={t("jobs.fields.referral_source_extra")}
|
||||||
name="referral_source_extra"
|
name="referral_source_extra"
|
||||||
>
|
>
|
||||||
@@ -176,6 +177,7 @@ export function JobsConvertButton({
|
|||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Select
|
<Select
|
||||||
|
className="ant-select-employee_csr"
|
||||||
showSearch
|
showSearch
|
||||||
style={{ width: 200 }}
|
style={{ width: 200 }}
|
||||||
optionFilterProp="children"
|
optionFilterProp="children"
|
||||||
@@ -210,7 +212,7 @@ export function JobsConvertButton({
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Select allowClear>
|
<Select allowClear className="ant-select-category">
|
||||||
{bodyshop.md_categories.map((s) => (
|
{bodyshop.md_categories.map((s) => (
|
||||||
<Select.Option key={s} value={s}>
|
<Select.Option key={s} value={s}>
|
||||||
{s}
|
{s}
|
||||||
@@ -243,7 +245,12 @@ export function JobsConvertButton({
|
|||||||
<Switch />
|
<Switch />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Space wrap>
|
<Space wrap>
|
||||||
<Button type="danger" onClick={() => form.submit()} loading={loading}>
|
<Button
|
||||||
|
type="danger"
|
||||||
|
data-cy="convert-button"
|
||||||
|
onClick={() => form.submit()}
|
||||||
|
loading={loading}
|
||||||
|
>
|
||||||
{t("jobs.actions.convert")}
|
{t("jobs.actions.convert")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={() => setVisible(false)}>
|
<Button onClick={() => setVisible(false)}>
|
||||||
@@ -264,6 +271,7 @@ export function JobsConvertButton({
|
|||||||
// style={{ display: job.converted ? "none" : "" }}
|
// style={{ display: job.converted ? "none" : "" }}
|
||||||
disabled={job.converted || jobRO}
|
disabled={job.converted || jobRO}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
|
data-cy="job-convert-button"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
|
|||||||
Reference in New Issue
Block a user