From 807dbf02482e34f897dfd9ab9b3f4d27806d3af3 Mon Sep 17 00:00:00 2001 From: swtmply Date: Thu, 17 Aug 2023 12:02:41 +0800 Subject: [PATCH] IO-2327 parts ordering test case --- .../e2e/parts-ordering/parts-ordering.cy.js | 64 +++++++++++++++++-- 1 file changed, 60 insertions(+), 4 deletions(-) diff --git a/client/cypress/e2e/parts-ordering/parts-ordering.cy.js b/client/cypress/e2e/parts-ordering/parts-ordering.cy.js index 8dbc72d57..1759564bf 100644 --- a/client/cypress/e2e/parts-ordering/parts-ordering.cy.js +++ b/client/cypress/e2e/parts-ordering/parts-ordering.cy.js @@ -1,15 +1,14 @@ import job from "../../fixtures/jobs/job-3.json"; +import job2 from "../../fixtures/jobs/job-4.json"; import moment from "moment"; describe( "Ordering parts for the job", { - defaultCommandTimeout: 5000, + defaultCommandTimeout: 10000, }, () => { - it("order parts for the job", () => { - const today = moment(new Date()).format("YYYY-MM-DD"); - + beforeEach(() => { cy.visit("/manage/jobs"); cy.get('[data-cy="active-jobs-table"]') @@ -17,6 +16,10 @@ describe( .find("> tr:not(.ant-table-measure-row)") .as("active-jobs-table") .should("not.have.class", "ant-table-placeholder"); + }); + + it("order multiple parts for the job", () => { + const today = moment(new Date()).format("YYYY-MM-DD"); cy.get("@active-jobs-table") .contains(job.clm_no) @@ -69,5 +72,58 @@ describe( .eq(15) .contains("Ordered"); }); + + it.only("order parts for the job", () => { + const today = moment(new Date()).format("YYYY-MM-DD"); + + cy.get("@active-jobs-table") + .contains(job2.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("input:checkbox") + .first() + .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"); + }); } );