From 8b36349951e85bd61e7e92d86192aacab33d4a24 Mon Sep 17 00:00:00 2001 From: Jim Ehrismann Date: Fri, 23 Oct 2020 16:09:12 -0400 Subject: [PATCH] addded Preferences page helm repo test Signed-off-by: Jim Ehrismann --- integration/__tests__/app.tests.ts | 11 +++++++++-- src/main/menu.ts | 13 ++++++++----- .../components/+preferences/preferences.tsx | 2 +- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/integration/__tests__/app.tests.ts b/integration/__tests__/app.tests.ts index 13c42dfe3b..854a92dde5 100644 --- a/integration/__tests__/app.tests.ts +++ b/integration/__tests__/app.tests.ts @@ -47,16 +47,23 @@ describe("Lens integration tests", () => { await clickWhatsNew(app) }) - // Todo figure out how to access main menu to get these to work it('shows "add cluster"', async () => { await app.electron.ipcRenderer.send('test-menu-item-click', "File", "Add Cluster") await app.client.waitUntilTextExists("h2", "Add Cluster") }) - it('shows "preferences"', async () => { + describe("preferences page", () => { + it('shows "preferences"', async () => { let appName: string = process.platform === "darwin" ? "Lens" : "File" await app.electron.ipcRenderer.send('test-menu-item-click', appName, "Preferences") await app.client.waitUntilTextExists("h2", "Preferences") + }) + + it('ensures helm repos', async () => { + await app.client.waitUntilTextExists("div.repos #message-stable", "stable") // wait for the helm-cli to fetch the stable repo + await app.client.click("#HelmRepoSelect") // click the repo select to activate the drop-down + await app.client.waitUntilTextExists("div.Select__option", "") // wait for at least one option to appear (any text) + }) }) it.skip('quits Lens"', async () => { diff --git a/src/main/menu.ts b/src/main/menu.ts index eee4b2aef0..66ecb3ff52 100644 --- a/src/main/menu.ts +++ b/src/main/menu.ts @@ -1,7 +1,7 @@ import { app, BrowserWindow, dialog, ipcMain, IpcMainEvent, Menu, MenuItem, MenuItemConstructorOptions, webContents, shell } from "electron" import { autorun } from "mobx"; import { WindowManager } from "./window-manager"; -import { appName, isMac, isWindows } from "../common/vars"; +import { appName, isMac, isWindows, isTestEnv } from "../common/vars"; import { addClusterURL } from "../renderer/components/+add-cluster/add-cluster.route"; import { preferencesURL } from "../renderer/components/+preferences/preferences.route"; import { whatsNewURL } from "../renderer/components/+whats-new/whats-new.route"; @@ -236,7 +236,9 @@ export function buildMenu(windowManager: WindowManager) { const menu = Menu.buildFromTemplate(Object.values(appMenu)); Menu.setApplicationMenu(menu); - if (!!process.env.JEST_WORKER_ID) { + if (isTestEnv) { + // this is a workaround for the test environment (spectron) not being able to directly access + // the application menus (https://github.com/electron-userland/spectron/issues/21) ipcMain.on('test-menu-item-click', (event: IpcMainEvent, ...names: string[]) => { let menu: Menu = Menu.getApplicationMenu() const parentLabels: string[] = []; @@ -251,18 +253,19 @@ export function buildMenu(windowManager: WindowManager) { menu = menuItem.submenu; } + let menuPath: string = parentLabels.join(" -> ") if (!menuItem) { - logger.info(`[MENU:test-menu-item-click] Cannot find menu item ${parentLabels.join(" -> ")}`); + logger.info(`[MENU:test-menu-item-click] Cannot find menu item ${menuPath}`); return; } const { enabled, visible, click } = menuItem; if (enabled === false || visible === false || typeof click !== 'function') { - logger.info(`[MENU:test-menu-item-click] Menu item ${parentLabels.join(" -> ")} not clickable`); + logger.info(`[MENU:test-menu-item-click] Menu item ${menuPath} not clickable`); return; } - logger.info(`[MENU:test-menu-item-click] Menu item ${parentLabels.join(" -> ")} click!`); + logger.info(`[MENU:test-menu-item-click] Menu item ${menuPath} click!`); menuItem.click(); }); } diff --git a/src/renderer/components/+preferences/preferences.tsx b/src/renderer/components/+preferences/preferences.tsx index 22cbd4a7b1..2fc58646df 100644 --- a/src/renderer/components/+preferences/preferences.tsx +++ b/src/renderer/components/+preferences/preferences.tsx @@ -128,7 +128,7 @@ export class Preferences extends React.Component {

Helm

-