From cf4cdf5c1cdf398f39d6a7688178c2c9e9623982 Mon Sep 17 00:00:00 2001 From: Devin Binnie <52460000+devinbinnie@users.noreply.github.com> Date: Thu, 26 Jan 2023 08:45:52 -0500 Subject: [PATCH] Fixed full screen E2E test for smaller displays (#2517) * Fixed full screen test for smaller displays * Fix bork --- e2e/specs/menu_bar/full_screen.test.js | 66 ++++++++++++++++++++++++++ e2e/specs/menu_bar/view_menu.test.js | 32 ------------- 2 files changed, 66 insertions(+), 32 deletions(-) create mode 100644 e2e/specs/menu_bar/full_screen.test.js diff --git a/e2e/specs/menu_bar/full_screen.test.js b/e2e/specs/menu_bar/full_screen.test.js new file mode 100644 index 00000000..85830131 --- /dev/null +++ b/e2e/specs/menu_bar/full_screen.test.js @@ -0,0 +1,66 @@ +// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. +'use strict'; + +const fs = require('fs'); + +const robot = require('robotjs'); + +const env = require('../../modules/environment'); +const {asyncSleep} = require('../../modules/utils'); + +describe('menu/view', function desc() { + this.timeout(30000); + + const config = env.demoMattermostConfig; + + beforeEach(async () => { + env.cleanDataDir(); + env.createTestUserDataDir(); + env.cleanTestConfig(); + fs.writeFileSync(env.configFilePath, JSON.stringify(config)); + fs.writeFileSync(env.boundsInfoPath, JSON.stringify({x: 0, y: 0, width: 700, height: 240, maximized: false, fullscreen: false})); + await asyncSleep(1000); + this.app = await env.getApp(); + this.serverMap = await env.getServerMap(this.app); + }); + + afterEach(async () => { + if (this.app) { + await this.app.close(); + } + await env.clearElectronInstances(); + }); + + // TODO: No keyboard shortcut for macOS + if (process.platform !== 'darwin') { + it('MM-T816 Toggle Full Screen in the Menu Bar', async () => { + const mainWindow = this.app.windows().find((window) => window.url().includes('index')); + const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen')); + await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'}); + const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win; + await env.loginToMattermost(firstServer); + await firstServer.waitForSelector('#post_textbox'); + let currentWidth = await firstServer.evaluate('window.outerWidth'); + let currentHeight = await firstServer.evaluate('window.outerHeight'); + await mainWindow.click('button.three-dot-menu'); + robot.keyTap('v'); + robot.keyTap('t'); + robot.keyTap('enter'); + await asyncSleep(1000); + const fullScreenWidth = await firstServer.evaluate('window.outerWidth'); + const fullScreenHeight = await firstServer.evaluate('window.outerHeight'); + fullScreenWidth.should.be.greaterThan(currentWidth); + fullScreenHeight.should.be.greaterThan(currentHeight); + await mainWindow.click('button.three-dot-menu'); + robot.keyTap('v'); + robot.keyTap('t'); + robot.keyTap('enter'); + await asyncSleep(1000); + currentWidth = await firstServer.evaluate('window.outerWidth'); + currentHeight = await firstServer.evaluate('window.outerHeight'); + currentWidth.should.be.lessThan(fullScreenWidth); + currentHeight.should.be.lessThan(fullScreenHeight); + }); + } +}); diff --git a/e2e/specs/menu_bar/view_menu.test.js b/e2e/specs/menu_bar/view_menu.test.js index 9bc05955..2498b8ce 100644 --- a/e2e/specs/menu_bar/view_menu.test.js +++ b/e2e/specs/menu_bar/view_menu.test.js @@ -70,38 +70,6 @@ describe('menu/view', function desc() { text.should.include('in:'); }); - // TODO: No keyboard shortcut for macOS - if (process.platform !== 'darwin') { - it('MM-T816 Toggle Full Screen in the Menu Bar', async () => { - const mainWindow = this.app.windows().find((window) => window.url().includes('index')); - const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen')); - await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'}); - const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win; - await env.loginToMattermost(firstServer); - await firstServer.waitForSelector('#searchBox'); - let currentWidth = await firstServer.evaluate('window.outerWidth'); - let currentHeight = await firstServer.evaluate('window.outerHeight'); - await mainWindow.click('button.three-dot-menu'); - robot.keyTap('v'); - robot.keyTap('t'); - robot.keyTap('enter'); - await asyncSleep(1000); - const fullScreenWidth = await firstServer.evaluate('window.outerWidth'); - const fullScreenHeight = await firstServer.evaluate('window.outerHeight'); - fullScreenWidth.should.be.greaterThan(currentWidth); - fullScreenHeight.should.be.greaterThan(currentHeight); - await mainWindow.click('button.three-dot-menu'); - robot.keyTap('v'); - robot.keyTap('t'); - robot.keyTap('enter'); - await asyncSleep(1000); - currentWidth = await firstServer.evaluate('window.outerWidth'); - currentHeight = await firstServer.evaluate('window.outerHeight'); - currentWidth.should.be.lessThan(fullScreenWidth); - currentHeight.should.be.lessThan(fullScreenHeight); - }); - } - it('MM-T817 Actual Size Zoom in the menu bar', async () => { const mainWindow = this.app.windows().find((window) => window.url().includes('index')); const browserWindow = await this.app.browserWindow(mainWindow);