From 011bc94e8c8460b1d31c42f06a4e17b4bc09ba71 Mon Sep 17 00:00:00 2001 From: Amir Raminfar Date: Tue, 19 Apr 2022 13:54:08 -0700 Subject: [PATCH] Cleans up search by removing for loop (#1719) * Cleans up search by removing for loop * Fixes tests --- assets/components.d.ts | 10 -- assets/components/LogEventSource.spec.ts | 18 ++- assets/components/LogViewer.vue | 71 ++++------ .../__snapshots__/LogEventSource.spec.ts.snap | 126 +++++++++++++++++- assets/composables/search.ts | 26 ++-- package.json | 1 + pnpm-lock.yaml | 15 +++ 7 files changed, 196 insertions(+), 71 deletions(-) diff --git a/assets/components.d.ts b/assets/components.d.ts index 57e37cb6..52be8d8d 100644 --- a/assets/components.d.ts +++ b/assets/components.d.ts @@ -5,8 +5,6 @@ import '@vue/runtime-core' declare module '@vue/runtime-core' { export interface GlobalComponents { - CarbonCaretDown: typeof import('~icons/carbon/caret-down')['default'] - CilColumns: typeof import('~icons/cil/columns')['default'] CilFindInPage: typeof import('~icons/cil/find-in-page')['default'] ContainerStat: typeof import('./components/ContainerStat.vue')['default'] ContainerTitle: typeof import('./components/ContainerTitle.vue')['default'] @@ -19,15 +17,7 @@ declare module '@vue/runtime-core' { LogViewer: typeof import('./components/LogViewer.vue')['default'] LogViewerWithSource: typeof import('./components/LogViewerWithSource.vue')['default'] MdiDotsVertical: typeof import('~icons/mdi/dots-vertical')['default'] - MdiLightChevronDoubleDown: typeof import('~icons/mdi-light/chevron-double-down')['default'] - MdiLightChevronLeft: typeof import('~icons/mdi-light/chevron-left')['default'] - MdiLightChevronRight: typeof import('~icons/mdi-light/chevron-right')['default'] - MdiLightCog: typeof import('~icons/mdi-light/cog')['default'] - MdiLightMagnify: typeof import('~icons/mdi-light/magnify')['default'] MobileMenu: typeof import('./components/MobileMenu.vue')['default'] - OcticonContainer24: typeof import('~icons/octicon/container24')['default'] - OcticonDownload24: typeof import('~icons/octicon/download24')['default'] - OcticonTrash24: typeof import('~icons/octicon/trash24')['default'] PastTime: typeof import('./components/PastTime.vue')['default'] RelativeTime: typeof import('./components/RelativeTime.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] diff --git a/assets/components/LogEventSource.spec.ts b/assets/components/LogEventSource.spec.ts index 9a496fce..6bcafdc8 100644 --- a/assets/components/LogEventSource.spec.ts +++ b/assets/components/LogEventSource.spec.ts @@ -8,6 +8,7 @@ import { settings } from "../composables/settings"; import { useSearchFilter } from "@/composables/search"; import { vi, describe, expect, beforeEach, test, beforeAll, afterAll } from "vitest"; import { computed, Ref } from "vue"; +import { createRouter, createWebHistory } from "vue-router"; vi.mock("lodash.debounce", () => ({ __esModule: true, @@ -50,7 +51,7 @@ describe("", () => { function createLogEventSource( { - searchFilter = undefined, + searchFilter = "", hourStyle = "auto", }: { searchFilter?: string | undefined; hourStyle?: "auto" | "24" | "12" } = { hourStyle: "auto", @@ -58,9 +59,22 @@ describe("", () => { ) { settings.value.hourStyle = hourStyle; search.searchFilter.value = searchFilter; + + const router = createRouter({ + history: createWebHistory("/"), + routes: [ + { + path: "/", + component: { + template: "Test from createLogEventSource", + }, + }, + ], + }); + return mount(LogEventSource, { global: { - plugins: [createTestingPinia({ createSpy: vi.fn })], + plugins: [router, createTestingPinia({ createSpy: vi.fn })], components: { LogViewer, }, diff --git a/assets/components/LogViewer.vue b/assets/components/LogViewer.vue index 7d72bdb5..6d8152a7 100644 --- a/assets/components/LogViewer.vue +++ b/assets/components/LogViewer.vue @@ -3,13 +3,13 @@
  • -
    +
    - +
    @@ -32,15 +32,13 @@