From 9dd3effb423ee4c5666121cc3bf0ad55013f881a Mon Sep 17 00:00:00 2001 From: SupaJoon Date: Thu, 30 May 2024 13:56:27 -0400 Subject: [PATCH] DEVPROD-5290, DEVPROD-5299: Represent SkippedLines with a range instead of a list (#134) --- .../integration/ansiLogs/ansi_filtering.ts | 8 +- .../integration/ansiLogs/ansi_logView.ts | 12 +-- .../integration/ansiLogs/ansi_searching.ts | 4 +- .../cypress/integration/project_filters.ts | 2 +- .../resmokeLogs/resmoke_evg_test_logView.ts | 12 +-- .../resmokeLogs/resmoke_filtering.ts | 8 +- .../resmokeLogs/resmoke_logView.ts | 12 +-- .../resmokeLogs/resmoke_searching.ts | 4 +- .../BookmarksBar/BookmarksBar.test.tsx | 6 +- .../src/components/BookmarksBar/index.tsx | 3 +- .../LogRow/BaseRow/SharingMenu/utils.test.ts | 9 ++- .../LogRow/BaseRow/SharingMenu/utils.ts | 2 +- .../components/LogRow/RowRenderer/index.tsx | 10 +-- .../SkippedLinesRow.stories.tsx} | 79 +++++++++--------- .../SkippedLinesRow.test.tsx} | 34 ++++---- ...kippedLinesRow_CollapsedAnsiRow.storyshot} | 0 ...pedLinesRow_CollapsedResmokeRow.storyshot} | 0 ...ppedLinesRow_CollapsedRowSingle.storyshot} | 8 +- .../SkippedLinesRow_SkippedAnsiRow.storyshot | 24 ++++++ ...edLinesRow_SkippedLinesRowSingle.storyshot | 81 +++++++++++++++++++ ...kippedLinesRow_SkippedResmokeRow.storyshot | 24 ++++++ .../index.tsx | 43 +++++----- .../context/LogContext/LogContext.test.tsx | 26 ++++-- apps/parsley/src/types/logs.ts | 17 +++- apps/parsley/src/utils/collapsedRow/index.ts | 12 --- .../src/utils/filterLogs/filterLogs.test.ts | 35 ++++++-- apps/parsley/src/utils/filterLogs/index.ts | 11 +-- .../utils/findLineIndex/findLineIndex.test.ts | 17 +++- apps/parsley/src/utils/findLineIndex/index.ts | 6 +- apps/parsley/src/utils/logRow/index.ts | 13 +++ apps/parsley/src/utils/logRowTypes/index.ts | 24 ++++++ apps/parsley/src/utils/searchLogs/index.ts | 2 +- .../src/utils/searchLogs/searchLogs.test.ts | 15 +++- 33 files changed, 400 insertions(+), 163 deletions(-) rename apps/parsley/src/components/LogRow/{CollapsedRow/CollapsedRow.stories.tsx => SkippedLinesRow/SkippedLinesRow.stories.tsx} (85%) rename apps/parsley/src/components/LogRow/{CollapsedRow/CollapsedRow.test.tsx => SkippedLinesRow/SkippedLinesRow.test.tsx} (90%) rename apps/parsley/src/components/LogRow/{CollapsedRow/__snapshots__/CollapsedRow_CollapsedAnsiRow.storyshot => SkippedLinesRow/__snapshots__/SkippedLinesRow_CollapsedAnsiRow.storyshot} (100%) rename apps/parsley/src/components/LogRow/{CollapsedRow/__snapshots__/CollapsedRow_CollapsedResmokeRow.storyshot => SkippedLinesRow/__snapshots__/SkippedLinesRow_CollapsedResmokeRow.storyshot} (100%) rename apps/parsley/src/components/LogRow/{CollapsedRow/__snapshots__/CollapsedRow_CollapsedRowSingle.storyshot => SkippedLinesRow/__snapshots__/SkippedLinesRow_CollapsedRowSingle.storyshot} (91%) create mode 100644 apps/parsley/src/components/LogRow/SkippedLinesRow/__snapshots__/SkippedLinesRow_SkippedAnsiRow.storyshot create mode 100644 apps/parsley/src/components/LogRow/SkippedLinesRow/__snapshots__/SkippedLinesRow_SkippedLinesRowSingle.storyshot create mode 100644 apps/parsley/src/components/LogRow/SkippedLinesRow/__snapshots__/SkippedLinesRow_SkippedResmokeRow.storyshot rename apps/parsley/src/components/LogRow/{CollapsedRow => SkippedLinesRow}/index.tsx (63%) delete mode 100644 apps/parsley/src/utils/collapsedRow/index.ts create mode 100644 apps/parsley/src/utils/logRow/index.ts create mode 100644 apps/parsley/src/utils/logRowTypes/index.ts diff --git a/apps/parsley/cypress/integration/ansiLogs/ansi_filtering.ts b/apps/parsley/cypress/integration/ansiLogs/ansi_filtering.ts index 68a9d4ddb..fe09d2b0f 100644 --- a/apps/parsley/cypress/integration/ansiLogs/ansi_filtering.ts +++ b/apps/parsley/cypress/integration/ansiLogs/ansi_filtering.ts @@ -99,7 +99,7 @@ describe("Filtering", () => { "contain", `filters=010${filter1},001${filter2}`, ); - cy.get("[data-cy^='collapsed-row-']").should("not.exist"); + cy.get("[data-cy^='skipped-lines-row-']").should("not.exist"); }); }); @@ -187,7 +187,7 @@ describe("Filtering", () => { "contain", `filters=010${filter1},001${filter2}`, ); - cy.get("[data-cy^='collapsed-row-']").should("not.exist"); + cy.get("[data-cy^='skipped-lines-row-']").should("not.exist"); }); }); }); @@ -199,7 +199,7 @@ describe("Filtering", () => { beforeEach(() => { cy.resetDrawerState(); cy.visit(`${logLink}?filters=100${filter}`); - cy.get("[data-cy^='collapsed-row-']").should("exist"); + cy.get("[data-cy^='skipped-lines-row-']").should("exist"); }); it("should be able to edit a filter", () => { @@ -221,7 +221,7 @@ describe("Filtering", () => { cy.get(`[aria-label="Delete filter"]`).click(); }); cy.location("search").should("not.contain", "filters"); - cy.get("[data-cy^='collapsed-row-']").should("not.exist"); + cy.get("[data-cy^='skipped-lines-row-']").should("not.exist"); }); }); }); diff --git a/apps/parsley/cypress/integration/ansiLogs/ansi_logView.ts b/apps/parsley/cypress/integration/ansiLogs/ansi_logView.ts index aa592057c..0663934e9 100644 --- a/apps/parsley/cypress/integration/ansiLogs/ansi_logView.ts +++ b/apps/parsley/cypress/integration/ansiLogs/ansi_logView.ts @@ -166,11 +166,11 @@ describe("expanding collapsed rows", () => { cy.dataCy("log-row-3").should("not.exist"); cy.dataCy("log-row-4").should("not.exist"); - cy.dataCy("collapsed-row-1-4").within(() => { + cy.dataCy("skipped-lines-row-1-4").within(() => { cy.contains("All").click(); }); - cy.dataCy("collapsed-row-1-4").should("not.exist"); + cy.dataCy("skipped-lines-row-1-4").should("not.exist"); cy.dataCy("log-row-1").should("be.visible"); cy.dataCy("log-row-2").should("be.visible"); cy.dataCy("log-row-3").should("be.visible"); @@ -178,7 +178,7 @@ describe("expanding collapsed rows", () => { }); it("should be able to see what rows have been expanded in the drawer", () => { - cy.dataCy("collapsed-row-1-4").within(() => { + cy.dataCy("skipped-lines-row-1-4").within(() => { cy.contains("All").click(); }); cy.toggleDrawer(); @@ -186,16 +186,16 @@ describe("expanding collapsed rows", () => { }); it("should be possible to re-collapse rows through the drawer", () => { - cy.dataCy("collapsed-row-1-4").within(() => { + cy.dataCy("skipped-lines-row-1-4").within(() => { cy.contains("All").click(); }); - cy.dataCy("collapsed-row-1-4").should("not.exist"); + cy.dataCy("skipped-lines-row-1-4").should("not.exist"); cy.toggleDrawer(); cy.dataCy("expanded-row-1-to-4").within(() => { cy.get(`[aria-label="Delete range"]`).click(); }); - cy.dataCy("collapsed-row-1-4").should("exist"); + cy.dataCy("skipped-lines-row-1-4").should("exist"); }); }); diff --git a/apps/parsley/cypress/integration/ansiLogs/ansi_searching.ts b/apps/parsley/cypress/integration/ansiLogs/ansi_searching.ts index d520b9302..4a4f0f53d 100644 --- a/apps/parsley/cypress/integration/ansiLogs/ansi_searching.ts +++ b/apps/parsley/cypress/integration/ansiLogs/ansi_searching.ts @@ -75,8 +75,8 @@ describe("Searching", () => { it("should be able to search on filtered content", () => { cy.addFilter("installation"); - cy.get("[data-cy^='collapsed-row-']").should("exist"); - cy.get("[data-cy^='collapsed-row-']").should("have.length", 3); + cy.get("[data-cy^='skipped-lines-row-']").should("exist"); + cy.get("[data-cy^='skipped-lines-row-']").should("have.length", 3); cy.addSearch("info"); cy.dataCy("search-count").should("be.visible"); diff --git a/apps/parsley/cypress/integration/project_filters.ts b/apps/parsley/cypress/integration/project_filters.ts index 58950c024..5d473b08e 100644 --- a/apps/parsley/cypress/integration/project_filters.ts +++ b/apps/parsley/cypress/integration/project_filters.ts @@ -28,7 +28,7 @@ describe("project filters", () => { "contain", "111%28NETWORK%257CASIO%257CEXECUTOR%257CCONNPOOL%257CREPL_HB%29", ); - cy.get("[data-cy^='collapsed-row-']").should("exist"); + cy.get("[data-cy^='skipped-lines-row-']").should("exist"); }); it("should disable checkbox if filter is already applied", () => { diff --git a/apps/parsley/cypress/integration/resmokeLogs/resmoke_evg_test_logView.ts b/apps/parsley/cypress/integration/resmokeLogs/resmoke_evg_test_logView.ts index ea405b8b2..9f76bcbb3 100644 --- a/apps/parsley/cypress/integration/resmokeLogs/resmoke_evg_test_logView.ts +++ b/apps/parsley/cypress/integration/resmokeLogs/resmoke_evg_test_logView.ts @@ -213,18 +213,18 @@ describe("expanding collapsed rows", () => { cy.dataCy("log-row-2").should("not.exist"); cy.dataCy("log-row-3").should("not.exist"); - cy.dataCy("collapsed-row-1-3").within(() => { + cy.dataCy("skipped-lines-row-1-3").within(() => { cy.contains("All").click(); }); - cy.dataCy("collapsed-row-1-3").should("not.exist"); + cy.dataCy("skipped-lines-row-1-3").should("not.exist"); cy.dataCy("log-row-1").should("be.visible"); cy.dataCy("log-row-2").should("be.visible"); cy.dataCy("log-row-3").should("be.visible"); }); it("should be able to see what rows have been expanded in the drawer", () => { - cy.dataCy("collapsed-row-1-3").within(() => { + cy.dataCy("skipped-lines-row-1-3").within(() => { cy.contains("All").click(); }); cy.toggleDrawer(); @@ -232,16 +232,16 @@ describe("expanding collapsed rows", () => { }); it("should be possible to re-collapse rows through the drawer", () => { - cy.dataCy("collapsed-row-1-3").within(() => { + cy.dataCy("skipped-lines-row-1-3").within(() => { cy.contains("All").click(); }); - cy.dataCy("collapsed-row-1-3").should("not.exist"); + cy.dataCy("skipped-lines-row-1-3").should("not.exist"); cy.toggleDrawer(); cy.dataCy("expanded-row-1-to-3").within(() => { cy.get(`[aria-label="Delete range"]`).click(); }); - cy.dataCy("collapsed-row-1-3").should("exist"); + cy.dataCy("skipped-lines-row-1-3").should("exist"); }); }); diff --git a/apps/parsley/cypress/integration/resmokeLogs/resmoke_filtering.ts b/apps/parsley/cypress/integration/resmokeLogs/resmoke_filtering.ts index 66ff8d79d..eac770c04 100644 --- a/apps/parsley/cypress/integration/resmokeLogs/resmoke_filtering.ts +++ b/apps/parsley/cypress/integration/resmokeLogs/resmoke_filtering.ts @@ -99,7 +99,7 @@ describe("Filtering", () => { "contain", `filters=010${filter1},001${filter2}`, ); - cy.get("[data-cy^='collapsed-row-']").should("not.exist"); + cy.get("[data-cy^='skipped-lines-row-']").should("not.exist"); }); }); @@ -187,7 +187,7 @@ describe("Filtering", () => { "contain", `filters=010${filter1},001${filter2}`, ); - cy.get("[data-cy^='collapsed-row-']").should("not.exist"); + cy.get("[data-cy^='skipped-lines-row-']").should("not.exist"); }); }); }); @@ -199,7 +199,7 @@ describe("Filtering", () => { beforeEach(() => { cy.resetDrawerState(); cy.visit(`${logLink}?filters=100${filter}`); - cy.get("[data-cy^='collapsed-row-']").should("exist"); + cy.get("[data-cy^='skipped-lines-row-']").should("exist"); }); it("should be able to edit a filter", () => { @@ -221,7 +221,7 @@ describe("Filtering", () => { cy.get(`[aria-label="Delete filter"]`).click(); }); cy.location("search").should("not.contain", "filters"); - cy.get("[data-cy^='collapsed-row-']").should("not.exist"); + cy.get("[data-cy^='skipped-lines-row-']").should("not.exist"); }); }); }); diff --git a/apps/parsley/cypress/integration/resmokeLogs/resmoke_logView.ts b/apps/parsley/cypress/integration/resmokeLogs/resmoke_logView.ts index 39d5b2d63..b7840194d 100644 --- a/apps/parsley/cypress/integration/resmokeLogs/resmoke_logView.ts +++ b/apps/parsley/cypress/integration/resmokeLogs/resmoke_logView.ts @@ -213,18 +213,18 @@ describe("expanding collapsed rows", () => { cy.dataCy("log-row-2").should("not.exist"); cy.dataCy("log-row-3").should("not.exist"); - cy.dataCy("collapsed-row-1-3").within(() => { + cy.dataCy("skipped-lines-row-1-3").within(() => { cy.contains("All").click(); }); - cy.dataCy("collapsed-row-1-3").should("not.exist"); + cy.dataCy("skipped-lines-row-1-3").should("not.exist"); cy.dataCy("log-row-1").should("be.visible"); cy.dataCy("log-row-2").should("be.visible"); cy.dataCy("log-row-3").should("be.visible"); }); it("should be able to see what rows have been expanded in the drawer", () => { - cy.dataCy("collapsed-row-1-3").within(() => { + cy.dataCy("skipped-lines-row-1-3").within(() => { cy.contains("All").click(); }); cy.toggleDrawer(); @@ -232,16 +232,16 @@ describe("expanding collapsed rows", () => { }); it("should be possible to re-collapse rows through the drawer", () => { - cy.dataCy("collapsed-row-1-3").within(() => { + cy.dataCy("skipped-lines-row-1-3").within(() => { cy.contains("All").click(); }); - cy.dataCy("collapsed-row-1-3").should("not.exist"); + cy.dataCy("skipped-lines-row-1-3").should("not.exist"); cy.toggleDrawer(); cy.dataCy("expanded-row-1-to-3").within(() => { cy.get(`[aria-label="Delete range"]`).click(); }); - cy.dataCy("collapsed-row-1-3").should("exist"); + cy.dataCy("skipped-lines-row-1-3").should("exist"); }); }); diff --git a/apps/parsley/cypress/integration/resmokeLogs/resmoke_searching.ts b/apps/parsley/cypress/integration/resmokeLogs/resmoke_searching.ts index 0f82c583c..993f1788a 100644 --- a/apps/parsley/cypress/integration/resmokeLogs/resmoke_searching.ts +++ b/apps/parsley/cypress/integration/resmokeLogs/resmoke_searching.ts @@ -74,8 +74,8 @@ describe("Searching", () => { it("should be able to search on filtered content", () => { cy.addFilter("conn49"); - cy.get("[data-cy^='collapsed-row-']").should("exist"); - cy.get("[data-cy^='collapsed-row-']").should("have.length", 7); + cy.get("[data-cy^='skipped-lines-row-']").should("exist"); + cy.get("[data-cy^='skipped-lines-row-']").should("have.length", 7); cy.addSearch("NETWORK"); cy.dataCy("search-count").should("be.visible"); diff --git a/apps/parsley/src/components/BookmarksBar/BookmarksBar.test.tsx b/apps/parsley/src/components/BookmarksBar/BookmarksBar.test.tsx index 3c14707ae..3a43059ed 100644 --- a/apps/parsley/src/components/BookmarksBar/BookmarksBar.test.tsx +++ b/apps/parsley/src/components/BookmarksBar/BookmarksBar.test.tsx @@ -107,7 +107,11 @@ describe("bookmarks bar", () => { renderWithRouterMatch( , { diff --git a/apps/parsley/src/components/BookmarksBar/index.tsx b/apps/parsley/src/components/BookmarksBar/index.tsx index 08f35ec4c..f7566477d 100644 --- a/apps/parsley/src/components/BookmarksBar/index.tsx +++ b/apps/parsley/src/components/BookmarksBar/index.tsx @@ -9,6 +9,7 @@ import Popconfirm from "components/Popconfirm"; import { QueryParams } from "constants/queryParams"; import { size, zIndex } from "constants/tokens"; import { useQueryParam } from "hooks/useQueryParam"; +import { ProcessedLogLines } from "types/logs"; import { findLineIndex } from "utils/findLineIndex"; const { gray, green, red } = palette; @@ -16,7 +17,7 @@ const { gray, green, red } = palette; interface BookmarksBarProps { failingLine?: number; lineCount: number; - processedLogLines: (number | number[])[]; + processedLogLines: ProcessedLogLines; scrollToLine: (scrollIndex: number) => void; } diff --git a/apps/parsley/src/components/LogRow/BaseRow/SharingMenu/utils.test.ts b/apps/parsley/src/components/LogRow/BaseRow/SharingMenu/utils.test.ts index 21c0eef95..e375d97d0 100644 --- a/apps/parsley/src/components/LogRow/BaseRow/SharingMenu/utils.test.ts +++ b/apps/parsley/src/components/LogRow/BaseRow/SharingMenu/utils.test.ts @@ -1,3 +1,4 @@ +import { ProcessedLogLines } from "types/logs"; import { getLinesInProcessedLogLinesFromSelectedLines } from "./utils"; describe("getLinesInProcessedLogLinesFromSelectedLines", () => { @@ -20,7 +21,13 @@ describe("getLinesInProcessedLogLinesFromSelectedLines", () => { expect(result).toStrictEqual([2, 3]); }); it("should not return collapsed lines", () => { - const processedLogLines = [1, 2, [3], 4, 5]; + const processedLogLines: ProcessedLogLines = [ + 1, + 2, + { range: { end: 4, start: 3 }, rowType: "SkippedLines" }, + 4, + 5, + ]; const selectedLines = { endingLine: 4, startingLine: 2 }; const result = getLinesInProcessedLogLinesFromSelectedLines( processedLogLines, diff --git a/apps/parsley/src/components/LogRow/BaseRow/SharingMenu/utils.ts b/apps/parsley/src/components/LogRow/BaseRow/SharingMenu/utils.ts index 84d9d8f58..3cb95b88a 100644 --- a/apps/parsley/src/components/LogRow/BaseRow/SharingMenu/utils.ts +++ b/apps/parsley/src/components/LogRow/BaseRow/SharingMenu/utils.ts @@ -1,6 +1,6 @@ import { ProcessedLogLines, SelectedLineRange } from "types/logs"; -import { isCollapsedRow } from "utils/collapsedRow"; import { findLineIndex } from "utils/findLineIndex"; +import { isCollapsedRow } from "utils/logRowTypes"; const getLinesInProcessedLogLinesFromSelectedLines = ( processedLogLines: ProcessedLogLines, diff --git a/apps/parsley/src/components/LogRow/RowRenderer/index.tsx b/apps/parsley/src/components/LogRow/RowRenderer/index.tsx index 55d2244ac..46cc1d5af 100644 --- a/apps/parsley/src/components/LogRow/RowRenderer/index.tsx +++ b/apps/parsley/src/components/LogRow/RowRenderer/index.tsx @@ -2,10 +2,10 @@ import { LogRenderingTypes } from "constants/enums"; import { useLogContext } from "context/LogContext"; import { useHighlightParam } from "hooks/useHighlightParam"; import { ProcessedLogLines } from "types/logs"; -import { isCollapsedRow } from "utils/collapsedRow"; +import { isSkippedLinesRow } from "utils/logRowTypes"; import AnsiRow from "../AnsiRow"; -import CollapsedRow from "../CollapsedRow"; import ResmokeRow from "../ResmokeRow"; +import SkippedLinesRow from "../SkippedLinesRow"; type RowRendererFunction = (props: { processedLogLines: ProcessedLogLines; @@ -55,12 +55,12 @@ const ParsleyRow: RowRendererFunction = ({ processedLogLines }) => { const result = (index: number) => { const processedLogLine = processedLogLines[index]; - if (isCollapsedRow(processedLogLine)) { + if (isSkippedLinesRow(processedLogLine)) { return ( - ); } diff --git a/apps/parsley/src/components/LogRow/CollapsedRow/CollapsedRow.stories.tsx b/apps/parsley/src/components/LogRow/SkippedLinesRow/SkippedLinesRow.stories.tsx similarity index 85% rename from apps/parsley/src/components/LogRow/CollapsedRow/CollapsedRow.stories.tsx rename to apps/parsley/src/components/LogRow/SkippedLinesRow/SkippedLinesRow.stories.tsx index a3902ae5e..49ede0058 100644 --- a/apps/parsley/src/components/LogRow/CollapsedRow/CollapsedRow.stories.tsx +++ b/apps/parsley/src/components/LogRow/SkippedLinesRow/SkippedLinesRow.stories.tsx @@ -6,53 +6,49 @@ import { LogRenderingTypes, LogTypes } from "constants/enums"; import { useLogContext } from "context/LogContext"; import WithToastContext from "test_utils/toast-decorator"; import { CustomMeta, CustomStoryObj } from "test_utils/types"; -import { ExpandedLine, ExpandedLines } from "types/logs"; -import CollapsedRow from "."; +import { ExpandedLines, ProcessedLogLines } from "types/logs"; +import SkippedLinesRow from "."; export default { - component: CollapsedRow, + component: SkippedLinesRow, decorators: [WithToastContext], -} satisfies CustomMeta; - -const CollapsedRowStory = (args: React.ComponentProps) => { - const [rows, setRows] = useState(args.collapsedLines); - const expandLines = (expandedLines: ExpandedLines) => { - const withinRange = (index: number, line: ExpandedLine) => - index >= line[0] && index <= line[1]; - - const intervals = rows.filter( - (line) => - !withinRange(line, expandedLines[0]) && - !withinRange(line, expandedLines[1]), - ); - setRows(intervals); +} satisfies CustomMeta; + +const SkippedLinesRowStory = ( + args: React.ComponentProps, +) => { + const [range, setRange] = useState(args.range); + const expandLines = (a: ExpandedLines) => { + const nextLineStart = a[0][1] + 1; + const nextLineEnd = a?.[1]?.[0] ?? nextLineStart; + setRange({ end: nextLineEnd, start: nextLineStart }); }; return ( - ); }; -export const CollapsedRowSingle: CustomStoryObj = { +export const SkippedLinesRowSingle: CustomStoryObj = { argTypes: { expandLines: { action: "expandLines" }, }, args: { - // Initialize an array with 100 collapsed lines. - collapsedLines: Array.from({ length: 100 }, (_, i) => i), + // Initialize an array with 100 skipped lines. + range: { end: 101, start: 1 }, }, - render: (args) => , + render: (args) => , }; -// CollapsedRow with AnsiRows. -const CollapsedAnsiRowStory = ( - args: React.ComponentProps & { +// SkippedLinesRow with AnsiRows. +const SkippedAnsiRowStory = ( + args: React.ComponentProps & { wrap: boolean; }, ) => { @@ -74,27 +70,27 @@ const CollapsedAnsiRowStory = ( ); }; -export const CollapsedAnsiRow: CustomStoryObj< - React.ComponentProps & { +export const SkippedAnsiRow: CustomStoryObj< + React.ComponentProps & { wrap: boolean; } > = { args: { wrap: false, }, - render: (args) => , + render: (args) => , }; -// CollapsedRow withs ResmokeRows. -const CollapsedResmokeRowStory = ( - args: React.ComponentProps & { +// SkippedLinesRow withs ResmokeRows. +const SkippedResmokeRowStory = ( + args: React.ComponentProps & { wrap: boolean; }, ) => { @@ -116,22 +112,22 @@ const CollapsedResmokeRowStory = ( ); }; -export const CollapsedResmokeRow: CustomStoryObj< - React.ComponentProps & { +export const SkippedResmokeRow: CustomStoryObj< + React.ComponentProps & { wrap: boolean; } > = { args: { wrap: false, }, - render: (args) => , + render: (args) => , }; const ansiLogLines = [ @@ -157,7 +153,14 @@ const resmokeLogLines = [ "[j0:sec1] Starting mongod on port 20002...", ]; -const collapsedLogLines = [0, 1, 2, [3, 4, 5], 6, 7]; +const skippedLogLines: ProcessedLogLines = [ + 0, + 1, + 2, + { range: { end: 6, start: 3 }, rowType: "SkippedLines" }, + 6, + 7, +]; const Container = styled.div` height: 400px; diff --git a/apps/parsley/src/components/LogRow/CollapsedRow/CollapsedRow.test.tsx b/apps/parsley/src/components/LogRow/SkippedLinesRow/SkippedLinesRow.test.tsx similarity index 90% rename from apps/parsley/src/components/LogRow/CollapsedRow/CollapsedRow.test.tsx rename to apps/parsley/src/components/LogRow/SkippedLinesRow/SkippedLinesRow.test.tsx index 8f6bd6f31..f9dcf9546 100644 --- a/apps/parsley/src/components/LogRow/CollapsedRow/CollapsedRow.test.tsx +++ b/apps/parsley/src/components/LogRow/SkippedLinesRow/SkippedLinesRow.test.tsx @@ -1,6 +1,6 @@ import { LogContextProvider } from "context/LogContext"; import { renderWithRouterMatch, screen, userEvent } from "test_utils"; -import CollapsedRow from "."; +import SkippedLinesRow from "."; const wrapper = (logs: string[]) => { const provider = ({ children }: { children: React.ReactNode }) => ( @@ -9,13 +9,13 @@ const wrapper = (logs: string[]) => { return provider; }; -describe("collapsedRow", () => { - it("renders a collapsed log line", () => { +describe("skippedLinesRow", () => { + it("renders a skipped log line", () => { renderWithRouterMatch( - , { wrapper: wrapper(logLines), @@ -28,11 +28,11 @@ describe("collapsedRow", () => { const user = userEvent.setup(); const expandLines = vi.fn(); renderWithRouterMatch( - , { wrapper: wrapper(logLines), @@ -54,11 +54,11 @@ describe("collapsedRow", () => { const user = userEvent.setup(); const expandLines = vi.fn(); renderWithRouterMatch( - , { wrapper: wrapper(logLines), @@ -72,12 +72,12 @@ describe("collapsedRow", () => { expect(expandLines).toHaveBeenCalledWith([[0, 10]]); }); - it("should not disable `Expand 5 Above and Below` button if there are less than 10 log lines in the collapsed row", async () => { + it("should not disable `Expand 5 Above and Below` button if there are less than 10 log lines in the skipped row", async () => { renderWithRouterMatch( - , { wrapper: wrapper(logLines), @@ -104,6 +104,6 @@ const logLines = [ "filler", ]; -const collapsedProps = { +const skippedLinesProps = { expandLines: vi.fn(), }; diff --git a/apps/parsley/src/components/LogRow/CollapsedRow/__snapshots__/CollapsedRow_CollapsedAnsiRow.storyshot b/apps/parsley/src/components/LogRow/SkippedLinesRow/__snapshots__/SkippedLinesRow_CollapsedAnsiRow.storyshot similarity index 100% rename from apps/parsley/src/components/LogRow/CollapsedRow/__snapshots__/CollapsedRow_CollapsedAnsiRow.storyshot rename to apps/parsley/src/components/LogRow/SkippedLinesRow/__snapshots__/SkippedLinesRow_CollapsedAnsiRow.storyshot diff --git a/apps/parsley/src/components/LogRow/CollapsedRow/__snapshots__/CollapsedRow_CollapsedResmokeRow.storyshot b/apps/parsley/src/components/LogRow/SkippedLinesRow/__snapshots__/SkippedLinesRow_CollapsedResmokeRow.storyshot similarity index 100% rename from apps/parsley/src/components/LogRow/CollapsedRow/__snapshots__/CollapsedRow_CollapsedResmokeRow.storyshot rename to apps/parsley/src/components/LogRow/SkippedLinesRow/__snapshots__/SkippedLinesRow_CollapsedResmokeRow.storyshot diff --git a/apps/parsley/src/components/LogRow/CollapsedRow/__snapshots__/CollapsedRow_CollapsedRowSingle.storyshot b/apps/parsley/src/components/LogRow/SkippedLinesRow/__snapshots__/SkippedLinesRow_CollapsedRowSingle.storyshot similarity index 91% rename from apps/parsley/src/components/LogRow/CollapsedRow/__snapshots__/CollapsedRow_CollapsedRowSingle.storyshot rename to apps/parsley/src/components/LogRow/SkippedLinesRow/__snapshots__/SkippedLinesRow_CollapsedRowSingle.storyshot index 0119a622e..28cbdb4bf 100644 --- a/apps/parsley/src/components/LogRow/CollapsedRow/__snapshots__/CollapsedRow_CollapsedRowSingle.storyshot +++ b/apps/parsley/src/components/LogRow/SkippedLinesRow/__snapshots__/SkippedLinesRow_CollapsedRowSingle.storyshot @@ -3,16 +3,16 @@ class="css-1mysoqc" >

100 Lines Skipped

+ +
+
+ + \ No newline at end of file diff --git a/apps/parsley/src/components/LogRow/SkippedLinesRow/__snapshots__/SkippedLinesRow_SkippedResmokeRow.storyshot b/apps/parsley/src/components/LogRow/SkippedLinesRow/__snapshots__/SkippedLinesRow_SkippedResmokeRow.storyshot new file mode 100644 index 000000000..e9021e381 --- /dev/null +++ b/apps/parsley/src/components/LogRow/SkippedLinesRow/__snapshots__/SkippedLinesRow_SkippedResmokeRow.storyshot @@ -0,0 +1,24 @@ +
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/apps/parsley/src/components/LogRow/CollapsedRow/index.tsx b/apps/parsley/src/components/LogRow/SkippedLinesRow/index.tsx similarity index 63% rename from apps/parsley/src/components/LogRow/CollapsedRow/index.tsx rename to apps/parsley/src/components/LogRow/SkippedLinesRow/index.tsx index 13c3992a3..ffbfd0645 100644 --- a/apps/parsley/src/components/LogRow/CollapsedRow/index.tsx +++ b/apps/parsley/src/components/LogRow/SkippedLinesRow/index.tsx @@ -5,60 +5,55 @@ import { Body, BodyProps } from "@leafygreen-ui/typography"; import { useLogWindowAnalytics } from "analytics"; import Icon from "components/Icon"; import { size } from "constants/tokens"; -import { ExpandedLines } from "types/logs"; +import { ExpandedLines, Range } from "types/logs"; import { RootRowProps } from "../types"; const SKIP_NUMBER = 5; -interface CollapsedRowProps extends RootRowProps { - collapsedLines: number[]; +interface Props extends RootRowProps { expandLines: (expandedLines: ExpandedLines) => void; + range: Range; } -const CollapsedRow: React.FC = ({ - collapsedLines, - expandLines, -}) => { +const SkippedLinesRow: React.FC = ({ expandLines, range }) => { const { sendEvent } = useLogWindowAnalytics(); const [, startTransition] = useTransition(); - - const numCollapsed = collapsedLines.length; - const start = collapsedLines[0]; - const end = collapsedLines[collapsedLines.length - 1]; - - const canExpandFive = SKIP_NUMBER * 2 < numCollapsed; + const { end, start } = range; + const numSkipped = end - start; + const lineEndInclusive = end - 1; + const canExpandFive = SKIP_NUMBER * 2 < numSkipped; const lineText = - numCollapsed !== 1 ? `${numCollapsed} Lines Skipped` : "1 Line Skipped"; + numSkipped !== 1 ? `${numSkipped} Lines Skipped` : "1 Line Skipped"; const expandFive = () => { if (canExpandFive) { startTransition(() => expandLines([ [start, start + (SKIP_NUMBER - 1)], - [end - (SKIP_NUMBER - 1), end], + [lineEndInclusive - (SKIP_NUMBER - 1), lineEndInclusive], ]), ); } else { - startTransition(() => expandLines([[start, end]])); + startTransition(() => expandLines([[start, lineEndInclusive]])); } sendEvent({ - lineCount: canExpandFive ? SKIP_NUMBER * 2 : numCollapsed, + lineCount: canExpandFive ? SKIP_NUMBER * 2 : numSkipped, name: "Expanded Lines", option: "Five", }); }; const expandAll = () => { - startTransition(() => expandLines([[start, end]])); + startTransition(() => expandLines([[start, lineEndInclusive]])); sendEvent({ - lineCount: numCollapsed, + lineCount: numSkipped, name: "Expanded Lines", option: "All", }); }; return ( - + {lineText} - + ); }; -CollapsedRow.displayName = "CollapsedRow"; +SkippedLinesRow.displayName = "SkippedLinesRow"; -const CollapsedLineWrapper = styled.div` +const LineWrapper = styled.div` display: flex; align-items: center; background-color: #f4f5f5; // Custom gray background color. @@ -99,4 +94,4 @@ const ButtonContainer = styled.div` gap: ${size.xs}; `; -export default CollapsedRow; +export default SkippedLinesRow; diff --git a/apps/parsley/src/context/LogContext/LogContext.test.tsx b/apps/parsley/src/context/LogContext/LogContext.test.tsx index d04898343..5be13227b 100644 --- a/apps/parsley/src/context/LogContext/LogContext.test.tsx +++ b/apps/parsley/src/context/LogContext/LogContext.test.tsx @@ -3,7 +3,7 @@ import { MemoryRouter, Route, Routes } from "react-router-dom"; import { MockInstance } from "vitest"; import { LogRenderingTypes } from "constants/enums"; import { act, renderHook, waitFor } from "test_utils"; -import { isCollapsedRow } from "utils/collapsedRow"; +import { isCollapsedRow } from "utils/logRowTypes"; import { LogContextProvider, useLogContext } from "."; import { DIRECTION } from "./types"; @@ -207,7 +207,11 @@ describe("useLogContext", () => { expect(result.current.lineCount).toBe(3); expect(result.current.processedLogLines).toHaveLength(3); - expect(result.current.processedLogLines).toStrictEqual([[0], 1, [2]]); + expect(result.current.processedLogLines).toStrictEqual([ + { range: { end: 1, start: 0 }, rowType: "SkippedLines" }, + 1, + { range: { end: 3, start: 2 }, rowType: "SkippedLines" }, + ]); }); it("non matching filters should collapse all of the logs", () => { const wrapper: React.FC<{ children: React.ReactNode }> = ({ @@ -223,7 +227,9 @@ describe("useLogContext", () => { expect(result.current.lineCount).toBe(3); expect(result.current.processedLogLines).toHaveLength(1); - expect(result.current.processedLogLines).toStrictEqual([[0, 1, 2]]); + expect(result.current.processedLogLines).toStrictEqual([ + { range: { end: 3, start: 0 }, rowType: "SkippedLines" }, + ]); }); describe("applying multiple filters should filter the list of logs and collapse unmatching ones", () => { it("should `AND` filters by default", () => { @@ -241,7 +247,9 @@ describe("useLogContext", () => { const { result } = renderHook(() => useLogContext(), { wrapper }); expect(result.current.lineCount).toBe(3); expect(result.current.processedLogLines).toHaveLength(1); - expect(result.current.processedLogLines).toStrictEqual([[0, 1, 2]]); + expect(result.current.processedLogLines).toStrictEqual([ + { range: { end: 3, start: 0 }, rowType: "SkippedLines" }, + ]); }); it("should `AND` filters if the query param specifies it", () => { const wrapper: React.FC<{ children: React.ReactNode }> = ({ @@ -258,7 +266,9 @@ describe("useLogContext", () => { const { result } = renderHook(() => useLogContext(), { wrapper }); expect(result.current.lineCount).toBe(3); expect(result.current.processedLogLines).toHaveLength(1); - expect(result.current.processedLogLines).toStrictEqual([[0, 1, 2]]); + expect(result.current.processedLogLines).toStrictEqual([ + { range: { end: 3, start: 0 }, rowType: "SkippedLines" }, + ]); }); it("should `OR` filters if the query param specifies it", () => { const wrapper: React.FC<{ children: React.ReactNode }> = ({ @@ -275,7 +285,11 @@ describe("useLogContext", () => { const { result } = renderHook(() => useLogContext(), { wrapper }); expect(result.current.lineCount).toBe(3); expect(result.current.processedLogLines).toHaveLength(3); - expect(result.current.processedLogLines).toStrictEqual([0, [1], 2]); + expect(result.current.processedLogLines).toStrictEqual([ + 0, + { range: { end: 2, start: 1 }, rowType: "SkippedLines" }, + 2, + ]); }); }); }); diff --git a/apps/parsley/src/types/logs.ts b/apps/parsley/src/types/logs.ts index d08a5f863..3dfcbb9ef 100644 --- a/apps/parsley/src/types/logs.ts +++ b/apps/parsley/src/types/logs.ts @@ -3,7 +3,20 @@ import { CaseSensitivity, MatchType } from "constants/enums"; type ExpandedLine = [number, number]; type ExpandedLines = ExpandedLine[]; -type ProcessedLogLine = number | number[]; +interface Range { + /** The starting line inclusive of the range */ + start: number; + /** The ending line exclusive of the range */ + end: number; +} + +interface SkippedLinesRow { + rowType: "SkippedLines"; + range: Range; +} + +type ProcessedLogLine = number | SkippedLinesRow; + type ProcessedLogLines = ProcessedLogLine[]; type Filter = { @@ -27,4 +40,6 @@ export type { ProcessedLogLine, ProcessedLogLines, SelectedLineRange, + SkippedLinesRow, + Range, }; diff --git a/apps/parsley/src/utils/collapsedRow/index.ts b/apps/parsley/src/utils/collapsedRow/index.ts deleted file mode 100644 index 605d1cbf4..000000000 --- a/apps/parsley/src/utils/collapsedRow/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { ProcessedLogLine } from "types/logs"; - -/** - * `isCollapsedRow` determines if a row is a collapsed row. Although it is a simple function, its purpose - * is to make the code more readable. - * @param logLine - the processed log line to check - * @returns true if the row is a collapsed row - */ -const isCollapsedRow = (logLine: ProcessedLogLine): logLine is number[] => - Array.isArray(logLine); - -export { isCollapsedRow }; diff --git a/apps/parsley/src/utils/filterLogs/filterLogs.test.ts b/apps/parsley/src/utils/filterLogs/filterLogs.test.ts index 2b1f63c47..209b42e15 100644 --- a/apps/parsley/src/utils/filterLogs/filterLogs.test.ts +++ b/apps/parsley/src/utils/filterLogs/filterLogs.test.ts @@ -26,7 +26,7 @@ describe("filterLogs", () => { ).toStrictEqual([0, 1, 2, 3, 4, 5, 6, 7]); }); - it("should hide collapsed rows if expandableRows is turned off", () => { + it("should hide skipped rows if expandableRows is turned off", () => { expect( filterLogs({ bookmarks: [], @@ -51,7 +51,7 @@ describe("filterLogs", () => { matchingLines: new Set([]), shareLine: undefined, }), - ).toStrictEqual([[0, 1, 2, 3, 4, 5, 6, 7]]); + ).toStrictEqual([{ range: { end: 8, start: 0 }, rowType: "SkippedLines" }]); }); describe("with matching lines", () => { @@ -66,7 +66,12 @@ describe("filterLogs", () => { matchingLines: new Set([1]), shareLine: undefined, }), - ).toStrictEqual([[0], 1, [2, 3, 4, 5, 6], 7]); + ).toStrictEqual([ + { range: { end: 1, start: 0 }, rowType: "SkippedLines" }, + 1, + { range: { end: 7, start: 2 }, rowType: "SkippedLines" }, + 7, + ]); }); it("should not collapse the share line", () => { @@ -80,7 +85,12 @@ describe("filterLogs", () => { matchingLines: new Set([1]), shareLine: 7, }), - ).toStrictEqual([[0], 1, [2, 3, 4, 5, 6], 7]); + ).toStrictEqual([ + { range: { end: 1, start: 0 }, rowType: "SkippedLines" }, + 1, + { range: { end: 7, start: 2 }, rowType: "SkippedLines" }, + 7, + ]); }); it("should not collapse the failing line", () => { @@ -94,7 +104,12 @@ describe("filterLogs", () => { matchingLines: new Set([1]), shareLine: undefined, }), - ).toStrictEqual([[0], 1, [2, 3, 4, 5, 6], 7]); + ).toStrictEqual([ + { range: { end: 1, start: 0 }, rowType: "SkippedLines" }, + 1, + { range: { end: 7, start: 2 }, rowType: "SkippedLines" }, + 7, + ]); }); it("should not collapse expanded lines", () => { @@ -108,7 +123,15 @@ describe("filterLogs", () => { matchingLines: new Set([1]), shareLine: undefined, }), - ).toStrictEqual([[0], 1, [2, 3], 4, 5, 6, [7]]); + ).toStrictEqual([ + { range: { end: 1, start: 0 }, rowType: "SkippedLines" }, + 1, + { range: { end: 4, start: 2 }, rowType: "SkippedLines" }, + 4, + 5, + 6, + { range: { end: 8, start: 7 }, rowType: "SkippedLines" }, + ]); }); }); }); diff --git a/apps/parsley/src/utils/filterLogs/index.ts b/apps/parsley/src/utils/filterLogs/index.ts index cb30ffacf..e022ef419 100644 --- a/apps/parsley/src/utils/filterLogs/index.ts +++ b/apps/parsley/src/utils/filterLogs/index.ts @@ -1,6 +1,7 @@ import { ExpandedLines, ProcessedLogLines } from "types/logs"; -import { isCollapsedRow } from "utils/collapsedRow"; import { isExpanded } from "utils/expandedLines"; +import { newSkippedLinesRow } from "utils/logRow"; +import { isSkippedLinesRow } from "utils/logRowTypes"; type FilterLogsParams = { logLines: string[]; @@ -25,7 +26,7 @@ type FilterLogsParams = { * @returns an array of numbers that indicates which log lines should be displayed, and which log lines * should be collapsed */ -const filterLogs = (options: FilterLogsParams): (number | number[])[] => { +const filterLogs = (options: FilterLogsParams): ProcessedLogLines => { const { bookmarks, expandableRows, @@ -64,10 +65,10 @@ const filterLogs = (options: FilterLogsParams): (number | number[])[] => { if (expandableRows) { // If the line doesn't match the filters, collapse it. const previousItem = arr[arr.length - 1]; - if (isCollapsedRow(previousItem)) { - previousItem.push(idx); + if (isSkippedLinesRow(previousItem)) { + previousItem.range.end = idx + 1; } else { - arr.push([idx]); + arr.push(newSkippedLinesRow(idx, idx + 1)); } } return arr; diff --git a/apps/parsley/src/utils/findLineIndex/findLineIndex.test.ts b/apps/parsley/src/utils/findLineIndex/findLineIndex.test.ts index 8bd778741..c3793344d 100644 --- a/apps/parsley/src/utils/findLineIndex/findLineIndex.test.ts +++ b/apps/parsley/src/utils/findLineIndex/findLineIndex.test.ts @@ -1,20 +1,29 @@ +import { ProcessedLogLines } from "types/logs"; import { findLineIndex } from "."; -const processedLines = [0, [1, 2], 3, [4, 5], 6, [7, 8, 9], 10]; +const processedLines: ProcessedLogLines = [ + 0, + { range: { end: 3, start: 1 }, rowType: "SkippedLines" }, + 3, + { range: { end: 6, start: 4 }, rowType: "SkippedLines" }, + 6, + { range: { end: 10, start: 7 }, rowType: "SkippedLines" }, + 10, +]; describe("findLineIndex", () => { - it("should correctly determine index when line number exists in array", () => { + it("should correctly determine index when line number exists directly in the array and is not represented in a Range object", () => { expect(findLineIndex(processedLines, 0)).toBe(0); expect(findLineIndex(processedLines, 3)).toBe(2); expect(findLineIndex(processedLines, 6)).toBe(4); }); - it("should correctly determine index when line number exists in nested array", () => { + it("should correctly determine index when line number is represented in a Range object", () => { expect(findLineIndex(processedLines, 1)).toBe(1); expect(findLineIndex(processedLines, 4)).toBe(3); }); - it("should return -1 when line number does not exist in array", () => { + it("should return -1 when line number is not represented in the array", () => { expect(findLineIndex(processedLines, -1)).toBe(-1); expect(findLineIndex(processedLines, 11)).toBe(-1); }); diff --git a/apps/parsley/src/utils/findLineIndex/index.ts b/apps/parsley/src/utils/findLineIndex/index.ts index b54d94fbd..51c68221a 100644 --- a/apps/parsley/src/utils/findLineIndex/index.ts +++ b/apps/parsley/src/utils/findLineIndex/index.ts @@ -1,5 +1,5 @@ import { ProcessedLogLines } from "types/logs"; -import { isCollapsedRow } from "utils/collapsedRow"; +import { isCollapsedRow } from "utils/logRowTypes"; /** * `findLineIndex` employs binary search to search for the index of a line number within the @@ -27,8 +27,8 @@ export const findLineIndex = ( // If the item is a collapsed row, we'll shift our search depending on the first and last line numbers // in the collapsed row. if (isCollapsedRow(midItem)) { - const firstItem = midItem[0]; - const lastItem = midItem[midItem.length - 1]; + const firstItem = midItem.range.start; + const lastItem = midItem.range.end - 1; // subtract 1 since end is exclusive if (firstItem <= lineNumber && lineNumber <= lastItem) { return midIdx; } diff --git a/apps/parsley/src/utils/logRow/index.ts b/apps/parsley/src/utils/logRow/index.ts new file mode 100644 index 000000000..335016654 --- /dev/null +++ b/apps/parsley/src/utils/logRow/index.ts @@ -0,0 +1,13 @@ +import { SkippedLinesRow } from "types/logs"; +/** + * + * @param start The start line number inclusive + * @param end The end line number exclusive + * @returns SkippedLines object + */ +const newSkippedLinesRow = (start: number, end: number): SkippedLinesRow => ({ + range: { end, start }, + rowType: "SkippedLines", +}); + +export { newSkippedLinesRow }; diff --git a/apps/parsley/src/utils/logRowTypes/index.ts b/apps/parsley/src/utils/logRowTypes/index.ts new file mode 100644 index 000000000..2af1bcb28 --- /dev/null +++ b/apps/parsley/src/utils/logRowTypes/index.ts @@ -0,0 +1,24 @@ +import { ProcessedLogLine, SkippedLinesRow } from "types/logs"; + +/** + * `isSkippedLinesRow` determines if a row is a SkippedLinesRow. + * @param logLine - the processed log line to check + * @returns true if the row is a SkippedLinesRow + */ + +const isSkippedLinesRow = ( + logLine: ProcessedLogLine, +): logLine is SkippedLinesRow => + typeof logLine === "object" && logLine.rowType === "SkippedLines"; + +/** + * `isCollapsedRow` determines if a row is a collapsed row such as SectionHeaderRow and SkippedLinesRow. + * Although it is a simple function, its purpose is to make the code more readable. + * @param logLine - the processed log line to check + * @returns true if the row is a collapsed row + */ +type CollapsedRow = SkippedLinesRow; +const isCollapsedRow = (logLine: ProcessedLogLine): logLine is CollapsedRow => + isSkippedLinesRow(logLine); + +export { isCollapsedRow, isSkippedLinesRow }; diff --git a/apps/parsley/src/utils/searchLogs/index.ts b/apps/parsley/src/utils/searchLogs/index.ts index b3115f0d6..81dd015d2 100644 --- a/apps/parsley/src/utils/searchLogs/index.ts +++ b/apps/parsley/src/utils/searchLogs/index.ts @@ -1,5 +1,5 @@ import { ProcessedLogLines } from "types/logs"; -import { isCollapsedRow } from "utils/collapsedRow"; +import { isCollapsedRow } from "utils/logRowTypes"; interface searchOptions { searchRegex: RegExp; diff --git a/apps/parsley/src/utils/searchLogs/searchLogs.test.ts b/apps/parsley/src/utils/searchLogs/searchLogs.test.ts index e5ef99173..2ec991710 100644 --- a/apps/parsley/src/utils/searchLogs/searchLogs.test.ts +++ b/apps/parsley/src/utils/searchLogs/searchLogs.test.ts @@ -1,3 +1,4 @@ +import { ProcessedLogLines } from "types/logs"; import searchLogs from "."; describe("searchLogs", () => { @@ -57,10 +58,15 @@ describe("searchLogs", () => { it("should not match on folded lines and should return the processedLogLine index", () => { const lines = ["line 1", "line 2", "line 3", "line 4"]; const getLine = vi.fn((index: number) => lines[index]); + const processedLogLines: ProcessedLogLines = [ + 0, + { range: { end: 3, start: 1 }, rowType: "SkippedLines" }, + 3, + ]; const options = { getLine, lowerBound: 0, - processedLogLines: [0, [1, 2], 3], + processedLogLines, searchRegex: /line/, }; const matchingIndices = searchLogs(options); @@ -72,10 +78,15 @@ describe("searchLogs", () => { it("should not search lines that are folded or if they are out of the range", () => { const lines = ["line 1", "line 2", "line 3", "line 4"]; const getLine = vi.fn((index: number) => lines[index]); + const processedLogLines: ProcessedLogLines = [ + 0, + { range: { end: 3, start: 1 }, rowType: "SkippedLines" }, + 3, + ]; const options = { getLine, lowerBound: 0, - processedLogLines: [0, [1, 2], 3], + processedLogLines, searchRegex: /line/, upperBound: 1, };