Replace static application window with ability to create many (#5979)

* Replace static application window with ability to create as many as you wish

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Adapt tests for replacing static application window with ability to create as many as you wish and separate starting of main and window in behaviours

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Make first render of application smaller in test that proves to be hard for CI

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Remove redundant code

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Simplify code

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen authored and GitHub committed 2022-08-16 15:55:42 +03:00
1 parent 299922c8a7
commit 63d5a34379
98 files changed
+3283 -2743

No files matched your search

@@ -19,7 +19,7 @@ import showErrorNotificationInjectable from "../../renderer/components/notificat
import type { AsyncResult } from "../../common/utils/async-result";
describe("add custom helm repository in preferences", () => {
let applicationBuilder: ApplicationBuilder;
let builder: ApplicationBuilder;
let showSuccessNotificationMock: jest.Mock;
let showErrorNotificationMock: jest.Mock;
let rendered: RenderResult;
@@ -31,41 +31,35 @@ describe("add custom helm repository in preferences", () => {
beforeEach(async () => {
jest.useFakeTimers();
applicationBuilder = getApplicationBuilder();
builder = getApplicationBuilder();
execFileMock = asyncFn();
getActiveHelmRepositoriesMock = asyncFn();
showSuccessNotificationMock = jest.fn();
showErrorNotificationMock = jest.fn();
applicationBuilder.beforeApplicationStart(({ mainDi, rendererDi }) => {
rendererDi.override(callForPublicHelmRepositoriesInjectable, () => async () => []);
showSuccessNotificationMock = jest.fn();
rendererDi.override(showSuccessNotificationInjectable, () => showSuccessNotificationMock);
showErrorNotificationMock = jest.fn();
rendererDi.override(showErrorNotificationInjectable, () => showErrorNotificationMock);
// TODO: Figure out how to make async validators unit testable
rendererDi.override(isPathInjectable, () => ({ debounce: 0, validate: async () => {} }));
mainDi.override(
getActiveHelmRepositoriesInjectable,
() => getActiveHelmRepositoriesMock,
);
builder.beforeApplicationStart((mainDi) => {
mainDi.override(getActiveHelmRepositoriesInjectable, () => getActiveHelmRepositoriesMock);
mainDi.override(execFileInjectable, () => execFileMock);
mainDi.override(helmBinaryPathInjectable, () => "some-helm-binary-path");
});
rendered = await applicationBuilder.render();
builder.beforeWindowStart((windowDi) => {
windowDi.override(callForPublicHelmRepositoriesInjectable, () => async () => []);
windowDi.override(showSuccessNotificationInjectable, () => showSuccessNotificationMock);
windowDi.override(showErrorNotificationInjectable, () => showErrorNotificationMock);
// TODO: Figure out how to make async validators unit testable
windowDi.override(isPathInjectable, () => ({ debounce: 0, validate: async () => {} }));
});
rendered = await builder.render();
});
describe("when navigating to preferences containing helm repositories", () => {
beforeEach(async () => {
applicationBuilder.preferences.navigate();
applicationBuilder.preferences.navigation.click("kubernetes");
builder.preferences.navigate();
builder.preferences.navigation.click("kubernetes");
});
it("renders", () => {
@@ -17,7 +17,7 @@ import showErrorNotificationInjectable from "../../renderer/components/notificat
import type { AsyncResult } from "../../common/utils/async-result";
describe("add helm repository from list in preferences", () => {
let applicationBuilder: ApplicationBuilder;
let builder: ApplicationBuilder;
let showSuccessNotificationMock: jest.Mock;
let showErrorNotificationMock: jest.Mock;
let rendered: RenderResult;
@@ -28,41 +28,33 @@ describe("add helm repository from list in preferences", () => {
let callForPublicHelmRepositoriesMock: AsyncFnMock<() => Promise<HelmRepo[]>>;
beforeEach(async () => {
applicationBuilder = getApplicationBuilder();
builder = getApplicationBuilder();
execFileMock = asyncFn();
getActiveHelmRepositoriesMock = asyncFn();
callForPublicHelmRepositoriesMock = asyncFn();
showSuccessNotificationMock = jest.fn();
showErrorNotificationMock = jest.fn();
applicationBuilder.beforeApplicationStart(({ mainDi, rendererDi }) => {
showSuccessNotificationMock = jest.fn();
rendererDi.override(showSuccessNotificationInjectable, () => showSuccessNotificationMock);
showErrorNotificationMock = jest.fn();
rendererDi.override(showErrorNotificationInjectable, () => showErrorNotificationMock);
rendererDi.override(
callForPublicHelmRepositoriesInjectable,
() => callForPublicHelmRepositoriesMock,
);
mainDi.override(
getActiveHelmRepositoriesInjectable,
() => getActiveHelmRepositoriesMock,
);
builder.beforeApplicationStart((mainDi) => {
mainDi.override(getActiveHelmRepositoriesInjectable, () => getActiveHelmRepositoriesMock);
mainDi.override(execFileInjectable, () => execFileMock);
mainDi.override(helmBinaryPathInjectable, () => "some-helm-binary-path");
});
rendered = await applicationBuilder.render();
builder.beforeWindowStart((windowDi) => {
windowDi.override(showSuccessNotificationInjectable, () => showSuccessNotificationMock);
windowDi.override(showErrorNotificationInjectable, () => showErrorNotificationMock);
windowDi.override(callForPublicHelmRepositoriesInjectable, () => callForPublicHelmRepositoriesMock);
});
rendered = await builder.render();
});
describe("when navigating to preferences containing helm repositories", () => {
beforeEach(async () => {
applicationBuilder.preferences.navigate();
applicationBuilder.preferences.navigation.click("kubernetes");
beforeEach(() => {
builder.preferences.navigate();
builder.preferences.navigation.click("kubernetes");
});
it("renders", () => {
@@ -100,7 +92,7 @@ describe("add helm repository from list in preferences", () => {
describe("when select for adding public repositories is clicked", () => {
beforeEach(() => {
applicationBuilder.select.openMenu(
builder.select.openMenu(
"selection-of-active-public-helm-repository",
);
});
@@ -113,7 +105,7 @@ describe("add helm repository from list in preferences", () => {
beforeEach(async () => {
getActiveHelmRepositoriesMock.mockClear();
applicationBuilder.select.selectOption(
builder.select.selectOption(
"selection-of-active-public-helm-repository",
"Some to be added repository",
);
@@ -207,7 +199,7 @@ describe("add helm repository from list in preferences", () => {
describe("when select for selecting active repositories is clicked", () => {
beforeEach(() => {
applicationBuilder.select.openMenu(
builder.select.openMenu(
"selection-of-active-public-helm-repository",
);
});
@@ -221,7 +213,7 @@ describe("add helm repository from list in preferences", () => {
execFileMock.mockClear();
getActiveHelmRepositoriesMock.mockClear();
applicationBuilder.select.selectOption(
builder.select.selectOption(
"selection-of-active-public-helm-repository",
"Some already active repository",
);
@@ -1,6 +1,448 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
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`] = `
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started renders 1`] = `
<body>
<div>
<div
class="Notifications flex column align-flex-end"
/>
<div
class="mainLayout"
style="--sidebar-width: 200px;"
>
<div
class="sidebar"
>
<div
class="flex flex-col"
data-testid="cluster-sidebar"
>
<div
class="SidebarCluster"
>
<div
class="Avatar rounded loadingAvatar"
style="width: 40px; height: 40px;"
>
??
</div>
<div
class="loadingClusterName"
/>
</div>
<div
class="sidebarNav sidebar-active-status"
>
<div
class="SidebarItem"
data-is-active-test="true"
data-testid="sidebar-item-workloads"
>
<a
aria-current="page"
class="nav-item flex gaps align-center expandable active"
data-testid="sidebar-item-link-for-workloads"
href="/"
>
<i
class="Icon svg focusable"
>
<span
class="icon"
/>
</i>
<span
class="link-text box grow"
>
Workloads
</span>
<i
class="Icon expand-icon box right material focusable"
>
<span
class="icon"
data-icon-name="keyboard_arrow_down"
>
keyboard_arrow_down
</span>
</i>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
data-testid="sidebar-item-config"
>
<a
class="nav-item flex gaps align-center"
data-testid="sidebar-item-link-for-config"
href="/"
>
<i
class="Icon material focusable"
>
<span
class="icon"
data-icon-name="list"
>
list
</span>
</i>
<span
class="link-text box grow"
>
Config
</span>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
data-testid="sidebar-item-network"
>
<a
class="nav-item flex gaps align-center expandable"
data-testid="sidebar-item-link-for-network"
href="/"
>
<i
class="Icon material focusable"
>
<span
class="icon"
data-icon-name="device_hub"
>
device_hub
</span>
</i>
<span
class="link-text box grow"
>
Network
</span>
<i
class="Icon expand-icon box right material focusable"
>
<span
class="icon"
data-icon-name="keyboard_arrow_down"
>
keyboard_arrow_down
</span>
</i>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
data-testid="sidebar-item-storage"
>
<a
class="nav-item flex gaps align-center"
data-testid="sidebar-item-link-for-storage"
href="/"
>
<i
class="Icon material focusable"
>
<span
class="icon"
data-icon-name="storage"
>
storage
</span>
</i>
<span
class="link-text box grow"
>
Storage
</span>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
data-testid="sidebar-item-helm"
>
<a
class="nav-item flex gaps align-center expandable"
data-testid="sidebar-item-link-for-helm"
href="/"
>
<i
class="Icon svg focusable"
>
<span
class="icon"
/>
</i>
<span
class="link-text box grow"
>
Helm
</span>
<i
class="Icon expand-icon box right material focusable"
>
<span
class="icon"
data-icon-name="keyboard_arrow_down"
>
keyboard_arrow_down
</span>
</i>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
data-testid="sidebar-item-user-management"
>
<a
class="nav-item flex gaps align-center"
data-testid="sidebar-item-link-for-user-management"
href="/"
>
<i
class="Icon material focusable"
>
<span
class="icon"
data-icon-name="security"
>
security
</span>
</i>
<span
class="link-text box grow"
>
Access Control
</span>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
data-testid="sidebar-item-custom-resources"
>
<a
class="nav-item flex gaps align-center expandable"
data-testid="sidebar-item-link-for-custom-resources"
href="/"
>
<i
class="Icon material focusable"
>
<span
class="icon"
data-icon-name="extension"
>
extension
</span>
</i>
<span
class="link-text box grow"
>
Custom Resources
</span>
<i
class="Icon expand-icon box right material focusable"
>
<span
class="icon"
data-icon-name="keyboard_arrow_down"
>
keyboard_arrow_down
</span>
</i>
</a>
</div>
</div>
</div>
<div
class="ResizingAnchor horizontal trailing"
/>
</div>
<div
class="contents"
>
<div
class="TabLayout"
data-testid="tab-layout"
>
<div
class="Tabs center scrollable"
>
<div
class="Tab flex gaps align-center active"
data-is-active-test="true"
data-testid="tab-link-for-overview"
role="tab"
tabindex="0"
>
<div
class="label"
>
Overview
</div>
</div>
</div>
<main>
<div
class="WorkloadsOverview flex column gaps"
>
<div
class="header flex gaps align-center"
>
<h5
class="box grow"
>
Overview
</h5>
<div
class="NamespaceSelectFilterParent"
data-testid="namespace-select-filter"
>
<div
class="Select theme-dark NamespaceSelect NamespaceSelectFilter css-b62m3t-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-overview-namespace-select-filter-input-live-region"
/>
<span
aria-atomic="false"
aria-live="polite"
aria-relevant="additions text"
class="css-1f43avz-a11yText-A11yText"
/>
<div
class="Select__control css-1s2u09g-control"
>
<div
class="Select__value-container Select__value-container--is-multi css-319lph-ValueContainer"
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-overview-namespace-select-filter-input-placeholder"
>
All namespaces
</div>
<div
class="Select__input-container css-6j8wv5-Input"
data-value=""
>
<input
aria-autocomplete="list"
aria-describedby="react-select-overview-namespace-select-filter-input-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
autocomplete="off"
autocorrect="off"
class="Select__input"
id="overview-namespace-select-filter-input"
role="combobox"
spellcheck="false"
style="opacity: 1; width: 100%; grid-area: 1 / 2; min-width: 2px; border: 0px; margin: 0px; outline: 0; padding: 0px;"
tabindex="0"
type="text"
value=""
/>
</div>
</div>
<div
class="Select__indicators css-1hb7zxy-IndicatorsContainer"
>
<span
class="Select__indicator-separator css-1okebmr-indicatorSeparator"
/>
<div
aria-hidden="true"
class="Select__indicator Select__dropdown-indicator css-tlfecz-indicatorContainer"
>
<svg
aria-hidden="true"
class="css-tj5bde-Svg"
focusable="false"
height="20"
viewBox="0 0 20 20"
width="20"
>
<path
d="M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"
/>
</svg>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class="OverviewStatuses"
>
<div
class="workloads"
/>
</div>
</div>
</main>
</div>
</div>
<div
class="footer"
>
<div
class="Dock"
tabindex="-1"
>
<div
class="ResizingAnchor vertical leading disabled"
/>
<div
class="tabs-container flex align-center"
>
<div
class="dockTabs"
role="tablist"
>
<div
class="Tabs tabs"
/>
</div>
<div
class="toolbar flex gaps align-center box grow pl-0"
>
<div
class="dock-menu box grow"
>
<i
class="Icon new-dock-tab material interactive focusable"
id="menu-actions-for-dock"
tabindex="0"
>
<span
class="icon"
data-icon-name="add"
>
add
</span>
</i>
<div>
New tab
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
`;
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`] = `
<body>
<div>
<div
@@ -927,7 +1369,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
</body>
`;
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`] = `
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`] = `
<body>
<div>
<div
@@ -1696,7 +2138,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
</body>
`;
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`] = `
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`] = `
<body>
<div>
<div
@@ -2709,7 +3151,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
</body>
`;
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`] = `
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`] = `
<body>
<div>
<div
@@ -3696,7 +4138,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
</body>
`;
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`] = `
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`] = `
<body>
<div>
<div
@@ -4678,7 +5120,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
</body>
`;
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`] = `
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`] = `
<body>
<div>
<div
@@ -5660,7 +6102,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
</body>
`;
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`] = `
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`] = `
<body>
<div>
<div
@@ -6664,7 +7106,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
</body>
`;
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`] = `
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`] = `
<body>
<div>
<div
@@ -7677,7 +8119,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
</body>
`;
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`] = `
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`] = `
<body>
<div>
<div
@@ -8659,7 +9101,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
</body>
`;
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`] = `
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`] = `
<body>
<div>
<div
@@ -9649,7 +10091,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
</body>
`;
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`] = `
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`] = `
<body>
<div>
<div
@@ -10498,7 +10940,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
</body>
`;
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`] = `
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`] = `
<body>
<div>
<div
@@ -11271,7 +11713,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
</body>
`;
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`] = `
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`] = `
<body>
<div>
<div
@@ -12180,7 +12622,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
</body>
`;
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`] = `
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`] = `
<body>
<div>
<div
@@ -13408,7 +13850,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
</body>
`;
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`] = `
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`] = `
<body>
<div>
<div
@@ -14226,7 +14668,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
</body>
`;
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`] = `
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`] = `
<body>
<div>
<div
@@ -15259,7 +15701,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
</body>
`;
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`] = `
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`] = `
<body>
<div>
<div
@@ -16290,7 +16732,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
</body>
`;
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`] = `
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`] = `
<body>
<div>
<div
@@ -17272,7 +17714,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
</body>
`;
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`] = `
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`] = `
<body>
<div>
<div
@@ -18254,7 +18696,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
</body>
`;
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`] = `
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`] = `
<body>
<div>
<div
File diff suppressed because it is too large. Load diff
@@ -15,18 +15,15 @@ import namespaceStoreInjectable from "../../../renderer/components/+namespaces/s
import type { NamespaceStore } from "../../../renderer/components/+namespaces/store";
import type { CallForHelmChartVersions } from "../../../renderer/components/+helm-charts/details/versions/call-for-helm-chart-versions.injectable";
import callForHelmChartVersionsInjectable from "../../../renderer/components/+helm-charts/details/versions/call-for-helm-chart-versions.injectable";
import { overrideFsWithFakes } from "../../../test-utils/override-fs-with-fakes";
import writeJsonFileInjectable from "../../../common/fs/write-json-file.injectable";
import directoryForLensLocalStorageInjectable from "../../../common/directory-for-lens-local-storage/directory-for-lens-local-storage.injectable";
import hostedClusterIdInjectable from "../../../renderer/cluster-frame-context/hosted-cluster-id.injectable";
import { TabKind } from "../../../renderer/components/dock/dock/store";
import { controlWhenStoragesAreReady } from "../../../renderer/utils/create-storage/storages-are-ready";
import type { DiContainer } from "@ogre-tools/injectable";
import callForCreateHelmReleaseInjectable from "../../../renderer/components/+helm-releases/create-release/call-for-create-helm-release.injectable";
describe("installing helm chart from previously opened tab", () => {
let builder: ApplicationBuilder;
let rendererDi: DiContainer;
let callForHelmChartVersionsMock: AsyncFnMock<CallForHelmChartVersions>;
let callForHelmChartValuesMock: AsyncFnMock<CallForHelmChartValues>;
let storagesAreReady: () => Promise<void>;
@@ -34,45 +31,43 @@ describe("installing helm chart from previously opened tab", () => {
beforeEach(() => {
builder = getApplicationBuilder();
rendererDi = builder.dis.rendererDi;
overrideFsWithFakes(rendererDi);
builder.setEnvironmentToClusterFrame();
callForHelmChartVersionsMock = asyncFn();
callForHelmChartValuesMock = asyncFn();
builder.beforeApplicationStart(({ rendererDi }) => {
rendererDi.override(
builder.beforeWindowStart((windowDi) => {
windowDi.override(
directoryForLensLocalStorageInjectable,
() => "/some-directory-for-lens-local-storage",
);
rendererDi.override(hostedClusterIdInjectable, () => "some-cluster-id");
windowDi.override(hostedClusterIdInjectable, () => "some-cluster-id");
storagesAreReady = controlWhenStoragesAreReady(rendererDi);
storagesAreReady = controlWhenStoragesAreReady(windowDi);
rendererDi.override(
windowDi.override(
callForHelmChartVersionsInjectable,
() => callForHelmChartVersionsMock,
);
rendererDi.override(
windowDi.override(
callForHelmChartValuesInjectable,
() => callForHelmChartValuesMock,
);
rendererDi.override(
windowDi.override(
callForHelmChartValuesInjectable,
() => callForHelmChartValuesMock,
);
rendererDi.override(
windowDi.override(
callForCreateHelmReleaseInjectable,
() => jest.fn(),
);
// TODO: Replace store mocking with mock for the actual side-effect (where the namespaces are coming from)
rendererDi.override(
windowDi.override(
namespaceStoreInjectable,
() =>
({
@@ -85,51 +80,51 @@ describe("installing helm chart from previously opened tab", () => {
} as unknown as NamespaceStore),
);
rendererDi.override(getRandomInstallChartTabIdInjectable, () =>
windowDi.override(getRandomInstallChartTabIdInjectable, () =>
jest
.fn(() => "some-irrelevant-tab-id")
.mockReturnValueOnce("some-first-tab-id"),
);
});
builder.setEnvironmentToClusterFrame();
});
describe("given tab for installing chart was previously opened, when application is started", () => {
let rendered: RenderResult;
beforeEach(async () => {
const writeJsonFile = rendererDi.inject(writeJsonFileInjectable);
builder.beforeWindowStart(async (windowDi) => {
const writeJsonFile = windowDi.inject(writeJsonFileInjectable);
writeJsonFile(
"/some-directory-for-lens-local-storage/some-cluster-id.json",
{
dock: {
height: 300,
tabs: [
{
id: "some-first-tab-id",
kind: TabKind.INSTALL_CHART,
title: "Helm Install: some-repository/some-name",
pinned: false,
await writeJsonFile(
"/some-directory-for-lens-local-storage/some-cluster-id.json",
{
dock: {
height: 300,
tabs: [
{
id: "some-first-tab-id",
kind: TabKind.INSTALL_CHART,
title: "Helm Install: some-repository/some-name",
pinned: false,
},
],
isOpen: true,
},
install_charts: {
"some-first-tab-id": {
name: "some-name",
repo: "some-repository",
version: "some-other-version",
values: "some-stored-configuration",
releaseName: "some-stored-custom-name",
namespace: "some-other-namespace",
},
],
isOpen: true,
},
install_charts: {
"some-first-tab-id": {
name: "some-name",
repo: "some-repository",
version: "some-other-version",
values: "some-stored-configuration",
releaseName: "some-stored-custom-name",
namespace: "some-other-namespace",
},
},
},
);
);
});
rendered = await builder.render();
@@ -19,15 +19,12 @@ import callForHelmChartReadmeInjectable from "../../../renderer/components/+helm
import type { CallForHelmChartVersions } from "../../../renderer/components/+helm-charts/details/versions/call-for-helm-chart-versions.injectable";
import callForHelmChartVersionsInjectable from "../../../renderer/components/+helm-charts/details/versions/call-for-helm-chart-versions.injectable";
import { flushPromises } from "../../../common/test-utils/flush-promises";
import { overrideFsWithFakes } from "../../../test-utils/override-fs-with-fakes";
import directoryForLensLocalStorageInjectable from "../../../common/directory-for-lens-local-storage/directory-for-lens-local-storage.injectable";
import hostedClusterIdInjectable from "../../../renderer/cluster-frame-context/hosted-cluster-id.injectable";
import dockStoreInjectable from "../../../renderer/components/dock/dock/store.injectable";
import type { DiContainer } from "@ogre-tools/injectable";
describe("opening dock tab for installing helm chart", () => {
let builder: ApplicationBuilder;
let rendererDi: DiContainer;
let callForHelmChartsMock: AsyncFnMock<CallForHelmCharts>;
let callForHelmChartVersionsMock: AsyncFnMock<CallForHelmChartVersions>;
let callForHelmChartReadmeMock: AsyncFnMock<CallForHelmChartReadme>;
@@ -36,49 +33,45 @@ describe("opening dock tab for installing helm chart", () => {
beforeEach(() => {
builder = getApplicationBuilder();
rendererDi = builder.dis.rendererDi;
overrideFsWithFakes(rendererDi);
callForHelmChartsMock = asyncFn();
callForHelmChartVersionsMock = asyncFn();
callForHelmChartReadmeMock = asyncFn();
callForHelmChartValuesMock = jest.fn();
builder.beforeApplicationStart(({ rendererDi }) => {
rendererDi.override(
builder.beforeWindowStart((windowDi) => {
windowDi.override(
directoryForLensLocalStorageInjectable,
() => "/some-directory-for-lens-local-storage",
);
rendererDi.override(hostedClusterIdInjectable, () => "some-cluster-id");
windowDi.override(hostedClusterIdInjectable, () => "some-cluster-id");
rendererDi.override(
windowDi.override(
callForHelmChartsInjectable,
() => callForHelmChartsMock,
);
rendererDi.override(
windowDi.override(
callForHelmChartVersionsInjectable,
() => callForHelmChartVersionsMock,
);
rendererDi.override(
windowDi.override(
callForHelmChartReadmeInjectable,
() => callForHelmChartReadmeMock,
);
rendererDi.override(
windowDi.override(
callForHelmChartValuesInjectable,
() => callForHelmChartValuesMock,
);
rendererDi.override(
windowDi.override(
callForCreateHelmReleaseInjectable,
() => jest.fn(),
);
rendererDi.override(getRandomInstallChartTabIdInjectable, () =>
windowDi.override(getRandomInstallChartTabIdInjectable, () =>
jest
.fn(() => "some-irrelevant-tab-id")
.mockReturnValueOnce("some-tab-id"),
@@ -96,7 +89,9 @@ describe("opening dock tab for installing helm chart", () => {
builder.helmCharts.navigate();
const dockStore = rendererDi.inject(dockStoreInjectable);
const windowDi = builder.applicationWindow.only.di;
const dockStore = windowDi.inject(dockStoreInjectable);
// TODO: Make TerminalWindow unit testable to allow realistic behaviour
dockStore.closeTab("terminal");
@@ -18,7 +18,7 @@ import callForPublicHelmRepositoriesInjectable from "../../renderer/components/+
import showErrorNotificationInjectable from "../../renderer/components/notifications/show-error-notification.injectable";
describe("listing active helm repositories in preferences", () => {
let applicationBuilder: ApplicationBuilder;
let builder: ApplicationBuilder;
let rendered: RenderResult;
let readYamlFileMock: AsyncFnMock<ReadYamlFile>;
let execFileMock: AsyncFnMock<ReturnType<typeof execFileInjectable["instantiate"]>>;
@@ -26,31 +26,33 @@ describe("listing active helm repositories in preferences", () => {
let showErrorNotificationMock: jest.Mock;
beforeEach(async () => {
applicationBuilder = getApplicationBuilder();
builder = getApplicationBuilder();
readYamlFileMock = asyncFn();
execFileMock = asyncFn();
showErrorNotificationMock = jest.fn();
loggerStub = { error: jest.fn() } as unknown as Logger;
applicationBuilder.beforeApplicationStart(({ mainDi, rendererDi }) => {
showErrorNotificationMock = jest.fn();
rendererDi.override(showErrorNotificationInjectable, () => showErrorNotificationMock);
rendererDi.override(callForPublicHelmRepositoriesInjectable, () => async () => []);
builder.beforeApplicationStart((mainDi) => {
mainDi.override(readYamlFileInjectable, () => readYamlFileMock);
mainDi.override(execFileInjectable, () => execFileMock);
mainDi.override(helmBinaryPathInjectable, () => "some-helm-binary-path");
mainDi.override(loggerInjectable, () => loggerStub);
});
rendered = await applicationBuilder.render();
builder.beforeWindowStart((windowDi) => {
windowDi.override(showErrorNotificationInjectable, () => showErrorNotificationMock);
windowDi.override(callForPublicHelmRepositoriesInjectable, () => async () => []);
});
rendered = await builder.render();
});
describe("when navigating to preferences containing helm repositories", () => {
beforeEach(async () => {
applicationBuilder.preferences.navigate();
applicationBuilder.preferences.navigation.click("kubernetes");
builder.preferences.navigate();
builder.preferences.navigation.click("kubernetes");
});
it("renders", () => {
@@ -16,7 +16,7 @@ import callForPublicHelmRepositoriesInjectable from "../../renderer/components/+
import type { AsyncResult } from "../../common/utils/async-result";
describe("remove helm repository from list of active repositories in preferences", () => {
let applicationBuilder: ApplicationBuilder;
let builder: ApplicationBuilder;
let rendered: RenderResult;
let getActiveHelmRepositoriesMock: AsyncFnMock<() => Promise<AsyncResult<HelmRepo[]>>>;
let execFileMock: AsyncFnMock<
@@ -24,30 +24,28 @@ describe("remove helm repository from list of active repositories in preferences
>;
beforeEach(async () => {
applicationBuilder = getApplicationBuilder();
builder = getApplicationBuilder();
execFileMock = asyncFn();
getActiveHelmRepositoriesMock = asyncFn();
applicationBuilder.beforeApplicationStart(({ mainDi, rendererDi }) => {
rendererDi.override(callForPublicHelmRepositoriesInjectable, () => async () => []);
mainDi.override(
getActiveHelmRepositoriesInjectable,
() => getActiveHelmRepositoriesMock,
);
builder.beforeApplicationStart((mainDi) => {
mainDi.override(getActiveHelmRepositoriesInjectable, () => getActiveHelmRepositoriesMock);
mainDi.override(execFileInjectable, () => execFileMock);
mainDi.override(helmBinaryPathInjectable, () => "some-helm-binary-path");
});
rendered = await applicationBuilder.render();
builder.beforeWindowStart((windowDi) => {
windowDi.override(callForPublicHelmRepositoriesInjectable, () => async () => []);
});
rendered = await builder.render();
});
describe("when navigating to preferences containing helm repositories", () => {
beforeEach(async () => {
applicationBuilder.preferences.navigate();
applicationBuilder.preferences.navigation.click("kubernetes");
builder.preferences.navigate();
builder.preferences.navigation.click("kubernetes");
});
it("renders", () => {