From c3f6ff9c563fc0d738a8e85d07436016218b6006 Mon Sep 17 00:00:00 2001 From: Amir Raminfar Date: Tue, 19 Nov 2024 12:01:03 -0800 Subject: [PATCH] feat: adds a short delay while waiting for logs to show (#3409) --- .../components/LogViewer/EventSource.spec.ts | 2 +- assets/components/LogViewer/EventSource.vue | 11 +++++++-- .../__snapshots__/EventSource.spec.ts.snap | 23 ------------------- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/assets/components/LogViewer/EventSource.spec.ts b/assets/components/LogViewer/EventSource.spec.ts index 52c7ee1b..9a1d9d24 100644 --- a/assets/components/LogViewer/EventSource.spec.ts +++ b/assets/components/LogViewer/EventSource.spec.ts @@ -103,7 +103,7 @@ describe("", () => { test("renders loading correctly", async () => { const wrapper = createLogEventSource(); - expect(wrapper.html()).toMatchSnapshot(); + expect(wrapper.find("ul.animate-pulse").exists()).toBe(true); }); test("should connect to EventSource", async () => { diff --git a/assets/components/LogViewer/EventSource.vue b/assets/components/LogViewer/EventSource.vue index e22c68f8..2d7c2451 100644 --- a/assets/components/LogViewer/EventSource.vue +++ b/assets/components/LogViewer/EventSource.vue @@ -1,12 +1,13 @@ @@ -29,6 +30,8 @@ const color = computed(() => { }); const noLogs = computed(() => messages.value.length === 0); +const waitingForMoreLog = refAutoReset(false, 3000); +watchImmediate(loading, () => (waitingForMoreLog.value = true)); defineExpose({ clear: () => (messages.value = []), @@ -41,4 +44,8 @@ const fetchMore = async () => { loadingMore.value = false; } }; + +const shuffle = (items: any[]) => { + return items.sort(() => Math.random() - 0.5); +}; diff --git a/assets/components/LogViewer/__snapshots__/EventSource.spec.ts.snap b/assets/components/LogViewer/__snapshots__/EventSource.spec.ts.snap index 9d65c971..4afebbac 100644 --- a/assets/components/LogViewer/__snapshots__/EventSource.spec.ts.snap +++ b/assets/components/LogViewer/__snapshots__/EventSource.spec.ts.snap @@ -60,29 +60,6 @@ exports[` > render html correctly > should render messag " `; -exports[` > renders loading correctly 1`] = ` -"
-
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    Loading... -
-
" -`; - exports[` > should parse messages 1`] = ` SimpleLogEntry { "_message": "This is a message.",