IO-2327 parts ordering send by email

This commit is contained in:
swtmply
2023-06-22 06:43:45 +08:00
parent 7ae48db212
commit 12d07f8318
6 changed files with 80 additions and 5 deletions

View File

@@ -0,0 +1,69 @@
describe(
"Ordering parts for the job",
{
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")
.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-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.antdFormSelect("vendor", "Vendor");
cy.get("#deliver_by").click();
cy.get('[title="2023-06-21"]').should("be.visible").click();
});
});
it("sending by email", () => {
// FIXME email preview not working
cy.get('[data-cy="part-order-checkbox-remove"]').check();
cy.get('[data-cy="order-part-submit"]').should("not.be.disabled").click();
cy.contains("Email Preview");
});
// TODO Send by PDF
// TODO Send by OEC
}
);

View File

@@ -497,6 +497,7 @@ export function JobLinesComponent({
{selectedLines.length > 0 && ` (${selectedLines.length})`}
</Button>
<Button
data-cy="order-parts-button"
disabled={
(job && !job.converted) ||
(selectedLines.length > 0 ? false : true) ||
@@ -526,6 +527,7 @@ export function JobLinesComponent({
{selectedLines.length > 0 && ` (${selectedLines.length})`}
</Button>
<Button
data-cy="filter-parts-button"
onClick={() => {
setState((state) => ({
...state,
@@ -575,6 +577,7 @@ export function JobLinesComponent({
}
/>
<Table
data-cy="repair-data-table"
columns={columns}
rowKey="id"
loading={loading}

View File

@@ -74,7 +74,7 @@ export function PartsOrderModalComponent({
);
return (
<div>
<div data-cy="parts-order-modal">
<Form.Item name="returnfrombill" style={{ display: "none" }}>
<Input />
</Form.Item>
@@ -98,6 +98,7 @@ export function PartsOrderModalComponent({
</Form.Item>
<Form.Item
name="deliver_by"
id="deliver_by"
rules={[
{
required: true,
@@ -122,7 +123,7 @@ export function PartsOrderModalComponent({
label={t("parts_orders.labels.removefrompartsqueue")}
valuePropName="checked"
>
<Checkbox />
<Checkbox data-cy="part-order-checkbox-remove" />
</Form.Item>
)}
{OEConnection.treatment === "on" && !isReturn && (
@@ -131,7 +132,7 @@ export function PartsOrderModalComponent({
label={t("parts_orders.labels.is_quote")}
valuePropName="checked"
>
<Checkbox />
<Checkbox data-cy="part-order-checkbox-quote" />
</Form.Item>
)}

View File

@@ -358,7 +358,7 @@ export function PartsOrderModalContainer({
}
onCancel={() => toggleModalVisible()}
onOk={() => form.submit()}
okButtonProps={{ loading: saving }}
okButtonProps={{ loading: saving, "data-cy": "order-part-submit" }}
cancelButtonProps={{ loading: saving }}
destroyOnClose
width="75%"

View File

@@ -30,6 +30,8 @@ const VendorSearchSelect = (
return (
<Select
id="vendor"
className="ant-select-vendor"
ref={ref}
showSearch
value={option}

View File

@@ -273,7 +273,7 @@ export function JobsDetailPage({
<Tabs.TabPane
forceRender
tab={
<span>
<span data-cy="tab-repairdata">
<BarsOutlined />
{t("menus.jobsdetail.repairdata")}
</span>