[playground] Wait for Monaco to fully load (#32584)

I'm not sure what exactly is causing the flakiness in the playground e2e
tests but I suspect it's some kind of timing issue.

Let's try waiting for Monaco to be fully initialized before running
tests.
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32584).
* __->__ #32584
* #32583
This commit is contained in:
lauren 2025-03-12 17:47:24 -04:00 committed by GitHub
parent e0e98d9560
commit 26bca0005c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -105,6 +105,9 @@ function nonReactFn() {
test('editor should open successfully', async ({page}) => {
await page.goto(`/`, {waitUntil: 'networkidle'});
await page.waitForFunction(
() => typeof window['MonacoEnvironment'] !== 'undefined',
);
await page.screenshot({
fullPage: true,
path: 'test-results/00-fresh-page.png',
@ -120,6 +123,9 @@ test('editor should compile from hash successfully', async ({page}) => {
};
const hash = encodeStore(store);
await page.goto(`/#${hash}`, {waitUntil: 'networkidle'});
await page.waitForFunction(
() => typeof window['MonacoEnvironment'] !== 'undefined',
);
// User input from hash compiles
await page.screenshot({
@ -143,6 +149,9 @@ test('reset button works', async ({page}) => {
};
const hash = encodeStore(store);
await page.goto(`/#${hash}`, {waitUntil: 'networkidle'});
await page.waitForFunction(
() => typeof window['MonacoEnvironment'] !== 'undefined',
);
// Reset button works
page.on('dialog', dialog => dialog.accept());
@ -166,6 +175,9 @@ TEST_CASE_INPUTS.forEach((t, idx) =>
};
const hash = encodeStore(store);
await page.goto(`/#${hash}`, {waitUntil: 'networkidle'});
await page.waitForFunction(
() => typeof window['MonacoEnvironment'] !== 'undefined',
);
await page.screenshot({
fullPage: true,
path: `test-results/03-0${idx}-${t.name}.png`,