-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce a collection of behavioural unit tests for navigation
This reverts commit ecd881c25df219b511d7efd43dac59e748b21cc7. Signed-off-by: Iku-turso <mikko.aspiala@gmail.com> Co-authored-by: Janne Savolainen <janne.savolainen@live.fi>
- Loading branch information
Showing
38 changed files
with
17,978 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...behaviours/__snapshots__/extension-special-characters-in-page-registrations.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`extension special characters in page registrations renders 1`] = `<div />`; | ||
|
||
exports[`extension special characters in page registrations when navigating to route with ID having special characters renders 1`] = ` | ||
<div> | ||
<div> | ||
Some page | ||
</div> | ||
</div> | ||
`; |
83 changes: 83 additions & 0 deletions
83
src/behaviours/__snapshots__/navigate-to-extension-page.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`navigate to extension page renders 1`] = `<div />`; | ||
|
||
exports[`navigate to extension page when extension navigates to child route renders 1`] = ` | ||
<div> | ||
<div> | ||
Child page | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`navigate to extension page when extension navigates to route with parameters renders 1`] = ` | ||
<div> | ||
<div> | ||
<ul> | ||
<li> | ||
some-string-value-from-navigate | ||
</li> | ||
<li> | ||
126 | ||
</li> | ||
<li> | ||
some-array-value-from-navigate | ||
</li> | ||
</ul> | ||
<button | ||
data-testid="button-to-change-page-parameters" | ||
type="button" | ||
> | ||
Some button | ||
</button> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`navigate to extension page when extension navigates to route without parameters renders 1`] = ` | ||
<div> | ||
<div> | ||
<ul> | ||
<li> | ||
some-string-value | ||
</li> | ||
<li> | ||
42 | ||
</li> | ||
<li> | ||
some-array-value,some-other-array-value | ||
</li> | ||
</ul> | ||
<button | ||
data-testid="button-to-change-page-parameters" | ||
type="button" | ||
> | ||
Some button | ||
</button> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`navigate to extension page when extension navigates to route without parameters when changing page parameters renders 1`] = ` | ||
<div> | ||
<div> | ||
<ul> | ||
<li> | ||
some-changed-string-value | ||
</li> | ||
<li> | ||
84 | ||
</li> | ||
<li> | ||
some-changed-array-value,some-other-changed-array-value | ||
</li> | ||
</ul> | ||
<button | ||
data-testid="button-to-change-page-parameters" | ||
type="button" | ||
> | ||
Some button | ||
</button> | ||
</div> | ||
</div> | ||
`; |
20 changes: 20 additions & 0 deletions
20
src/behaviours/__snapshots__/navigating-between-routes.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`navigating between routes given route with optional path parameters when navigating to route with path parameters renders 1`] = ` | ||
<div> | ||
<pre> | ||
{ | ||
"someParameter": "some-value", | ||
"someOtherParameter": "some-other-value" | ||
} | ||
</pre> | ||
</div> | ||
`; | ||
|
||
exports[`navigating between routes given route without path parameters when navigating to route renders 1`] = ` | ||
<div> | ||
<div> | ||
Some component | ||
</div> | ||
</div> | ||
`; |
89 changes: 89 additions & 0 deletions
89
src/behaviours/add-cluster/__snapshots__/navigation-using-application-menu.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`add-cluster - navigation using application menu renders 1`] = `<div />`; | ||
|
||
exports[`add-cluster - navigation using application menu when navigating to add cluster using application menu renders 1`] = ` | ||
<div> | ||
<div | ||
class="SettingLayout" | ||
data-testid="add-cluster-page" | ||
> | ||
<div | ||
class="contentRegion" | ||
id="ScrollSpyRoot" | ||
> | ||
<div | ||
class="content flex column gaps" | ||
> | ||
<h2> | ||
Add Clusters from Kubeconfig | ||
</h2> | ||
<p> | ||
Clusters added here are | ||
<b> | ||
not | ||
</b> | ||
merged into the | ||
<code> | ||
~/.kube/config | ||
</code> | ||
file. | ||
<a | ||
href="https://docs.k8slens.dev/main//catalog/add-clusters/" | ||
rel="noreferrer" | ||
target="_blank" | ||
> | ||
Read more about adding clusters | ||
</a> | ||
. | ||
</p> | ||
<div | ||
class="flex column" | ||
/> | ||
<div | ||
class="actions-panel" | ||
> | ||
<button | ||
class="Button primary" | ||
disabled="" | ||
type="button" | ||
> | ||
Add clusters | ||
</button> | ||
</div> | ||
</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> | ||
`; |
51 changes: 51 additions & 0 deletions
51
src/behaviours/add-cluster/navigation-using-application-menu.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* 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"; | ||
|
||
// TODO: Make components free of side effects by making them deterministic | ||
jest.mock("../../renderer/components/tooltip"); | ||
jest.mock("../../renderer/components/monaco-editor/monaco-editor"); | ||
|
||
describe("add-cluster - navigation using application menu", () => { | ||
let applicationBuilder: ApplicationBuilder; | ||
let rendered: RenderResult; | ||
|
||
beforeEach(async () => { | ||
applicationBuilder = getApplicationBuilder().beforeSetups(({ mainDi }) => { | ||
mainDi.override(isAutoUpdateEnabledInjectable, () => () => false); | ||
}); | ||
|
||
rendered = await applicationBuilder.render(); | ||
}); | ||
|
||
it("renders", () => { | ||
expect(rendered.container).toMatchSnapshot(); | ||
}); | ||
|
||
it("does not show add cluster page yet", () => { | ||
const actual = rendered.queryByTestId("add-cluster-page"); | ||
|
||
expect(actual).toBeNull(); | ||
}); | ||
|
||
describe("when navigating to add cluster using application menu", () => { | ||
beforeEach(() => { | ||
applicationBuilder.applicationMenu.click("file.add-cluster"); | ||
}); | ||
|
||
it("renders", () => { | ||
expect(rendered.container).toMatchSnapshot(); | ||
}); | ||
|
||
it("shows add cluster page", () => { | ||
const actual = rendered.getByTestId("add-cluster-page"); | ||
|
||
expect(actual).not.toBeNull(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.