From 353d6d010cb09769b07ac466339577c6dfd24a7b Mon Sep 17 00:00:00 2001 From: swtmply Date: Fri, 4 Aug 2023 04:36:16 +0800 Subject: [PATCH] IO-2327 part ordering test cases --- .../e2e/parts-ordering/parts-ordering.cy.js | 118 ++++++++++-------- 1 file changed, 64 insertions(+), 54 deletions(-) diff --git a/client/cypress/e2e/parts-ordering/parts-ordering.cy.js b/client/cypress/e2e/parts-ordering/parts-ordering.cy.js index a8dba80af..74efcd382 100644 --- a/client/cypress/e2e/parts-ordering/parts-ordering.cy.js +++ b/client/cypress/e2e/parts-ordering/parts-ordering.cy.js @@ -1,69 +1,79 @@ +import job from "../../fixtures/jobs/job-3.json"; +import moment from "moment"; + describe( "Ordering parts for the job", { defaultCommandTimeout: 5000, }, () => { - beforeEach(() => { - cy.visit("/manage"); + it("order parts for the job", () => { + const today = moment(new Date()).format("YYYY-MM-DD"); - 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.visit("/manage/jobs"); + + cy.intercept("POST", Cypress.env("graphql_dev_endpoint"), (req) => { + if (req.body.operationName === "QUERY_BODYSHOP") { + req.alias = "bodyshop"; } - - 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="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.contains("Email Preview"); - }); + cy.get(".ant-notification-notice-message").contains( + "Parts order created successfully." + ); - // TODO Send by PDF - // TODO Send by OEC + 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"); + }); } );