Restructure to monorepo (#6907)

* wip: restructure to monorepo

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* refactor create-release-pr to a package

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* build fixes

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* github workflow fixes

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* fix typo

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* add webpack-env types to core

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* fix github workflows

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* refactor/fix integration tests

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* lint fix

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* yarn run dev

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* eslint settings for vscode

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* move templates to right package

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* open-lens build fixes

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* integration test fix

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* fix nx task dependencies

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* use bash shell for unit tests in test workflow

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* fix test:unit for windows

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* fix win-ca webpack error in open-lens

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* fix win-ca webpack error in open-lens

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* fix build:app on windows

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* remove ELECTRON_BUILDER_EXTRA_ARGS

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* sync src/ from master

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* remove Makefile from core

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen authored and GitHub committed 2023-01-24 10:46:26 -08:00
1 parent 0066ca4ea2
commit 2657df2293
3321 files changed
+28699 -11447

No files matched your search

@@ -0,0 +1,338 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`status-bar-items-originating-from-extensions when application starts when extension with status bar items is loaded renders 1`] = `
<body>
<div>
<div
class="ClusterManager"
>
<div
class="topBar"
>
<div
class="items"
>
<div
class="preventedDragging"
>
<i
class="Icon material interactive disabled focusable"
data-testid="home-button"
>
<span
class="icon"
data-icon-name="home"
>
home
</span>
</i>
</div>
<div
class="size-sm"
/>
<div
class="preventedDragging"
>
<i
class="Icon material interactive disabled focusable"
data-testid="history-back"
>
<span
class="icon"
data-icon-name="arrow_back"
>
arrow_back
</span>
</i>
</div>
<div
class="size-sm"
/>
<div
class="preventedDragging"
>
<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="separator"
/>
</div>
</div>
<main>
<div
id="lens-views"
/>
<div
class="flex justify-center Welcome align-center"
data-testid="welcome-page"
>
<div
data-testid="welcome-banner-container"
style="width: 320px;"
>
<i
class="Icon logo svg focusable"
>
<span
class="icon"
/>
</i>
<div
class="flex justify-center"
>
<div
data-testid="welcome-text-container"
style="width: 320px;"
>
<h2>
Welcome to some-product-name!
</h2>
<p>
To get you started we have auto-detected your clusters in your
kubeconfig file and added them to the catalog, your centralized
view for managing all your cloud-native resources.
<br />
<br />
If you have any questions or feedback, please join our
<a
class="link"
href="https://k8slens.dev/slack.html"
rel="noreferrer"
target="_blank"
>
Lens Community slack channel
</a>
.
</p>
<ul
class="block"
data-testid="welcome-menu-container"
style="width: 320px;"
>
<li
class="flex grid-12"
>
<i
class="Icon box col-1 material focusable"
>
<span
class="icon"
data-icon-name="view_list"
>
view_list
</span>
</i>
<a
class="box col-10"
>
Browse Clusters in Catalog
</a>
<i
class="Icon box col-1 material focusable"
>
<span
class="icon"
data-icon-name="navigate_next"
>
navigate_next
</span>
</i>
</li>
</ul>
</div>
</div>
</div>
</div>
</main>
<div
class="HotbarMenu flex column"
>
<div
class="HotbarItems flex column gaps"
>
<div
class="HotbarCell isDraggingOwner animateDown"
index="0"
>
<div
style="z-index: 12; position: absolute;"
>
<div
class="HotbarIcon contextMenuAvailable"
>
<div
class="Avatar rounded disabled avatar"
id="hotbarIcon-hotbar-icon-catalog-entity"
style="width: 40px; height: 40px; background: rgb(5, 1, 130);"
>
Ca
</div>
</div>
</div>
</div>
<div
class="HotbarCell isDraggingOwner animateDown"
index="1"
/>
<div
class="HotbarCell isDraggingOwner animateDown"
index="2"
/>
<div
class="HotbarCell isDraggingOwner animateDown"
index="3"
/>
<div
class="HotbarCell isDraggingOwner animateDown"
index="4"
/>
<div
class="HotbarCell isDraggingOwner animateDown"
index="5"
/>
<div
class="HotbarCell isDraggingOwner animateDown"
index="6"
/>
<div
class="HotbarCell isDraggingOwner animateDown"
index="7"
/>
<div
class="HotbarCell isDraggingOwner animateDown"
index="8"
/>
<div
class="HotbarCell isDraggingOwner animateDown"
index="9"
/>
<div
class="HotbarCell isDraggingOwner animateDown"
index="10"
/>
<div
class="HotbarCell isDraggingOwner animateDown"
index="11"
/>
</div>
<div
class="HotbarSelector"
>
<i
class="Icon Icon previous material interactive focusable"
tabindex="0"
>
<span
class="icon"
data-icon-name="arrow_left"
>
arrow_left
</span>
</i>
<div
class="HotbarIndex"
>
<div
class="badge Badge small clickable"
id="hotbarIndex"
>
1
</div>
</div>
<i
class="Icon material interactive focusable"
tabindex="0"
>
<span
class="icon"
data-icon-name="arrow_right"
>
arrow_right
</span>
</i>
</div>
</div>
<div
class="StatusBar"
data-testid="status-bar"
>
<div
class="leftSide"
data-testid="status-bar-left"
>
<div
class="item"
data-origin="some-name"
>
<div
data-testid="some-testId"
>
left1
</div>
</div>
<div
class="item"
data-origin="some-name"
>
<div
data-testid="some-testId"
>
left2
</div>
</div>
</div>
<div
class="rightSide"
data-testid="status-bar-right"
>
<div
class="item"
data-origin="some-name"
>
<div
data-testid="some-testId"
>
right3
</div>
</div>
<div
class="item"
data-origin="some-name"
>
<span
data-testid="some-testId"
>
right2
</span>
</div>
<div
class="item"
data-origin="some-name"
>
<span
data-testid="some-testId"
>
right1
</span>
</div>
</div>
</div>
</div>
<div
class="Notifications flex column align-flex-end"
/>
</div>
</body>
`;
@@ -0,0 +1,171 @@
/**
* 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 React from "react";
import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
import getRandomIdInjectable from "../../common/utils/get-random-id.injectable";
import type { FakeExtensionOptions } from "../../renderer/components/test-utils/get-extension-fake";
import { computed } from "mobx";
describe("status-bar-items-originating-from-extensions", () => {
let applicationBuilder: ApplicationBuilder;
beforeEach(() => {
applicationBuilder = getApplicationBuilder();
applicationBuilder.beforeWindowStart((windowDi) => {
windowDi.unoverride(getRandomIdInjectable);
windowDi.permitSideEffects(getRandomIdInjectable);
});
});
describe("when application starts", () => {
let rendered: RenderResult;
beforeEach(async () => {
rendered = await applicationBuilder.render();
});
it("when multiple extensions with status bar items are loaded, shows items in correct order", () => {
const testExtension1 = {
id: "some-id",
name: "some-name",
rendererOptions: {
statusBarItems: [
{
components: {
Item: () => <div data-testid="some-testId">extension1</div>,
position: "right" as const,
},
},
],
},
};
const testExtension2 = {
id: "some-other-id",
name: "some-other-name",
rendererOptions: {
statusBarItems: [
{
components: {
Item: () => <div data-testid="some-testId">extension2</div>,
position: "right" as const,
},
},
],
},
};
applicationBuilder.extensions.enable(testExtension1, testExtension2);
const rightSide = rendered.getByTestId("status-bar-right");
const actual = getExpectedTestStatusBarTexts(rightSide, [
"extension1",
"extension2",
]);
expect(actual).toEqual(["extension2", "extension1"]);
});
describe("when extension with status bar items is loaded", () => {
let testExtensionOptions: FakeExtensionOptions;
beforeEach(() => {
testExtensionOptions = {
id: "some-id",
name: "some-name",
rendererOptions: {
statusBarItems: [
{
item: () => <span data-testid="some-testId">right1</span>,
},
{
item: () => <span data-testid="some-testId">right2</span>,
},
{
components: {
Item: () => <div data-testid="some-testId">right3</div>,
position: "right" as const,
},
},
{
components: {
Item: () => <div data-testid="some-testId">right4</div>,
position: "right" as const,
},
visible: computed(() => false),
},
{
components: {
Item: () => <div data-testid="some-testId">left1</div>,
position: "left" as const,
},
},
{
components: {
Item: () => <div data-testid="some-testId">left2</div>,
position: "left" as const,
},
},
],
},
};
applicationBuilder.extensions.enable(testExtensionOptions);
});
it("renders", () => {
expect(rendered.baseElement).toMatchSnapshot();
});
it("shows right side status bar items in the correct order", () => {
const rightSide = rendered.getByTestId("status-bar-right");
const actual = getExpectedTestStatusBarTexts(rightSide, [
"right1",
"right2",
"right3",
]);
expect(actual).toEqual(["right3", "right2", "right1"]);
});
it("doesn't show invisible status bar item", () => {
const rightSide = rendered.getByTestId("status-bar-right");
expect(getTestStatusBarTexts(rightSide)).not.toContain("right4");
});
it("shows left side status bar items in the correct order", () => {
const leftSide = rendered.getByTestId("status-bar-left");
const actual = getExpectedTestStatusBarTexts(leftSide, ["left2", "left1"]);
expect(actual).toEqual(["left1", "left2"]);
});
it("when the extension is removed, shows there are no extension status bar items", () => {
applicationBuilder.extensions.disable(testExtensionOptions);
const actual = rendered.queryAllByTestId("some-testId");
expect(actual).toHaveLength(0);
});
});
});
});
const getTestStatusBarTexts = (actual: HTMLElement) =>
Array.from(actual.children)
.map((elem) => String(elem.textContent));
const getExpectedTestStatusBarTexts = (actual: HTMLElement, expectedTexts: string[]) =>
getTestStatusBarTexts(actual).filter((textContent) => textContent && expectedTexts.includes(textContent));