diff --git a/.swcrc b/.swcrc new file mode 100644 index 0000000000..742642b7eb --- /dev/null +++ b/.swcrc @@ -0,0 +1,18 @@ +{ + "module": { + "type": "commonjs" + }, + "jsc": { + "parser": { + "syntax": "typescript", + "tsx": true, + "decorators": true, + "dynamicImport": false + }, + "transform": { + "legacyDecorator": true, + "decoratorMetadata": true + }, + "target": "es2019" + } +} diff --git a/LICENSE b/LICENSE index 208e7c2e9c..42319c9dae 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021 OpenLens Authors. +Copyright (c) 2022 OpenLens Authors. Portions of this software are licensed as follows: diff --git a/package.json b/package.json index 1b1414d2a5..7c038a4f13 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,9 @@ "productName": "OpenLens", "description": "OpenLens - Open Source IDE for Kubernetes", "homepage": "https://github.com/lensapp/lens", - "version": "5.6.0-alpha.0", + "version": "5.6.0-alpha.2", "main": "static/build/main.js", - "copyright": "© 2021 OpenLens Authors", + "copyright": "© 2022 OpenLens Authors", "license": "MIT", "author": { "name": "OpenLens Authors", @@ -50,7 +50,7 @@ "bundledKubectlVersion": "1.23.3", "bundledHelmVersion": "3.7.2", "sentryDsn": "", - "contentSecurityPolicy": "script-src 'unsafe-eval' 'self'; frame-src http://*.localhost:*/; img-src *" + "contentSecurityPolicy": "script-src 'unsafe-eval' 'self'; frame-src http://*.localhost:*/; img-src * data:" }, "engines": { "node": ">=16 <17" @@ -59,8 +59,12 @@ "collectCoverage": false, "verbose": true, "transform": { - "^.+\\.tsx?$": "ts-jest" + "^.+\\.(t|j)sx?$": [ + "@swc/jest" + ] }, + "testEnvironment": "jsdom", + "resolver": "/src/jest-28-resolver.js", "moduleNameMapper": { "\\.(css|scss)$": "identity-obj-proxy", "\\.(svg|png|jpg|eot|woff2?|ttf)$": "/__mocks__/assetMock.ts" @@ -76,11 +80,7 @@ "setupFilesAfterEnv": [ "/src/jest-after-env.setup.ts" ], - "globals": { - "ts-jest": { - "isolatedModules": true - } - } + "runtime": "@side/jest-runtime" }, "build": { "generateUpdatesFilesForAllChannels": true, @@ -204,16 +204,17 @@ }, "dependencies": { "@astronautlabs/jsonpath": "^1.1.0", - "@hapi/call": "^8.0.1", + "@hapi/call": "^9.0.0", "@hapi/subtext": "^7.0.3", "@kubernetes/client-node": "^0.16.3", "@material-ui/styles": "^4.11.5", - "@ogre-tools/injectable": "7.1.0", - "@ogre-tools/injectable-react": "7.1.0", "@ogre-tools/fp": "7.1.0", + "@ogre-tools/injectable": "7.1.0", "@ogre-tools/injectable-extension-for-auto-registration": "7.1.0", + "@ogre-tools/injectable-react": "7.1.0", "@sentry/electron": "^3.0.7", "@sentry/integrations": "^6.19.3", + "@side/jest-runtime": "^1.0.0", "@types/circular-dependency-plugin": "5.0.5", "abort-controller": "^3.0.0", "auto-bind": "^4.0.0", @@ -233,15 +234,15 @@ "handlebars": "^4.7.7", "history": "^4.10.1", "http-proxy": "^1.18.1", - "immer": "^9.0.14", + "immer": "^9.0.15", "joi": "^17.6.0", "js-yaml": "^4.1.0", "jsdom": "^16.7.0", "lodash": "^4.17.15", "mac-ca": "^1.0.6", - "marked": "^4.0.16", + "marked": "^4.0.17", "md5-file": "^5.0.0", - "mobx": "^6.5.0", + "mobx": "^6.6.0", "mobx-observable-history": "^2.0.3", "mobx-react": "^7.5.0", "mobx-utils": "^6.0.4", @@ -279,7 +280,7 @@ "winston": "^3.7.2", "winston-console-format": "^1.0.8", "winston-transport-browserconsole": "^1.0.5", - "ws": "^8.7.0" + "ws": "^8.8.0" }, "devDependencies": { "@async-fn/jest": "1.6.1", @@ -288,6 +289,8 @@ "@material-ui/lab": "^4.0.0-alpha.60", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.7", "@sentry/types": "^6.19.7", + "@swc/core": "^1.2.197", + "@swc/jest": "^0.2.21", "@testing-library/dom": "^7.31.2", "@testing-library/jest-dom": "^5.16.4", "@testing-library/react": "^12.1.5", @@ -304,9 +307,11 @@ "@types/fs-extra": "^9.0.13", "@types/glob-to-regexp": "^0.4.1", "@types/gunzip-maybe": "^1.4.0", + "@types/hapi__call": "^9.0.0", + "@types/hapi__subtext": "^7.0.0", "@types/html-webpack-plugin": "^3.2.6", "@types/http-proxy": "^1.17.9", - "@types/jest": "^26.0.24", + "@types/jest": "^28.1.1", "@types/js-yaml": "^4.0.5", "@types/jsdom": "^16.2.14", "@types/lodash": "^4.14.181", @@ -314,7 +319,7 @@ "@types/md5-file": "^4.0.2", "@types/mini-css-extract-plugin": "^2.4.0", "@types/mock-fs": "^4.13.1", - "@types/node": "^16.11.39", + "@types/node": "^16.11.40", "@types/node-fetch": "^2.6.1", "@types/npm": "^2.0.32", "@types/proper-lockfile": "^4.1.2", @@ -331,7 +336,7 @@ "@types/request": "^2.48.7", "@types/request-promise-native": "^1.0.18", "@types/semver": "^7.3.9", - "@types/sharp": "^0.30.2", + "@types/sharp": "^0.30.4", "@types/spdy": "^3.4.5", "@types/tar": "^4.0.5", "@types/tar-stream": "^2.2.2", @@ -344,7 +349,7 @@ "@types/webpack-dev-server": "^4.7.2", "@types/webpack-env": "^1.17.0", "@types/webpack-node-externals": "^2.5.3", - "@typescript-eslint/eslint-plugin": "^5.27.1", + "@typescript-eslint/eslint-plugin": "^5.28.0", "@typescript-eslint/parser": "^5.27.0", "ansi_up": "^5.1.0", "chart.js": "^2.9.4", @@ -352,20 +357,20 @@ "cli-progress": "^3.11.1", "color": "^3.2.1", "command-line-args": "^5.2.1", - "concurrently": "^7.2.1", + "concurrently": "^7.2.2", "css-loader": "^6.7.1", "deepdash": "^5.3.9", "dompurify": "^2.3.8", "electron": "^15.5.7", "electron-builder": "^23.0.3", "electron-notarize": "^0.3.0", - "esbuild": "^0.14.38", + "esbuild": "^0.14.43", "esbuild-loader": "^2.19.0", - "eslint": "^8.16.0", + "eslint": "^8.17.0", "eslint-plugin-header": "^3.1.1", "eslint-plugin-import": "^2.26.0", "eslint-plugin-react": "^7.30.0", - "eslint-plugin-react-hooks": "^4.5.0", + "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-unused-imports": "^2.0.0", "flex.box": "^3.4.4", "fork-ts-checker-webpack-plugin": "^6.5.2", @@ -374,10 +379,11 @@ "identity-obj-proxy": "^3.0.0", "ignore-loader": "^0.1.2", "include-media": "^1.4.9", - "jest": "26.6.3", + "jest": "^28.1.1", "jest-canvas-mock": "^2.3.1", + "jest-environment-jsdom": "^28.1.1", "jest-fetch-mock": "^3.0.3", - "jest-mock-extended": "^1.0.18", + "jest-mock-extended": "^2.0.6", "make-plural": "^6.2.2", "mini-css-extract-plugin": "^2.6.0", "mock-http": "^1.1.0", @@ -396,24 +402,23 @@ "react-select-event": "^5.5.0", "react-table": "^7.8.0", "react-window": "^1.8.7", - "sass": "^1.52.2", + "sass": "^1.52.3", "sass-loader": "^12.6.0", "sharp": "^0.30.6", "style-loader": "^3.3.1", "tailwindcss": "^3.0.23", "tar-stream": "^2.2.0", - "ts-jest": "26.5.6", "ts-loader": "^9.2.8", - "ts-node": "^10.7.0", - "type-fest": "^2.13.0", + "ts-node": "^10.8.1", + "type-fest": "^2.13.1", "typed-emitter": "^1.4.0", "typedoc": "0.22.17", "typedoc-plugin-markdown": "^3.11.12", - "typescript": "^4.5.5", + "typescript": "^4.7.3", "typescript-plugin-css-modules": "^3.4.0", "webpack": "^5.73.0", "webpack-cli": "^4.9.2", - "webpack-dev-server": "^4.9.1", + "webpack-dev-server": "^4.9.2", "webpack-node-externals": "^3.0.0", "xterm": "^4.18.0", "xterm-addon-fit": "^0.5.0" diff --git a/scripts/clear-release-pr.mjs b/scripts/create-release-pr.mjs similarity index 93% rename from scripts/clear-release-pr.mjs rename to scripts/create-release-pr.mjs index 4b55384e61..54b6ed17c5 100755 --- a/scripts/clear-release-pr.mjs +++ b/scripts/create-release-pr.mjs @@ -133,7 +133,8 @@ const relaventPrsQuery = await Promise.all( ); const relaventPrs = relaventPrsQuery .filter(query => query.stdout) - .map(query => query.pr); + .map(query => query.pr) + .filter(pr => pr.labels.every(label => label.name !== "skip-changelog")); const enhancementPrLabelName = "enhancement"; const bugfixPrLabelName = "bug"; @@ -152,11 +153,15 @@ const prBodyLines = [ "", ]; +function getPrEntry(pr) { + return `- ${pr.title} (**[#${pr.number}](https://github.com/lensapp/lens/pull/${pr.number})**) https://github.com/${pr.author.login}`; +} + if (enhancementPrs.length > 0) { prBodyLines.push( "## 🚀 Features", "", - ...enhancementPrs.map(pr => `- ${pr.title} (**#${pr.number}**) https://github.com/${pr.author.login}`), + ...enhancementPrs.map(getPrEntry), "", ); } @@ -165,7 +170,7 @@ if (bugfixPrs.length > 0) { prBodyLines.push( "## 🐛 Bug Fixes", "", - ...bugfixPrs.map(pr => `- ${pr.title} (**#${pr.number}**) https://github.com/${pr.author.login}`), + ...bugfixPrs.map(getPrEntry), "", ); } @@ -174,7 +179,7 @@ if (maintenencePrs.length > 0) { prBodyLines.push( "## 🧰 Maintenance", "", - ...maintenencePrs.map(pr => `- ${pr.title} (**#${pr.number}**) https://github.com/${pr.author.login}`), + ...maintenencePrs.map(getPrEntry), "", ); } diff --git a/src/behaviours/__snapshots__/extension-special-characters-in-page-registrations.test.tsx.snap b/src/behaviours/__snapshots__/extension-special-characters-in-page-registrations.test.tsx.snap index 80b0028469..5a952f701b 100644 --- a/src/behaviours/__snapshots__/extension-special-characters-in-page-registrations.test.tsx.snap +++ b/src/behaviours/__snapshots__/extension-special-characters-in-page-registrations.test.tsx.snap @@ -2,6 +2,16 @@ exports[`extension special characters in page registrations renders 1`] = `
+
+
+
+
@@ -10,6 +20,16 @@ exports[`extension special characters in page registrations renders 1`] = ` exports[`extension special characters in page registrations when navigating to route with ID having special characters renders 1`] = `
+
+
+
+
Some page
diff --git a/src/behaviours/__snapshots__/navigate-to-extension-page.test.tsx.snap b/src/behaviours/__snapshots__/navigate-to-extension-page.test.tsx.snap index c96763fe6e..f73444ff0e 100644 --- a/src/behaviours/__snapshots__/navigate-to-extension-page.test.tsx.snap +++ b/src/behaviours/__snapshots__/navigate-to-extension-page.test.tsx.snap @@ -2,6 +2,16 @@ exports[`navigate to extension page renders 1`] = `
+
+
+
+
@@ -10,6 +20,16 @@ exports[`navigate to extension page renders 1`] = ` exports[`navigate to extension page when extension navigates to child route renders 1`] = `
+
+
+
+
Child page
@@ -21,6 +41,16 @@ exports[`navigate to extension page when extension navigates to child route rend exports[`navigate to extension page when extension navigates to route with parameters renders 1`] = `
+
+
+
+
  • @@ -48,6 +78,16 @@ exports[`navigate to extension page when extension navigates to route with param exports[`navigate to extension page when extension navigates to route without parameters renders 1`] = `
    +
    +
    +
    +
    • @@ -75,6 +115,16 @@ exports[`navigate to extension page when extension navigates to route without pa exports[`navigate to extension page when extension navigates to route without parameters when changing page parameters renders 1`] = `
      +
      +
      +
      +
      • diff --git a/src/behaviours/__snapshots__/navigating-between-routes.test.tsx.snap b/src/behaviours/__snapshots__/navigating-between-routes.test.tsx.snap index 10e9eb2d39..bd3c3f51e7 100644 --- a/src/behaviours/__snapshots__/navigating-between-routes.test.tsx.snap +++ b/src/behaviours/__snapshots__/navigating-between-routes.test.tsx.snap @@ -2,6 +2,16 @@ exports[`navigating between routes given route with optional path parameters when navigating to route with path parameters renders 1`] = `
        +
        +
        +
        +
             {
           "someParameter": "some-value",
        @@ -16,6 +26,16 @@ exports[`navigating between routes given route with optional path parameters whe
         
         exports[`navigating between routes given route without path parameters when navigating to route renders 1`] = `
         
        +
        +
        +
        +
        Some component
        diff --git a/src/behaviours/add-cluster/__snapshots__/navigation-using-application-menu.test.tsx.snap b/src/behaviours/add-cluster/__snapshots__/navigation-using-application-menu.test.tsx.snap index 0fd00133aa..f6067dec05 100644 --- a/src/behaviours/add-cluster/__snapshots__/navigation-using-application-menu.test.tsx.snap +++ b/src/behaviours/add-cluster/__snapshots__/navigation-using-application-menu.test.tsx.snap @@ -2,6 +2,16 @@ exports[`add-cluster - navigation using application menu renders 1`] = `
        +
        +
        +
        +
        @@ -10,6 +20,16 @@ exports[`add-cluster - navigation using application menu renders 1`] = ` exports[`add-cluster - navigation using application menu when navigating to add cluster using application menu renders 1`] = `
        +
        +
        +
        +
        +
        +
        +
        +
        @@ -13,6 +23,16 @@ exports[`installing update using tray when started renders 1`] = ` exports[`installing update using tray when started when user checks for updates using tray renders 1`] = `
        +
        +
        +
        +
        @@ -64,6 +84,16 @@ exports[`installing update using tray when started when user checks for updates exports[`installing update using tray when started when user checks for updates using tray when new update is discovered renders 1`] = `
        +
        +
        +
        +
        @@ -155,6 +185,16 @@ exports[`installing update using tray when started when user checks for updates exports[`installing update using tray when started when user checks for updates using tray when new update is discovered when download fails renders 1`] = `
        +
        +
        +
        +
        @@ -286,6 +326,16 @@ exports[`installing update using tray when started when user checks for updates exports[`installing update using tray when started when user checks for updates using tray when new update is discovered when download succeeds renders 1`] = `
        +
        +
        +
        +
        @@ -447,6 +497,16 @@ Lens should restart automatically, if it doesn't please restart manually. Instal exports[`installing update using tray when started when user checks for updates using tray when no new update is discovered renders 1`] = `
        +
        +
        +
        +
        diff --git a/src/behaviours/application-update/__snapshots__/installing-update.test.ts.snap b/src/behaviours/application-update/__snapshots__/installing-update.test.ts.snap index 7025289254..0e271ef2d3 100644 --- a/src/behaviours/application-update/__snapshots__/installing-update.test.ts.snap +++ b/src/behaviours/application-update/__snapshots__/installing-update.test.ts.snap @@ -3,6 +3,16 @@ exports[`installing update when started renders 1`] = `
        +
        +
        +
        +
        @@ -13,6 +23,16 @@ exports[`installing update when started renders 1`] = ` exports[`installing update when started when user checks for updates renders 1`] = `
        +
        +
        +
        +
        @@ -23,6 +43,16 @@ exports[`installing update when started when user checks for updates renders 1`] exports[`installing update when started when user checks for updates when new update is discovered renders 1`] = `
        +
        +
        +
        +
        @@ -33,6 +63,16 @@ exports[`installing update when started when user checks for updates when new up exports[`installing update when started when user checks for updates when new update is discovered when download fails renders 1`] = `
        +
        +
        +
        +
        @@ -43,6 +83,16 @@ exports[`installing update when started when user checks for updates when new up exports[`installing update when started when user checks for updates when new update is discovered when download succeeds renders 1`] = `
        +
        +
        +
        +
        @@ -53,6 +103,16 @@ exports[`installing update when started when user checks for updates when new up exports[`installing update when started when user checks for updates when new update is discovered when download succeeds when user answers not to install the update renders 1`] = `
        +
        +
        +
        +
        @@ -63,6 +123,16 @@ exports[`installing update when started when user checks for updates when new up exports[`installing update when started when user checks for updates when new update is discovered when download succeeds when user answers to install the update renders 1`] = `
        +
        +
        +
        +
        @@ -73,6 +143,16 @@ exports[`installing update when started when user checks for updates when new up exports[`installing update when started when user checks for updates when no new update is discovered renders 1`] = `
        +
        +
        +
        +
        diff --git a/src/behaviours/application-update/__snapshots__/periodical-checking-of-updates.test.ts.snap b/src/behaviours/application-update/__snapshots__/periodical-checking-of-updates.test.ts.snap index 84fa35ae04..744a9dfb7e 100644 --- a/src/behaviours/application-update/__snapshots__/periodical-checking-of-updates.test.ts.snap +++ b/src/behaviours/application-update/__snapshots__/periodical-checking-of-updates.test.ts.snap @@ -3,6 +3,16 @@ exports[`periodical checking of updates given updater is enabled and configuration exists, when started renders 1`] = `
        +
        +
        +
        +
        diff --git a/src/behaviours/application-update/__snapshots__/selection-of-update-stability.test.ts.snap b/src/behaviours/application-update/__snapshots__/selection-of-update-stability.test.ts.snap index dc96c447b0..ea700234da 100644 --- a/src/behaviours/application-update/__snapshots__/selection-of-update-stability.test.ts.snap +++ b/src/behaviours/application-update/__snapshots__/selection-of-update-stability.test.ts.snap @@ -3,6 +3,16 @@ exports[`selection of update stability when started renders 1`] = `
        +
        +
        +
        +
        diff --git a/src/behaviours/application-update/analytics-for-installing-update.test.ts b/src/behaviours/application-update/analytics-for-installing-update.test.ts new file mode 100644 index 0000000000..c33a3f92af --- /dev/null +++ b/src/behaviours/application-update/analytics-for-installing-update.test.ts @@ -0,0 +1,225 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ +import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; +import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; +import electronUpdaterIsActiveInjectable from "../../main/electron-app/features/electron-updater-is-active.injectable"; +import publishIsConfiguredInjectable from "../../main/application-update/publish-is-configured.injectable"; +import type { AsyncFnMock } from "@async-fn/jest"; +import asyncFn from "@async-fn/jest"; +import type { CheckForPlatformUpdates } from "../../main/application-update/check-for-platform-updates/check-for-platform-updates.injectable"; +import checkForPlatformUpdatesInjectable from "../../main/application-update/check-for-platform-updates/check-for-platform-updates.injectable"; +import appEventBusInjectable from "../../common/app-event-bus/app-event-bus.injectable"; +import type { DiContainer } from "@ogre-tools/injectable"; +import processCheckingForUpdatesInjectable from "../../main/application-update/check-for-updates/process-checking-for-updates.injectable"; +import type { DownloadPlatformUpdate } from "../../main/application-update/download-platform-update/download-platform-update.injectable"; +import downloadPlatformUpdateInjectable from "../../main/application-update/download-platform-update/download-platform-update.injectable"; +import quitAndInstallUpdateInjectable from "../../main/application-update/quit-and-install-update.injectable"; +import appVersionInjectable from "../../common/get-configuration-file-model/app-version/app-version.injectable"; +import periodicalCheckForUpdatesInjectable from "../../main/application-update/periodical-check-for-updates/periodical-check-for-updates.injectable"; + +describe("analytics for installing update", () => { + let applicationBuilder: ApplicationBuilder; + let checkForPlatformUpdatesMock: AsyncFnMock; + let downloadPlatformUpdateMock: AsyncFnMock; + let analyticsListenerMock: jest.Mock; + let mainDi: DiContainer; + + beforeEach(async () => { + jest.useFakeTimers(); + + global.Date.now = () => new Date("2015-10-21T07:28:00Z").getTime(); + + applicationBuilder = getApplicationBuilder(); + + analyticsListenerMock = jest.fn(); + + applicationBuilder.beforeApplicationStart(({ mainDi }) => { + mainDi.override(appVersionInjectable, () => "42.0.0"); + + checkForPlatformUpdatesMock = asyncFn(); + + mainDi.override( + checkForPlatformUpdatesInjectable, + () => checkForPlatformUpdatesMock, + ); + + downloadPlatformUpdateMock = asyncFn(); + + mainDi.override(downloadPlatformUpdateInjectable, () => downloadPlatformUpdateMock); + mainDi.override(electronUpdaterIsActiveInjectable, () => true); + + mainDi.override(publishIsConfiguredInjectable, () => true); + + const eventBus = mainDi.inject(appEventBusInjectable); + + eventBus.addListener(analyticsListenerMock); + }); + + mainDi = applicationBuilder.dis.mainDi; + }); + + describe("given application is started and checking updates periodically", () => { + beforeEach(async () => { + mainDi.unoverride(periodicalCheckForUpdatesInjectable); + mainDi.permitSideEffects(periodicalCheckForUpdatesInjectable); + + await applicationBuilder.render(); + + }); + + it("sends event to analytics for being checked periodically", () => { + expect(analyticsListenerMock).toHaveBeenCalledWith({ + name: "app", + action: "checking-for-updates", + + params: { + currentDateTime: "2015-10-21T07:28:00Z", + source: "periodic", + }, + }); + }); + + it("when enough time passes to check for updates again, sends event to analytics for being checked periodically", () => { + analyticsListenerMock.mockClear(); + + jest.advanceTimersByTime(1000 * 60 * 60 * 2); + + expect(analyticsListenerMock).toHaveBeenCalledWith({ + name: "app", + action: "checking-for-updates", + + params: { + currentDateTime: "2015-10-21T07:28:00Z", + source: "periodic", + }, + }); + }); + }); + + describe("when application is started", () => { + beforeEach(async () => { + analyticsListenerMock.mockClear(); + + await applicationBuilder.render(); + }); + + it("sends event to analytics about the current version", () => { + expect(analyticsListenerMock).toHaveBeenCalledWith({ + name: "app", + action: "current-version", + + params: { + version: "42.0.0", + currentDateTime: "2015-10-21T07:28:00Z", + }, + }); + }); + + it("when checking for updates using tray, sends event to analytics for being checked from tray", async () => { + analyticsListenerMock.mockClear(); + + applicationBuilder.tray.click("check-for-updates"); + + expect(analyticsListenerMock.mock.calls).toEqual([ + [ + { + name: "app", + action: "checking-for-updates", + + params: { + currentDateTime: "2015-10-21T07:28:00Z", + source: "tray", + }, + }, + ], + ]); + + }); + + it("when checking for updates using application menu, sends event to analytics for being checked from application menu", async () => { + analyticsListenerMock.mockClear(); + + applicationBuilder.applicationMenu.click("root.check-for-updates"); + + expect(analyticsListenerMock.mock.calls).toEqual([ + [ + { + name: "app", + action: "checking-for-updates", + + params: { + currentDateTime: "2015-10-21T07:28:00Z", + source: "application-menu", + }, + }, + ], + ]); + }); + + describe("given checking for updates, when check for updates resolves with new update being available", () => { + beforeEach(async () => { + const processCheckingForUpdates = mainDi.inject(processCheckingForUpdatesInjectable); + + processCheckingForUpdates("irrelevant"); + + analyticsListenerMock.mockClear(); + + await checkForPlatformUpdatesMock.resolve({ + updateWasDiscovered: true, + version: "43.0.0", + }); + }); + + it("sends event to analytics about new update being available", () => { + expect(analyticsListenerMock.mock.calls).toEqual([ + [ + { + name: "app", + action: "update-was-discovered", + + params: { + version: "43.0.0", + currentDateTime: "2015-10-21T07:28:00Z", + }, + }, + ], + ]); + }); + + describe("given update is downloaded", () => { + beforeEach(async () => { + analyticsListenerMock.mockClear(); + + await downloadPlatformUpdateMock.resolve({ downloadWasSuccessful: true }); + }); + + it("does not send event to analytics about update downloaded being successful", () => { + expect(analyticsListenerMock).not.toHaveBeenCalled(); + }); + + it("when installing the update, sends event to analytics about installing the update", () => { + const quitAndInstallUpdate = mainDi.inject(quitAndInstallUpdateInjectable); + + quitAndInstallUpdate(); + + expect(analyticsListenerMock.mock.calls).toEqual([ + [ + { + name: "app", + action: "start-installing-update", + + params: { + version: "43.0.0", + currentDateTime: "2015-10-21T07:28:00Z", + updateChannel: "latest", + }, + }, + ], + ]); + }); + }); + }); + }); +}); diff --git a/src/behaviours/application-update/downgrading-version-update.test.ts b/src/behaviours/application-update/downgrading-version-update.test.ts index e8e5635fb3..2abefa1ac8 100644 --- a/src/behaviours/application-update/downgrading-version-update.test.ts +++ b/src/behaviours/application-update/downgrading-version-update.test.ts @@ -22,8 +22,6 @@ describe("downgrading version update", () => { let mainDi: DiContainer; beforeEach(() => { - jest.useFakeTimers(); - applicationBuilder = getApplicationBuilder(); applicationBuilder.beforeApplicationStart(({ mainDi }) => { @@ -79,7 +77,7 @@ describe("downgrading version update", () => { const processCheckingForUpdates = mainDi.inject(processCheckingForUpdatesInjectable); - processCheckingForUpdates(); + processCheckingForUpdates("irrelevant"); expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(expect.any(Object), { allowDowngrade: downgradeIsAllowed }); }); diff --git a/src/behaviours/application-update/installing-update.test.ts b/src/behaviours/application-update/installing-update.test.ts index 3fec5f6d27..14cd107598 100644 --- a/src/behaviours/application-update/installing-update.test.ts +++ b/src/behaviours/application-update/installing-update.test.ts @@ -4,7 +4,7 @@ */ import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; -import quitAndInstallUpdateInjectable from "../../main/electron-app/features/quit-and-install-update.injectable"; +import quitAndInstallUpdateInjectable from "../../main/application-update/quit-and-install-update.injectable"; import type { RenderResult } from "@testing-library/react"; import electronUpdaterIsActiveInjectable from "../../main/electron-app/features/electron-updater-is-active.injectable"; import publishIsConfiguredInjectable from "../../main/application-update/publish-is-configured.injectable"; @@ -67,7 +67,7 @@ describe("installing update", () => { describe("when started", () => { let rendered: RenderResult; - let processCheckingForUpdates: () => Promise; + let processCheckingForUpdates: (source: string) => Promise; beforeEach(async () => { rendered = await applicationBuilder.render(); @@ -83,7 +83,7 @@ describe("installing update", () => { let processCheckingForUpdatesPromise: Promise; beforeEach(async () => { - processCheckingForUpdatesPromise = processCheckingForUpdates(); + processCheckingForUpdatesPromise = processCheckingForUpdates("irrelevant"); }); it("checks for updates", () => { diff --git a/src/behaviours/application-update/selection-of-update-stability.test.ts b/src/behaviours/application-update/selection-of-update-stability.test.ts index 1792fcd484..1fd6e22dbd 100644 --- a/src/behaviours/application-update/selection-of-update-stability.test.ts +++ b/src/behaviours/application-update/selection-of-update-stability.test.ts @@ -4,7 +4,7 @@ */ import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; -import quitAndInstallUpdateInjectable from "../../main/electron-app/features/quit-and-install-update.injectable"; +import quitAndInstallUpdateInjectable from "../../main/application-update/quit-and-install-update.injectable"; import type { RenderResult } from "@testing-library/react"; import electronUpdaterIsActiveInjectable from "../../main/electron-app/features/electron-updater-is-active.injectable"; import publishIsConfiguredInjectable from "../../main/application-update/publish-is-configured.injectable"; @@ -72,7 +72,7 @@ describe("selection of update stability", () => { describe("when started", () => { let rendered: RenderResult; - let processCheckingForUpdates: () => Promise; + let processCheckingForUpdates: (source: string) => Promise; beforeEach(async () => { rendered = await applicationBuilder.render(); @@ -97,7 +97,7 @@ describe("selection of update stability", () => { selectedUpdateChannel.setValue(updateChannels.alpha.id); - processCheckingForUpdates(); + processCheckingForUpdates("irrelevant"); }); it('checks updates from update channel "alpha"', () => { @@ -191,7 +191,7 @@ describe("selection of update stability", () => { describe("when checking for updates", () => { beforeEach(() => { - processCheckingForUpdates(); + processCheckingForUpdates("irrelevant"); }); describe('when update from "beta" channel is discovered', () => { @@ -241,7 +241,7 @@ describe("selection of update stability", () => { const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable); - processCheckingForUpdates(); + processCheckingForUpdates("irrelevant"); expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(updateChannels.beta, expect.any(Object)); }); @@ -259,7 +259,7 @@ describe("selection of update stability", () => { const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable); - processCheckingForUpdates(); + processCheckingForUpdates("irrelevant"); expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(updateChannels.latest, expect.any(Object)); }); @@ -273,7 +273,7 @@ describe("selection of update stability", () => { const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable); - processCheckingForUpdates(); + processCheckingForUpdates("irrelevant"); expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith( updateChannels.latest, @@ -290,7 +290,7 @@ describe("selection of update stability", () => { const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable); - processCheckingForUpdates(); + processCheckingForUpdates("irrelevant"); expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(updateChannels.alpha, expect.any(Object)); }); @@ -304,7 +304,7 @@ describe("selection of update stability", () => { const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable); - processCheckingForUpdates(); + processCheckingForUpdates("irrelevant"); expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(updateChannels.beta, expect.any(Object)); }); @@ -324,7 +324,7 @@ describe("selection of update stability", () => { const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable); - processCheckingForUpdates(); + processCheckingForUpdates("irrelevant"); expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(updateChannels.beta, expect.any(Object)); }); diff --git a/src/behaviours/cluster/sidebar-and-tab-navigation-for-core.test.tsx b/src/behaviours/cluster/sidebar-and-tab-navigation-for-core.test.tsx index f270b7d13e..a8c26acc2a 100644 --- a/src/behaviours/cluster/sidebar-and-tab-navigation-for-core.test.tsx +++ b/src/behaviours/cluster/sidebar-and-tab-navigation-for-core.test.tsx @@ -14,7 +14,7 @@ import { sidebarItemsInjectionToken } from "../../renderer/components/layout/sid import { computed } from "mobx"; import { noop } from "lodash/fp"; import routeIsActiveInjectable from "../../renderer/routes/route-is-active.injectable"; -import { routeInjectionToken } from "../../common/front-end-routing/route-injection-token"; +import { frontEndRouteInjectionToken } from "../../common/front-end-routing/front-end-route-injection-token"; import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; import writeJsonFileInjectable from "../../common/fs/write-json-file.injectable"; @@ -337,7 +337,7 @@ const testRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); const testRouteComponentInjectable = getInjectable({ diff --git a/src/behaviours/cluster/visibility-of-sidebar-items.test.tsx b/src/behaviours/cluster/visibility-of-sidebar-items.test.tsx index aa73936470..c0e0cc88f3 100644 --- a/src/behaviours/cluster/visibility-of-sidebar-items.test.tsx +++ b/src/behaviours/cluster/visibility-of-sidebar-items.test.tsx @@ -10,7 +10,7 @@ import { computed } from "mobx"; import { routeSpecificComponentInjectionToken } from "../../renderer/routes/route-specific-component-injection-token"; import React from "react"; import isAllowedResourceInjectable from "../../common/utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../common/front-end-routing/route-injection-token"; +import { frontEndRouteInjectionToken } from "../../common/front-end-routing/front-end-route-injection-token"; import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; import { navigateToRouteInjectionToken } from "../../common/front-end-routing/navigate-to-route-injection-token"; @@ -83,7 +83,7 @@ const testRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); const testRouteComponentInjectable = getInjectable({ diff --git a/src/behaviours/extensions/__snapshots__/navigation-using-application-menu.test.ts.snap b/src/behaviours/extensions/__snapshots__/navigation-using-application-menu.test.ts.snap index c14ccb6160..8dd45c656a 100644 --- a/src/behaviours/extensions/__snapshots__/navigation-using-application-menu.test.ts.snap +++ b/src/behaviours/extensions/__snapshots__/navigation-using-application-menu.test.ts.snap @@ -2,6 +2,16 @@ exports[`extensions - navigation using application menu renders 1`] = `
        +
        +
        +
        +
        @@ -10,6 +20,16 @@ exports[`extensions - navigation using application menu renders 1`] = ` exports[`extensions - navigation using application menu when navigating to extensions using application menu renders 1`] = `
        +
        +
        +
        +
        { }); describe("when navigating to extensions using application menu", () => { - beforeEach(async () => { - await applicationBuilder.applicationMenu.click("root.extensions"); + beforeEach(() => { + applicationBuilder.applicationMenu.click("root.extensions"); }); it("focuses the window", () => { diff --git a/src/behaviours/helm-charts/__snapshots__/add-custom-helm-repository-in-preferences.test.ts.snap b/src/behaviours/helm-charts/__snapshots__/add-custom-helm-repository-in-preferences.test.ts.snap new file mode 100644 index 0000000000..21803cf04a --- /dev/null +++ b/src/behaviours/helm-charts/__snapshots__/add-custom-helm-repository-in-preferences.test.ts.snap @@ -0,0 +1,6951 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`add custom helm repository in preferences when navigating to preferences containing helm repositories renders 1`] = ` + +
        +
        +
        +
        +
        +
        + +
        +
        +
        +
        +

        + Kubernetes +

        +
        +
        + Kubectl binary download + +
        + +
        +
        +
        + Download mirror + +
        +
        + + +
        +
        +
        + Download mirror for kubectl +
        +
        + +
        +
        +
        + + +
        +
        +
        +
        +
        +
        + Directory for binaries + +
        +
        + +
        +
        +
        + The directory to download binaries into. +
        +
        +
        +
        + Path to kubectl binary + +
        +
        + +
        +
        +
        +
        +
        +
        +

        + Kubeconfig Syncs +

        +
        + +
        +
        + Synced Items + +
        +
        +
        + No files and folders have been synced yet +
        +
        +
        +
        +
        +

        + Helm Charts +

        +
        +
        +
        +
        + + +
        +
        +
        + Repositories +
        +
        + +
        +
        +
        + + + +
        +
        +
        + +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        + + + close + + +
        + +
        +
        +
        +
        +
        +
        +
        + +`; + +exports[`add custom helm repository in preferences when navigating to preferences containing helm repositories when active repositories resolve renders 1`] = ` + +
        +
        +
        +
        +
        +
        + +
        +
        +
        +
        +

        + Kubernetes +

        +
        +
        + Kubectl binary download + +
        + +
        +
        +
        + Download mirror + +
        +
        + + +
        +
        +
        + Download mirror for kubectl +
        +
        + +
        +
        +
        + + +
        +
        +
        +
        +
        +
        + Directory for binaries + +
        +
        + +
        +
        +
        + The directory to download binaries into. +
        +
        +
        +
        + Path to kubectl binary + +
        +
        + +
        +
        +
        +
        +
        +
        +

        + Kubeconfig Syncs +

        +
        + +
        +
        + Synced Items + +
        +
        +
        + No files and folders have been synced yet +
        +
        +
        +
        +
        +

        + Helm Charts +

        +
        +
        +
        +
        + + +
        +
        +
        + Repositories +
        +
        + +
        +
        +
        + + +
        +
        +
        + +
        +
        +
        +
        +
        + Some active repository +
        +
        + some-url +
        +
        + + + delete + + +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        + + + close + + +
        + +
        +
        +
        +
        +
        +
        +
        + +`; + +exports[`add custom helm repository in preferences when navigating to preferences containing helm repositories when active repositories resolve when selecting to add custom repository renders 1`] = ` + +
        +
        +
        +
        +
        +
        + +
        +
        +
        +
        +

        + Kubernetes +

        +
        +
        + Kubectl binary download + +
        + +
        +
        +
        + Download mirror + +
        +
        + + +
        +
        +
        + Download mirror for kubectl +
        +
        + +
        +
        +
        + + +
        +
        +
        +
        +
        +
        + Directory for binaries + +
        +
        + +
        +
        +
        + The directory to download binaries into. +
        +
        +
        +
        + Path to kubectl binary + +
        +
        + +
        +
        +
        +
        +
        +
        +

        + Kubeconfig Syncs +

        +
        + +
        +
        + Synced Items + +
        +
        +
        + No files and folders have been synced yet +
        +
        +
        +
        +
        +

        + Helm Charts +

        +
        +
        +
        +
        + + +
        +
        +
        + Repositories +
        +
        + +
        +
        +
        + + +
        +
        +
        + +
        +
        +
        +
        +
        + Some active repository +
        +
        + some-url +
        +
        + + + delete + + +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        + + + close + + +
        + +
        +
        +
        +
        +
        +
        +
        +