Files
bodyshop/client/cypress/e2e/parts-ordering/parts-ordering.cy.js
2023-08-04 12:08:34 +08:00

74 lines
2.2 KiB
JavaScript

import job from "../../fixtures/jobs/job-3.json";
import moment from "moment";
describe(
"Ordering parts for the job",
{
defaultCommandTimeout: 5000,
},
() => {
it("order parts for the job", () => {
const today = moment(new Date()).format("YYYY-MM-DD");
cy.visit("/manage/jobs");
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-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-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");
});
}
);