From 2c5410b65232e699ed0e496adf4209de8b9e8fbe Mon Sep 17 00:00:00 2001 From: Psami-wondah Date: Sat, 5 Oct 2024 07:42:19 +0100 Subject: [PATCH] feat: DX-1924 - Issue with reordering rowframe --- cypress/e2e/{1-dx => }/1-test-login.cy.ts | 0 cypress/e2e/{1-dx => }/2-datasets.cy.ts | 0 cypress/e2e/{1-dx => }/3-charts.cy.ts | 0 cypress/e2e/{1-dx => }/4-reports.cy.ts | 59 ++++++++++--------- cypress/e2e/{1-dx => }/5-dashboard.cy.ts | 0 cypress/e2e/{1-dx => }/6-home.cy.ts | 0 cypress/e2e/{1-dx => }/7-general.cy.ts | 0 .../components/placeholder/index.tsx | 2 +- 8 files changed, 32 insertions(+), 29 deletions(-) rename cypress/e2e/{1-dx => }/1-test-login.cy.ts (100%) rename cypress/e2e/{1-dx => }/2-datasets.cy.ts (100%) rename cypress/e2e/{1-dx => }/3-charts.cy.ts (100%) rename cypress/e2e/{1-dx => }/4-reports.cy.ts (95%) rename cypress/e2e/{1-dx => }/5-dashboard.cy.ts (100%) rename cypress/e2e/{1-dx => }/6-home.cy.ts (100%) rename cypress/e2e/{1-dx => }/7-general.cy.ts (100%) diff --git a/cypress/e2e/1-dx/1-test-login.cy.ts b/cypress/e2e/1-test-login.cy.ts similarity index 100% rename from cypress/e2e/1-dx/1-test-login.cy.ts rename to cypress/e2e/1-test-login.cy.ts diff --git a/cypress/e2e/1-dx/2-datasets.cy.ts b/cypress/e2e/2-datasets.cy.ts similarity index 100% rename from cypress/e2e/1-dx/2-datasets.cy.ts rename to cypress/e2e/2-datasets.cy.ts diff --git a/cypress/e2e/1-dx/3-charts.cy.ts b/cypress/e2e/3-charts.cy.ts similarity index 100% rename from cypress/e2e/1-dx/3-charts.cy.ts rename to cypress/e2e/3-charts.cy.ts diff --git a/cypress/e2e/1-dx/4-reports.cy.ts b/cypress/e2e/4-reports.cy.ts similarity index 95% rename from cypress/e2e/1-dx/4-reports.cy.ts rename to cypress/e2e/4-reports.cy.ts index 6418319a9..36d821bd7 100644 --- a/cypress/e2e/1-dx/4-reports.cy.ts +++ b/cypress/e2e/4-reports.cy.ts @@ -343,34 +343,6 @@ describe("Edit, duplicate and delete report", () => { ).should("be.visible"); }); - // it("Can drag and drop rows in a report", () => { - // cy.get("[data-cy=home-search-button]").click(); - // cy.wait(2000); - // cy.get("[data-cy=filter-search-input]").type( - // `{selectall}{backspace}${reportTestName}` - // ); - - // cy.wait("@fetchReports"); - - // cy.contains('[data-cy="report-grid-item"]', `${reportTestName} - Edited`) - // .first() - // .scrollIntoView() - // .within(() => { - // cy.get('[data-cy="report-grid-item-menu-btn"]').click(); - // }); - - // cy.intercept(`${apiUrl}/report/*`).as("fetchReport"); - - // cy.get('[data-cy="report-grid-item-edit-btn"]').click(); - - // cy.wait("@fetchReport"); - - // cy.get('[data-cy="row-frame-container-0"]').within(() => { - // cy.get('[data-cy="row-frame-handle"]').drag(); - // }); - // cy.get('[data-cy="report-row-placeholder"]').eq(2).scrollIntoView().drop(); - // }); - it("Can delete an item from a box in a row", () => { cy.get("[data-cy=home-search-button]").click(); cy.wait(2000); @@ -590,6 +562,37 @@ describe("Edit, duplicate and delete report", () => { }); cy.get('[data-cy="row-frame-chart-item-0-1"]').should("have.length", 0); + cy.wait(5000); + }); + + it("Can drag and drop rows in a report", () => { + cy.get("[data-cy=home-search-button]").click(); + cy.wait(2000); + cy.get("[data-cy=filter-search-input]").type( + `{selectall}{backspace}${reportTestName}` + ); + + cy.wait("@fetchReports"); + + cy.contains('[data-cy="report-grid-item"]', `${reportTestName} - Edited`) + .first() + .scrollIntoView() + .within(() => { + cy.get('[data-cy="report-grid-item-menu-btn"]').click(); + }); + + cy.intercept(`${apiUrl}/report/*`).as("fetchReport"); + + cy.get('[data-cy="report-grid-item-edit-btn"]').click(); + + cy.wait("@fetchReport"); + + cy.get('[data-cy="row-frame-container-0"]').within(() => { + cy.get('[data-cy="row-frame-handle"]').drag(); + }); + cy.get('[data-cy="report-row-placeholder"]').eq(2).scrollIntoView().drop(); + cy.get('[data-cy="row-frame-text-item-0-0"]').should("have.length", 0); + cy.wait(5000); }); it("Can delete a report", () => { diff --git a/cypress/e2e/1-dx/5-dashboard.cy.ts b/cypress/e2e/5-dashboard.cy.ts similarity index 100% rename from cypress/e2e/1-dx/5-dashboard.cy.ts rename to cypress/e2e/5-dashboard.cy.ts diff --git a/cypress/e2e/1-dx/6-home.cy.ts b/cypress/e2e/6-home.cy.ts similarity index 100% rename from cypress/e2e/1-dx/6-home.cy.ts rename to cypress/e2e/6-home.cy.ts diff --git a/cypress/e2e/1-dx/7-general.cy.ts b/cypress/e2e/7-general.cy.ts similarity index 100% rename from cypress/e2e/1-dx/7-general.cy.ts rename to cypress/e2e/7-general.cy.ts diff --git a/src/app/modules/report-module/components/placeholder/index.tsx b/src/app/modules/report-module/components/placeholder/index.tsx index 18d1d7789..dc1c8afcb 100644 --- a/src/app/modules/report-module/components/placeholder/index.tsx +++ b/src/app/modules/report-module/components/placeholder/index.tsx @@ -15,7 +15,7 @@ const PlaceHolder = (props: PlaceholderProps) => { props.index ?? draft.findIndex((frame) => frame.id === props.rowId) + 1; const fakeId = v4(); - const tempItem = draft[dragIndex]; + const tempItem = { ...draft[dragIndex] }; draft[dragIndex].id = fakeId; draft.splice(dropIndex, 0, tempItem);