mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Remove 'Update Now' notification (#5750)
This commit is contained in:
parent
b9ae92add6
commit
a1f79092a5
@ -628,7 +628,7 @@ exports[`installing update using tray when started when user checks for updates
|
|||||||
>
|
>
|
||||||
<i
|
<i
|
||||||
class="Icon close material interactive focusable"
|
class="Icon close material interactive focusable"
|
||||||
data-testid="close-notification-for-notification_371"
|
data-testid="close-notification-for-notification_335"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@ -668,77 +668,7 @@ exports[`installing update using tray when started when user checks for updates
|
|||||||
>
|
>
|
||||||
<i
|
<i
|
||||||
class="Icon close material interactive focusable"
|
class="Icon close material interactive focusable"
|
||||||
data-testid="close-notification-for-notification_374"
|
data-testid="close-notification-for-notification_338"
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="close"
|
|
||||||
>
|
|
||||||
close
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="Animate opacity notification flex info enter"
|
|
||||||
style="--enter-duration: 100ms; --leave-duration: 100ms;"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="box"
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
class="Icon material focusable"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="info_outline"
|
|
||||||
>
|
|
||||||
info_outline
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="message box grow"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="flex column gaps"
|
|
||||||
data-testid="ask-boolean-some-irrelevant-random-id"
|
|
||||||
>
|
|
||||||
<b>
|
|
||||||
Update Available
|
|
||||||
</b>
|
|
||||||
<p>
|
|
||||||
Version some-version of Lens IDE is available and ready to be installed. Would you like to update now?
|
|
||||||
|
|
||||||
Lens should restart automatically, if it doesn't please restart manually. Installed extensions might require updating.
|
|
||||||
</p>
|
|
||||||
<div
|
|
||||||
class="flex gaps row align-left box grow"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
class="Button light"
|
|
||||||
data-testid="ask-boolean-some-irrelevant-random-id-button-yes"
|
|
||||||
type="button"
|
|
||||||
>
|
|
||||||
Yes
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
class="Button active outlined"
|
|
||||||
data-testid="ask-boolean-some-irrelevant-random-id-button-no"
|
|
||||||
type="button"
|
|
||||||
>
|
|
||||||
No
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="box"
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
class="Icon close material interactive focusable"
|
|
||||||
data-testid="close-notification-for-ask-boolean-for-some-irrelevant-random-id"
|
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
|
|||||||
@ -361,172 +361,6 @@ exports[`installing update when started when user checks for updates when new up
|
|||||||
</body>
|
</body>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`installing update when started when user checks for updates when new update is discovered when download succeeds when user answers not to install the update renders 1`] = `
|
|
||||||
<body>
|
|
||||||
<div>
|
|
||||||
<div
|
|
||||||
class="topBar"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="items"
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive focusable"
|
|
||||||
data-testid="home-button"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="home"
|
|
||||||
>
|
|
||||||
home
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive disabled focusable"
|
|
||||||
data-testid="history-back"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="arrow_back"
|
|
||||||
>
|
|
||||||
arrow_back
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive disabled focusable"
|
|
||||||
data-testid="history-forward"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="arrow_forward"
|
|
||||||
>
|
|
||||||
arrow_forward
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
<button
|
|
||||||
class="updateButton"
|
|
||||||
data-testid="update-button"
|
|
||||||
data-warning-level="light"
|
|
||||||
id="update-lens-button"
|
|
||||||
>
|
|
||||||
Update
|
|
||||||
<i
|
|
||||||
class="Icon icon material focusable"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="arrow_drop_down"
|
|
||||||
>
|
|
||||||
arrow_drop_down
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="items"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="StatusBar"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="leftSide"
|
|
||||||
/>
|
|
||||||
<div
|
|
||||||
class="rightSide"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="Notifications flex column align-flex-end"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`installing update when started when user checks for updates when new update is discovered when download succeeds when user answers to install the update renders 1`] = `
|
|
||||||
<body>
|
|
||||||
<div>
|
|
||||||
<div
|
|
||||||
class="topBar"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="items"
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive focusable"
|
|
||||||
data-testid="home-button"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="home"
|
|
||||||
>
|
|
||||||
home
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive disabled focusable"
|
|
||||||
data-testid="history-back"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="arrow_back"
|
|
||||||
>
|
|
||||||
arrow_back
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive disabled focusable"
|
|
||||||
data-testid="history-forward"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="arrow_forward"
|
|
||||||
>
|
|
||||||
arrow_forward
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
<button
|
|
||||||
class="updateButton"
|
|
||||||
data-testid="update-button"
|
|
||||||
data-warning-level="light"
|
|
||||||
id="update-lens-button"
|
|
||||||
>
|
|
||||||
Update
|
|
||||||
<i
|
|
||||||
class="Icon icon material focusable"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="arrow_drop_down"
|
|
||||||
>
|
|
||||||
arrow_drop_down
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="items"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="StatusBar"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="leftSide"
|
|
||||||
/>
|
|
||||||
<div
|
|
||||||
class="rightSide"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="Notifications flex column align-flex-end"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`installing update when started when user checks for updates when no new update is discovered renders 1`] = `
|
exports[`installing update when started when user checks for updates when no new update is discovered renders 1`] = `
|
||||||
<body>
|
<body>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@ -15,8 +15,6 @@ import asyncFn from "@async-fn/jest";
|
|||||||
import type { DownloadPlatformUpdate } from "../../main/application-update/download-platform-update/download-platform-update.injectable";
|
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 downloadPlatformUpdateInjectable from "../../main/application-update/download-platform-update/download-platform-update.injectable";
|
||||||
import setUpdateOnQuitInjectable from "../../main/electron-app/features/set-update-on-quit.injectable";
|
import setUpdateOnQuitInjectable from "../../main/electron-app/features/set-update-on-quit.injectable";
|
||||||
import type { AskBoolean } from "../../main/ask-boolean/ask-boolean.injectable";
|
|
||||||
import askBooleanInjectable from "../../main/ask-boolean/ask-boolean.injectable";
|
|
||||||
import showInfoNotificationInjectable from "../../renderer/components/notifications/show-info-notification.injectable";
|
import showInfoNotificationInjectable from "../../renderer/components/notifications/show-info-notification.injectable";
|
||||||
import processCheckingForUpdatesInjectable from "../../main/application-update/check-for-updates/process-checking-for-updates.injectable";
|
import processCheckingForUpdatesInjectable from "../../main/application-update/check-for-updates/process-checking-for-updates.injectable";
|
||||||
|
|
||||||
@ -27,7 +25,6 @@ describe("installing update", () => {
|
|||||||
let downloadPlatformUpdateMock: AsyncFnMock<DownloadPlatformUpdate>;
|
let downloadPlatformUpdateMock: AsyncFnMock<DownloadPlatformUpdate>;
|
||||||
let setUpdateOnQuitMock: jest.Mock;
|
let setUpdateOnQuitMock: jest.Mock;
|
||||||
let showInfoNotificationMock: jest.Mock;
|
let showInfoNotificationMock: jest.Mock;
|
||||||
let askBooleanMock: AsyncFnMock<AskBoolean>;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
applicationBuilder = getApplicationBuilder();
|
applicationBuilder = getApplicationBuilder();
|
||||||
@ -38,11 +35,9 @@ describe("installing update", () => {
|
|||||||
downloadPlatformUpdateMock = asyncFn();
|
downloadPlatformUpdateMock = asyncFn();
|
||||||
setUpdateOnQuitMock = jest.fn();
|
setUpdateOnQuitMock = jest.fn();
|
||||||
showInfoNotificationMock = jest.fn(() => () => {});
|
showInfoNotificationMock = jest.fn(() => () => {});
|
||||||
askBooleanMock = asyncFn();
|
|
||||||
|
|
||||||
rendererDi.override(showInfoNotificationInjectable, () => showInfoNotificationMock);
|
rendererDi.override(showInfoNotificationInjectable, () => showInfoNotificationMock);
|
||||||
|
|
||||||
mainDi.override(askBooleanInjectable, () => askBooleanMock);
|
|
||||||
mainDi.override(setUpdateOnQuitInjectable, () => setUpdateOnQuitMock);
|
mainDi.override(setUpdateOnQuitInjectable, () => setUpdateOnQuitMock);
|
||||||
|
|
||||||
mainDi.override(
|
mainDi.override(
|
||||||
@ -160,10 +155,6 @@ describe("installing update", () => {
|
|||||||
expect(showInfoNotificationMock).toHaveBeenCalledWith("Download of update failed");
|
expect(showInfoNotificationMock).toHaveBeenCalledWith("Download of update failed");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not ask user to install update", () => {
|
|
||||||
expect(askBooleanMock).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("renders", () => {
|
it("renders", () => {
|
||||||
expect(rendered.baseElement).toMatchSnapshot();
|
expect(rendered.baseElement).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
@ -181,43 +172,6 @@ describe("installing update", () => {
|
|||||||
it("renders", () => {
|
it("renders", () => {
|
||||||
expect(rendered.baseElement).toMatchSnapshot();
|
expect(rendered.baseElement).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("asks user to install update immediately", () => {
|
|
||||||
expect(askBooleanMock).toHaveBeenCalledWith({
|
|
||||||
title: "Update Available",
|
|
||||||
question:
|
|
||||||
"Version some-version of Lens IDE is available and ready to be installed. Would you like to update now?\n\n" +
|
|
||||||
"Lens should restart automatically, if it doesn't please restart manually. Installed extensions might require updating.",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("when user answers to install the update", () => {
|
|
||||||
beforeEach(async () => {
|
|
||||||
await askBooleanMock.resolve(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("renders", () => {
|
|
||||||
expect(rendered.baseElement).toMatchSnapshot();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("quits application and installs the update", () => {
|
|
||||||
expect(quitAndInstallUpdateMock).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("when user answers not to install the update", () => {
|
|
||||||
beforeEach(async () => {
|
|
||||||
await askBooleanMock.resolve(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("renders", () => {
|
|
||||||
expect(rendered.baseElement).toMatchSnapshot();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("does not quit application and install the update", () => {
|
|
||||||
expect(quitAndInstallUpdateMock).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -19,8 +19,6 @@ import downloadPlatformUpdateInjectable from "../../main/application-update/down
|
|||||||
import selectedUpdateChannelInjectable from "../../common/application-update/selected-update-channel/selected-update-channel.injectable";
|
import selectedUpdateChannelInjectable from "../../common/application-update/selected-update-channel/selected-update-channel.injectable";
|
||||||
import type { IComputedValue } from "mobx";
|
import type { IComputedValue } from "mobx";
|
||||||
import setUpdateOnQuitInjectable from "../../main/electron-app/features/set-update-on-quit.injectable";
|
import setUpdateOnQuitInjectable from "../../main/electron-app/features/set-update-on-quit.injectable";
|
||||||
import type { AskBoolean } from "../../main/ask-boolean/ask-boolean.injectable";
|
|
||||||
import askBooleanInjectable from "../../main/ask-boolean/ask-boolean.injectable";
|
|
||||||
import showInfoNotificationInjectable from "../../renderer/components/notifications/show-info-notification.injectable";
|
import showInfoNotificationInjectable from "../../renderer/components/notifications/show-info-notification.injectable";
|
||||||
import processCheckingForUpdatesInjectable from "../../main/application-update/check-for-updates/process-checking-for-updates.injectable";
|
import processCheckingForUpdatesInjectable from "../../main/application-update/check-for-updates/process-checking-for-updates.injectable";
|
||||||
import appVersionInjectable from "../../common/get-configuration-file-model/app-version/app-version.injectable";
|
import appVersionInjectable from "../../common/get-configuration-file-model/app-version/app-version.injectable";
|
||||||
@ -32,7 +30,6 @@ describe("selection of update stability", () => {
|
|||||||
let downloadPlatformUpdateMock: AsyncFnMock<DownloadPlatformUpdate>;
|
let downloadPlatformUpdateMock: AsyncFnMock<DownloadPlatformUpdate>;
|
||||||
let setUpdateOnQuitMock: jest.Mock;
|
let setUpdateOnQuitMock: jest.Mock;
|
||||||
let showInfoNotificationMock: jest.Mock;
|
let showInfoNotificationMock: jest.Mock;
|
||||||
let askBooleanMock: AsyncFnMock<AskBoolean>;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
applicationBuilder = getApplicationBuilder();
|
applicationBuilder = getApplicationBuilder();
|
||||||
@ -43,11 +40,9 @@ describe("selection of update stability", () => {
|
|||||||
downloadPlatformUpdateMock = asyncFn();
|
downloadPlatformUpdateMock = asyncFn();
|
||||||
setUpdateOnQuitMock = jest.fn();
|
setUpdateOnQuitMock = jest.fn();
|
||||||
showInfoNotificationMock = jest.fn(() => () => {});
|
showInfoNotificationMock = jest.fn(() => () => {});
|
||||||
askBooleanMock = asyncFn();
|
|
||||||
|
|
||||||
rendererDi.override(showInfoNotificationInjectable, () => showInfoNotificationMock);
|
rendererDi.override(showInfoNotificationInjectable, () => showInfoNotificationMock);
|
||||||
|
|
||||||
mainDi.override(askBooleanInjectable, () => askBooleanMock);
|
|
||||||
mainDi.override(setUpdateOnQuitInjectable, () => setUpdateOnQuitMock);
|
mainDi.override(setUpdateOnQuitInjectable, () => setUpdateOnQuitMock);
|
||||||
|
|
||||||
mainDi.override(
|
mainDi.override(
|
||||||
|
|||||||
@ -7,21 +7,17 @@ import selectedUpdateChannelInjectable from "../../../common/application-update/
|
|||||||
import updatesAreBeingDiscoveredInjectable from "../../../common/application-update/updates-are-being-discovered/updates-are-being-discovered.injectable";
|
import updatesAreBeingDiscoveredInjectable from "../../../common/application-update/updates-are-being-discovered/updates-are-being-discovered.injectable";
|
||||||
import discoveredUpdateVersionInjectable from "../../../common/application-update/discovered-update-version/discovered-update-version.injectable";
|
import discoveredUpdateVersionInjectable from "../../../common/application-update/discovered-update-version/discovered-update-version.injectable";
|
||||||
import { runInAction } from "mobx";
|
import { runInAction } from "mobx";
|
||||||
import askBooleanInjectable from "../../ask-boolean/ask-boolean.injectable";
|
|
||||||
import downloadUpdateInjectable from "../download-update/download-update.injectable";
|
import downloadUpdateInjectable from "../download-update/download-update.injectable";
|
||||||
import broadcastChangeInUpdatingStatusInjectable from "./broadcast-change-in-updating-status.injectable";
|
import broadcastChangeInUpdatingStatusInjectable from "./broadcast-change-in-updating-status.injectable";
|
||||||
import checkForUpdatesStartingFromChannelInjectable from "./check-for-updates-starting-from-channel.injectable";
|
import checkForUpdatesStartingFromChannelInjectable from "./check-for-updates-starting-from-channel.injectable";
|
||||||
import withOrphanPromiseInjectable from "../../../common/utils/with-orphan-promise/with-orphan-promise.injectable";
|
import withOrphanPromiseInjectable from "../../../common/utils/with-orphan-promise/with-orphan-promise.injectable";
|
||||||
import emitEventInjectable from "../../../common/app-event-bus/emit-event.injectable";
|
import emitEventInjectable from "../../../common/app-event-bus/emit-event.injectable";
|
||||||
import { getCurrentDateTime } from "../../../common/utils/date/get-current-date-time";
|
import { getCurrentDateTime } from "../../../common/utils/date/get-current-date-time";
|
||||||
import quitAndInstallUpdateInjectable from "../quit-and-install-update.injectable";
|
|
||||||
|
|
||||||
const processCheckingForUpdatesInjectable = getInjectable({
|
const processCheckingForUpdatesInjectable = getInjectable({
|
||||||
id: "process-checking-for-updates",
|
id: "process-checking-for-updates",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const askBoolean = di.inject(askBooleanInjectable);
|
|
||||||
const quitAndInstallUpdate = di.inject(quitAndInstallUpdateInjectable);
|
|
||||||
const downloadUpdate = di.inject(downloadUpdateInjectable);
|
const downloadUpdate = di.inject(downloadUpdateInjectable);
|
||||||
const selectedUpdateChannel = di.inject(selectedUpdateChannelInjectable);
|
const selectedUpdateChannel = di.inject(selectedUpdateChannelInjectable);
|
||||||
const broadcastChangeInUpdatingStatus = di.inject(broadcastChangeInUpdatingStatusInjectable);
|
const broadcastChangeInUpdatingStatus = di.inject(broadcastChangeInUpdatingStatusInjectable);
|
||||||
@ -86,19 +82,6 @@ const processCheckingForUpdatesInjectable = getInjectable({
|
|||||||
broadcastChangeInUpdatingStatus({
|
broadcastChangeInUpdatingStatus({
|
||||||
eventId: "download-for-update-failed",
|
eventId: "download-for-update-failed",
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const userWantsToInstallUpdate = await askBoolean({
|
|
||||||
title: "Update Available",
|
|
||||||
|
|
||||||
question: `Version ${version} of Lens IDE is available and ready to be installed. Would you like to update now?\n\n` +
|
|
||||||
`Lens should restart automatically, if it doesn't please restart manually. Installed extensions might require updating.`,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (userWantsToInstallUpdate) {
|
|
||||||
quitAndInstallUpdate();
|
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,666 +0,0 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
||||||
|
|
||||||
exports[`ask-boolean given started when asking multiple questions renders 1`] = `
|
|
||||||
<body>
|
|
||||||
<div>
|
|
||||||
<div
|
|
||||||
class="topBar"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="items"
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive focusable"
|
|
||||||
data-testid="home-button"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="home"
|
|
||||||
>
|
|
||||||
home
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive disabled focusable"
|
|
||||||
data-testid="history-back"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="arrow_back"
|
|
||||||
>
|
|
||||||
arrow_back
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive disabled focusable"
|
|
||||||
data-testid="history-forward"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="arrow_forward"
|
|
||||||
>
|
|
||||||
arrow_forward
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="items"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="StatusBar"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="leftSide"
|
|
||||||
/>
|
|
||||||
<div
|
|
||||||
class="rightSide"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="Notifications flex column align-flex-end"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="Animate opacity notification flex info enter"
|
|
||||||
style="--enter-duration: 100ms; --leave-duration: 100ms;"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="box"
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
class="Icon material focusable"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="info_outline"
|
|
||||||
>
|
|
||||||
info_outline
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="message box grow"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="flex column gaps"
|
|
||||||
data-testid="ask-boolean-some-random-id-1"
|
|
||||||
>
|
|
||||||
<b>
|
|
||||||
some-title
|
|
||||||
</b>
|
|
||||||
<p>
|
|
||||||
Some question
|
|
||||||
</p>
|
|
||||||
<div
|
|
||||||
class="flex gaps row align-left box grow"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
class="Button light"
|
|
||||||
data-testid="ask-boolean-some-random-id-1-button-yes"
|
|
||||||
type="button"
|
|
||||||
>
|
|
||||||
Yes
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
class="Button active outlined"
|
|
||||||
data-testid="ask-boolean-some-random-id-1-button-no"
|
|
||||||
type="button"
|
|
||||||
>
|
|
||||||
No
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="box"
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
class="Icon close material interactive focusable"
|
|
||||||
data-testid="close-notification-for-ask-boolean-for-some-random-id-1"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="close"
|
|
||||||
>
|
|
||||||
close
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="Animate opacity notification flex info enter"
|
|
||||||
style="--enter-duration: 100ms; --leave-duration: 100ms;"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="box"
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
class="Icon material focusable"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="info_outline"
|
|
||||||
>
|
|
||||||
info_outline
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="message box grow"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="flex column gaps"
|
|
||||||
data-testid="ask-boolean-some-random-id-2"
|
|
||||||
>
|
|
||||||
<b>
|
|
||||||
some-other-title
|
|
||||||
</b>
|
|
||||||
<p>
|
|
||||||
Some other question
|
|
||||||
</p>
|
|
||||||
<div
|
|
||||||
class="flex gaps row align-left box grow"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
class="Button light"
|
|
||||||
data-testid="ask-boolean-some-random-id-2-button-yes"
|
|
||||||
type="button"
|
|
||||||
>
|
|
||||||
Yes
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
class="Button active outlined"
|
|
||||||
data-testid="ask-boolean-some-random-id-2-button-no"
|
|
||||||
type="button"
|
|
||||||
>
|
|
||||||
No
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="box"
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
class="Icon close material interactive focusable"
|
|
||||||
data-testid="close-notification-for-ask-boolean-for-some-random-id-2"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="close"
|
|
||||||
>
|
|
||||||
close
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`ask-boolean given started when asking multiple questions when answering to first question renders 1`] = `
|
|
||||||
<body>
|
|
||||||
<div>
|
|
||||||
<div
|
|
||||||
class="topBar"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="items"
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive focusable"
|
|
||||||
data-testid="home-button"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="home"
|
|
||||||
>
|
|
||||||
home
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive disabled focusable"
|
|
||||||
data-testid="history-back"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="arrow_back"
|
|
||||||
>
|
|
||||||
arrow_back
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive disabled focusable"
|
|
||||||
data-testid="history-forward"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="arrow_forward"
|
|
||||||
>
|
|
||||||
arrow_forward
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="items"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="StatusBar"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="leftSide"
|
|
||||||
/>
|
|
||||||
<div
|
|
||||||
class="rightSide"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="Notifications flex column align-flex-end"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="Animate opacity notification flex info enter"
|
|
||||||
style="--enter-duration: 100ms; --leave-duration: 100ms;"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="box"
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
class="Icon material focusable"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="info_outline"
|
|
||||||
>
|
|
||||||
info_outline
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="message box grow"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="flex column gaps"
|
|
||||||
data-testid="ask-boolean-some-random-id-2"
|
|
||||||
>
|
|
||||||
<b>
|
|
||||||
some-other-title
|
|
||||||
</b>
|
|
||||||
<p>
|
|
||||||
Some other question
|
|
||||||
</p>
|
|
||||||
<div
|
|
||||||
class="flex gaps row align-left box grow"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
class="Button light"
|
|
||||||
data-testid="ask-boolean-some-random-id-2-button-yes"
|
|
||||||
type="button"
|
|
||||||
>
|
|
||||||
Yes
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
class="Button active outlined"
|
|
||||||
data-testid="ask-boolean-some-random-id-2-button-no"
|
|
||||||
type="button"
|
|
||||||
>
|
|
||||||
No
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="box"
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
class="Icon close material interactive focusable"
|
|
||||||
data-testid="close-notification-for-ask-boolean-for-some-random-id-2"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="close"
|
|
||||||
>
|
|
||||||
close
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`ask-boolean given started when asking question renders 1`] = `
|
|
||||||
<body>
|
|
||||||
<div>
|
|
||||||
<div
|
|
||||||
class="topBar"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="items"
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive focusable"
|
|
||||||
data-testid="home-button"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="home"
|
|
||||||
>
|
|
||||||
home
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive disabled focusable"
|
|
||||||
data-testid="history-back"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="arrow_back"
|
|
||||||
>
|
|
||||||
arrow_back
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive disabled focusable"
|
|
||||||
data-testid="history-forward"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="arrow_forward"
|
|
||||||
>
|
|
||||||
arrow_forward
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="items"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="StatusBar"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="leftSide"
|
|
||||||
/>
|
|
||||||
<div
|
|
||||||
class="rightSide"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="Notifications flex column align-flex-end"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="Animate opacity notification flex info enter"
|
|
||||||
style="--enter-duration: 100ms; --leave-duration: 100ms;"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="box"
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
class="Icon material focusable"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="info_outline"
|
|
||||||
>
|
|
||||||
info_outline
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="message box grow"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="flex column gaps"
|
|
||||||
data-testid="ask-boolean-some-random-id-1"
|
|
||||||
>
|
|
||||||
<b>
|
|
||||||
some-title
|
|
||||||
</b>
|
|
||||||
<p>
|
|
||||||
Some question
|
|
||||||
</p>
|
|
||||||
<div
|
|
||||||
class="flex gaps row align-left box grow"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
class="Button light"
|
|
||||||
data-testid="ask-boolean-some-random-id-1-button-yes"
|
|
||||||
type="button"
|
|
||||||
>
|
|
||||||
Yes
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
class="Button active outlined"
|
|
||||||
data-testid="ask-boolean-some-random-id-1-button-no"
|
|
||||||
type="button"
|
|
||||||
>
|
|
||||||
No
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="box"
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
class="Icon close material interactive focusable"
|
|
||||||
data-testid="close-notification-for-ask-boolean-for-some-random-id-1"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="close"
|
|
||||||
>
|
|
||||||
close
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`ask-boolean given started when asking question when user answers "no" renders 1`] = `
|
|
||||||
<body>
|
|
||||||
<div>
|
|
||||||
<div
|
|
||||||
class="topBar"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="items"
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive focusable"
|
|
||||||
data-testid="home-button"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="home"
|
|
||||||
>
|
|
||||||
home
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive disabled focusable"
|
|
||||||
data-testid="history-back"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="arrow_back"
|
|
||||||
>
|
|
||||||
arrow_back
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive disabled focusable"
|
|
||||||
data-testid="history-forward"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="arrow_forward"
|
|
||||||
>
|
|
||||||
arrow_forward
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="items"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="StatusBar"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="leftSide"
|
|
||||||
/>
|
|
||||||
<div
|
|
||||||
class="rightSide"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="Notifications flex column align-flex-end"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`ask-boolean given started when asking question when user answers "yes" renders 1`] = `
|
|
||||||
<body>
|
|
||||||
<div>
|
|
||||||
<div
|
|
||||||
class="topBar"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="items"
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive focusable"
|
|
||||||
data-testid="home-button"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="home"
|
|
||||||
>
|
|
||||||
home
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive disabled focusable"
|
|
||||||
data-testid="history-back"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="arrow_back"
|
|
||||||
>
|
|
||||||
arrow_back
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive disabled focusable"
|
|
||||||
data-testid="history-forward"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="arrow_forward"
|
|
||||||
>
|
|
||||||
arrow_forward
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="items"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="StatusBar"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="leftSide"
|
|
||||||
/>
|
|
||||||
<div
|
|
||||||
class="rightSide"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="Notifications flex column align-flex-end"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`ask-boolean given started when asking question when user closes notification without answering the question renders 1`] = `
|
|
||||||
<body>
|
|
||||||
<div>
|
|
||||||
<div
|
|
||||||
class="topBar"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="items"
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive focusable"
|
|
||||||
data-testid="home-button"
|
|
||||||
tabindex="0"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="home"
|
|
||||||
>
|
|
||||||
home
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive disabled focusable"
|
|
||||||
data-testid="history-back"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="arrow_back"
|
|
||||||
>
|
|
||||||
arrow_back
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
<i
|
|
||||||
class="Icon material interactive disabled focusable"
|
|
||||||
data-testid="history-forward"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="icon"
|
|
||||||
data-icon-name="arrow_forward"
|
|
||||||
>
|
|
||||||
arrow_forward
|
|
||||||
</span>
|
|
||||||
</i>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="items"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="StatusBar"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="leftSide"
|
|
||||||
/>
|
|
||||||
<div
|
|
||||||
class="rightSide"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="Notifications flex column align-flex-end"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
`;
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
|
||||||
import type { AskBooleanAnswerChannel } from "../../common/ask-boolean/ask-boolean-answer-channel.injectable";
|
|
||||||
import askBooleanAnswerChannelInjectable from "../../common/ask-boolean/ask-boolean-answer-channel.injectable";
|
|
||||||
import askBooleanPromiseInjectable from "./ask-boolean-promise.injectable";
|
|
||||||
import type { MessageChannelListener } from "../../common/utils/channel/message-channel-listener-injection-token";
|
|
||||||
import { messageChannelListenerInjectionToken } from "../../common/utils/channel/message-channel-listener-injection-token";
|
|
||||||
|
|
||||||
|
|
||||||
const askBooleanAnswerChannelListenerInjectable = getInjectable({
|
|
||||||
id: "ask-boolean-answer-channel-listener",
|
|
||||||
|
|
||||||
instantiate: (di): MessageChannelListener<AskBooleanAnswerChannel> => ({
|
|
||||||
channel: di.inject(askBooleanAnswerChannelInjectable),
|
|
||||||
|
|
||||||
handler: ({ id, value }) => {
|
|
||||||
const answerPromise = di.inject(askBooleanPromiseInjectable, id);
|
|
||||||
|
|
||||||
answerPromise.resolve(value);
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
|
|
||||||
injectionToken: messageChannelListenerInjectionToken,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default askBooleanAnswerChannelListenerInjectable;
|
|
||||||
@ -1,33 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
|
|
||||||
|
|
||||||
const askBooleanPromiseInjectable = getInjectable({
|
|
||||||
id: "ask-boolean-promise",
|
|
||||||
|
|
||||||
instantiate: (di, questionId: string) => {
|
|
||||||
void questionId;
|
|
||||||
|
|
||||||
let resolve: (value: boolean) => void;
|
|
||||||
|
|
||||||
const promise = new Promise<boolean>(_resolve => {
|
|
||||||
resolve = _resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
return ({
|
|
||||||
promise,
|
|
||||||
|
|
||||||
resolve: (value: boolean) => {
|
|
||||||
resolve(value);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
lifecycle: lifecycleEnum.keyedSingleton({
|
|
||||||
getInstanceKey: (di, questionId: string) => questionId,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default askBooleanPromiseInjectable;
|
|
||||||
@ -1,39 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
|
||||||
import { messageToChannelInjectionToken } from "../../common/utils/channel/message-to-channel-injection-token";
|
|
||||||
import askBooleanQuestionChannelInjectable from "../../common/ask-boolean/ask-boolean-question-channel.injectable";
|
|
||||||
import askBooleanPromiseInjectable from "./ask-boolean-promise.injectable";
|
|
||||||
import getRandomIdInjectable from "../../common/utils/get-random-id.injectable";
|
|
||||||
|
|
||||||
export type AskBoolean = ({
|
|
||||||
title,
|
|
||||||
question,
|
|
||||||
}: {
|
|
||||||
title: string;
|
|
||||||
question: string;
|
|
||||||
}) => Promise<boolean>;
|
|
||||||
|
|
||||||
const askBooleanInjectable = getInjectable({
|
|
||||||
id: "ask-boolean",
|
|
||||||
|
|
||||||
instantiate: (di): AskBoolean => {
|
|
||||||
const messageToChannel = di.inject(messageToChannelInjectionToken);
|
|
||||||
const askBooleanChannel = di.inject(askBooleanQuestionChannelInjectable);
|
|
||||||
const getRandomId = di.inject(getRandomIdInjectable);
|
|
||||||
|
|
||||||
return async ({ title, question }) => {
|
|
||||||
const id = getRandomId();
|
|
||||||
|
|
||||||
const returnValuePromise = di.inject(askBooleanPromiseInjectable, id);
|
|
||||||
|
|
||||||
await messageToChannel(askBooleanChannel, { id, title, question });
|
|
||||||
|
|
||||||
return await returnValuePromise.promise;
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export default askBooleanInjectable;
|
|
||||||
@ -1,206 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
|
||||||
import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
|
||||||
import type { AskBoolean } from "./ask-boolean.injectable";
|
|
||||||
import askBooleanInjectable from "./ask-boolean.injectable";
|
|
||||||
import { getPromiseStatus } from "../../common/test-utils/get-promise-status";
|
|
||||||
import type { RenderResult } from "@testing-library/react";
|
|
||||||
import { fireEvent } from "@testing-library/react";
|
|
||||||
import getRandomIdInjectable from "../../common/utils/get-random-id.injectable";
|
|
||||||
|
|
||||||
describe("ask-boolean", () => {
|
|
||||||
let applicationBuilder: ApplicationBuilder;
|
|
||||||
let askBoolean: AskBoolean;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
applicationBuilder = getApplicationBuilder();
|
|
||||||
|
|
||||||
const getRandomIdFake = jest
|
|
||||||
.fn()
|
|
||||||
.mockReturnValueOnce("some-random-id-1")
|
|
||||||
.mockReturnValueOnce("some-random-id-2");
|
|
||||||
|
|
||||||
applicationBuilder.dis.mainDi.override(getRandomIdInjectable, () => getRandomIdFake);
|
|
||||||
|
|
||||||
askBoolean = applicationBuilder.dis.mainDi.inject(askBooleanInjectable);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("given started", () => {
|
|
||||||
let rendered: RenderResult;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
rendered = await applicationBuilder.render();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("when asking question", () => {
|
|
||||||
let actualPromise: Promise<boolean>;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
actualPromise = askBoolean({
|
|
||||||
title: "some-title",
|
|
||||||
question: "Some question",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("does not resolve yet", async () => {
|
|
||||||
const promiseStatus = await getPromiseStatus(actualPromise);
|
|
||||||
|
|
||||||
expect(promiseStatus.fulfilled).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("renders", () => {
|
|
||||||
expect(rendered.baseElement).toMatchSnapshot();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("shows notification", () => {
|
|
||||||
const notification = rendered.getByTestId("ask-boolean-some-random-id-1");
|
|
||||||
|
|
||||||
expect(notification).not.toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when user answers "yes"', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
const button = rendered.getByTestId("ask-boolean-some-random-id-1-button-yes");
|
|
||||||
|
|
||||||
fireEvent.click(button);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("renders", () => {
|
|
||||||
expect(rendered.baseElement).toMatchSnapshot();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("does not show notification anymore", () => {
|
|
||||||
const notification = rendered.queryByTestId("ask-boolean-some-random-id-1");
|
|
||||||
|
|
||||||
expect(notification).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("resolves", async () => {
|
|
||||||
const actual = await actualPromise;
|
|
||||||
|
|
||||||
expect(actual).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when user answers "no"', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
const button = rendered.getByTestId("ask-boolean-some-random-id-1-button-no");
|
|
||||||
|
|
||||||
fireEvent.click(button);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("renders", () => {
|
|
||||||
expect(rendered.baseElement).toMatchSnapshot();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("does not show notification anymore", () => {
|
|
||||||
const notification = rendered.queryByTestId("ask-boolean-some-random-id-1");
|
|
||||||
|
|
||||||
expect(notification).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("resolves", async () => {
|
|
||||||
const actual = await actualPromise;
|
|
||||||
|
|
||||||
expect(actual).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("when user closes notification without answering the question", () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
const button = rendered.getByTestId("close-notification-for-ask-boolean-for-some-random-id-1");
|
|
||||||
|
|
||||||
fireEvent.click(button);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("renders", () => {
|
|
||||||
expect(rendered.baseElement).toMatchSnapshot();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("does not show notification anymore", () => {
|
|
||||||
const notification = rendered.queryByTestId("ask-boolean-some-random-id-1");
|
|
||||||
|
|
||||||
expect(notification).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("resolves", async () => {
|
|
||||||
const actual = await actualPromise;
|
|
||||||
|
|
||||||
expect(actual).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("when asking multiple questions", () => {
|
|
||||||
let firstQuestionPromise: Promise<boolean>;
|
|
||||||
let secondQuestionPromise: Promise<boolean>;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
firstQuestionPromise = askBoolean({
|
|
||||||
title: "some-title",
|
|
||||||
question: "Some question",
|
|
||||||
});
|
|
||||||
|
|
||||||
secondQuestionPromise = askBoolean({
|
|
||||||
title: "some-other-title",
|
|
||||||
question: "Some other question",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("renders", () => {
|
|
||||||
expect(rendered.baseElement).toMatchSnapshot();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("shows notification for first question", () => {
|
|
||||||
const notification = rendered.getByTestId("ask-boolean-some-random-id-1");
|
|
||||||
|
|
||||||
expect(notification).not.toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("shows notification for second question", () => {
|
|
||||||
const notification = rendered.getByTestId("ask-boolean-some-random-id-2");
|
|
||||||
|
|
||||||
expect(notification).not.toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("when answering to first question", () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
const button = rendered.getByTestId("ask-boolean-some-random-id-1-button-no");
|
|
||||||
|
|
||||||
fireEvent.click(button);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("renders", () => {
|
|
||||||
expect(rendered.baseElement).toMatchSnapshot();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("does not show notification for first question anymore", () => {
|
|
||||||
const notification = rendered.queryByTestId("ask-boolean-some-random-id-1");
|
|
||||||
|
|
||||||
expect(notification).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("still shows notification for second question", () => {
|
|
||||||
const notification = rendered.getByTestId("ask-boolean-some-random-id-2");
|
|
||||||
|
|
||||||
expect(notification).not.toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("resolves first question", async () => {
|
|
||||||
const actual = await firstQuestionPromise;
|
|
||||||
|
|
||||||
expect(actual).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("does not resolve second question yet", async () => {
|
|
||||||
const promiseStatus = await getPromiseStatus(secondQuestionPromise);
|
|
||||||
|
|
||||||
expect(promiseStatus.fulfilled).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Loading…
Reference in New Issue
Block a user