IO-2327 added some test cases on posting bills

This commit is contained in:
swtmply
2023-08-18 11:51:56 +08:00
parent 807dbf0248
commit e89145e85f
7 changed files with 170 additions and 13 deletions

View File

@@ -18,7 +18,7 @@ describe(
.should("not.have.class", "ant-table-placeholder"); .should("not.have.class", "ant-table-placeholder");
}); });
it("order multiple parts for the job", () => { it("order parts for the job", () => {
const today = moment(new Date()).format("YYYY-MM-DD"); const today = moment(new Date()).format("YYYY-MM-DD");
cy.get("@active-jobs-table") cy.get("@active-jobs-table")
@@ -73,7 +73,7 @@ describe(
.contains("Ordered"); .contains("Ordered");
}); });
it.only("order parts for the job", () => { it.only("order multiple parts for the job", () => {
const today = moment(new Date()).format("YYYY-MM-DD"); const today = moment(new Date()).format("YYYY-MM-DD");
cy.get("@active-jobs-table") cy.get("@active-jobs-table")
@@ -110,6 +110,8 @@ describe(
cy.get("#deliver_by").click(); cy.get("#deliver_by").click();
cy.get(`[title="${today}"]`).should("be.visible").click({ force: true }); cy.get(`[title="${today}"]`).should("be.visible").click({ force: true });
cy.get('[data-cy="part-order-comments"]').type("testing from cypress");
cy.get('[data-cy="part-order-select-none"]').check(); cy.get('[data-cy="part-order-select-none"]').check();
cy.get('[data-cy="order-part-submit"]').should("not.be.disabled").click(); cy.get('[data-cy="order-part-submit"]').should("not.be.disabled").click();

View File

@@ -5,7 +5,7 @@ import Dinero from "dinero.js";
const uuid = () => Cypress._.random(0, 1e6); const uuid = () => Cypress._.random(0, 1e6);
describe( describe.only(
"Billing job parts orders", "Billing job parts orders",
{ {
defaultCommandTimeout: 10000, defaultCommandTimeout: 10000,
@@ -35,12 +35,57 @@ describe(
.parent() .parent()
.find('[data-cy="active-job-link"]') .find('[data-cy="active-job-link"]')
.click(); .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", () => {
// Order a part
// Go to repair data tab
cy.get('[data-cy="tab-repairdata"]').should("be.visible").click();
// Click on filter parts only
cy.get('[data-cy="filter-parts-button"]')
.should("not.be.disabled")
.click();
// Select multiple rows
cy.get('[data-cy="repair-data-table"]')
.find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)")
.first()
.find(".ant-checkbox-input")
.click();
// Click Order Parts
cy.get('[data-cy="order-parts-button"]')
.should("not.be.disabled")
.click();
// Modal should be visible
cy.get('[data-cy="parts-order-modal"]').should("be.visible");
// Fill required fields
cy.get(".ant-select-selection-search").find(`#vendorid`).click();
cy.get(`#vendorid_list`)
.next()
.find(".ant-select-item-option-content")
.first()
.click({ force: true });
cy.get("#deliver_by").click();
cy.get(`[title="${today}"]`).should("be.visible").click({ force: true });
cy.get('[data-cy="part-order-comments"]').type("testing from cypress");
cy.get('[data-cy="part-order-select-none"]').check();
cy.get('[data-cy="order-part-submit"]').should("not.be.disabled").click();
cy.get(".ant-notification-notice-message").contains(
"Parts order created successfully."
);
cy.get('[data-cy="repair-data-table"]')
.find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)")
.first()
.find(".ant-table-cell")
.eq(15)
.contains("Ordered");
cy.get('[data-cy="tab-partssublet"]').should("be.visible").click();
// 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")
@@ -55,7 +100,6 @@ describe(
.click(); .click();
// fill out form // fill out form
// data-cy="bill-form-invoice"
cy.get('[data-cy="bill-form-invoice"]').type(uuid()); cy.get('[data-cy="bill-form-invoice"]').type(uuid());
cy.get("#bill-form-date").click(); cy.get("#bill-form-date").click();
@@ -90,9 +134,100 @@ describe(
cy.get(".ant-notification-notice-message").contains( cy.get(".ant-notification-notice-message").contains(
"Invoice added successfully." "Invoice added successfully."
); );
cy.get('[data-cy="tab-repairdata"]').should("be.visible").click();
cy.get('[data-cy="filter-parts-button"]')
.should("not.be.disabled")
.click();
cy.get('[data-cy="repair-data-table"]')
.find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)")
.first()
.find(".ant-table-cell")
.eq(15)
.contains("Received");
});
it("backorders part from order", () => {
cy.get('[data-cy="tab-partssublet"]').should("be.visible").click();
cy.get('[data-cy="part-orders-table"]')
.find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)")
.as("orders-table")
.should("not.have.class", "ant-table-placeholder");
cy.get("@orders-table")
.first()
.should("be.visible")
.find('[data-cy="view-part-order-button"]')
.click();
cy.get('[data-cy="mark-backorder-button"]').click();
cy.get(".backorder-date").click();
cy.get(`[title="${today}"]`).should("be.visible").click({ force: true });
cy.get('[data-cy="mark-for-backorder-button"]').click();
cy.get(".ant-drawer-close").click();
cy.get('[data-cy="tab-repairdata"]').should("be.visible").click();
cy.get('[data-cy="filter-parts-button"]')
.should("not.be.disabled")
.click();
cy.get('[data-cy="repair-data-table"]')
.find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)")
.first()
.find(".ant-table-cell")
.eq(15)
.contains("Backordered");
});
it.only("order parts inhouse", () => {
cy.get('[data-cy="tab-repairdata"]').should("be.visible").click();
// Click on filter parts only
cy.get('[data-cy="filter-parts-button"]')
.should("not.be.disabled")
.click();
// Select multiple rows
cy.get('[data-cy="repair-data-table"]')
.find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)")
.first()
.find(".ant-checkbox-input")
.click();
// Click Order Parts
cy.get('[data-cy="order-parts-inhouse-button"]')
.should("not.be.disabled")
.click();
cy.antdSelect("bill-vendor");
cy.antdSelect("bill-cost-center");
cy.get('[data-cy="bill-form-save-button"]').click({ force: true });
cy.get(".ant-notification-notice-message").contains(
"Invoice added successfully."
);
cy.get('[data-cy="repair-data-table"]')
.find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)")
.first()
.find(".ant-table-cell")
.eq(15)
.contains("Received");
}); });
it("posts bill directly", () => { it("posts bill directly", () => {
cy.get('[data-cy="tab-partssublet"]').should("be.visible").click();
cy.get('[data-cy="bills-post-button"]').should("be.visible").click(); cy.get('[data-cy="bills-post-button"]').should("be.visible").click();
// Add New Line // Add New Line
@@ -144,6 +279,8 @@ describe(
}); });
it("posts a bill with save and new", () => { it("posts a bill with save and new", () => {
cy.get('[data-cy="tab-partssublet"]').should("be.visible").click();
cy.get('[data-cy="bills-post-button"]').should("be.visible").click(); cy.get('[data-cy="bills-post-button"]').should("be.visible").click();
// Add New Line // Add New Line
@@ -197,6 +334,8 @@ describe(
}); });
it("uploads a document to a bill", () => { it("uploads a document to a bill", () => {
cy.get('[data-cy="tab-partssublet"]').should("be.visible").click();
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)")
@@ -216,6 +355,8 @@ describe(
}); });
it("marks bill as exported", () => { it("marks bill as exported", () => {
cy.get('[data-cy="tab-partssublet"]').should("be.visible").click();
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)")
@@ -242,6 +383,8 @@ describe(
}); });
it("marks bill for re-export", () => { it("marks bill for re-export", () => {
cy.get('[data-cy="tab-partssublet"]').should("be.visible").click();
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)")

View File

@@ -441,6 +441,7 @@ export function JobLinesComponent({
</Tag> </Tag>
)} )}
<Button <Button
data-cy="order-parts-inhouse-button"
disabled={ disabled={
(job && !job.converted) || (job && !job.converted) ||
(selectedLines.length > 0 ? false : true) || (selectedLines.length > 0 ? false : true) ||

View File

@@ -78,9 +78,13 @@ export function PartsOrderLineBackorderButton({
<div> <div>
<Form form={form} onFinish={handleFinish}> <Form form={form} onFinish={handleFinish}>
<Form.Item name="eta"> <Form.Item name="eta">
<FormDatePicker /> <FormDatePicker className="backorder-date" />
</Form.Item> </Form.Item>
<Button type="primary" onClick={() => form.submit()}> <Button
data-cy="mark-for-backorder-button"
type="primary"
onClick={() => form.submit()}
>
{t("parts_orders.actions.backordered")} {t("parts_orders.actions.backordered")}
</Button> </Button>
<Button onClick={() => setVisibility(false)}>Close</Button> <Button onClick={() => setVisibility(false)}>Close</Button>
@@ -95,7 +99,11 @@ export function PartsOrderLineBackorderButton({
visible={visibility} visible={visibility}
disabled={disabled} disabled={disabled}
> >
<Button loading={loading} onClick={handlePopover}> <Button
data-cy="mark-backorder-button"
loading={loading}
onClick={handlePopover}
>
{isAlreadyBackordered {isAlreadyBackordered
? t("parts_orders.actions.receive") ? t("parts_orders.actions.receive")
: t("parts_orders.actions.backordered")} : t("parts_orders.actions.backordered")}

View File

@@ -90,7 +90,10 @@ export function PartsOrderListTableComponent({
const recordActions = (record, showView = false) => ( const recordActions = (record, showView = false) => (
<Space wrap> <Space wrap>
{showView && ( {showView && (
<Button onClick={() => handleOnRowClick(record)}> <Button
data-cy="view-part-order-button"
onClick={() => handleOnRowClick(record)}
>
<EyeFilled /> <EyeFilled />
</Button> </Button>
)} )}

View File

@@ -321,7 +321,7 @@ export function PartsOrderModalComponent({
</Space> </Space>
} }
> >
<Input.TextArea rows={3} /> <Input.TextArea rows={3} data-cy="part-order-comments" />
</Form.Item> </Form.Item>
<Form.Item noStyle shouldUpdate> <Form.Item noStyle shouldUpdate>

View File

@@ -362,7 +362,7 @@ export function PartsOrderModalContainer({
cancelButtonProps={{ loading: saving }} cancelButtonProps={{ loading: saving }}
destroyOnClose destroyOnClose
width="75%" width="75%"
forceRender // forceRender
> >
{error ? <AlertComponent message={error.message} type="error" /> : null} {error ? <AlertComponent message={error.message} type="error" /> : null}
<Form <Form