IO-2327 posting bills test cases

This commit is contained in:
swtmply
2023-08-04 12:08:34 +08:00
parent 353d6d010c
commit e4671b9bd6
4 changed files with 235 additions and 231 deletions

View File

@@ -12,12 +12,6 @@ describe(
cy.visit("/manage/jobs"); cy.visit("/manage/jobs");
cy.intercept("POST", Cypress.env("graphql_dev_endpoint"), (req) => {
if (req.body.operationName === "QUERY_BODYSHOP") {
req.alias = "bodyshop";
}
});
cy.get('[data-cy="active-jobs-table"]') cy.get('[data-cy="active-jobs-table"]')
.find(".ant-table-tbody") .find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)") .find("> tr:not(.ant-table-measure-row)")

View File

@@ -1,4 +1,7 @@
import uniqueId from "lodash/uniqueId"; import job from "../../fixtures/jobs/job-3.json";
import moment from "moment";
const uuid = () => Cypress._.random(0, 1e6);
describe( describe(
"Billing job parts orders", "Billing job parts orders",
@@ -6,34 +9,33 @@ describe(
defaultCommandTimeout: 5000, defaultCommandTimeout: 5000,
}, },
() => { () => {
const today = moment(new Date()).format("YYYY-MM-DD");
beforeEach(() => { beforeEach(() => {
cy.visit("/manage"); cy.viewport(1280, 720);
cy.visit("/manage/jobs");
cy.get("body").then(($body) => { cy.intercept("POST", Cypress.env("graphql_dev_endpoint"), (req) => {
if ($body.text().includes("Login")) { if (req.body.operationName === "SEARCH_VENDOR_AUTOCOMPLETE") {
// Log in req.alias = "vendors";
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")
.should("be.visible")
.find("tr")
.should("not.have.class", "ant-table-placeholder");
cy.get(".ant-table-row")
.not(':contains("Open")')
.first()
.find("a")
.first()
.click();
cy.url().should("include", "/manage/jobs");
// Go to repair data tab
cy.get('[data-cy="tab-partssublet"]').should("be.visible").click();
}); });
cy.get('[data-cy="active-jobs-table"]')
.find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)")
.as("active-jobs-table")
.should("not.have.class", "ant-table-placeholder");
cy.get("@active-jobs-table")
.contains(job.clm_no)
.first()
.parent()
.find('[data-cy="active-job-link"]')
.click();
// Go to repair data tab
cy.get('[data-cy="tab-partssublet"]').should("be.visible").click();
}); });
it("receives a part bill", () => { it("receives a part bill", () => {
@@ -52,29 +54,28 @@ describe(
// fill out form // fill out form
// data-cy="bill-form-invoice" // data-cy="bill-form-invoice"
cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("1QBD246-00-")); cy.get('[data-cy="bill-form-invoice"]').type(uuid());
cy.get("#bill-form-date").click(); cy.get("#bill-form-date").click();
cy.get('[title="2023-07-06"]').should("be.visible").click(); cy.get(`[title="${today}"]`).should("be.visible").click({ force: true });
// get table
cy.get('[data-cy="bill-line-table"]').each(($row) => { cy.get('[data-cy="bill-line-table"]').each(($row) => {
// get retail amount // get retail amount
cy.wrap($row) cy.wrap($row)
.find('[data-cy="bill-line-actual-price"]') .find('[data-cy="bill-line-actual-price"]')
.invoke("val") .click({ force: true, multiple: true });
.then((p) => { cy.wrap($row)
const vendorPercentOff = 0.2; .find('[data-cy="bill-line-actual-cost"]')
.click({ multiple: true });
// get cost - vendor's percent off
const cost = p - p * vendorPercentOff;
cy.get('[data-cy="bill-form-bill-total"]').type(p);
cy.wrap($row).find('[data-cy="bill-line-actual-cost"]').type(cost);
});
}); });
// Click save cy.get('[data-cy="bill-line-actual-cost"]').then((cells) => {
const totals = cells.toArray().map((el) => Number(el.value));
const sum = Cypress._.sum(totals);
cy.get('[data-cy="bill-form-bill-total"]').type(sum);
});
// // Click save
cy.get('[data-cy="bill-form-save-button"]').click(); cy.get('[data-cy="bill-form-save-button"]').click();
cy.get(".ant-notification-notice-message").contains( cy.get(".ant-notification-notice-message").contains(
@@ -94,28 +95,30 @@ describe(
// Select Line // Select Line
cy.antdSelect("bill-line", "-- Not On Estimate --"); cy.antdSelect("bill-line", "-- Not On Estimate --");
// Fill the Form // Fill the Form
cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("1QBD246-01-")); cy.get('[data-cy="bill-form-invoice"]').type(uuid());
cy.get("#bill-form-date").click(); cy.get("#bill-form-date").click();
cy.get('[title="2023-07-06"]').should("be.visible").click(); cy.get(`[title="${today}"]`).should("be.visible").click({ force: true });
// get table
cy.get('[data-cy="bill-line-table"]').each(($row) => { cy.get('[data-cy="bill-line-table"]').each(($row) => {
// get retail amount // get retail amount
cy.wrap($row) cy.wrap($row)
.find('[data-cy="bill-line-actual-price"]') .find('[data-cy="bill-line-actual-price"]')
.invoke("val") .click({ force: true, multiple: true });
.then((p) => { cy.wrap($row)
const vendorPercentOff = 0.2; .find('[data-cy="bill-line-actual-cost"]')
.click({ multiple: true });
// get cost - vendor's percent off
const cost = p - p * vendorPercentOff;
cy.get('[data-cy="bill-form-bill-total"]').type(p);
cy.wrap($row).find('[data-cy="bill-line-actual-cost"]').type(cost);
});
}); });
cy.get('[data-cy="bill-line-actual-cost"]').then((cells) => {
const totals = cells.toArray().map((el) => Number(el.value));
const sum = Cypress._.sum(totals);
cy.get('[data-cy="bill-form-bill-total"]').type(sum);
});
cy.antdSelect("bill-cost-center");
// Click save // Click save
cy.get('[data-cy="bill-form-save-button"]').click(); cy.get('[data-cy="bill-form-save-button"]').click();
@@ -136,28 +139,30 @@ describe(
// Select Line // Select Line
cy.antdSelect("bill-line", "-- Not On Estimate --"); cy.antdSelect("bill-line", "-- Not On Estimate --");
// Fill the Form // Fill the Form
cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("1QBD246-02-")); cy.get('[data-cy="bill-form-invoice"]').type(uuid());
cy.get("#bill-form-date").click(); cy.get("#bill-form-date").click();
cy.get('[title="2023-07-06"]').should("be.visible").click(); cy.get(`[title="${today}"]`).should("be.visible").click({ force: true });
// get table
cy.get('[data-cy="bill-line-table"]').each(($row) => { cy.get('[data-cy="bill-line-table"]').each(($row) => {
// get retail amount // get retail amount
cy.wrap($row) cy.wrap($row)
.find('[data-cy="bill-line-actual-price"]') .find('[data-cy="bill-line-actual-price"]')
.invoke("val") .click({ force: true, multiple: true });
.then((p) => { cy.wrap($row)
const vendorPercentOff = 0.2; .find('[data-cy="bill-line-actual-cost"]')
.click({ multiple: true });
// get cost - vendor's percent off
const cost = p - p * vendorPercentOff;
cy.get('[data-cy="bill-form-bill-total"]').type(p);
cy.wrap($row).find('[data-cy="bill-line-actual-cost"]').type(cost);
});
}); });
cy.get('[data-cy="bill-line-actual-cost"]').then((cells) => {
const totals = cells.toArray().map((el) => Number(el.value));
const sum = Cypress._.sum(totals);
cy.get('[data-cy="bill-form-bill-total"]').type(sum);
});
cy.antdSelect("bill-cost-center");
// Click save // Click save
cy.get('[data-cy="bill-form-savenew-button"]') cy.get('[data-cy="bill-form-savenew-button"]')
.should("not.be.disabled") .should("not.be.disabled")
@@ -241,202 +246,202 @@ describe(
} }
); );
describe( // describe(
"Validating and calculating bills", // "Validating and calculating bills",
{ // {
defaultCommandTimeout: 5000, // defaultCommandTimeout: 5000,
}, // },
() => { // () => {
beforeEach(() => { // beforeEach(() => {
cy.visit("/manage"); // cy.visit("/manage");
cy.get("body").then(($body) => { // cy.get("body").then(($body) => {
if ($body.text().includes("Login")) { // if ($body.text().includes("Login")) {
// Log in // // Log in
cy.get('[data-cy="username"]').type("john@imex.dev"); // cy.get('[data-cy="username"]').type("john@imex.dev");
cy.get('[data-cy="password"]').type("john123"); // cy.get('[data-cy="password"]').type("john123");
cy.get('[data-cy="sign-in-button"]').click(); // cy.get('[data-cy="sign-in-button"]').click();
} // }
cy.get(".ant-table-tbody") // cy.get(".ant-table-tbody")
.should("be.visible") // .should("be.visible")
.find("tr") // .find("tr")
.should("not.have.class", "ant-table-placeholder"); // .should("not.have.class", "ant-table-placeholder");
cy.get(".ant-table-row").contains("QBD261").click(); // cy.get(".ant-table-row").contains("QBD261").click();
cy.url().should("include", "/manage/jobs"); // cy.url().should("include", "/manage/jobs");
// Go to repair data tab // // Go to repair data tab
cy.get('[data-cy="tab-partssublet"]').should("be.visible").click(); // cy.get('[data-cy="tab-partssublet"]').should("be.visible").click();
}); // });
}); // });
it("validates auto reconciliation through posting bill", () => { // it("validates auto reconciliation through posting bill", () => {
// Find the first row in the parts order // // Find the first row in the parts order
cy.get('[data-cy="part-orders-table"]') // cy.get('[data-cy="part-orders-table"]')
.find(".ant-table-tbody") // .find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)") // .find("> tr:not(.ant-table-measure-row)")
.as("orders-table") // .as("orders-table")
.should("not.have.class", "ant-table-placeholder"); // .should("not.have.class", "ant-table-placeholder");
cy.get("@orders-table") // cy.get("@orders-table")
.first() // .first()
.should("be.visible") // .should("be.visible")
.find('[data-cy="receive-bill-button"]') // .find('[data-cy="receive-bill-button"]')
.click(); // .click();
// fill out form // // fill out form
cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("1QBD261-0")); // cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("1QBD261-0"));
cy.get("#bill-form-date").click(); // cy.get("#bill-form-date").click();
cy.get('[title="2023-07-06"]').should("be.visible").click(); // cy.get('[title="2023-07-06"]').should("be.visible").click();
cy.get('[data-cy="bill-form-bill-total"]').type("70.46"); // cy.get('[data-cy="bill-form-bill-total"]').type("70.46");
cy.get('[data-cy="bill-line-actual-cost"]').type("67.10"); // cy.get('[data-cy="bill-line-actual-cost"]').type("67.10");
cy.get("#bill-form-discrepancy").should("have.text", "$0.00"); // cy.get("#bill-form-discrepancy").should("have.text", "$0.00");
// Click save // // Click save
cy.get('[data-cy="bill-form-save-button"]').click(); // cy.get('[data-cy="bill-form-save-button"]').click();
cy.get("#retailtotal").should("have.text", "$83.87"); // cy.get("#retailtotal").should("have.text", "$83.87");
cy.get(".discrepancy").each(($statistic) => { // cy.get(".discrepancy").each(($statistic) => {
cy.wrap($statistic).should("have.text", "$0.00"); // cy.wrap($statistic).should("have.text", "$0.00");
}); // });
}); // });
it("returning item and validating statistics", () => { // it("returning item and validating statistics", () => {
cy.get('[data-cy="bills-table"]') // cy.get('[data-cy="bills-table"]')
.find(".ant-table-tbody") // .find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)") // .find("> tr:not(.ant-table-measure-row)")
.as("bills-table") // .as("bills-table")
.should("not.have.class", "ant-table-placeholder"); // .should("not.have.class", "ant-table-placeholder");
cy.get("@bills-table") // cy.get("@bills-table")
.first() // .first()
.should("not.be.disabled") // .should("not.be.disabled")
.find('[data-cy="return-items-button"]') // .find('[data-cy="return-items-button"]')
.click(); // .click();
cy.get('[data-cy="billline-checkbox"]').check(); // cy.get('[data-cy="billline-checkbox"]').check();
cy.get('[data-cy="billline-return-items-ok-button"]').click(); // cy.get('[data-cy="billline-return-items-ok-button"]').click();
cy.get("#order-quantity").type("1", { force: true, multiple: true }); // cy.get("#order-quantity").type("1", { force: true, multiple: true });
cy.get('[data-cy="part-order-select-none"]').click({ // cy.get('[data-cy="part-order-select-none"]').click({
multiple: true, // multiple: true,
force: true, // force: true,
}); // });
cy.get('[data-cy="order-part-submit"]').click({ // cy.get('[data-cy="order-part-submit"]').click({
multiple: true, // multiple: true,
force: true, // force: true,
}); // });
cy.get("#totalReturns").should("have.text", "$83.87"); // cy.get("#totalReturns").should("have.text", "$83.87");
cy.get("#calculatedcreditsnotreceived").should("have.text", "$83.87"); // cy.get("#calculatedcreditsnotreceived").should("have.text", "$83.87");
cy.get("#creditsnotreceived").should("have.text", "$83.87"); // cy.get("#creditsnotreceived").should("have.text", "$83.87");
}); // });
it("receives credit memo without return part", () => { // it("receives credit memo without return part", () => {
// Find the first row in the parts order // // Find the first row in the parts order
cy.get('[data-cy="part-orders-table"]') // cy.get('[data-cy="part-orders-table"]')
.find(".ant-table-tbody") // .find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)") // .find("> tr:not(.ant-table-measure-row)")
.as("orders-table") // .as("orders-table")
.should("not.have.class", "ant-table-placeholder"); // .should("not.have.class", "ant-table-placeholder");
cy.get("@orders-table") // cy.get("@orders-table")
.find('[data-cy="part-order-return-checkbox"]') // .find('[data-cy="part-order-return-checkbox"]')
.filter(":checked") // .filter(":checked")
.first() // .first()
.parent() // .parent()
.parent() // .parent()
.parent() // .parent()
.parent() // .parent()
.find('[data-cy="receive-bill-button"]') // .find('[data-cy="receive-bill-button"]')
.click(); // .click();
// fill out form // // fill out form
cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("1QBD261-01-")); // cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("1QBD261-01-"));
cy.get("#bill-form-date").click(); // cy.get("#bill-form-date").click();
cy.get('[title="2023-07-06"]').should("be.visible").click(); // cy.get('[title="2023-07-06"]').should("be.visible").click();
cy.get('[data-cy="bill-form-bill-total"]').type("70.46"); // cy.get('[data-cy="bill-form-bill-total"]').type("70.46");
cy.get('[data-cy="bill-line-actual-cost"]').type("67.10"); // cy.get('[data-cy="bill-line-actual-cost"]').type("67.10");
cy.get("#bill-form-discrepancy").should("have.text", "$0.00"); // cy.get("#bill-form-discrepancy").should("have.text", "$0.00");
// Click save // // Click save
cy.get('[data-cy="bill-form-save-button"]').click(); // cy.get('[data-cy="bill-form-save-button"]').click();
cy.get("#totalReturns").should("have.text", "$83.87"); // cy.get("#totalReturns").should("have.text", "$83.87");
cy.get("#calculatedcreditsnotreceived").should("have.text", "$0.00"); // cy.get("#calculatedcreditsnotreceived").should("have.text", "$0.00");
cy.get("#creditsnotreceived").should("have.text", "$83.87"); // cy.get("#creditsnotreceived").should("have.text", "$83.87");
}); // });
it("receives credit memo with return part", () => { // it("receives credit memo with return part", () => {
// Find the first row in the parts order // // Find the first row in the parts order
cy.get('[data-cy="part-orders-table"]') // cy.get('[data-cy="part-orders-table"]')
.find(".ant-table-tbody") // .find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)") // .find("> tr:not(.ant-table-measure-row)")
.as("orders-table") // .as("orders-table")
.should("not.have.class", "ant-table-placeholder"); // .should("not.have.class", "ant-table-placeholder");
cy.get("@orders-table") // cy.get("@orders-table")
.find('[data-cy="part-order-return-checkbox"]') // .find('[data-cy="part-order-return-checkbox"]')
.filter(":checked") // .filter(":checked")
.first() // .first()
.parent() // .parent()
.parent() // .parent()
.parent() // .parent()
.parent() // .parent()
.find('[data-cy="receive-bill-button"]') // .find('[data-cy="receive-bill-button"]')
.click(); // .click();
// fill out form // // fill out form
cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("1QBD261-02-")); // cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("1QBD261-02-"));
cy.get("#bill-form-date").click(); // cy.get("#bill-form-date").click();
cy.get('[title="2023-07-06"]').should("be.visible").click(); // cy.get('[title="2023-07-06"]').should("be.visible").click();
cy.get('[data-cy="bill-form-bill-total"]').type("70.46"); // cy.get('[data-cy="bill-form-bill-total"]').type("70.46");
cy.get('[data-cy="bill-line-actual-cost"]').type("67.10"); // cy.get('[data-cy="bill-line-actual-cost"]').type("67.10");
cy.get("#bill-form-discrepancy").should("have.text", "$0.00"); // cy.get("#bill-form-discrepancy").should("have.text", "$0.00");
cy.get('[data-cy="mark-as-received-checkbox"]').check(); // cy.get('[data-cy="mark-as-received-checkbox"]').check();
// Click save // // Click save
cy.get('[data-cy="bill-form-save-button"]').click(); // cy.get('[data-cy="bill-form-save-button"]').click();
cy.get("#totalReturns").should("have.text", "$83.87"); // cy.get("#totalReturns").should("have.text", "$83.87");
cy.get("#calculatedcreditsnotreceived").should("have.text", "$0.00"); // cy.get("#calculatedcreditsnotreceived").should("have.text", "$0.00");
cy.get("#creditsnotreceived").should("have.text", "$0.00"); // cy.get("#creditsnotreceived").should("have.text", "$0.00");
}); // });
it("views the row expander if it has the order and bill", () => { // it("views the row expander if it has the order and bill", () => {
cy.get('[data-cy="tab-repairdata"]').should("be.visible").click(); // cy.get('[data-cy="tab-repairdata"]').should("be.visible").click();
cy.get('[data-cy="filter-parts-button"]') // cy.get('[data-cy="filter-parts-button"]')
.should("not.be.disabled") // .should("not.be.disabled")
.click(); // .click();
cy.get('[data-cy="repair-data-table"]') // cy.get('[data-cy="repair-data-table"]')
.find(".ant-table-tbody") // .find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)") // .find("> tr:not(.ant-table-measure-row)")
.first() // .first()
.next() // .next()
.find("td") // .find("td")
.first() // .first()
.click(); // .click();
cy.get('[data-cy="parts-bills-order"]') // cy.get('[data-cy="parts-bills-order"]')
.should("be.visible") // .should("be.visible")
.find("li") // .find("li")
.first() // .first()
.should("not.have.text", "This part has not yet been ordered."); // .should("not.have.text", "This part has not yet been ordered.");
}); // });
} // }
); // );

View File

@@ -317,7 +317,12 @@ export function BillEnterModalLinesComponent({
}; };
}, },
formInput: (record, index) => ( formInput: (record, index) => (
<Select showSearch style={{ minWidth: "3rem" }} disabled={disabled}> <Select
showSearch
style={{ minWidth: "3rem" }}
disabled={disabled}
className="ant-select-bill-cost-center"
>
{bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber {bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber
? CiecaSelect(true, false) ? CiecaSelect(true, false)
: responsibilityCenters.costs.map((item) => ( : responsibilityCenters.costs.map((item) => (