1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

fixed tests

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
Jim Ehrismann 2022-06-29 11:20:01 -04:00
parent f03cb6457a
commit b5488e651e
30 changed files with 383 additions and 133 deletions

View File

@ -56,7 +56,9 @@ exports[`extension special characters in page registrations renders 1`] = `
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -127,7 +129,9 @@ exports[`extension special characters in page registrations when navigating to r
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -56,7 +56,9 @@ exports[`navigate to extension page renders 1`] = `
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -127,7 +129,9 @@ exports[`navigate to extension page when extension navigates to child route rend
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -201,7 +205,9 @@ exports[`navigate to extension page when extension navigates to route with param
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -291,7 +297,9 @@ exports[`navigate to extension page when extension navigates to route without pa
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -381,7 +389,9 @@ exports[`navigate to extension page when extension navigates to route without pa
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -56,7 +56,9 @@ exports[`navigating between routes given route with optional path parameters whe
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -133,7 +135,9 @@ exports[`navigating between routes given route without path parameters when navi
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -56,7 +56,9 @@ exports[`add-cluster - navigation using application menu renders 1`] = `
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -127,7 +129,9 @@ exports[`add-cluster - navigation using application menu when navigating to add
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -57,7 +57,9 @@ exports[`installing update using tray when started renders 1`] = `
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -133,7 +135,9 @@ exports[`installing update using tray when started when user checks for updates
<div
class="Spinner singleColor"
/>
<div>
<div
data-testid="auto-update-component"
>
Checking for updates...
</div>
</div>
@ -247,8 +251,10 @@ exports[`installing update using tray when started when user checks for updates
<div
class="item"
>
<div>
Download for version some-version started
<div
data-testid="auto-update-component"
>
Download for version some-version started...
</div>
<div
class="Spinner singleColor"
@ -422,8 +428,10 @@ exports[`installing update using tray when started when user checks for updates
<div
class="item"
>
<div>
No new updates available
<div
data-testid="auto-update-component"
>
Download of update failed
</div>
</div>
</div>
@ -634,7 +642,9 @@ exports[`installing update using tray when started when user checks for updates
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
some-version is available
</div>
</div>
@ -788,7 +798,9 @@ exports[`installing update using tray when started when user checks for updates
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -57,7 +57,9 @@ exports[`installing update when started renders 1`] = `
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -133,7 +135,9 @@ exports[`installing update when started when user checks for updates renders 1`]
<div
class="Spinner singleColor"
/>
<div>
<div
data-testid="auto-update-component"
>
Checking for updates...
</div>
</div>
@ -206,8 +210,10 @@ exports[`installing update when started when user checks for updates when new up
<div
class="item"
>
<div>
Download for version some-version started
<div
data-testid="auto-update-component"
>
Download for version some-version started...
</div>
<div
class="Spinner singleColor"
@ -300,8 +306,10 @@ exports[`installing update when started when user checks for updates when new up
<div
class="item"
>
<div>
No new updates available
<div
data-testid="auto-update-component"
>
Download of update failed
</div>
</div>
</div>
@ -391,7 +399,9 @@ exports[`installing update when started when user checks for updates when new up
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
some-version is available
</div>
</div>
@ -464,7 +474,9 @@ exports[`installing update when started when user checks for updates when no new
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -57,7 +57,9 @@ exports[`periodical checking of updates given updater is enabled and configurati
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -57,7 +57,9 @@ exports[`selection of update stability when started renders 1`] = `
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -15,7 +15,12 @@ import asyncFn from "@async-fn/jest";
import type { DownloadPlatformUpdate } from "../../main/application-update/download-platform-update/download-platform-update.injectable";
import downloadPlatformUpdateInjectable from "../../main/application-update/download-platform-update/download-platform-update.injectable";
import setUpdateOnQuitInjectable from "../../main/electron-app/features/set-update-on-quit.injectable";
<<<<<<< HEAD
import showInfoNotificationInjectable from "../../renderer/components/notifications/show-info-notification.injectable";
=======
import type { AskBoolean } from "../../main/ask-boolean/ask-boolean.injectable";
import askBooleanInjectable from "../../main/ask-boolean/ask-boolean.injectable";
>>>>>>> 035dcaf34f (fixed tests)
import processCheckingForUpdatesInjectable from "../../main/application-update/check-for-updates/process-checking-for-updates.injectable";
describe("installing update", () => {
@ -24,20 +29,32 @@ describe("installing update", () => {
let checkForPlatformUpdatesMock: AsyncFnMock<CheckForPlatformUpdates>;
let downloadPlatformUpdateMock: AsyncFnMock<DownloadPlatformUpdate>;
let setUpdateOnQuitMock: jest.Mock;
<<<<<<< HEAD
let showInfoNotificationMock: jest.Mock;
=======
let askBooleanMock: AsyncFnMock<AskBoolean>;
>>>>>>> 035dcaf34f (fixed tests)
beforeEach(() => {
jest.useFakeTimers();
applicationBuilder = getApplicationBuilder();
applicationBuilder.beforeApplicationStart(({ mainDi, rendererDi }) => {
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
quitAndInstallUpdateMock = jest.fn();
checkForPlatformUpdatesMock = asyncFn();
downloadPlatformUpdateMock = asyncFn();
setUpdateOnQuitMock = jest.fn();
<<<<<<< HEAD
showInfoNotificationMock = jest.fn(() => () => {});
rendererDi.override(showInfoNotificationInjectable, () => showInfoNotificationMock);
=======
askBooleanMock = asyncFn();
mainDi.override(askBooleanInjectable, () => askBooleanMock);
>>>>>>> 035dcaf34f (fixed tests)
mainDi.override(setUpdateOnQuitInjectable, () => setUpdateOnQuitMock);
mainDi.override(
@ -98,8 +115,6 @@ describe("installing update", () => {
describe("when no new update is discovered", () => {
beforeEach(async () => {
showInfoNotificationMock.mockClear();
await checkForPlatformUpdatesMock.resolve({
updateWasDiscovered: false,
});
@ -108,7 +123,7 @@ describe("installing update", () => {
});
it("notifies the user", () => {
expect(showInfoNotificationMock).toHaveBeenCalledWith("No new updates available");
expect(rendered.getByTestId("auto-update-component")).toHaveTextContent("No new updates available");
});
it("does not start downloading update", () => {
@ -135,7 +150,7 @@ describe("installing update", () => {
});
it("notifies the user that download is happening", () => {
expect(showInfoNotificationMock).toHaveBeenCalledWith("Download for version some-version started...");
expect(rendered.getByTestId("auto-update-component")).toHaveTextContent("Download for version some-version started...");
});
it("renders", () => {
@ -152,7 +167,7 @@ describe("installing update", () => {
});
it("notifies the user about failed download", () => {
expect(showInfoNotificationMock).toHaveBeenCalledWith("Download of update failed");
expect(rendered.getByTestId("auto-update-component")).toHaveTextContent("Download of update failed");
});
it("renders", () => {
@ -169,6 +184,10 @@ describe("installing update", () => {
expect(quitAndInstallUpdateMock).not.toHaveBeenCalled();
});
it("notifies the user about successful download", () => {
expect(rendered.getByTestId("auto-update-component")).toHaveTextContent("some-version is available");
});
it("renders", () => {
expect(rendered.baseElement).toMatchSnapshot();
});

View File

@ -56,7 +56,9 @@ exports[`extensions - navigation using application menu renders 1`] = `
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -127,7 +129,9 @@ exports[`extensions - navigation using application menu when navigating to exten
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -57,7 +57,9 @@ exports[`add custom helm repository in preferences when navigating to preference
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -589,7 +591,9 @@ exports[`add custom helm repository in preferences when navigating to preference
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -1128,7 +1132,9 @@ exports[`add custom helm repository in preferences when navigating to preference
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -1776,7 +1782,9 @@ exports[`add custom helm repository in preferences when navigating to preference
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -2323,7 +2331,9 @@ exports[`add custom helm repository in preferences when navigating to preference
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -2971,7 +2981,9 @@ exports[`add custom helm repository in preferences when navigating to preference
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -3795,7 +3807,9 @@ exports[`add custom helm repository in preferences when navigating to preference
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -4442,7 +4456,11 @@ exports[`add custom helm repository in preferences when navigating to preference
>
<div
class="item"
/>
>
<div
data-testid="auto-update-component"
/>
</div>
</div>
<div
class="rightSide"
@ -5262,7 +5280,11 @@ exports[`add custom helm repository in preferences when navigating to preference
>
<div
class="item"
/>
>
<div
data-testid="auto-update-component"
/>
</div>
</div>
<div
class="rightSide"
@ -5906,7 +5928,11 @@ exports[`add custom helm repository in preferences when navigating to preference
>
<div
class="item"
/>
>
<div
data-testid="auto-update-component"
/>
</div>
</div>
<div
class="rightSide"
@ -6449,7 +6475,11 @@ exports[`add custom helm repository in preferences when navigating to preference
>
<div
class="item"
/>
>
<div
data-testid="auto-update-component"
/>
</div>
</div>
<div
class="rightSide"
@ -6985,7 +7015,11 @@ exports[`add custom helm repository in preferences when navigating to preference
>
<div
class="item"
/>
>
<div
data-testid="auto-update-component"
/>
</div>
</div>
<div
class="rightSide"

View File

@ -57,7 +57,9 @@ exports[`add helm repository from list in preferences when navigating to prefere
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -589,7 +591,9 @@ exports[`add helm repository from list in preferences when navigating to prefere
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -1128,7 +1132,9 @@ exports[`add helm repository from list in preferences when navigating to prefere
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -1720,7 +1726,9 @@ exports[`add helm repository from list in preferences when navigating to prefere
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -2259,7 +2267,9 @@ exports[`add helm repository from list in preferences when navigating to prefere
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -2798,7 +2808,9 @@ exports[`add helm repository from list in preferences when navigating to prefere
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -3330,7 +3342,9 @@ exports[`add helm repository from list in preferences when navigating to prefere
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -3899,7 +3913,9 @@ exports[`add helm repository from list in preferences when navigating to prefere
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -4531,7 +4547,9 @@ exports[`add helm repository from list in preferences when navigating to prefere
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -5100,7 +5118,9 @@ exports[`add helm repository from list in preferences when navigating to prefere
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -57,7 +57,9 @@ exports[`listing active helm repositories in preferences when navigating to pref
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -589,7 +591,9 @@ exports[`listing active helm repositories in preferences when navigating to pref
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -1121,7 +1125,9 @@ exports[`listing active helm repositories in preferences when navigating to pref
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -1545,7 +1551,9 @@ exports[`listing active helm repositories in preferences when navigating to pref
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -2077,7 +2085,9 @@ exports[`listing active helm repositories in preferences when navigating to pref
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -2501,7 +2511,9 @@ exports[`listing active helm repositories in preferences when navigating to pref
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -3033,7 +3045,9 @@ exports[`listing active helm repositories in preferences when navigating to pref
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -3602,7 +3616,9 @@ exports[`listing active helm repositories in preferences when navigating to pref
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -4026,7 +4042,9 @@ exports[`listing active helm repositories in preferences when navigating to pref
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -4450,7 +4468,9 @@ exports[`listing active helm repositories in preferences when navigating to pref
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -57,7 +57,9 @@ exports[`remove helm repository from list of active repositories in preferences
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -589,7 +591,9 @@ exports[`remove helm repository from list of active repositories in preferences
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -1128,7 +1132,9 @@ exports[`remove helm repository from list of active repositories in preferences
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -1667,7 +1673,9 @@ exports[`remove helm repository from list of active repositories in preferences
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -56,7 +56,9 @@ exports[`preferences - closing-preferences given accessing preferences directly
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -660,7 +662,9 @@ exports[`preferences - closing-preferences given accessing preferences directly
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -868,7 +872,9 @@ exports[`preferences - closing-preferences given accessing preferences directly
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -942,7 +948,9 @@ exports[`preferences - closing-preferences given accessing preferences directly
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -1016,7 +1024,9 @@ exports[`preferences - closing-preferences given already in a page and then navi
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -1620,7 +1630,9 @@ exports[`preferences - closing-preferences given already in a page and then navi
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -1828,7 +1840,9 @@ exports[`preferences - closing-preferences given already in a page and then navi
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -2036,7 +2050,9 @@ exports[`preferences - closing-preferences given already in a page and then navi
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -56,7 +56,9 @@ exports[`preferences - navigation to application preferences given in some child
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -324,7 +326,9 @@ exports[`preferences - navigation to application preferences given in some child
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -56,7 +56,9 @@ exports[`preferences - navigation to editor preferences given in preferences, wh
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -648,7 +650,9 @@ exports[`preferences - navigation to editor preferences given in preferences, wh
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -71,7 +71,9 @@ exports[`preferences - navigation to extension specific preferences given in pre
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -313,7 +315,9 @@ exports[`preferences - navigation to extension specific preferences given in pre
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -567,7 +571,9 @@ exports[`preferences - navigation to extension specific preferences given in pre
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -821,7 +827,9 @@ exports[`preferences - navigation to extension specific preferences given in pre
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -1098,7 +1106,9 @@ exports[`preferences - navigation to extension specific preferences given in pre
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -1690,7 +1700,9 @@ exports[`preferences - navigation to extension specific preferences given in pre
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -2317,7 +2329,9 @@ exports[`preferences - navigation to extension specific preferences given in pre
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -2583,7 +2597,9 @@ exports[`preferences - navigation to extension specific preferences given in pre
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -2794,7 +2810,9 @@ exports[`preferences - navigation to extension specific preferences when navigat
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -3036,7 +3054,9 @@ exports[`preferences - navigation to extension specific preferences when navigat
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -56,7 +56,9 @@ exports[`preferences - navigation to kubernetes preferences given in preferences
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -648,7 +650,9 @@ exports[`preferences - navigation to kubernetes preferences given in preferences
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -56,7 +56,9 @@ exports[`preferences - navigation to proxy preferences given in preferences, whe
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -648,7 +650,9 @@ exports[`preferences - navigation to proxy preferences given in preferences, whe
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -56,7 +56,9 @@ exports[`preferences - navigation to telemetry preferences given URL for Sentry
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -310,7 +312,9 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -902,7 +906,9 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -1506,7 +1512,9 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -1748,7 +1756,9 @@ exports[`preferences - navigation to telemetry preferences given no URL for Sent
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -56,7 +56,9 @@ exports[`preferences - navigation to terminal preferences given in preferences,
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -648,7 +650,9 @@ exports[`preferences - navigation to terminal preferences given in preferences,
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -56,7 +56,9 @@ exports[`preferences - navigation using application menu renders 1`] = `
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -127,7 +129,9 @@ exports[`preferences - navigation using application menu when navigating to pref
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -57,7 +57,9 @@ exports[`show-about-using-tray renders 1`] = `
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -130,7 +132,9 @@ exports[`show-about-using-tray when navigating using tray renders 1`] = `
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -56,7 +56,9 @@ exports[`welcome - navigation using application menu renders 1`] = `
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -127,7 +129,9 @@ exports[`welcome - navigation using application menu when navigating to welcome
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -9,6 +9,7 @@ import { syncBoxInjectionToken } from "../../utils/sync-box/sync-box-injection-t
export interface ProgressOfDownload {
percentage: number;
failed?: string;
}
export type ProgressOfUpdateDownload = SyncBox<ProgressOfDownload>;

View File

@ -38,6 +38,7 @@ const downloadUpdateInjectable = getInjectable({
runInAction(() => {
if (!downloadWasSuccessful) {
progressOfUpdateDownload.set({ percentage: 0, failed: "Download of update failed" });
discoveredVersionState.set(null);
}

View File

@ -12,7 +12,9 @@ exports[`ask-boolean given started when asking multiple questions renders 1`] =
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -177,7 +179,9 @@ exports[`ask-boolean given started when asking multiple questions when answering
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -274,7 +278,9 @@ exports[`ask-boolean given started when asking question renders 1`] = `
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -371,7 +377,9 @@ exports[`ask-boolean given started when asking question when user answers "no" r
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -399,7 +407,9 @@ exports[`ask-boolean given started when asking question when user answers "yes"
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>
@ -427,7 +437,9 @@ exports[`ask-boolean given started when asking question when user closes notific
<div
class="item"
>
<div>
<div
data-testid="auto-update-component"
>
No new updates available
</div>
</div>

View File

@ -44,33 +44,35 @@ const EndNote = ({ version, note }: EndNoteProps) => {
return note(version ?? "");
};
const DivWithTestId = (text: string) => <div data-testid="auto-update-component">{text}</div>;
const checking = () => (
<>
<Spinner/>
<div>{"Checking for updates..."}</div>
{DivWithTestId("Checking for updates..." )}
</>
);
const available = (version: string) => <div>{`${version ?? "Update"} is available`}</div>;
const available = (version: string) => DivWithTestId(`${version ?? "Update"} is available`);
const notAvailable = () => <div>{"No new updates available"}</div>;
const notAvailable = () => DivWithTestId("No new updates available");
const downloading = (version: string, percentDone: number) => {
if ( percentDone === 0 ) {
return (
<>
<div>{`Download for version ${version} started `}</div>
{DivWithTestId(`Download for version ${version} started...`)}
<Spinner/>
</>
);
}
return <div>{`Download for version ${version} ${percentDone}%...`}</div>;
return DivWithTestId(`Download for version ${version} ${percentDone}%...`);
};
const downloadSucceeded = (version: string) => <div>{`Download for version ${version} complete`}</div>;
const downloadFailed = (errMsg: string) => DivWithTestId(errMsg);
const idle = () => <></>;
const idle = () => DivWithTestId("");
export const NonInjectedAutoUpdateComponent = observer(({
@ -81,15 +83,13 @@ export const NonInjectedAutoUpdateComponent = observer(({
}: Dependencies) => {
const discoveredVersion = discoveredVersionState.value.get();
const { percentage, failed } = progressOfUpdateDownload.value.get();
if (downloadingUpdateState.value.get()) {
assert(discoveredVersion);
const roundedPercentage = Math.round(progressOfUpdateDownload.value.get().percentage);
if ( roundedPercentage > 99 ) {
return <EndNote note={downloadSucceeded} version={discoveredVersion.version} />;
}
const roundedPercentage = Math.round(percentage);
return downloading(discoveredVersion.version, roundedPercentage);
}
@ -102,6 +102,10 @@ export const NonInjectedAutoUpdateComponent = observer(({
return <EndNote note={available} version={discoveredVersion.version} />;
}
if ( failed ) {
return <EndNote note={downloadFailed} version={failed} />;
}
return <EndNote note={notAvailable} />;
});

View File

@ -4,15 +4,14 @@
*/
import { getInjectable } from "@ogre-tools/injectable";
import { computed } from "mobx";
import React from "react";
import { AutoUpdateComponent } from "./auto-update-status-bar-item";
import { AutoUpdateComponent } from "./auto-update-component";
import { statusBarItemInjectionToken } from "./status-bar-item-injection-token";
const autoUpdateStatusBarItemInjectable = getInjectable({
id: "quit-app-separator-tray-item",
instantiate: () => ({
component: () => <AutoUpdateComponent data-testid="auto-update-component" />,
component: AutoUpdateComponent,
position: "left" as const,
visible: computed(() => true),
}),