From 88fd18ef0246ef59d73772a7289c5f4f2ef9f201 Mon Sep 17 00:00:00 2001 From: Goh Yin Hao Date: Wed, 23 Feb 2022 22:09:37 +0800 Subject: [PATCH] [MM-T2637] add e2e test for minimize/maximize app when double click header (#1983) --- e2e/specs/server_management/header.test.js | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 e2e/specs/server_management/header.test.js diff --git a/e2e/specs/server_management/header.test.js b/e2e/specs/server_management/header.test.js new file mode 100644 index 00000000..c88143f2 --- /dev/null +++ b/e2e/specs/server_management/header.test.js @@ -0,0 +1,47 @@ +// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +'use strict'; + +const fs = require('fs'); + +const env = require('../../modules/environment'); +const {asyncSleep} = require('../../modules/utils'); + +describe('header', function desc() { + this.timeout(30000); + + beforeEach(async () => { + env.createTestUserDataDir(); + env.cleanTestConfig(); + }); + + afterEach(async () => { + if (this.app) { + try { + await this.app.close(); + // eslint-disable-next-line no-empty + } catch (err) {} + } + }); + + it('MM-T2637 Double-Clicking on the header should minimize/maximize the app', async () => { + const initialBounds = {x: 0, y: 0, width: 800, height: 400, maximized: false}; + fs.writeFileSync(env.boundsInfoPath, JSON.stringify(initialBounds)); + this.app = await env.getApp(); + const mainWindow = await this.app.firstWindow(); + const browserWindow = await this.app.browserWindow(mainWindow); + const header = await mainWindow.locator('div.topBar'); + const headerBounds = await header.boundingBox(); + await header.dblclick({position: {x: headerBounds.width / 2, y: headerBounds.y / 2}}); + await asyncSleep(1000); + const isMaximized = await browserWindow.evaluate((window) => window.isMaximized()); + isMaximized.should.be.equal(true); + const maximizedHeaderBounds = await header.boundingBox(); + await header.dblclick({position: {x: maximizedHeaderBounds.width / 2, y: maximizedHeaderBounds.y / 2}}); + await asyncSleep(1000); + const revertedBounds = await browserWindow.evaluate((window) => window.getContentBounds()); + revertedBounds.height.should.be.equal(initialBounds.height); + revertedBounds.width.should.be.equal(initialBounds.width); + }); +});