Skip to content

Commit 22677d9

Browse files
authored
chore(e2e): small screen fixes (#6351)
* no need to check the whole document. what's shown depends on virtual scrolling * maximize the window in e2e tests in electron
1 parent 0a92de6 commit 22677d9

File tree

3 files changed

+30
-66
lines changed

3 files changed

+30
-66
lines changed

packages/compass-e2e-tests/helpers/compass.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,19 +1020,28 @@ export async function init(
10201020
// For browser.executeAsync(). Trying to see if it will work for browser.execute() too.
10211021
await browser.setTimeout({ script: 5_000 });
10221022

1023-
// larger window for more consistent results
1024-
const [width, height] = await browser.execute(() => {
1025-
// in case setWindowSize() below doesn't work
1026-
window.resizeTo(window.screen.availWidth, window.screen.availHeight);
1023+
if (TEST_COMPASS_WEB) {
1024+
// larger window for more consistent results
1025+
const [width, height] = await browser.execute(() => {
1026+
// in case setWindowSize() below doesn't work
1027+
window.resizeTo(window.screen.availWidth, window.screen.availHeight);
10271028

1028-
return [window.screen.availWidth, window.screen.availHeight];
1029-
});
1030-
debug(`available width=${width}, height=${height}`);
1031-
try {
1032-
// window.resizeTo() doesn't work on firefox
1033-
await browser.setWindowSize(width, height);
1034-
} catch (err: any) {
1035-
console.error(err?.stack);
1029+
return [window.screen.availWidth, window.screen.availHeight];
1030+
});
1031+
// getting available width=1512, height=944 in electron on mac which is arbitrary
1032+
debug(`available width=${width}, height=${height}`);
1033+
try {
1034+
// window.resizeTo() doesn't work on firefox
1035+
await browser.setWindowSize(width, height);
1036+
} catch (err: any) {
1037+
console.error(err?.stack);
1038+
}
1039+
} else {
1040+
await browser.execute(() => {
1041+
// eslint-disable-next-line @typescript-eslint/no-var-requires
1042+
const { ipcRenderer } = require('electron');
1043+
ipcRenderer.invoke('compass:maximize');
1044+
});
10361045
}
10371046

10381047
if (compass.needsCloseWelcomeModal) {

packages/compass-e2e-tests/tests/collection-import.test.ts

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -813,60 +813,7 @@ describe('Collection import', function () {
813813

814814
const result = await getFirstListDocument(browser);
815815

816-
// The values are the text as they appear in the page, so numbers are
817-
// strings, strings have double-quotes inside them and dates got formatted.
818-
// Arrays and objects start off collapsed.
819-
try {
820-
expect(result).to.deep.equal({
821-
_id: '1001265',
822-
access: '"Pool, hot tub and tennis"',
823-
accommodates: '2',
824-
address: 'Object',
825-
amenities: 'Array (36)',
826-
availability: 'Object',
827-
bathrooms: '1',
828-
bed_type: '"Real Bed"',
829-
bedrooms: '1',
830-
beds: '1',
831-
calendar_last_scraped: '2019-03-06T05:00:00.000+00:00',
832-
cancellation_policy: '"strict_14_with_grace_period"',
833-
cleaning_fee: '100',
834-
description:
835-
'"A short distance from Honolulu\'s billion dollar mall, and the same dis…"',
836-
extra_people: '0',
837-
first_review: '2013-05-24T04:00:00.000+00:00',
838-
guests_included: '1',
839-
host: 'Object',
840-
house_rules:
841-
'"The general welfare and well being of all the community."',
842-
images: 'Object',
843-
interaction:
844-
'"We try our best at creating, simple responsive management which never …"',
845-
last_review: '2019-02-07T05:00:00.000+00:00',
846-
last_scraped: '2019-03-06T05:00:00.000+00:00',
847-
listing_url: '"https://www.airbnb.com/rooms/1001265"',
848-
maximum_nights: '365',
849-
minimum_nights: '3',
850-
monthly_price: '2150',
851-
name: '"Ocean View Waikiki Marina w/prkg"',
852-
neighborhood_overview: '"You can breath ocean as well as aloha."',
853-
number_of_reviews: '96',
854-
price: '115',
855-
property_type: '"Condominium"',
856-
review_scores: 'Object',
857-
reviews: 'Array (96)',
858-
room_type: '"Entire home/apt"',
859-
space:
860-
'"Great studio located on Ala Moana across the street from Yacht Harbor …"',
861-
summary:
862-
'"A short distance from Honolulu\'s billion dollar mall, and the same dis…"',
863-
transit: '"Honolulu does have a very good air conditioned bus system."',
864-
weekly_price: '650',
865-
});
866-
} catch (err) {
867-
console.log(JSON.stringify(result, null, 2));
868-
throw err;
869-
}
816+
expect(result._id).to.equal('1001265');
870817
});
871818

872819
it('supports CSV files with BOM', async function () {

packages/compass/src/main/window-manager.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,14 @@ class CompassWindowManager {
276276
shell.showItemInFolder(filename);
277277
});
278278

279+
// To resize an electron window you have to do it from the main process.
280+
// This is here so that the e2e tests can resize the window from the
281+
// renderer process.
282+
ipcMain?.handle('compass:maximize', () => {
283+
const first = BrowserWindow.getAllWindows()[0];
284+
first.maximize();
285+
});
286+
279287
await electronApp.whenReady();
280288
await onAppReady();
281289

0 commit comments

Comments
 (0)