From aa064cc573c9aee8e50bb365c0a215ee1c62be64 Mon Sep 17 00:00:00 2001 From: swtmply Date: Mon, 19 Jun 2023 07:54:49 +0800 Subject: [PATCH] IO-2327 job importing tests --- .../cypress/e2e/job-import/converting.cy.js | 4 +- .../cypress/e2e/job-import/job-import.cy.js | 66 ++++++++++++++++++- .../jobs-available-table.component.jsx | 5 +- .../jobs-find-modal.component.jsx | 1 + .../jobs-find-modal.container.jsx | 5 +- .../loading-spinner.component.jsx | 2 +- .../owner-find-modal.component.jsx | 1 + .../owner-find-modal.container.jsx | 2 + 8 files changed, 79 insertions(+), 7 deletions(-) diff --git a/client/cypress/e2e/job-import/converting.cy.js b/client/cypress/e2e/job-import/converting.cy.js index 93347deb8..acf8bad25 100644 --- a/client/cypress/e2e/job-import/converting.cy.js +++ b/client/cypress/e2e/job-import/converting.cy.js @@ -57,9 +57,9 @@ describe( cy.get("#driveable").should("have.class", "ant-switch").click(); cy.get("#towin").should("have.class", "ant-switch").click(); - // cy.get('[data-cy="convert-button"]').click(); + cy.get('[data-cy="convert-button"]').click(); - // cy.get(".ant-notification-notice-message").contains("successfully"); + cy.get(".ant-notification-notice-message").contains("successfully"); }); } ); diff --git a/client/cypress/e2e/job-import/job-import.cy.js b/client/cypress/e2e/job-import/job-import.cy.js index 8a829b95c..7e3d02d3c 100644 --- a/client/cypress/e2e/job-import/job-import.cy.js +++ b/client/cypress/e2e/job-import/job-import.cy.js @@ -15,9 +15,7 @@ describe( cy.get('[data-cy="sign-in-button"]').click(); } }); - }); - it("checks if there are available jobs", () => { cy.get('[data-cy="available-jobs-table"]') .find("tr") .should("not.have.class", "ant-table-placeholder"); @@ -39,5 +37,69 @@ describe( cy.url().should("include", "/manage/jobs"); }); + + it("imports a supplement for an existing job", () => { + cy.get('[data-cy="add-job-as-supplement"]') + .filter(":enabled") + .first() + .click(); + + cy.get('[data-cy="existing-jobs-table"]') + .find(".ant-table-tbody tr") + .should("not.have.class", "ant-table-placeholder") + .first() + .click(); + + cy.get('[data-cy="existing-jobs-ok-button"]') + .should("not.be", "disabled") + .click(); + + cy.get(".ant-notification-notice-message") + .contains("Job supplemented successfully.") + .click(); + + cy.url().should("include", "/manage/jobs"); + }); + + it("imports a job with an existing owner", () => { + let hasOwner = false; + + cy.get('[data-cy="add-job-as-new-button"]') + .filter(":enabled") + .each(($el) => { + cy.then(() => { + if (hasOwner) return false; + + cy.wrap($el).click(); + + // check if table is not empty + cy.get('[data-cy="existing-owner-table"]', { timeout: 20000 }) + .find(".ant-table-tbody tr") + .should("not.have.class", "ant-table-placeholder") + .then(($table) => { + if ($table.length === 0) { + cy.get('[data-cy="existing-owners-cancel-button"]').click(); + } + + cy.wrap($table).first().click(); + + cy.get('[data-cy="new_owner_checkbox"]').should( + "not.be", + "checked" + ); + + hasOwner = true; + }); + }); + }); + + cy.get('[data-cy="existing-owners-ok-button"]').click(); + + cy.get(".ant-notification-notice-message") + .contains("Job created successfully. Click to view.") + .click(); + + cy.url().should("include", "/manage/jobs"); + }); } ); diff --git a/client/src/components/jobs-available-table/jobs-available-table.component.jsx b/client/src/components/jobs-available-table/jobs-available-table.component.jsx index 513e795e0..be282547d 100644 --- a/client/src/components/jobs-available-table/jobs-available-table.component.jsx +++ b/client/src/components/jobs-available-table/jobs-available-table.component.jsx @@ -177,7 +177,10 @@ export function JobsAvailableComponent({ > - diff --git a/client/src/components/jobs-find-modal/jobs-find-modal.component.jsx b/client/src/components/jobs-find-modal/jobs-find-modal.component.jsx index 330c0e5db..e464e6df4 100644 --- a/client/src/components/jobs-find-modal/jobs-find-modal.component.jsx +++ b/client/src/components/jobs-find-modal/jobs-find-modal.component.jsx @@ -167,6 +167,7 @@ export default function JobsFindModalComponent({ /> )} + data-cy="existing-jobs-table" pagination={{ position: "bottom" }} columns={columns} rowKey="id" diff --git a/client/src/components/jobs-find-modal/jobs-find-modal.container.jsx b/client/src/components/jobs-find-modal/jobs-find-modal.container.jsx index 7bb3591cb..308f2c2f3 100644 --- a/client/src/components/jobs-find-modal/jobs-find-modal.container.jsx +++ b/client/src/components/jobs-find-modal/jobs-find-modal.container.jsx @@ -77,7 +77,10 @@ export default connect( title={t("jobs.labels.existing_jobs")} width={"80%"} destroyOnClose - okButtonProps={{ disabled: selectedJob ? false : true }} + okButtonProps={{ + disabled: selectedJob ? false : true, + "data-cy": "existing-jobs-ok-button", + }} {...modalProps} > {loading ? : null} diff --git a/client/src/components/loading-spinner/loading-spinner.component.jsx b/client/src/components/loading-spinner/loading-spinner.component.jsx index e66b0f1af..5907020aa 100644 --- a/client/src/components/loading-spinner/loading-spinner.component.jsx +++ b/client/src/components/loading-spinner/loading-spinner.component.jsx @@ -10,7 +10,7 @@ export default function LoadingSpinner({ loading = true, message, ...props }) { size="large" style={{ position: "relative", - alignContent: "center" + alignContent: "center", }} delay={200} tip={message ? message : null} diff --git a/client/src/components/owner-find-modal/owner-find-modal.component.jsx b/client/src/components/owner-find-modal/owner-find-modal.component.jsx index ce9998ea6..ab8898e8c 100644 --- a/client/src/components/owner-find-modal/owner-find-modal.component.jsx +++ b/client/src/components/owner-find-modal/owner-find-modal.component.jsx @@ -82,6 +82,7 @@ export default function OwnerFindModalComponent({ return (
{loading ? : null}