IO-2327 posting bills test cases
This commit is contained in:
@@ -448,6 +448,14 @@ describe.only(
|
||||
.click({ multiple: true });
|
||||
});
|
||||
|
||||
cy.get('[data-cy="is-credit-memo-switch"]').click();
|
||||
|
||||
cy.get('[data-cy="is-credit-memo-switch"]').should(
|
||||
"have.attr",
|
||||
"aria-checked",
|
||||
"false"
|
||||
);
|
||||
|
||||
cy.get('[data-cy="bill-line-actual-cost"]').then((cells) => {
|
||||
cy.get('[data-cy="bill-line-actual-price"]').then((priceCells) => {
|
||||
const totals = cells.toArray().map((el) => Number(el.value));
|
||||
@@ -493,7 +501,7 @@ describe.only(
|
||||
}
|
||||
);
|
||||
|
||||
cy.get('[data-cy="bill-form-save-button"]').click();
|
||||
// cy.get('[data-cy="bill-form-save-button"]').click();
|
||||
|
||||
cy.get("#totalReturns")
|
||||
.invoke("text")
|
||||
@@ -515,7 +523,7 @@ describe.only(
|
||||
});
|
||||
});
|
||||
|
||||
it.only("receives credit memo with return part", () => {
|
||||
it("receives credit memo with return part", () => {
|
||||
// Find the first row in the parts order
|
||||
cy.get('[data-cy="part-orders-table"]')
|
||||
.find(".ant-table-tbody")
|
||||
@@ -550,7 +558,6 @@ describe.only(
|
||||
.click({ multiple: true });
|
||||
});
|
||||
|
||||
// TODO Credit memo should be checked
|
||||
cy.get('[data-cy="is-credit-memo-switch"]').should(
|
||||
"have.attr",
|
||||
"aria-checked",
|
||||
@@ -558,57 +565,79 @@ describe.only(
|
||||
);
|
||||
|
||||
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);
|
||||
|
||||
// Get taxes add it to the sum
|
||||
cy.get('[data-cy="bill-form-tax"]').then((taxes) => {
|
||||
const subtotals = taxes
|
||||
cy.get('[data-cy="bill-line-actual-price"]').then((priceCells) => {
|
||||
const totals = cells.toArray().map((el) => Number(el.value));
|
||||
const priceTotals = priceCells
|
||||
.toArray()
|
||||
.map((el) => Number(el.innerText.substring(1)));
|
||||
const totalTax = Cypress._.sum(subtotals);
|
||||
.map((el) => Number(el.value));
|
||||
const sum = Cypress._.sum(totals);
|
||||
const priceSum = Cypress._.sum(priceTotals);
|
||||
|
||||
const billAmount = sum + totalTax;
|
||||
cy.get('[data-cy="bill-form-bill-total"]').type(sum);
|
||||
|
||||
cy.get('[data-cy="bill-form-bill-total"]')
|
||||
.find("input")
|
||||
.clear()
|
||||
.type(billAmount);
|
||||
// Get taxes add it to the sum
|
||||
cy.get('[data-cy="bill-form-tax"]').then((taxes) => {
|
||||
const subtotals = taxes
|
||||
.toArray()
|
||||
.map((el) => Number(el.innerText.substring(1)));
|
||||
const totalTax = Cypress._.sum(subtotals);
|
||||
|
||||
const billAmount = sum + totalTax;
|
||||
|
||||
cy.get('[data-cy="bill-form-bill-total"]')
|
||||
.find("input")
|
||||
.clear()
|
||||
.type(billAmount);
|
||||
});
|
||||
|
||||
cy.get("#bill-form-discrepancy").should("have.text", "$0.00");
|
||||
|
||||
cy.get(`.ant-select-bill-cost-center > .ant-select-selector`).each(
|
||||
(select) => {
|
||||
cy.wrap(select).click();
|
||||
|
||||
cy.wrap(select)
|
||||
.find("input")
|
||||
.invoke("attr", "id")
|
||||
.then((id) => {
|
||||
cy.get(`#${id}_list`)
|
||||
.next()
|
||||
.find(".ant-select-item-option-content")
|
||||
.first()
|
||||
.click({ force: true });
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
cy.get('[data-cy="mark-as-received-checkbox"]').check({
|
||||
multiple: true,
|
||||
});
|
||||
|
||||
cy.get('[data-cy="bill-form-save-button"]').click();
|
||||
|
||||
cy.get("#totalReturns")
|
||||
.invoke("text")
|
||||
.then((value) => {
|
||||
const totalReturns =
|
||||
Number(value.substring(1)) - priceSum < 0
|
||||
? 0
|
||||
: Number(value.substring(1)) - priceSum;
|
||||
|
||||
cy.get("#creditsnotreceived").should(
|
||||
"have.text",
|
||||
Dinero({
|
||||
amount: totalReturns,
|
||||
precision: 0,
|
||||
}).toFormat()
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
cy.get("#bill-form-discrepancy").should("have.text", "$0.00");
|
||||
|
||||
cy.get(`.ant-select-bill-cost-center > .ant-select-selector`).each(
|
||||
(select) => {
|
||||
cy.wrap(select).click();
|
||||
|
||||
cy.wrap(select)
|
||||
.find("input")
|
||||
.invoke("attr", "id")
|
||||
.then((id) => {
|
||||
cy.get(`#${id}_list`)
|
||||
.next()
|
||||
.find(".ant-select-item-option-content")
|
||||
.first()
|
||||
.click({ force: true });
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
cy.get('[data-cy="mark-as-received-checkbox"]').check();
|
||||
|
||||
// Click save
|
||||
// cy.get('[data-cy="bill-form-save-button"]').click();
|
||||
|
||||
// TODO add assertion to the total
|
||||
cy.get("#calculatedcreditsnotreceived").should("have.text", "$0.00");
|
||||
cy.get("#creditsnotreceived").should("have.text", "$0.00");
|
||||
});
|
||||
|
||||
// TODO add more assertions to the parts table
|
||||
it("views the row expander if it has the order and bill", () => {
|
||||
// location, status
|
||||
it.only("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="filter-parts-button"]')
|
||||
@@ -619,7 +648,6 @@ describe.only(
|
||||
.find(".ant-table-tbody")
|
||||
.find("> tr:not(.ant-table-measure-row)")
|
||||
.first()
|
||||
.next()
|
||||
.find("td")
|
||||
.first()
|
||||
.click();
|
||||
|
||||
Reference in New Issue
Block a user