From 960e55f2150b6e8f6d4f92c4f3f0ec67bf201e2f Mon Sep 17 00:00:00 2001 From: hatim dinia Date: Mon, 14 Oct 2024 17:06:46 +0200 Subject: [PATCH] fix: correct lint and types issues --- .../explore/Results/ResultDetails/index.tsx | 4 +- .../MatrixGrid/useGridCellContent.test.ts | 56 --------------- .../common/MatrixGrid/utils.test.ts | 72 ------------------- 3 files changed, 2 insertions(+), 130 deletions(-) diff --git a/webapp/src/components/App/Singlestudy/explore/Results/ResultDetails/index.tsx b/webapp/src/components/App/Singlestudy/explore/Results/ResultDetails/index.tsx index ad2a838019..3011f257d6 100644 --- a/webapp/src/components/App/Singlestudy/explore/Results/ResultDetails/index.tsx +++ b/webapp/src/components/App/Singlestudy/explore/Results/ResultDetails/index.tsx @@ -266,7 +266,7 @@ function ResultDetails() { columns={generateCustomColumns({ titles: matrix.columns, })} - isReaOnlyEnabled + isReadOnlyEnabled /> ) } @@ -292,7 +292,7 @@ function ResultDetails() { }), ]} dateTime={dateTime} - isReaOnlyEnabled + isReadOnlyEnabled /> ) } diff --git a/webapp/src/components/common/MatrixGrid/useGridCellContent.test.ts b/webapp/src/components/common/MatrixGrid/useGridCellContent.test.ts index 880cf9fe5b..8adf3041d5 100644 --- a/webapp/src/components/common/MatrixGrid/useGridCellContent.test.ts +++ b/webapp/src/components/common/MatrixGrid/useGridCellContent.test.ts @@ -80,42 +80,6 @@ function renderGridCellContent( } describe("useGridCellContent", () => { - test("returns correct text cell content for DateTime columns", () => { - const columns: EnhancedGridColumn[] = [ - { - id: "date", - title: "Date", - type: ColumnTypes.DateTime, - width: 150, - editable: false, - }, - { - id: "data1", - title: "TS 1", - type: ColumnTypes.Number, - width: 50, - editable: true, - }, - ]; - - const dateTime = ["2024-01-07T00:00:00Z", "2024-01-02T00:00:00Z"]; - - const data = [ - [11, 10], - [12, 15], - ]; - - const getCellContent = renderGridCellContent(data, columns, dateTime); - const cell = getCellContent([0, 0]); - - if ("displayData" in cell) { - expect(cell.kind).toBe("text"); - expect(cell.displayData).toBe("7 janv. 2024, 00:00"); - } else { - throw new Error("Expected a text cell with displayData"); - } - }); - describe("returns correct cell content for Aggregate columns", () => { const columns: EnhancedGridColumn[] = [ { @@ -220,17 +184,6 @@ describe("useGridCellContent", () => { aggregates, ); - const dateTimeCell = getCellContent([0, 0]); - - if (dateTimeCell.kind === "text" && "displayData" in dateTimeCell) { - expect(dateTimeCell.data).toBe(""); - expect(dateTimeCell.displayData).toBe("1 janv. 2021, 00:00"); - } else { - throw new Error( - "Expected a DateTime cell with displayData containing the year 2021", - ); - } - const numberCell = getCellContent([1, 0]); if (numberCell.kind === "number" && "data" in numberCell) { @@ -319,15 +272,6 @@ describe("useGridCellContent with mixed column types", () => { throw new Error("Expected a text cell with data for row header"); } - // Test date column (DateTime column) - const dateCell = getCellContent([1, 0]); - if (dateCell.kind === "text" && "displayData" in dateCell) { - expect(dateCell.data).toBe(""); - expect(dateCell.displayData).toBe("1 janv. 2024, 00:00"); - } else { - throw new Error("Expected a text cell with data for date"); - } - // Test first data column (Number column) const firstDataCell = getCellContent([2, 0]); diff --git a/webapp/src/components/common/MatrixGrid/utils.test.ts b/webapp/src/components/common/MatrixGrid/utils.test.ts index 6d96350d86..403e46c0ed 100644 --- a/webapp/src/components/common/MatrixGrid/utils.test.ts +++ b/webapp/src/components/common/MatrixGrid/utils.test.ts @@ -35,78 +35,6 @@ describe("generateDateTime", () => { const result = generateDateTime(metadata); expect(result).toHaveLength(5); }); - - test.each([ - { - level: "hourly", - start: "2023-01-01T00:00:00Z", - expected: [ - "2023-01-01T00:00:00.000Z", - "2023-01-01T01:00:00.000Z", - "2023-01-01T02:00:00.000Z", - ], - }, - { - level: "daily", - start: "2023-01-01T00:00:00Z", - expected: [ - "2023-01-01T00:00:00.000Z", - "2023-01-02T00:00:00.000Z", - "2023-01-03T00:00:00.000Z", - ], - }, - { - level: "weekly", - start: "2023-01-01T00:00:00Z", - expected: [ - "2023-01-01T00:00:00.000Z", - "2023-01-08T00:00:00.000Z", - "2023-01-15T00:00:00.000Z", - ], - }, - { - level: "monthly", - start: "2023-01-15T00:00:00Z", - expected: [ - "2023-01-15T00:00:00.000Z", - "2023-02-15T00:00:00.000Z", - "2023-03-15T00:00:00.000Z", - ], - }, - { - level: "annual", - start: "2020-02-29T00:00:00Z", - expected: ["2020-02-29T00:00:00.000Z", "2021-02-28T00:00:00.000Z"], - }, - ] as const)( - "generates correct dates for $level level", - ({ level, start, expected }) => { - const metadata: MatrixIndex = { - start_date: start, - steps: expected.length, - first_week_size: 7, - level: level as MatrixIndex["level"], - }; - - const result = generateDateTime(metadata); - - expect(result).toEqual(expected); - }, - ); - - test("handles edge cases", () => { - const metadata: MatrixIndex = { - start_date: "2023-12-31T23:59:59Z", - steps: 2, - first_week_size: 7, - level: StudyOutputDownloadLevelDTO.HOURLY, - }; - const result = generateDateTime(metadata); - expect(result).toEqual([ - "2023-12-31T23:59:59.000Z", - "2024-01-01T00:59:59.000Z", - ]); - }); }); describe("generateTimeSeriesColumns", () => {