mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix open CommandDialog (#5818)
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
81e4dabf01
commit
ede8a2e91f
13 files changed
+2241
-76
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,148 @@
|
||||
/**
|
||||
* 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 userEvent from "@testing-library/user-event";
|
||||
import platformInjectable from "../../common/vars/platform.injectable";
|
||||
import { type ApplicationBuilder, getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||
|
||||
describe("Command Pallet: keyboard shortcut tests", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let rendered: RenderResult;
|
||||
|
||||
beforeEach(async () => {
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
});
|
||||
|
||||
describe("when on macOS", () => {
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.dis.rendererDi.override(platformInjectable, () => "darwin");
|
||||
rendered = await applicationBuilder.render();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
expect(rendered.baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("does not show the command pallet yet", () => {
|
||||
const actual = rendered.queryByTestId("command-container");
|
||||
|
||||
expect(actual).toBeNull();
|
||||
});
|
||||
|
||||
describe("when pressing ESC", () => {
|
||||
beforeEach(() => {
|
||||
userEvent.keyboard("{Escape}");
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
expect(rendered.baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("does not show the command pallet yet", () => {
|
||||
const actual = rendered.queryByTestId("command-container");
|
||||
|
||||
expect(actual).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("when pressing SHIFT+CMD+P", () => {
|
||||
beforeEach(() => {
|
||||
userEvent.keyboard("{Shift>}{Meta>}P{/Meta}{/Shift}");
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
expect(rendered.baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("shows the command pallet", () => {
|
||||
const actual = rendered.queryByTestId("command-container");
|
||||
|
||||
expect(actual).toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe("when pressing ESC", () => {
|
||||
beforeEach(() => {
|
||||
userEvent.keyboard("{Escape}");
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
expect(rendered.baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("no longer shows the command pallet", () => {
|
||||
const actual = rendered.queryByTestId("command-container");
|
||||
|
||||
expect(actual).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("when on linux", () => {
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.dis.rendererDi.override(platformInjectable, () => "linux");
|
||||
rendered = await applicationBuilder.render();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
expect(rendered.baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("does not show the command pallet yet", () => {
|
||||
const actual = rendered.queryByTestId("command-container");
|
||||
|
||||
expect(actual).toBeNull();
|
||||
});
|
||||
|
||||
describe("when pressing ESC", () => {
|
||||
beforeEach(() => {
|
||||
userEvent.keyboard("{Escape}");
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
expect(rendered.baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("does not show the command pallet yet", () => {
|
||||
const actual = rendered.queryByTestId("command-container");
|
||||
|
||||
expect(actual).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("when pressing SHIFT+CTRL+P", () => {
|
||||
beforeEach(() => {
|
||||
userEvent.keyboard("{Shift>}{Control>}P{/Control}{/Shift}");
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
expect(rendered.baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("shows the command pallet", () => {
|
||||
const actual = rendered.queryByTestId("command-container");
|
||||
|
||||
expect(actual).toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe("when pressing ESC", () => {
|
||||
beforeEach(() => {
|
||||
userEvent.keyboard("{Escape}");
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
expect(rendered.baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("no longer shows the command pallet", () => {
|
||||
const actual = rendered.queryByTestId("command-container");
|
||||
|
||||
expect(actual).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user