mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Introduce a collection of behavioural unit tests for navigation (#5085)
This reverts commit ecd881c25df219b511d7efd43dac59e748b21cc7. Signed-off-by: Iku-turso <mikko.aspiala@gmail.com> Co-authored-by: Janne Savolainen <janne.savolainen@live.fi> Co-authored-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
1 parent
68a605ded9
commit
55d8e0e06c
38 files changed
+17978
No files matched your search
+123
@@ -0,0 +1,123 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`extensions - navigation using application menu renders 1`] = `<div />`;
|
||||
|
||||
exports[`extensions - navigation using application menu when navigating to extensions using application menu renders 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="SettingLayout DropFileInput Extensions"
|
||||
data-testid="extensions-page"
|
||||
>
|
||||
<div
|
||||
class="contentRegion"
|
||||
id="ScrollSpyRoot"
|
||||
>
|
||||
<div
|
||||
class="content"
|
||||
>
|
||||
<section>
|
||||
<h1>
|
||||
Extensions
|
||||
</h1>
|
||||
<div
|
||||
class="mb-14 mt-3"
|
||||
>
|
||||
<p>
|
||||
Add new features via Lens Extensions.
|
||||
|
||||
Check out
|
||||
<a
|
||||
href="https://docs.k8slens.dev/main//extensions/"
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
docs
|
||||
</a>
|
||||
|
||||
and list of
|
||||
<a
|
||||
href="https://github.com/lensapp/lens-extensions/blob/main/README.md"
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
available extensions
|
||||
</a>
|
||||
.
|
||||
</p>
|
||||
</div>
|
||||
<section
|
||||
class="mt-2"
|
||||
>
|
||||
<div
|
||||
class="SubTitle"
|
||||
>
|
||||
Name or file path or URL to an extension package (tar, tgz)
|
||||
|
||||
</div>
|
||||
<div
|
||||
class="flex"
|
||||
>
|
||||
<div
|
||||
class="flex-1"
|
||||
/>
|
||||
<div
|
||||
class="flex-initial"
|
||||
>
|
||||
<button
|
||||
class="Button w-80 h-full primary"
|
||||
type="button"
|
||||
>
|
||||
Install
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<small
|
||||
class="mt-3"
|
||||
>
|
||||
<b>
|
||||
Pro-Tip
|
||||
</b>
|
||||
: you can drag-n-drop tarball-file to this area
|
||||
</small>
|
||||
</section>
|
||||
<div>
|
||||
<div
|
||||
class="Spinner singleColor center"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<div
|
||||
class="toolsRegion"
|
||||
>
|
||||
<div
|
||||
class="fixed top-[60px]"
|
||||
>
|
||||
<div>
|
||||
<div
|
||||
aria-label="Close"
|
||||
role="button"
|
||||
>
|
||||
<i
|
||||
class="Icon material focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="close"
|
||||
>
|
||||
close
|
||||
</span>
|
||||
</i>
|
||||
</div>
|
||||
<div
|
||||
aria-hidden="true"
|
||||
>
|
||||
ESC
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { RenderResult } from "@testing-library/react";
|
||||
import { ApplicationBuilder, getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||
import isAutoUpdateEnabledInjectable from "../../main/is-auto-update-enabled.injectable";
|
||||
import extensionsStoreInjectable from "../../extensions/extensions-store/extensions-store.injectable";
|
||||
import type { ExtensionsStore } from "../../extensions/extensions-store/extensions-store";
|
||||
import fileSystemProvisionerStoreInjectable from "../../extensions/extension-loader/create-extension-instance/file-system-provisioner-store/file-system-provisioner-store.injectable";
|
||||
import type { FileSystemProvisionerStore } from "../../extensions/extension-loader/create-extension-instance/file-system-provisioner-store/file-system-provisioner-store";
|
||||
import focusWindowInjectable from "../../renderer/ipc-channel-listeners/focus-window.injectable";
|
||||
|
||||
// TODO: Make components free of side effects by making them deterministic
|
||||
jest.mock("../../renderer/components/input/input");
|
||||
|
||||
describe("extensions - navigation using application menu", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let rendered: RenderResult;
|
||||
let focusWindowMock: jest.Mock;
|
||||
|
||||
beforeEach(async () => {
|
||||
applicationBuilder = getApplicationBuilder().beforeSetups(({ mainDi, rendererDi }) => {
|
||||
mainDi.override(isAutoUpdateEnabledInjectable, () => () => false);
|
||||
rendererDi.override(extensionsStoreInjectable, () => ({}) as unknown as ExtensionsStore);
|
||||
rendererDi.override(fileSystemProvisionerStoreInjectable, () => ({}) as unknown as FileSystemProvisionerStore);
|
||||
|
||||
focusWindowMock = jest.fn();
|
||||
|
||||
rendererDi.override(focusWindowInjectable, () => focusWindowMock);
|
||||
});
|
||||
|
||||
rendered = await applicationBuilder.render();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
expect(rendered.container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("does not show extensions page yet", () => {
|
||||
const actual = rendered.queryByTestId("extensions-page");
|
||||
|
||||
expect(actual).toBeNull();
|
||||
});
|
||||
|
||||
describe("when navigating to extensions using application menu", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder.applicationMenu.click("root.extensions");
|
||||
});
|
||||
|
||||
it("focuses the window", () => {
|
||||
expect(focusWindowMock).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
expect(rendered.container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("shows extensions page", () => {
|
||||
const actual = rendered.getByTestId("extensions-page");
|
||||
|
||||
expect(actual).not.toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user