test: fixup flaky tests (#44379)

* test: fixup flaky test

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

* test: disable flaky protocol speed test on macOS

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

* test: fixup flaky test in api-browser-window-spec.ts

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
This commit is contained in:
trop[bot] 2024-10-23 17:16:38 -04:00 committed by GitHub
parent b9b982cd7d
commit 1d0cd8bf59
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 9 deletions

View file

@ -17,7 +17,7 @@ import * as nodeUrl from 'node:url';
import { emittedUntil, emittedNTimes } from './lib/events-helpers';
import { HexColors, hasCapturableScreen, ScreenCapture } from './lib/screen-helpers';
import { ifit, ifdescribe, defer, listen } from './lib/spec-helpers';
import { ifit, ifdescribe, defer, listen, waitUntil } from './lib/spec-helpers';
import { closeWindow, closeAllWindows } from './lib/window-helpers';
const fixtures = path.resolve(__dirname, 'fixtures');
@ -6015,8 +6015,10 @@ describe('BrowserWindow module', () => {
w.webContents.on('enter-html-full-screen', async () => {
enterCount++;
if (w.isFullScreen()) reject(new Error('w.isFullScreen should be false'));
await waitUntil(async () => {
const isFS = await w.webContents.executeJavaScript('!!document.fullscreenElement');
if (!isFS) reject(new Error('Document should have fullscreen element'));
return isFS === true;
});
checkDone();
});

View file

@ -1737,7 +1737,8 @@ describe('protocol module', () => {
});
// TODO(nornagon): this test doesn't pass on Linux currently, investigate.
ifit(process.platform !== 'linux')('is fast', async () => {
// test is also flaky on CI on macOS so it is currently disabled there as well.
ifit(process.platform !== 'linux' && (!process.env.CI || process.platform !== 'darwin'))('is fast', async () => {
// 128 MB of spaces.
const chunk = new Uint8Array(128 * 1024 * 1024);
chunk.fill(' '.charCodeAt(0));

View file

@ -15,7 +15,7 @@ import * as path from 'node:path';
import { setTimeout } from 'node:timers/promises';
import * as url from 'node:url';
import { ifit, ifdescribe, defer, itremote, listen, startRemoteControlApp } from './lib/spec-helpers';
import { ifit, ifdescribe, defer, itremote, listen, startRemoteControlApp, waitUntil } from './lib/spec-helpers';
import { closeAllWindows } from './lib/window-helpers';
import { PipeTransport } from './pipe-transport';
@ -2944,10 +2944,12 @@ describe('iframe using HTML fullscreen API while window is OS-fullscreened', ()
);
await once(w.webContents, 'leave-html-full-screen');
await expect(waitUntil(async () => {
const width = await w.webContents.executeJavaScript(
"document.querySelector('iframe').offsetWidth"
);
expect(width).to.equal(0);
return width === 0;
})).to.eventually.be.fulfilled();
w.setFullScreen(false);
await once(w, 'leave-full-screen');