[MM-38875] Migrate E2E testing to Playwright, re-enable tests (#1800)
* WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * [MM-38875] Migrate E2E testing to Playwright, re-enable tests * Add functionality to map view names to Playwright windows * Added search box test * Added robot.js for automating key presses * Add test using key strokes to navigate menu * Reload test and added webcontentsid to test helper * Check Ctrl+Shift+R as well * oops * Reorganize Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
@@ -100,3 +100,6 @@ export const BROWSER_HISTORY_PUSH = 'browser-history-push';
|
||||
export const APP_LOGGED_IN = 'app-logged-in';
|
||||
|
||||
export const GET_AVAILABLE_SPELL_CHECKER_LANGUAGES = 'get-available-spell-checker-languages';
|
||||
|
||||
export const GET_VIEW_NAME = 'get-view-name';
|
||||
export const GET_VIEW_WEBCONTENTS_ID = 'get-view-webcontents-id';
|
||||
|
@@ -51,6 +51,7 @@ export function displayMention(title: string, body: string, channel: {id: string
|
||||
});
|
||||
|
||||
mention.on('click', () => {
|
||||
log.info('notification click', serverName, mention);
|
||||
if (serverName) {
|
||||
windowManager.switchTab(serverName, TAB_MESSAGING);
|
||||
webcontents.send('notification-clicked', {channel, teamId, url});
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
/* eslint-disable no-magic-numbers */
|
||||
|
||||
import {ipcRenderer, webFrame} from 'electron';
|
||||
import {contextBridge, ipcRenderer, webFrame} from 'electron';
|
||||
|
||||
// I've filed an issue in electron-log https://github.com/megahertz/electron-log/issues/267
|
||||
// we'll be able to use it again if there is a workaround for the 'os' import
|
||||
@@ -23,6 +23,8 @@ import {
|
||||
CLOSE_TEAMS_DROPDOWN,
|
||||
BROWSER_HISTORY_PUSH,
|
||||
APP_LOGGED_IN,
|
||||
GET_VIEW_NAME,
|
||||
GET_VIEW_WEBCONTENTS_ID,
|
||||
} from 'common/communication';
|
||||
|
||||
const UNREAD_COUNT_INTERVAL = 1000;
|
||||
@@ -36,6 +38,13 @@ let shouldSendNotifications;
|
||||
|
||||
console.log('Preload initialized');
|
||||
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
contextBridge.exposeInMainWorld('testHelper', {
|
||||
getViewName: () => ipcRenderer.invoke(GET_VIEW_NAME),
|
||||
getWebContentsId: () => ipcRenderer.invoke(GET_VIEW_WEBCONTENTS_ID),
|
||||
});
|
||||
}
|
||||
|
||||
ipcRenderer.invoke('get-app-version').then(({name, version}) => {
|
||||
appVersion = version;
|
||||
appName = name;
|
||||
|
@@ -77,13 +77,11 @@ export class MattermostView extends EventEmitter {
|
||||
this.options = Object.assign({}, options);
|
||||
this.options.webPreferences = {
|
||||
nativeWindowOpen: true,
|
||||
contextIsolation: process.env.NODE_ENV !== 'test',
|
||||
preload,
|
||||
additionalArguments: [
|
||||
`version=${app.getVersion()}`,
|
||||
`appName=${app.name}`,
|
||||
],
|
||||
nodeIntegration: process.env.NODE_ENV === 'test',
|
||||
...options.webPreferences,
|
||||
};
|
||||
this.isVisible = false;
|
||||
@@ -273,12 +271,7 @@ export class MattermostView extends EventEmitter {
|
||||
}
|
||||
|
||||
getWebContents = () => {
|
||||
if (this.status === Status.READY) {
|
||||
return this.view.webContents;
|
||||
} else if (this.window) {
|
||||
return this.window.webContents; // if it's not ready you are looking at the renderer process
|
||||
}
|
||||
return WindowManager.getMainWindow()?.webContents;
|
||||
return this.view.webContents;
|
||||
}
|
||||
|
||||
handleInputEvents = (_: Event, input: Input) => {
|
||||
|
@@ -32,9 +32,7 @@ export class ModalView<T, T2> {
|
||||
log.info(`preloading with ${preload}`);
|
||||
this.view = new BrowserView({webPreferences: {
|
||||
nativeWindowOpen: true,
|
||||
contextIsolation: process.env.NODE_ENV !== 'test',
|
||||
preload,
|
||||
nodeIntegration: process.env.NODE_ENV === 'test',
|
||||
|
||||
// Workaround for this issue: https://github.com/electron/electron/issues/30993
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
|
@@ -46,9 +46,7 @@ export default class TeamDropdownView {
|
||||
const preload = getLocalPreload('dropdown.js');
|
||||
this.view = new BrowserView({webPreferences: {
|
||||
nativeWindowOpen: true,
|
||||
contextIsolation: process.env.NODE_ENV !== 'test',
|
||||
preload,
|
||||
nodeIntegration: process.env.NODE_ENV === 'test',
|
||||
|
||||
// Workaround for this issue: https://github.com/electron/electron/issues/30993
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
|
@@ -295,8 +295,6 @@ export class ViewManager {
|
||||
const urlView = new BrowserView({
|
||||
webPreferences: {
|
||||
nativeWindowOpen: true,
|
||||
contextIsolation: process.env.NODE_ENV !== 'test',
|
||||
nodeIntegration: process.env.NODE_ENV === 'test',
|
||||
|
||||
// Workaround for this issue: https://github.com/electron/electron/issues/30993
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
|
@@ -169,8 +169,6 @@ const generateNewWindowListener = (getServersFunction: () => TeamWithTabs[], spe
|
||||
center: true,
|
||||
webPreferences: {
|
||||
nativeWindowOpen: true,
|
||||
nodeIntegration: process.env.NODE_ENV === 'test',
|
||||
contextIsolation: process.env.NODE_ENV !== 'test',
|
||||
spellcheck: (typeof spellcheck === 'undefined' ? true : spellcheck),
|
||||
},
|
||||
});
|
||||
|
@@ -80,8 +80,6 @@ function createMainWindow(config: CombinedConfig, options: {linuxAppIcon: string
|
||||
backgroundColor: '#fff', // prevents blurry text: https://electronjs.org/docs/faq#the-font-looks-blurry-what-is-this-and-what-can-i-do
|
||||
webPreferences: {
|
||||
nativeWindowOpen: true,
|
||||
nodeIntegration: process.env.NODE_ENV === 'test',
|
||||
contextIsolation: process.env.NODE_ENV !== 'test',
|
||||
disableBlinkFeatures: 'Auxclick',
|
||||
preload,
|
||||
spellcheck,
|
||||
|
@@ -2,7 +2,7 @@
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import path from 'path';
|
||||
import {app, BrowserWindow, nativeImage, systemPreferences, ipcMain, IpcMainEvent} from 'electron';
|
||||
import {app, BrowserWindow, nativeImage, systemPreferences, ipcMain, IpcMainEvent, IpcMainInvokeEvent} from 'electron';
|
||||
import log from 'electron-log';
|
||||
|
||||
import {CombinedConfig} from 'types/config';
|
||||
@@ -18,6 +18,8 @@ import {
|
||||
UPDATE_SHORTCUT_MENU,
|
||||
BROWSER_HISTORY_PUSH,
|
||||
APP_LOGGED_IN,
|
||||
GET_VIEW_NAME,
|
||||
GET_VIEW_WEBCONTENTS_ID,
|
||||
} from 'common/communication';
|
||||
import urlUtils from 'common/utils/url';
|
||||
|
||||
@@ -54,6 +56,8 @@ ipcMain.on(REACT_APP_INITIALIZED, handleReactAppInitialized);
|
||||
ipcMain.on(LOADING_SCREEN_ANIMATION_FINISHED, handleLoadingScreenAnimationFinished);
|
||||
ipcMain.on(BROWSER_HISTORY_PUSH, handleBrowserHistoryPush);
|
||||
ipcMain.on(APP_LOGGED_IN, handleAppLoggedIn);
|
||||
ipcMain.handle(GET_VIEW_NAME, handleGetViewName);
|
||||
ipcMain.handle(GET_VIEW_WEBCONTENTS_ID, handleGetWebContentsId);
|
||||
|
||||
export function setConfig(data: CombinedConfig) {
|
||||
if (data) {
|
||||
@@ -585,3 +589,11 @@ export function getCurrentTeamName() {
|
||||
function handleAppLoggedIn(event: IpcMainEvent, viewName: string) {
|
||||
status.viewManager?.reloadViewIfNeeded(viewName);
|
||||
}
|
||||
|
||||
function handleGetViewName(event: IpcMainInvokeEvent) {
|
||||
return getViewNameByWebContentsId(event.sender.id);
|
||||
}
|
||||
function handleGetWebContentsId(event: IpcMainInvokeEvent) {
|
||||
return event.sender.id;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user