[MM-59823] Migrate BrowserView
to WebContentsView
(#3177)
* Migrate to WebContentsView from BrowserView * A bit of cleanup, stop holding reference to the loading screen * Fix tests * Fix i18n --------- Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
@@ -43,7 +43,7 @@ describe('application', function desc() {
|
||||
const browserWindow = await this.app.browserWindow(mainWindow);
|
||||
const webContentsId = this.serverMap[`${config.teams[1].name}___TAB_MESSAGING`].webContentsId;
|
||||
const isActive = await browserWindow.evaluate((window, id) => {
|
||||
return window.getBrowserViews().find((view) => view.webContents.id === id).webContents.getURL();
|
||||
return window.contentView.children.find((view) => view.webContents.id === id).webContents.getURL();
|
||||
}, webContentsId);
|
||||
isActive.should.equal('https://github.com/test/url/');
|
||||
const dropdownButtonText = await mainWindow.innerText('.ServerDropdownButton');
|
||||
|
@@ -54,17 +54,17 @@ describe('menu_bar/dropdown', function desc() {
|
||||
after(afterFunc);
|
||||
|
||||
it('MM-T4406_1 should show the dropdown', async () => {
|
||||
let dropdownHeight = await browserWindow.evaluate((window) => window.getBrowserViews().find((view) => view.webContents.getURL().includes('dropdown')).getBounds().height);
|
||||
let dropdownHeight = await browserWindow.evaluate((window) => window.contentView.children.find((view) => view.webContents.getURL().includes('dropdown')).getBounds().height);
|
||||
dropdownHeight.should.equal(0);
|
||||
|
||||
await mainWindow.click('.ServerDropdownButton');
|
||||
dropdownHeight = await browserWindow.evaluate((window) => window.getBrowserViews().find((view) => view.webContents.getURL().includes('dropdown')).getBounds().height);
|
||||
dropdownHeight = await browserWindow.evaluate((window) => window.contentView.children.find((view) => view.webContents.getURL().includes('dropdown')).getBounds().height);
|
||||
dropdownHeight.should.be.greaterThan(0);
|
||||
});
|
||||
|
||||
it('MM-T4406_2 should hide the dropdown', async () => {
|
||||
await mainWindow.click('.TabBar');
|
||||
const dropdownHeight = await browserWindow.evaluate((window) => window.getBrowserViews().find((view) => view.webContents.getURL().includes('dropdown')).getBounds().height);
|
||||
const dropdownHeight = await browserWindow.evaluate((window) => window.contentView.children.find((view) => view.webContents.getURL().includes('dropdown')).getBounds().height);
|
||||
dropdownHeight.should.equal(0);
|
||||
});
|
||||
});
|
||||
@@ -100,9 +100,9 @@ describe('menu_bar/dropdown', function desc() {
|
||||
after(afterFunc);
|
||||
|
||||
it('MM-T4408_1 should show the first view', async () => {
|
||||
const firstViewIsAttached = await browserWindow.evaluate((window, url) => Boolean(window.getBrowserViews().find((view) => view.webContents.getURL() === url)), env.exampleURL);
|
||||
const firstViewIsAttached = await browserWindow.evaluate((window, url) => Boolean(window.contentView.children.find((view) => view.webContents.getURL() === url)), env.exampleURL);
|
||||
firstViewIsAttached.should.be.true;
|
||||
const secondViewIsAttached = await browserWindow.evaluate((window) => Boolean(window.getBrowserViews().find((view) => view.webContents.getURL() === 'https://github.com/')));
|
||||
const secondViewIsAttached = await browserWindow.evaluate((window) => Boolean(window.contentView.children.find((view) => view.webContents.getURL() === 'https://github.com/')));
|
||||
secondViewIsAttached.should.be.false;
|
||||
});
|
||||
|
||||
@@ -110,9 +110,9 @@ describe('menu_bar/dropdown', function desc() {
|
||||
await mainWindow.click('.ServerDropdownButton');
|
||||
await dropdownView.click('.ServerDropdown button.ServerDropdown__button:nth-child(2)');
|
||||
|
||||
const firstViewIsAttached = await browserWindow.evaluate((window, url) => Boolean(window.getBrowserViews().find((view) => view.webContents.getURL() === url)), env.exampleURL);
|
||||
const firstViewIsAttached = await browserWindow.evaluate((window, url) => Boolean(window.contentView.children.find((view) => view.webContents.getURL() === url)), env.exampleURL);
|
||||
firstViewIsAttached.should.be.false;
|
||||
const secondViewIsAttached = await browserWindow.evaluate((window) => Boolean(window.getBrowserViews().find((view) => view.webContents.getURL() === 'https://github.com/')));
|
||||
const secondViewIsAttached = await browserWindow.evaluate((window) => Boolean(window.contentView.children.find((view) => view.webContents.getURL() === 'https://github.com/')));
|
||||
secondViewIsAttached.should.be.true;
|
||||
});
|
||||
});
|
||||
|
@@ -11,7 +11,7 @@ const {asyncSleep} = require('../../modules/utils');
|
||||
|
||||
async function setupPromise(window, id) {
|
||||
const promise = new Promise((resolve) => {
|
||||
const browserView = window.getBrowserViews().find((view) => view.webContents.id === id);
|
||||
const browserView = window.contentView.children.find((view) => view.webContents.id === id);
|
||||
browserView.webContents.on('did-finish-load', () => {
|
||||
resolve();
|
||||
});
|
||||
@@ -22,13 +22,13 @@ async function setupPromise(window, id) {
|
||||
|
||||
function getZoomFactorOfServer(browserWindow, serverId) {
|
||||
return browserWindow.evaluate(
|
||||
(window, id) => window.getBrowserViews().find((view) => view.webContents.id === id).webContents.getZoomFactor(),
|
||||
(window, id) => window.contentView.children.find((view) => view.webContents.id === id).webContents.getZoomFactor(),
|
||||
serverId,
|
||||
);
|
||||
}
|
||||
function setZoomFactorOfServer(browserWindow, serverId, zoomFactor) {
|
||||
return browserWindow.evaluate(
|
||||
(window, {id, zoom}) => window.getBrowserViews().find((view) => view.webContents.id === id).webContents.setZoomFactor(zoom),
|
||||
(window, {id, zoom}) => window.contentView.children.find((view) => view.webContents.id === id).webContents.setZoomFactor(zoom),
|
||||
{id: serverId, zoom: zoomFactor},
|
||||
);
|
||||
}
|
||||
@@ -82,12 +82,12 @@ describe('menu/view', function desc() {
|
||||
|
||||
robot.keyTap('=', [env.cmdOrCtrl]);
|
||||
await asyncSleep(1000);
|
||||
let zoomLevel = await browserWindow.evaluate((window, id) => window.getBrowserViews().find((view) => view.webContents.id === id).webContents.getZoomFactor(), firstServerId);
|
||||
let zoomLevel = await browserWindow.evaluate((window, id) => window.contentView.children.find((view) => view.webContents.id === id).webContents.getZoomFactor(), firstServerId);
|
||||
zoomLevel.should.be.greaterThan(1);
|
||||
|
||||
robot.keyTap('0', [env.cmdOrCtrl]);
|
||||
await asyncSleep(1000);
|
||||
zoomLevel = await browserWindow.evaluate((window, id) => window.getBrowserViews().find((view) => view.webContents.id === id).webContents.getZoomFactor(), firstServerId);
|
||||
zoomLevel = await browserWindow.evaluate((window, id) => window.contentView.children.find((view) => view.webContents.id === id).webContents.getZoomFactor(), firstServerId);
|
||||
zoomLevel.should.be.equal(1);
|
||||
});
|
||||
|
||||
@@ -104,7 +104,7 @@ describe('menu/view', function desc() {
|
||||
|
||||
robot.keyTap('=', [env.cmdOrCtrl]);
|
||||
await asyncSleep(1000);
|
||||
const zoomLevel = await browserWindow.evaluate((window, id) => window.getBrowserViews().find((view) => view.webContents.id === id).webContents.getZoomFactor(), firstServerId);
|
||||
const zoomLevel = await browserWindow.evaluate((window, id) => window.contentView.children.find((view) => view.webContents.id === id).webContents.getZoomFactor(), firstServerId);
|
||||
zoomLevel.should.be.greaterThan(1);
|
||||
});
|
||||
|
||||
@@ -144,7 +144,7 @@ describe('menu/view', function desc() {
|
||||
|
||||
robot.keyTap('-', [env.cmdOrCtrl]);
|
||||
await asyncSleep(1000);
|
||||
const zoomLevel = await browserWindow.evaluate((window, id) => window.getBrowserViews().find((view) => view.webContents.id === id).webContents.getZoomFactor(), firstServerId);
|
||||
const zoomLevel = await browserWindow.evaluate((window, id) => window.contentView.children.find((view) => view.webContents.id === id).webContents.getZoomFactor(), firstServerId);
|
||||
zoomLevel.should.be.lessThan(1);
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user