From d83d223742babab54ee694b81775abdec99a88c4 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Fri, 20 Jan 2023 10:01:22 -0500 Subject: [PATCH] Better fake time impl Signed-off-by: Sebastian Malton --- src/common/test-utils/use-fake-time.ts | 20 +- .../utils/reactive-now/reactive-now.test.tsx | 4 +- .../application-menu/application-menu.test.ts | 4 +- ...g-of-orphan-application-menu-items.test.ts | 4 +- .../analytics-for-installing-update.test.ts | 10 +- ...alling-update-using-topbar-button.test.tsx | 10 +- ...g-time-since-update-was-downloaded.test.ts | 10 +- .../periodical-checking-of-updates.test.ts | 10 +- .../installing-update.test.ts | 9 +- .../opening-entity-details.test.tsx.snap | 52 -- ...when-cluster-is-not-relevant.test.tsx.snap | 76 -- ...when-cluster-is-not-relevant.test.tsx.snap | 76 -- ...when-cluster-is-not-relevant.test.tsx.snap | 76 -- ...when-cluster-is-not-relevant.test.tsx.snap | 76 -- .../show-status-for-a-kube-object.test.tsx | 9 +- .../edit-namespace-from-new-tab.test.tsx.snap | 570 ------------- ...e-from-previously-opened-tab.test.tsx.snap | 38 - ...debar-and-tab-navigation-for-core.test.tsx | 10 +- ...and-tab-navigation-for-extensions.test.tsx | 10 +- ...when-cluster-is-not-relevant.test.tsx.snap | 76 -- ...tom-helm-repository-in-preferences.test.ts | 11 +- ...lling-helm-chart-from-new-tab.test.ts.snap | 760 ------------------ ...rt-from-previously-opened-tab.test.ts.snap | 38 - ...tab-for-installing-helm-chart.test.ts.snap | 304 ------- .../upgrade-chart-new-tab.test.ts.snap | 76 -- .../upgrade-chart-new-tab.test.ts | 10 +- ...wing-details-for-helm-release.test.ts.snap | 570 ------------- .../showing-details-for-helm-release.test.ts | 9 +- ...ing-the-app-using-application-menu.test.ts | 10 +- .../components/countdown/countdown.test.tsx | 4 +- .../__tests__/render-delay.test.tsx | 4 +- .../test-utils/get-application-builder.tsx | 13 +- .../cluster-frame/cluster-frame.test.tsx | 4 +- 33 files changed, 105 insertions(+), 2858 deletions(-) diff --git a/src/common/test-utils/use-fake-time.ts b/src/common/test-utils/use-fake-time.ts index 7d57ef648d..d431101af5 100644 --- a/src/common/test-utils/use-fake-time.ts +++ b/src/common/test-utils/use-fake-time.ts @@ -15,17 +15,21 @@ export const advanceFakeTime = (milliseconds: number) => { jest.advanceTimersByTime(milliseconds); }); }; +export interface TestUsingFakeTimeOptions { + dateTime?: string; + autoAdvance?: boolean; +} -export const testUsingFakeTime = (dateTime = "2015-10-21T07:28:00Z") => { +export const testUsingFakeTime = ({ autoAdvance = true, dateTime = "2015-10-21T07:28:00Z" }: TestUsingFakeTimeOptions = {}) => { usingFakeTime = true; - jest.useFakeTimers({ - doNotFake: [ - "nextTick", - "setImmediate", - "clearImmediate", - ], - }); + const setInterval = global.setInterval; + + jest.useFakeTimers(); + + if (autoAdvance) { + setInterval(() => advanceFakeTime(20), 20); + } jest.setSystemTime(new Date(dateTime)); }; diff --git a/src/common/utils/reactive-now/reactive-now.test.tsx b/src/common/utils/reactive-now/reactive-now.test.tsx index ab9b185438..6bb8940ca7 100644 --- a/src/common/utils/reactive-now/reactive-now.test.tsx +++ b/src/common/utils/reactive-now/reactive-now.test.tsx @@ -15,7 +15,9 @@ describe("reactiveNow", () => { let someComputed: IComputedValue; beforeEach(() => { - testUsingFakeTime("2015-10-21T07:28:00Z"); + testUsingFakeTime({ + dateTime: "2015-10-21T07:28:00Z", + }); someComputed = computed(() => { const currentTimestamp = reactiveNow(); diff --git a/src/features/application-menu/application-menu.test.ts b/src/features/application-menu/application-menu.test.ts index 0db35db744..1d7d3244fe 100644 --- a/src/features/application-menu/application-menu.test.ts +++ b/src/features/application-menu/application-menu.test.ts @@ -5,7 +5,7 @@ import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; import populateApplicationMenuInjectable from "./main/populate-application-menu.injectable"; -import { advanceFakeTime, testUsingFakeTime } from "../../common/test-utils/use-fake-time"; +import { advanceFakeTime } from "../../common/test-utils/use-fake-time"; import { getCompositePaths } from "../../common/utils/composite/get-composite-paths/get-composite-paths"; import platformInjectable, { allPlatforms } from "../../common/vars/platform.injectable"; @@ -14,8 +14,6 @@ describe.each(allPlatforms)("application-menu, given platform is '%s'", (platfor let populateApplicationMenuMock: jest.Mock; beforeEach(async () => { - testUsingFakeTime(); - populateApplicationMenuMock = jest.fn(); builder = getApplicationBuilder(); diff --git a/src/features/application-menu/handling-of-orphan-application-menu-items.test.ts b/src/features/application-menu/handling-of-orphan-application-menu-items.test.ts index 7f35861a45..6d27370b43 100644 --- a/src/features/application-menu/handling-of-orphan-application-menu-items.test.ts +++ b/src/features/application-menu/handling-of-orphan-application-menu-items.test.ts @@ -5,7 +5,7 @@ import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; import populateApplicationMenuInjectable from "./main/populate-application-menu.injectable"; -import { advanceFakeTime, testUsingFakeTime } from "../../common/test-utils/use-fake-time"; +import { advanceFakeTime } from "../../common/test-utils/use-fake-time"; import { getCompositePaths } from "../../common/utils/composite/get-composite-paths/get-composite-paths"; import { getInjectable } from "@ogre-tools/injectable"; import applicationMenuItemInjectionToken from "./main/menu-items/application-menu-item-injection-token"; @@ -18,8 +18,6 @@ describe("handling-of-orphan-application-menu-items, given orphan menu item", () let logErrorMock: jest.Mock; beforeEach(async () => { - testUsingFakeTime(); - populateApplicationMenuMock = jest.fn(); logErrorMock = jest.fn(); diff --git a/src/features/application-update/analytics-for-installing-update.test.ts b/src/features/application-update/analytics-for-installing-update.test.ts index ce77d37229..494f22a285 100644 --- a/src/features/application-update/analytics-for-installing-update.test.ts +++ b/src/features/application-update/analytics-for-installing-update.test.ts @@ -17,7 +17,7 @@ import type { DownloadPlatformUpdate } from "./main/download-update/download-pla import downloadPlatformUpdateInjectable from "./main/download-update/download-platform-update/download-platform-update.injectable"; import quitAndInstallUpdateInjectable from "./main/quit-and-install-update.injectable"; import periodicalCheckForUpdatesInjectable from "./child-features/periodical-checking-of-updates/main/periodical-check-for-updates.injectable"; -import { advanceFakeTime, testUsingFakeTime } from "../../common/test-utils/use-fake-time"; +import { advanceFakeTime } from "../../common/test-utils/use-fake-time"; import emitEventInjectable from "../../common/app-event-bus/emit-event.injectable"; import getBuildVersionInjectable from "../../main/vars/build-version/get-build-version.injectable"; @@ -29,9 +29,11 @@ describe("analytics for installing update", () => { let mainDi: DiContainer; beforeEach(async () => { - testUsingFakeTime("2015-10-21T07:28:00Z"); - - builder = getApplicationBuilder(); + builder = getApplicationBuilder({ + useFakeTime: { + dateTime: "2015-10-21T07:28:00Z", + }, + }); analyticsListenerMock = jest.fn(); diff --git a/src/features/application-update/child-features/application-update-using-top-bar/installing-update-using-topbar-button.test.tsx b/src/features/application-update/child-features/application-update-using-top-bar/installing-update-using-topbar-button.test.tsx index adede427d2..2487f66289 100644 --- a/src/features/application-update/child-features/application-update-using-top-bar/installing-update-using-topbar-button.test.tsx +++ b/src/features/application-update/child-features/application-update-using-top-bar/installing-update-using-topbar-button.test.tsx @@ -16,7 +16,7 @@ import type { ApplicationBuilder } from "../../../../renderer/components/test-ut import { getApplicationBuilder } from "../../../../renderer/components/test-utils/get-application-builder"; import processCheckingForUpdatesInjectable from "../../main/process-checking-for-updates.injectable"; import quitAndInstallUpdateInjectable from "../../main/quit-and-install-update.injectable"; -import { advanceFakeTime, testUsingFakeTime } from "../../../../common/test-utils/use-fake-time"; +import { advanceFakeTime } from "../../../../common/test-utils/use-fake-time"; function daysToMilliseconds(days: number) { return Math.round(days * 24 * 60 * 60 * 1000); @@ -29,9 +29,11 @@ describe("encourage user to update when sufficient time passed since update was let quitAndInstallUpdateMock: jest.MockedFunction<() => void>; beforeEach(() => { - testUsingFakeTime("2015-10-21T07:28:00Z"); - - applicationBuilder = getApplicationBuilder(); + applicationBuilder = getApplicationBuilder({ + useFakeTime: { + dateTime: "2015-10-21T07:28:00Z", + }, + }); applicationBuilder.beforeApplicationStart((mainDi) => { checkForPlatformUpdatesMock = asyncFn(); diff --git a/src/features/application-update/child-features/force-user-to-update-when-too-long-time-since-update-was-downloaded/force-user-to-update-when-too-long-time-since-update-was-downloaded.test.ts b/src/features/application-update/child-features/force-user-to-update-when-too-long-time-since-update-was-downloaded/force-user-to-update-when-too-long-time-since-update-was-downloaded.test.ts index 39ac24570a..813813a21e 100644 --- a/src/features/application-update/child-features/force-user-to-update-when-too-long-time-since-update-was-downloaded/force-user-to-update-when-too-long-time-since-update-was-downloaded.test.ts +++ b/src/features/application-update/child-features/force-user-to-update-when-too-long-time-since-update-was-downloaded/force-user-to-update-when-too-long-time-since-update-was-downloaded.test.ts @@ -14,7 +14,7 @@ import type { DiContainer } from "@ogre-tools/injectable"; import processCheckingForUpdatesInjectable from "../../main/process-checking-for-updates.injectable"; import type { RenderResult } from "@testing-library/react"; import { fireEvent } from "@testing-library/react"; -import { advanceFakeTime, testUsingFakeTime } from "../../../../common/test-utils/use-fake-time"; +import { advanceFakeTime } from "../../../../common/test-utils/use-fake-time"; import quitAndInstallUpdateInjectable from "../../main/quit-and-install-update.injectable"; import timeAfterUpdateMustBeInstalledInjectable from "./renderer/force-update-modal/time-after-update-must-be-installed.injectable"; import secondsAfterInstallStartsInjectable from "./renderer/force-update-modal/seconds-after-install-starts.injectable"; @@ -31,9 +31,11 @@ describe("force user to update when too long since update was downloaded", () => let quitAndInstallUpdateMock: jest.Mock; beforeEach(() => { - testUsingFakeTime("2015-10-21T07:28:00Z"); - - applicationBuilder = getApplicationBuilder(); + applicationBuilder = getApplicationBuilder({ + useFakeTime: { + dateTime: "2015-10-21T07:28:00Z", + }, + }); applicationBuilder.beforeApplicationStart(mainDi => { checkForPlatformUpdatesMock = asyncFn(); diff --git a/src/features/application-update/child-features/periodical-checking-of-updates/periodical-checking-of-updates.test.ts b/src/features/application-update/child-features/periodical-checking-of-updates/periodical-checking-of-updates.test.ts index 22765b85de..546e19848b 100644 --- a/src/features/application-update/child-features/periodical-checking-of-updates/periodical-checking-of-updates.test.ts +++ b/src/features/application-update/child-features/periodical-checking-of-updates/periodical-checking-of-updates.test.ts @@ -9,7 +9,7 @@ import electronUpdaterIsActiveInjectable from "../../../../main/electron-app/fea import publishIsConfiguredInjectable from "../../main/updating-is-enabled/publish-is-configured/publish-is-configured.injectable"; import processCheckingForUpdatesInjectable from "../../main/process-checking-for-updates.injectable"; import periodicalCheckForUpdatesInjectable from "./main/periodical-check-for-updates.injectable"; -import { advanceFakeTime, testUsingFakeTime } from "../../../../common/test-utils/use-fake-time"; +import { advanceFakeTime } from "../../../../common/test-utils/use-fake-time"; const ENOUGH_TIME = 1000 * 60 * 60 * 2; @@ -18,9 +18,11 @@ describe("periodical checking of updates", () => { let processCheckingForUpdatesMock: jest.Mock; beforeEach(() => { - testUsingFakeTime("2015-10-21T07:28:00Z"); - - builder = getApplicationBuilder(); + builder = getApplicationBuilder({ + useFakeTime: { + dateTime: "2015-10-21T07:28:00Z", + }, + }); builder.beforeApplicationStart((mainDi) => { mainDi.unoverride(periodicalCheckForUpdatesInjectable); diff --git a/src/features/application-update/installing-update.test.ts b/src/features/application-update/installing-update.test.ts index 81529a851f..eee794e9d7 100644 --- a/src/features/application-update/installing-update.test.ts +++ b/src/features/application-update/installing-update.test.ts @@ -16,7 +16,6 @@ import type { DownloadPlatformUpdate } from "./main/download-update/download-pla import downloadPlatformUpdateInjectable from "./main/download-update/download-platform-update/download-platform-update.injectable"; import setUpdateOnQuitInjectable from "../../main/electron-app/features/set-update-on-quit.injectable"; import processCheckingForUpdatesInjectable from "./main/process-checking-for-updates.injectable"; -import { testUsingFakeTime } from "../../common/test-utils/use-fake-time"; import staticFilesDirectoryInjectable from "../../common/vars/static-files-directory.injectable"; describe("installing update", () => { @@ -27,9 +26,11 @@ describe("installing update", () => { let setUpdateOnQuitMock: jest.Mock; beforeEach(() => { - testUsingFakeTime("2015-10-21T07:28:00Z"); - - builder = getApplicationBuilder(); + builder = getApplicationBuilder({ + useFakeTime: { + dateTime: "2015-10-21T07:28:00Z", + }, + }); builder.beforeApplicationStart((mainDi) => { quitAndInstallUpdateMock = jest.fn(); diff --git a/src/features/catalog/__snapshots__/opening-entity-details.test.tsx.snap b/src/features/catalog/__snapshots__/opening-entity-details.test.tsx.snap index 49d085fc85..20e9018015 100644 --- a/src/features/catalog/__snapshots__/opening-entity-details.test.tsx.snap +++ b/src/features/catalog/__snapshots__/opening-entity-details.test.tsx.snap @@ -3630,38 +3630,6 @@ exports[`opening catalog entity details panel when navigated to the catalog when class="Notifications flex column align-flex-end" /> -
-
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -431,44 +393,6 @@ exports[`disable-cluster-pages-when-cluster-is-not-relevant given extension shou exports[`disable-cluster-pages-when-cluster-is-not-relevant given extension shouldn't be enabled for the cluster, when navigating renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
diff --git a/src/features/cluster/extension-api/__snapshots__/disable-sidebar-items-when-cluster-is-not-relevant.test.tsx.snap b/src/features/cluster/extension-api/__snapshots__/disable-sidebar-items-when-cluster-is-not-relevant.test.tsx.snap index 0faccf1aaa..11cf4f3d4e 100644 --- a/src/features/cluster/extension-api/__snapshots__/disable-sidebar-items-when-cluster-is-not-relevant.test.tsx.snap +++ b/src/features/cluster/extension-api/__snapshots__/disable-sidebar-items-when-cluster-is-not-relevant.test.tsx.snap @@ -3,44 +3,6 @@ exports[`disable sidebar items when cluster is not relevant given extension should be enabled for the cluster renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -571,44 +533,6 @@ exports[`disable sidebar items when cluster is not relevant given extension shou exports[`disable sidebar items when cluster is not relevant given extension shouldn't be enabled for the cluster renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
diff --git a/src/features/cluster/kube-object-menu/extension-api/__snapshots__/disable-kube-object-menu-items-when-cluster-is-not-relevant.test.tsx.snap b/src/features/cluster/kube-object-menu/extension-api/__snapshots__/disable-kube-object-menu-items-when-cluster-is-not-relevant.test.tsx.snap index f1f1bb8490..3f5aaa6da6 100644 --- a/src/features/cluster/kube-object-menu/extension-api/__snapshots__/disable-kube-object-menu-items-when-cluster-is-not-relevant.test.tsx.snap +++ b/src/features/cluster/kube-object-menu/extension-api/__snapshots__/disable-kube-object-menu-items-when-cluster-is-not-relevant.test.tsx.snap @@ -3,44 +3,6 @@ exports[`disable kube object menu items when cluster is not relevant given extension should be enabled for the cluster renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -436,44 +398,6 @@ exports[`disable kube object menu items when cluster is not relevant given exten exports[`disable kube object menu items when cluster is not relevant given extension shouldn't be enabled for the cluster renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
diff --git a/src/features/cluster/kube-object-status-icon/extension-api/__snapshots__/disable-kube-object-statuses-when-cluster-is-not-relevant.test.tsx.snap b/src/features/cluster/kube-object-status-icon/extension-api/__snapshots__/disable-kube-object-statuses-when-cluster-is-not-relevant.test.tsx.snap index 56d42fced8..65a272099b 100644 --- a/src/features/cluster/kube-object-status-icon/extension-api/__snapshots__/disable-kube-object-statuses-when-cluster-is-not-relevant.test.tsx.snap +++ b/src/features/cluster/kube-object-status-icon/extension-api/__snapshots__/disable-kube-object-statuses-when-cluster-is-not-relevant.test.tsx.snap @@ -3,44 +3,6 @@ exports[`disable kube object statuses when cluster is not relevant given extension should be enabled for the cluster renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -465,44 +427,6 @@ exports[`disable kube object statuses when cluster is not relevant given extensi exports[`disable kube object statuses when cluster is not relevant given extension shouldn't be enabled for the cluster renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
diff --git a/src/features/cluster/kube-object-status-icon/show-status-for-a-kube-object.test.tsx b/src/features/cluster/kube-object-status-icon/show-status-for-a-kube-object.test.tsx index 49fe7f9efd..c5522e2715 100644 --- a/src/features/cluster/kube-object-status-icon/show-status-for-a-kube-object.test.tsx +++ b/src/features/cluster/kube-object-status-icon/show-status-for-a-kube-object.test.tsx @@ -5,7 +5,6 @@ import { KubeObjectStatusLevel } from "../../../common/k8s-api/kube-object-status"; import { KubeObject } from "../../../common/k8s-api/kube-object"; import React from "react"; -import { testUsingFakeTime } from "../../../common/test-utils/use-fake-time"; import type { DiContainer } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable"; import type { IAtom } from "mobx"; @@ -28,9 +27,11 @@ describe("show status for a kube object", () => { let criticalStatusIsShown: boolean; beforeEach(() => { - testUsingFakeTime("2015-10-21T07:28:00Z"); - - builder = getApplicationBuilder(); + builder = getApplicationBuilder({ + useFakeTime: { + dateTime: "2015-10-21T07:28:00Z", + }, + }); infoStatusIsShown = false; diff --git a/src/features/cluster/namespaces/__snapshots__/edit-namespace-from-new-tab.test.tsx.snap b/src/features/cluster/namespaces/__snapshots__/edit-namespace-from-new-tab.test.tsx.snap index 6675611fca..90b5e5ca48 100644 --- a/src/features/cluster/namespaces/__snapshots__/edit-namespace-from-new-tab.test.tsx.snap +++ b/src/features/cluster/namespaces/__snapshots__/edit-namespace-from-new-tab.test.tsx.snap @@ -681,44 +681,6 @@ exports[`cluster/namespaces - edit namespace from new tab when navigating to nam exports[`cluster/namespaces - edit namespace from new tab when navigating to namespaces when namespaces resolve when clicking the context menu for a namespace when clicking to edit namespace when call for namespace resolves with failure renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -1364,44 +1326,6 @@ exports[`cluster/namespaces - edit namespace from new tab when navigating to nam exports[`cluster/namespaces - edit namespace from new tab when navigating to namespaces when namespaces resolve when clicking the context menu for a namespace when clicking to edit namespace when call for namespace resolves with namespace given change in configuration renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -2116,44 +2040,6 @@ metadata: exports[`cluster/namespaces - edit namespace from new tab when navigating to namespaces when namespaces resolve when clicking the context menu for a namespace when clicking to edit namespace when call for namespace resolves with namespace given clicking the context menu for second namespace, when clicking to edit namespace renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -2846,44 +2732,6 @@ exports[`cluster/namespaces - edit namespace from new tab when navigating to nam exports[`cluster/namespaces - edit namespace from new tab when navigating to namespaces when namespaces resolve when clicking the context menu for a namespace when clicking to edit namespace when call for namespace resolves with namespace given clicking the context menu for second namespace, when clicking to edit namespace when second namespace resolves renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -3648,44 +3496,6 @@ metadata: exports[`cluster/namespaces - edit namespace from new tab when navigating to namespaces when namespaces resolve when clicking the context menu for a namespace when clicking to edit namespace when call for namespace resolves with namespace given clicking the context menu for second namespace, when clicking to edit namespace when second namespace resolves when clicking dock tab for the first namespace renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -4452,44 +4262,6 @@ metadata: exports[`cluster/namespaces - edit namespace from new tab when navigating to namespaces when namespaces resolve when clicking the context menu for a namespace when clicking to edit namespace when call for namespace resolves with namespace given invalid change in configuration renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -5218,44 +4990,6 @@ exports[`cluster/namespaces - edit namespace from new tab when navigating to nam exports[`cluster/namespaces - edit namespace from new tab when navigating to namespaces when namespaces resolve when clicking the context menu for a namespace when clicking to edit namespace when call for namespace resolves with namespace given no changes in the configuration, when selecting to save renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -5979,44 +5713,6 @@ metadata: exports[`cluster/namespaces - edit namespace from new tab when navigating to namespaces when namespaces resolve when clicking the context menu for a namespace when clicking to edit namespace when call for namespace resolves with namespace given no changes in the configuration, when selecting to save when saving resolves with failure renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -6731,44 +6427,6 @@ metadata: exports[`cluster/namespaces - edit namespace from new tab when navigating to namespaces when namespaces resolve when clicking the context menu for a namespace when clicking to edit namespace when call for namespace resolves with namespace given no changes in the configuration, when selecting to save when saving resolves with success renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -7483,44 +7141,6 @@ metadata: exports[`cluster/namespaces - edit namespace from new tab when navigating to namespaces when namespaces resolve when clicking the context menu for a namespace when clicking to edit namespace when call for namespace resolves with namespace renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -8235,44 +7855,6 @@ metadata: exports[`cluster/namespaces - edit namespace from new tab when navigating to namespaces when namespaces resolve when clicking the context menu for a namespace when clicking to edit namespace when call for namespace resolves with namespace when selecting to cancel renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -8822,44 +8404,6 @@ exports[`cluster/namespaces - edit namespace from new tab when navigating to nam exports[`cluster/namespaces - edit namespace from new tab when navigating to namespaces when namespaces resolve when clicking the context menu for a namespace when clicking to edit namespace when call for namespace resolves with namespace when selecting to save and close renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -9583,44 +9127,6 @@ metadata: exports[`cluster/namespaces - edit namespace from new tab when navigating to namespaces when namespaces resolve when clicking the context menu for a namespace when clicking to edit namespace when call for namespace resolves with namespace when selecting to save and close when saving resolves with failure renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -10170,44 +9676,6 @@ exports[`cluster/namespaces - edit namespace from new tab when navigating to nam exports[`cluster/namespaces - edit namespace from new tab when navigating to namespaces when namespaces resolve when clicking the context menu for a namespace when clicking to edit namespace when call for namespace resolves with namespace when selecting to save and close when saving resolves with success renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -10757,44 +10225,6 @@ exports[`cluster/namespaces - edit namespace from new tab when navigating to nam exports[`cluster/namespaces - edit namespace from new tab when navigating to namespaces when namespaces resolve when clicking the context menu for a namespace when clicking to edit namespace when call for namespace resolves without namespace renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
diff --git a/src/features/cluster/namespaces/__snapshots__/edit-namespace-from-previously-opened-tab.test.tsx.snap b/src/features/cluster/namespaces/__snapshots__/edit-namespace-from-previously-opened-tab.test.tsx.snap index 1612e1d052..6de953e63e 100644 --- a/src/features/cluster/namespaces/__snapshots__/edit-namespace-from-previously-opened-tab.test.tsx.snap +++ b/src/features/cluster/namespaces/__snapshots__/edit-namespace-from-previously-opened-tab.test.tsx.snap @@ -588,44 +588,6 @@ exports[`cluster/namespaces - edit namespaces from previously opened tab given t exports[`cluster/namespaces - edit namespaces from previously opened tab given tab was previously opened, when application is started when call for namespace resolves with namespace renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
diff --git a/src/features/cluster/sidebar-and-tab-navigation-for-core.test.tsx b/src/features/cluster/sidebar-and-tab-navigation-for-core.test.tsx index a4995c38ae..3db74bdcc1 100644 --- a/src/features/cluster/sidebar-and-tab-navigation-for-core.test.tsx +++ b/src/features/cluster/sidebar-and-tab-navigation-for-core.test.tsx @@ -20,7 +20,7 @@ import writeJsonFileInjectable from "../../common/fs/write-json-file.injectable" import pathExistsInjectable from "../../common/fs/path-exists.injectable"; import readJsonFileInjectable from "../../common/fs/read-json-file.injectable"; import { navigateToRouteInjectionToken } from "../../common/front-end-routing/navigate-to-route-injection-token"; -import { advanceFakeTime, testUsingFakeTime } from "../../common/test-utils/use-fake-time"; +import { advanceFakeTime } from "../../common/test-utils/use-fake-time"; import storageSaveDelayInjectable from "../../renderer/utils/create-storage/storage-save-delay.injectable"; import { flushPromises } from "../../common/test-utils/flush-promises"; @@ -29,9 +29,11 @@ describe("cluster - sidebar and tab navigation for core", () => { let rendered: RenderResult; beforeEach(() => { - testUsingFakeTime("2015-10-21T07:28:00Z"); - - builder = getApplicationBuilder(); + builder = getApplicationBuilder({ + useFakeTime: { + dateTime: "2015-10-21T07:28:00Z", + }, + }); builder.setEnvironmentToClusterFrame(); diff --git a/src/features/cluster/sidebar-and-tab-navigation-for-extensions.test.tsx b/src/features/cluster/sidebar-and-tab-navigation-for-extensions.test.tsx index 27a211a0cb..688ecbee67 100644 --- a/src/features/cluster/sidebar-and-tab-navigation-for-extensions.test.tsx +++ b/src/features/cluster/sidebar-and-tab-navigation-for-extensions.test.tsx @@ -15,7 +15,7 @@ import pathExistsInjectable from "../../common/fs/path-exists.injectable"; import readJsonFileInjectable from "../../common/fs/read-json-file.injectable"; import { navigateToRouteInjectionToken } from "../../common/front-end-routing/navigate-to-route-injection-token"; import assert from "assert"; -import { advanceFakeTime, testUsingFakeTime } from "../../common/test-utils/use-fake-time"; +import { advanceFakeTime } from "../../common/test-utils/use-fake-time"; import type { IObservableValue } from "mobx"; import { runInAction, computed, observable } from "mobx"; import storageSaveDelayInjectable from "../../renderer/utils/create-storage/storage-save-delay.injectable"; @@ -27,9 +27,11 @@ describe("cluster - sidebar and tab navigation for extensions", () => { let rendered: RenderResult; beforeEach(() => { - testUsingFakeTime("2015-10-21T07:28:00Z"); - - applicationBuilder = getApplicationBuilder(); + applicationBuilder = getApplicationBuilder({ + useFakeTime: { + dateTime: "2015-10-21T07:28:00Z", + }, + }); applicationBuilder.setEnvironmentToClusterFrame(); diff --git a/src/features/cluster/workloads/overview/extension-api/__snapshots__/disable-workloads-overview-details-when-cluster-is-not-relevant.test.tsx.snap b/src/features/cluster/workloads/overview/extension-api/__snapshots__/disable-workloads-overview-details-when-cluster-is-not-relevant.test.tsx.snap index 1b29e79e6b..88336b2d92 100644 --- a/src/features/cluster/workloads/overview/extension-api/__snapshots__/disable-workloads-overview-details-when-cluster-is-not-relevant.test.tsx.snap +++ b/src/features/cluster/workloads/overview/extension-api/__snapshots__/disable-workloads-overview-details-when-cluster-is-not-relevant.test.tsx.snap @@ -3,44 +3,6 @@ exports[`disable workloads overview details when cluster is not relevant given extension should be enabled for the cluster renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -558,44 +520,6 @@ exports[`disable workloads overview details when cluster is not relevant given e exports[`disable workloads overview details when cluster is not relevant given extension shouldn't be enabled for the cluster renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
diff --git a/src/features/helm-charts/add-custom-helm-repository-in-preferences.test.ts b/src/features/helm-charts/add-custom-helm-repository-in-preferences.test.ts index 495d2e9fb3..1b9e304005 100644 --- a/src/features/helm-charts/add-custom-helm-repository-in-preferences.test.ts +++ b/src/features/helm-charts/add-custom-helm-repository-in-preferences.test.ts @@ -18,7 +18,6 @@ import isPathInjectable from "../../renderer/components/input/validators/is-path import showSuccessNotificationInjectable from "../../renderer/components/notifications/show-success-notification.injectable"; import showErrorNotificationInjectable from "../../renderer/components/notifications/show-error-notification.injectable"; import type { AsyncResult } from "../../common/utils/async-result"; -import { testUsingFakeTime } from "../../common/test-utils/use-fake-time"; describe("add custom helm repository in preferences", () => { let builder: ApplicationBuilder; @@ -29,11 +28,11 @@ describe("add custom helm repository in preferences", () => { let getActiveHelmRepositoriesMock: AsyncFnMock<() => Promise>>; beforeEach(async () => { - jest.useFakeTimers(); - - builder = getApplicationBuilder(); - - testUsingFakeTime("2021-01-01 12:00:00"); + builder = getApplicationBuilder({ + useFakeTime: { + dateTime: "2021-01-01 12:00:00", + }, + }); execFileMock = asyncFn(); getActiveHelmRepositoriesMock = asyncFn(); diff --git a/src/features/helm-charts/installing-chart/__snapshots__/installing-helm-chart-from-new-tab.test.ts.snap b/src/features/helm-charts/installing-chart/__snapshots__/installing-helm-chart-from-new-tab.test.ts.snap index 1e47ed84e1..1e63a80e12 100644 --- a/src/features/helm-charts/installing-chart/__snapshots__/installing-helm-chart-from-new-tab.test.ts.snap +++ b/src/features/helm-charts/installing-chart/__snapshots__/installing-helm-chart-from-new-tab.test.ts.snap @@ -472,44 +472,6 @@ exports[`installing helm chart from new tab given tab for installing chart was n exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -1425,44 +1387,6 @@ exports[`installing helm chart from new tab given tab for installing chart was n exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -2223,44 +2147,6 @@ exports[`installing helm chart from new tab given tab for installing chart was n exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given changing version to be installed renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -3265,44 +3151,6 @@ exports[`installing helm chart from new tab given tab for installing chart was n exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given changing version to be installed when version is selected renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -4281,44 +4129,6 @@ exports[`installing helm chart from new tab given tab for installing chart was n exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given changing version to be installed when version is selected when default configuration resolves renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -5292,44 +5102,6 @@ exports[`installing helm chart from new tab given tab for installing chart was n exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given custom name is inputted renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -6303,44 +6075,6 @@ exports[`installing helm chart from new tab given tab for installing chart was n exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given invalid change in configuration renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -7336,44 +7070,6 @@ exports[`installing helm chart from new tab given tab for installing chart was n exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given namespace selection is opened renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -8378,44 +8074,6 @@ exports[`installing helm chart from new tab given tab for installing chart was n exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given namespace selection is opened when namespace is selected renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -9389,44 +9047,6 @@ exports[`installing helm chart from new tab given tab for installing chart was n exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given no changes in configuration, when installing the chart renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -10408,44 +10028,6 @@ exports[`installing helm chart from new tab given tab for installing chart was n exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given no changes in configuration, when installing the chart when installation resolves renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -11239,44 +10821,6 @@ exports[`installing helm chart from new tab given tab for installing chart was n exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given no changes in configuration, when installing the chart when installation resolves when selected to see the installed release renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -12052,44 +11596,6 @@ exports[`installing helm chart from new tab given tab for installing chart was n exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given no changes in configuration, when installing the chart when installation resolves when selected to show execution output renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -12990,44 +12496,6 @@ exports[`installing helm chart from new tab given tab for installing chart was n exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given opening details for second chart, when details resolve renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -14247,44 +13715,6 @@ exports[`installing helm chart from new tab given tab for installing chart was n exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given opening details for second chart, when details resolve when selecting to install second chart renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -15097,44 +14527,6 @@ exports[`installing helm chart from new tab given tab for installing chart was n exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given opening details for second chart, when details resolve when selecting to install second chart when configuration and versions resolve renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -16162,44 +15554,6 @@ exports[`installing helm chart from new tab given tab for installing chart was n exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given opening details for second chart, when details resolve when selecting to install second chart when configuration and versions resolve when selecting the dock tab for installing first chart renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -17225,44 +16579,6 @@ exports[`installing helm chart from new tab given tab for installing chart was n exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given valid change in configuration renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -18236,44 +17552,6 @@ exports[`installing helm chart from new tab given tab for installing chart was n exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -19247,44 +18525,6 @@ exports[`installing helm chart from new tab given tab for installing chart was n exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve when cancelled renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
diff --git a/src/features/helm-charts/installing-chart/__snapshots__/installing-helm-chart-from-previously-opened-tab.test.ts.snap b/src/features/helm-charts/installing-chart/__snapshots__/installing-helm-chart-from-previously-opened-tab.test.ts.snap index 7636ade12e..e865fbd42f 100644 --- a/src/features/helm-charts/installing-chart/__snapshots__/installing-helm-chart-from-previously-opened-tab.test.ts.snap +++ b/src/features/helm-charts/installing-chart/__snapshots__/installing-helm-chart-from-previously-opened-tab.test.ts.snap @@ -563,44 +563,6 @@ exports[`installing helm chart from previously opened tab given tab for installi exports[`installing helm chart from previously opened tab given tab for installing chart was previously opened, when application is started when configuration and version resolves renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
diff --git a/src/features/helm-charts/installing-chart/__snapshots__/opening-dock-tab-for-installing-helm-chart.test.ts.snap b/src/features/helm-charts/installing-chart/__snapshots__/opening-dock-tab-for-installing-helm-chart.test.ts.snap index de1103cdc7..29919cf55b 100644 --- a/src/features/helm-charts/installing-chart/__snapshots__/opening-dock-tab-for-installing-helm-chart.test.ts.snap +++ b/src/features/helm-charts/installing-chart/__snapshots__/opening-dock-tab-for-installing-helm-chart.test.ts.snap @@ -540,44 +540,6 @@ exports[`opening dock tab for installing helm chart given application is started exports[`opening dock tab for installing helm chart given application is started, when navigating to helm charts when charts resolve renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -1247,44 +1209,6 @@ exports[`opening dock tab for installing helm chart given application is started exports[`opening dock tab for installing helm chart given application is started, when navigating to helm charts when charts resolve when opening details of a chart renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -2011,44 +1935,6 @@ exports[`opening dock tab for installing helm chart given application is started exports[`opening dock tab for installing helm chart given application is started, when navigating to helm charts when charts resolve when opening details of a chart when chart versions resolve renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -2958,44 +2844,6 @@ exports[`opening dock tab for installing helm chart given application is started exports[`opening dock tab for installing helm chart given application is started, when navigating to helm charts when charts resolve when opening details of a chart when chart versions resolve when readme resolves renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -3915,44 +3763,6 @@ exports[`opening dock tab for installing helm chart given application is started exports[`opening dock tab for installing helm chart given application is started, when navigating to helm charts when charts resolve when opening details of a chart when chart versions resolve when readme resolves when selecting different version renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -4862,44 +4672,6 @@ exports[`opening dock tab for installing helm chart given application is started exports[`opening dock tab for installing helm chart given application is started, when navigating to helm charts when charts resolve when opening details of a chart when chart versions resolve when readme resolves when selecting different version when readme rejects renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -5813,44 +5585,6 @@ exports[`opening dock tab for installing helm chart given application is started exports[`opening dock tab for installing helm chart given application is started, when navigating to helm charts when charts resolve when opening details of a chart when chart versions resolve when readme resolves when selecting different version when readme resolves renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -6770,44 +6504,6 @@ exports[`opening dock tab for installing helm chart given application is started exports[`opening dock tab for installing helm chart given application is started, when navigating to helm charts when charts resolve when opening details of a chart when chart versions resolve when readme resolves when selecting to install the chart renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
diff --git a/src/features/helm-charts/upgrade-chart/__snapshots__/upgrade-chart-new-tab.test.ts.snap b/src/features/helm-charts/upgrade-chart/__snapshots__/upgrade-chart-new-tab.test.ts.snap index 9e3eaf6f93..4e71769f94 100644 --- a/src/features/helm-charts/upgrade-chart/__snapshots__/upgrade-chart-new-tab.test.ts.snap +++ b/src/features/helm-charts/upgrade-chart/__snapshots__/upgrade-chart-new-tab.test.ts.snap @@ -703,44 +703,6 @@ exports[`New Upgrade Helm Chart Dock Tab given a namespace is selected when navi exports[`New Upgrade Helm Chart Dock Tab given a namespace is selected when navigating to the helm releases view when helm releases resolves renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -1506,44 +1468,6 @@ exports[`New Upgrade Helm Chart Dock Tab given a namespace is selected when navi exports[`New Upgrade Helm Chart Dock Tab given a namespace is selected when navigating to the helm releases view when helm releases resolves when clicking the menu for a helm release renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
diff --git a/src/features/helm-charts/upgrade-chart/upgrade-chart-new-tab.test.ts b/src/features/helm-charts/upgrade-chart/upgrade-chart-new-tab.test.ts index 7d46856fec..7fb6234466 100644 --- a/src/features/helm-charts/upgrade-chart/upgrade-chart-new-tab.test.ts +++ b/src/features/helm-charts/upgrade-chart/upgrade-chart-new-tab.test.ts @@ -17,7 +17,7 @@ import type { RequestHelmReleaseConfiguration } from "../../../common/k8s-api/en import requestHelmReleaseConfigurationInjectable from "../../../common/k8s-api/endpoints/helm-releases.api/request-configuration.injectable"; import type { RequestHelmReleases } from "../../../common/k8s-api/endpoints/helm-releases.api/request-releases.injectable"; import requestHelmReleasesInjectable from "../../../common/k8s-api/endpoints/helm-releases.api/request-releases.injectable"; -import { advanceFakeTime, testUsingFakeTime } from "../../../common/test-utils/use-fake-time"; +import { advanceFakeTime } from "../../../common/test-utils/use-fake-time"; import dockStoreInjectable from "../../../renderer/components/dock/dock/store.injectable"; import type { ApplicationBuilder } from "../../../renderer/components/test-utils/get-application-builder"; import { getApplicationBuilder } from "../../../renderer/components/test-utils/get-application-builder"; @@ -32,7 +32,11 @@ describe("New Upgrade Helm Chart Dock Tab", () => { let navigateToHelmReleases: NavigateToHelmReleases; beforeEach(async () => { - builder = getApplicationBuilder(); + builder = getApplicationBuilder({ + useFakeTime: { + dateTime: "2020-01-12 12:00:00", + }, + }); builder.setEnvironmentToClusterFrame(); builder.beforeWindowStart((windowDi) => { @@ -51,8 +55,6 @@ describe("New Upgrade Helm Chart Dock Tab", () => { navigateToHelmReleases = windowDi.inject(navigateToHelmReleasesInjectable); }); - testUsingFakeTime("2020-01-12 12:00:00"); - builder.namespaces.add("my-first-namespace"); builder.namespaces.add("my-second-namespace"); diff --git a/src/features/helm-releases/__snapshots__/showing-details-for-helm-release.test.ts.snap b/src/features/helm-releases/__snapshots__/showing-details-for-helm-release.test.ts.snap index 86e80acc4c..cb894fd66b 100644 --- a/src/features/helm-releases/__snapshots__/showing-details-for-helm-release.test.ts.snap +++ b/src/features/helm-releases/__snapshots__/showing-details-for-helm-release.test.ts.snap @@ -784,44 +784,6 @@ exports[`showing details for helm release given application is started when navi exports[`showing details for helm release given application is started when navigating to helm releases when releases resolve but there is none, renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -1570,44 +1532,6 @@ exports[`showing details for helm release given application is started when navi exports[`showing details for helm release given application is started when navigating to helm releases when releases resolve renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -2546,44 +2470,6 @@ exports[`showing details for helm release given application is started when navi exports[`showing details for helm release given application is started when navigating to helm releases when releases resolve when selecting release to see details renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -3583,44 +3469,6 @@ exports[`showing details for helm release given application is started when navi exports[`showing details for helm release given application is started when navigating to helm releases when releases resolve when selecting release to see details when call for release resolve with release renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -4620,44 +4468,6 @@ exports[`showing details for helm release given application is started when navi exports[`showing details for helm release given application is started when navigating to helm releases when releases resolve when selecting release to see details when call for release resolve with release when configuration resolves renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -5902,44 +5712,6 @@ exports[`showing details for helm release given application is started when navi exports[`showing details for helm release given application is started when navigating to helm releases when releases resolve when selecting release to see details when call for release resolve with release when configuration resolves when changing the configuration renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -7184,44 +6956,6 @@ exports[`showing details for helm release given application is started when navi exports[`showing details for helm release given application is started when navigating to helm releases when releases resolve when selecting release to see details when call for release resolve with release when configuration resolves when changing the configuration when saving renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -8466,44 +8200,6 @@ exports[`showing details for helm release given application is started when navi exports[`showing details for helm release given application is started when navigating to helm releases when releases resolve when selecting release to see details when call for release resolve with release when configuration resolves when changing the configuration when saving when requestHelmCharts resolves when requestHelmChartVersions resolves when update resolves with failure renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -9553,44 +9249,6 @@ exports[`showing details for helm release given application is started when navi exports[`showing details for helm release given application is started when navigating to helm releases when releases resolve when selecting release to see details when call for release resolve with release when configuration resolves when changing the configuration when saving when requestHelmCharts resolves when requestHelmChartVersions resolves when update resolves with success renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -10642,44 +10300,6 @@ exports[`showing details for helm release given application is started when navi exports[`showing details for helm release given application is started when navigating to helm releases when releases resolve when selecting release to see details when call for release resolve with release when configuration resolves when changing the configuration when toggling to see only user defined values when configuration resolves renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -11924,44 +11544,6 @@ exports[`showing details for helm release given application is started when navi exports[`showing details for helm release given application is started when navigating to helm releases when releases resolve when selecting release to see details when call for release resolve with release when configuration resolves when selecting to upgrade chart renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -12961,44 +12543,6 @@ exports[`showing details for helm release given application is started when navi exports[`showing details for helm release given application is started when navigating to helm releases when releases resolve when selecting release to see details when call for release resolves with error renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -14001,44 +13545,6 @@ exports[`showing details for helm release given application is started when navi exports[`showing details for helm release given application is started when navigating to helm releases when releases resolve when selecting release to see details when details is closed renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -14977,44 +14483,6 @@ exports[`showing details for helm release given application is started when navi exports[`showing details for helm release given application is started when navigating to helm releases when releases resolve when selecting release to see details when details is closed when opening details for same release renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
@@ -16014,44 +15482,6 @@ exports[`showing details for helm release given application is started when navi exports[`showing details for helm release given application is started when navigating to helm releases when releases resolve when selecting release to see details when opening details for second release renders 1`] = `
-
-
-
-
- -
- - - close - - -
- Close -
-
-
-
-
-
diff --git a/src/features/helm-releases/showing-details-for-helm-release.test.ts b/src/features/helm-releases/showing-details-for-helm-release.test.ts index 9294b3057e..6d379f5a76 100644 --- a/src/features/helm-releases/showing-details-for-helm-release.test.ts +++ b/src/features/helm-releases/showing-details-for-helm-release.test.ts @@ -15,7 +15,6 @@ import type { RequestHelmReleaseConfiguration } from "../../common/k8s-api/endpo import requestHelmReleaseConfigurationInjectable from "../../common/k8s-api/endpoints/helm-releases.api/request-configuration.injectable"; import type { RequestHelmReleaseUpdate } from "../../common/k8s-api/endpoints/helm-releases.api/request-update.injectable"; import requestHelmReleaseUpdateInjectable from "../../common/k8s-api/endpoints/helm-releases.api/request-update.injectable"; -import { testUsingFakeTime } from "../../common/test-utils/use-fake-time"; import type { RequestDetailedHelmRelease } from "../../renderer/components/+helm-releases/release-details/release-details-model/request-detailed-helm-release.injectable"; import requestDetailedHelmReleaseInjectable from "../../renderer/components/+helm-releases/release-details/release-details-model/request-detailed-helm-release.injectable"; import showSuccessNotificationInjectable from "../../renderer/components/notifications/show-success-notification.injectable"; @@ -45,9 +44,11 @@ describe("showing details for helm release", () => { let showCheckedErrorNotificationMock: jest.Mock; beforeEach(() => { - testUsingFakeTime("2015-10-21T07:28:00Z"); - - builder = getApplicationBuilder(); + builder = getApplicationBuilder({ + useFakeTime: { + dateTime: "2015-10-21T07:28:00Z", + }, + }); builder.setEnvironmentToClusterFrame(); diff --git a/src/features/quitting-and-restarting-the-app/quitting-the-app-using-application-menu.test.ts b/src/features/quitting-and-restarting-the-app/quitting-the-app-using-application-menu.test.ts index 4777a920f9..5ca643d63e 100644 --- a/src/features/quitting-and-restarting-the-app/quitting-the-app-using-application-menu.test.ts +++ b/src/features/quitting-and-restarting-the-app/quitting-the-app-using-application-menu.test.ts @@ -9,7 +9,7 @@ import type { ClusterManager } from "../../main/cluster/manager"; import exitAppInjectable from "../../main/electron-app/features/exit-app.injectable"; import clusterManagerInjectable from "../../main/cluster/manager.injectable"; import stopServicesAndExitAppInjectable from "../../main/stop-services-and-exit-app.injectable"; -import { advanceFakeTime, testUsingFakeTime } from "../../common/test-utils/use-fake-time"; +import { advanceFakeTime } from "../../common/test-utils/use-fake-time"; describe("quitting the app using application menu", () => { describe("given application has started", () => { @@ -18,9 +18,11 @@ describe("quitting the app using application menu", () => { let exitAppMock: jest.Mock; beforeEach(async () => { - testUsingFakeTime("2015-10-21T07:28:00Z"); - - builder = getApplicationBuilder(); + builder = getApplicationBuilder({ + useFakeTime: { + dateTime: "2015-10-21T07:28:00Z", + }, + }); builder.beforeApplicationStart( (mainDi) => { diff --git a/src/renderer/components/countdown/countdown.test.tsx b/src/renderer/components/countdown/countdown.test.tsx index 6a84e6970e..146fef2512 100644 --- a/src/renderer/components/countdown/countdown.test.tsx +++ b/src/renderer/components/countdown/countdown.test.tsx @@ -20,7 +20,9 @@ describe("countdown", () => { let render: DiRender; beforeEach(() => { - testUsingFakeTime("2015-10-21T07:28:00Z"); + testUsingFakeTime({ + dateTime: "2015-10-21T07:28:00Z", + }); di = createContainer("irrelevant"); diff --git a/src/renderer/components/render-delay/__tests__/render-delay.test.tsx b/src/renderer/components/render-delay/__tests__/render-delay.test.tsx index e83bee28c0..0458a871a4 100644 --- a/src/renderer/components/render-delay/__tests__/render-delay.test.tsx +++ b/src/renderer/components/render-delay/__tests__/render-delay.test.tsx @@ -21,7 +21,9 @@ describe("", () => { render = renderFor(di); - testUsingFakeTime("2020-01-17 12:18:19"); + testUsingFakeTime({ + dateTime: "2020-01-17 12:18:19", + }); di.override(cancelIdleCallbackInjectable, () => clearTimeout); di.override(requestIdleCallbackInjectable, () => (callback, opts) => setTimeout(callback, opts.timeout) as any); diff --git a/src/renderer/components/test-utils/get-application-builder.tsx b/src/renderer/components/test-utils/get-application-builder.tsx index 196fcb817a..43f0bdeea5 100644 --- a/src/renderer/components/test-utils/get-application-builder.tsx +++ b/src/renderer/components/test-utils/get-application-builder.tsx @@ -67,6 +67,7 @@ import shouldStartHiddenInjectable from "../../../main/electron-app/features/sho import fsInjectable from "../../../common/fs/fs.injectable"; import joinPathsInjectable from "../../../common/path/join-paths.injectable"; import homeDirectoryPathInjectable from "../../../common/os/home-directory-path.injectable"; +import type { TestUsingFakeTimeOptions } from "../../../common/test-utils/use-fake-time"; import { testUsingFakeTime } from "../../../common/test-utils/use-fake-time"; import type { LensFetch } from "../../../common/fetch/lens-fetch.injectable"; import lensFetchInjectable from "../../../common/fetch/lens-fetch.injectable"; @@ -163,7 +164,11 @@ interface Environment { onAllowKubeResource: () => void; } -export const getApplicationBuilder = () => { +export interface ApplicationBuilderOptions { + useFakeTime?: boolean | TestUsingFakeTimeOptions; +} + +export const getApplicationBuilder = ({ useFakeTime = true }: ApplicationBuilderOptions = {}) => { const mainDi = getMainDi({ doGeneralOverrides: true, }); @@ -172,7 +177,11 @@ export const getApplicationBuilder = () => { mainDi.register(mainExtensionsStateInjectable); }); - testUsingFakeTime(); + if (useFakeTime === true) { + testUsingFakeTime(); + } else if (useFakeTime) { + testUsingFakeTime(useFakeTime); + } const { overrideForWindow, sendToWindow } = overrideChannels(mainDi); diff --git a/src/renderer/frames/cluster-frame/cluster-frame.test.tsx b/src/renderer/frames/cluster-frame/cluster-frame.test.tsx index c403ad6b49..811e82d56f 100644 --- a/src/renderer/frames/cluster-frame/cluster-frame.test.tsx +++ b/src/renderer/frames/cluster-frame/cluster-frame.test.tsx @@ -47,7 +47,9 @@ describe("", () => { di.override(storesAndApisCanBeCreatedInjectable, () => true); di.override(currentlyInClusterFrameInjectable, () => true); - testUsingFakeTime("2000-01-01 12:00:00am"); + testUsingFakeTime({ + dateTime: "2000-01-01 12:00:00am", + }); const createCluster = di.inject(createClusterInjectable);