Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/runtime_build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ jobs:
if: steps.node_modules.outputs.cache-hit != 'true'
- run: |
yarn generate-inline-fizz-runtime
git diff --quiet || (echo "There was a change to the Fizz runtime. Run `yarn generate-inline-fizz-runtime` and check in the result." && false)
git diff --exit-code || (echo "There was a change to the Fizz runtime. Run \`yarn generate-inline-fizz-runtime\` and check in the result." && false)

# ----- FEATURE FLAGS -----
flags:
Expand Down Expand Up @@ -567,7 +567,7 @@ jobs:
- name: Search build artifacts for unminified errors
run: |
yarn extract-errors
git diff --quiet || (echo "Found unminified errors. Either update the error codes map or disable error minification for the affected build, if appropriate." && false)
git diff --exit-code || (echo "Found unminified errors. Either update the error codes map or disable error minification for the affected build, if appropriate." && false)

check_release_dependencies:
name: Check release dependencies
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { PluginOptions } from 
'babel-plugin-react-compiler/dist';
({
  //compilationMode: "all"
} satisfies Partial<PluginOptions>);
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { c as _c } from "react/compiler-runtime";
export default function TestComponent(t0) {
const $ = _c(2);
const { x } = t0;
let t1;
if ($[0] !== x || true) {
t1 = <Button>{x}</Button>;
$[0] = x;
$[1] = t1;
} else {
t1 = $[1];
}
return t1;
}
172 changes: 159 additions & 13 deletions compiler/apps/playground/__tests__/e2e/page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/

import {expect, test} from '@playwright/test';
import {expect, test, type Page} from '@playwright/test';
import {encodeStore, type Store} from '../../lib/stores';
import {defaultConfig} from '../../lib/defaultStore';
import {format} from 'prettier';

function isMonacoLoaded(): boolean {
Expand All @@ -20,6 +21,15 @@
return format(data.join(''), {parser: 'babel'});
}

async function expandConfigs(page: Page): Promise<void> {
const expandButton = page.locator('[title="Expand config editor"]');
expandButton.click();
}

const TEST_SOURCE = `export default function TestComponent({ x }) {
return <Button>{x}</Button>;
}`;

const TEST_CASE_INPUTS = [
{
name: 'module-scope-use-memo',
Expand Down Expand Up @@ -121,10 +131,9 @@

test('editor should compile from hash successfully', async ({page}) => {
const store: Store = {
source: `export default function TestComponent({ x }) {
return <Button>{x}</Button>;
}
`,
source: TEST_SOURCE,
config: defaultConfig,
showInternals: false,
};
const hash = encodeStore(store);
await page.goto(`/#${hash}`, {waitUntil: 'networkidle'});
Expand All @@ -136,7 +145,7 @@
path: 'test-results/01-compiles-from-hash.png',
});
const text =
(await page.locator('.monaco-editor').nth(3).allInnerTexts()) ?? [];
(await page.locator('.monaco-editor-output').allInnerTexts()) ?? [];
const output = await formatPrint(text);

expect(output).not.toEqual('');
Expand All @@ -145,10 +154,9 @@

test('reset button works', async ({page}) => {
const store: Store = {
source: `export default function TestComponent({ x }) {
return <Button>{x}</Button>;
}
`,
source: TEST_SOURCE,
config: defaultConfig,
showInternals: false,
};
const hash = encodeStore(store);
await page.goto(`/#${hash}`, {waitUntil: 'networkidle'});
Expand All @@ -157,33 +165,171 @@
// Reset button works
page.on('dialog', dialog => dialog.accept());
await page.getByRole('button', {name: 'Reset'}).click();
await expandConfigs(page);

await page.screenshot({
fullPage: true,
path: 'test-results/02-reset-button-works.png',
});
const text =
(await page.locator('.monaco-editor').nth(3).allInnerTexts()) ?? [];
(await page.locator('.monaco-editor-output').allInnerTexts()) ?? [];
const output = await formatPrint(text);

const configText =
(await page.locator('.monaco-editor-config').allInnerTexts()) ?? [];
const configOutput = configText.join('');

expect(output).not.toEqual('');
expect(output).toMatchSnapshot('02-default-output.txt');
expect(configOutput).not.toEqual('');
expect(configOutput).toMatchSnapshot('default-config.txt');

Check failure on line 185 in compiler/apps/playground/__tests__/e2e/page.spec.ts

View workflow job for this annotation

GitHub Actions / Test playground

[chromium] › __tests__/e2e/page.spec.ts:155:5 › reset button works

1) [chromium] › __tests__/e2e/page.spec.ts:155:5 › reset button works ──────────────────────────── Retry #3 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(string).toMatchSnapshot(expected) @@ -1,5 +1,5 @@ import type { PluginOptions } from  'babel-plugin-react-compiler/dist'; ({   //compilationMode: "all" -} satisfies Partial<PluginOptions>); +} satisfies PluginOptions); Expected: /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/default-config.txt Received: /home/runner/work/lib-react/lib-react/compiler/apps/playground/test-results/page-reset-button-works-chromium-retry3/default-config-actual.txt 183 | expect(output).toMatchSnapshot('02-default-output.txt'); 184 | expect(configOutput).not.toEqual(''); > 185 | expect(configOutput).toMatchSnapshot('default-config.txt'); | ^ 186 | }); 187 | 188 | test('defaults load when only source is in Store', async ({page}) => { at /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/page.spec.ts:185:24

Check failure on line 185 in compiler/apps/playground/__tests__/e2e/page.spec.ts

View workflow job for this annotation

GitHub Actions / Test playground

[chromium] › __tests__/e2e/page.spec.ts:155:5 › reset button works

1) [chromium] › __tests__/e2e/page.spec.ts:155:5 › reset button works ──────────────────────────── Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(string).toMatchSnapshot(expected) @@ -1,5 +1,5 @@ import type { PluginOptions } from  'babel-plugin-react-compiler/dist'; ({   //compilationMode: "all" -} satisfies Partial<PluginOptions>); +} satisfies PluginOptions); Expected: /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/default-config.txt Received: /home/runner/work/lib-react/lib-react/compiler/apps/playground/test-results/page-reset-button-works-chromium-retry2/default-config-actual.txt 183 | expect(output).toMatchSnapshot('02-default-output.txt'); 184 | expect(configOutput).not.toEqual(''); > 185 | expect(configOutput).toMatchSnapshot('default-config.txt'); | ^ 186 | }); 187 | 188 | test('defaults load when only source is in Store', async ({page}) => { at /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/page.spec.ts:185:24

Check failure on line 185 in compiler/apps/playground/__tests__/e2e/page.spec.ts

View workflow job for this annotation

GitHub Actions / Test playground

[chromium] › __tests__/e2e/page.spec.ts:155:5 › reset button works

1) [chromium] › __tests__/e2e/page.spec.ts:155:5 › reset button works ──────────────────────────── Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(string).toMatchSnapshot(expected) @@ -1,5 +1,5 @@ import type { PluginOptions } from  'babel-plugin-react-compiler/dist'; ({   //compilationMode: "all" -} satisfies Partial<PluginOptions>); +} satisfies PluginOptions); Expected: /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/default-config.txt Received: /home/runner/work/lib-react/lib-react/compiler/apps/playground/test-results/page-reset-button-works-chromium-retry1/default-config-actual.txt 183 | expect(output).toMatchSnapshot('02-default-output.txt'); 184 | expect(configOutput).not.toEqual(''); > 185 | expect(configOutput).toMatchSnapshot('default-config.txt'); | ^ 186 | }); 187 | 188 | test('defaults load when only source is in Store', async ({page}) => { at /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/page.spec.ts:185:24

Check failure on line 185 in compiler/apps/playground/__tests__/e2e/page.spec.ts

View workflow job for this annotation

GitHub Actions / Test playground

[chromium] › __tests__/e2e/page.spec.ts:155:5 › reset button works

1) [chromium] › __tests__/e2e/page.spec.ts:155:5 › reset button works ──────────────────────────── Error: expect(string).toMatchSnapshot(expected) @@ -1,5 +1,5 @@ import type { PluginOptions } from  'babel-plugin-react-compiler/dist'; ({   //compilationMode: "all" -} satisfies Partial<PluginOptions>); +} satisfies PluginOptions); Expected: /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/default-config.txt Received: /home/runner/work/lib-react/lib-react/compiler/apps/playground/test-results/page-reset-button-works-chromium/default-config-actual.txt 183 | expect(output).toMatchSnapshot('02-default-output.txt'); 184 | expect(configOutput).not.toEqual(''); > 185 | expect(configOutput).toMatchSnapshot('default-config.txt'); | ^ 186 | }); 187 | 188 | test('defaults load when only source is in Store', async ({page}) => { at /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/page.spec.ts:185:24

Check failure on line 185 in compiler/apps/playground/__tests__/e2e/page.spec.ts

View workflow job for this annotation

GitHub Actions / Test playground

[chromium] › __tests__/e2e/page.spec.ts:155:5 › reset button works

1) [chromium] › __tests__/e2e/page.spec.ts:155:5 › reset button works ──────────────────────────── Retry #3 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(string).toMatchSnapshot(expected) @@ -1,5 +1,5 @@ import type { PluginOptions } from  'babel-plugin-react-compiler/dist'; ({   //compilationMode: "all" -} satisfies Partial<PluginOptions>); +} satisfies PluginOptions); Expected: /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/default-config.txt Received: /home/runner/work/lib-react/lib-react/compiler/apps/playground/test-results/page-reset-button-works-chromium-retry3/default-config-actual.txt 183 | expect(output).toMatchSnapshot('02-default-output.txt'); 184 | expect(configOutput).not.toEqual(''); > 185 | expect(configOutput).toMatchSnapshot('default-config.txt'); | ^ 186 | }); 187 | 188 | test('defaults load when only source is in Store', async ({page}) => { at /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/page.spec.ts:185:24

Check failure on line 185 in compiler/apps/playground/__tests__/e2e/page.spec.ts

View workflow job for this annotation

GitHub Actions / Test playground

[chromium] › __tests__/e2e/page.spec.ts:155:5 › reset button works

1) [chromium] › __tests__/e2e/page.spec.ts:155:5 › reset button works ──────────────────────────── Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(string).toMatchSnapshot(expected) @@ -1,5 +1,5 @@ import type { PluginOptions } from  'babel-plugin-react-compiler/dist'; ({   //compilationMode: "all" -} satisfies Partial<PluginOptions>); +} satisfies PluginOptions); Expected: /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/default-config.txt Received: /home/runner/work/lib-react/lib-react/compiler/apps/playground/test-results/page-reset-button-works-chromium-retry2/default-config-actual.txt 183 | expect(output).toMatchSnapshot('02-default-output.txt'); 184 | expect(configOutput).not.toEqual(''); > 185 | expect(configOutput).toMatchSnapshot('default-config.txt'); | ^ 186 | }); 187 | 188 | test('defaults load when only source is in Store', async ({page}) => { at /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/page.spec.ts:185:24

Check failure on line 185 in compiler/apps/playground/__tests__/e2e/page.spec.ts

View workflow job for this annotation

GitHub Actions / Test playground

[chromium] › __tests__/e2e/page.spec.ts:155:5 › reset button works

1) [chromium] › __tests__/e2e/page.spec.ts:155:5 › reset button works ──────────────────────────── Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(string).toMatchSnapshot(expected) @@ -1,5 +1,5 @@ import type { PluginOptions } from  'babel-plugin-react-compiler/dist'; ({   //compilationMode: "all" -} satisfies Partial<PluginOptions>); +} satisfies PluginOptions); Expected: /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/default-config.txt Received: /home/runner/work/lib-react/lib-react/compiler/apps/playground/test-results/page-reset-button-works-chromium-retry1/default-config-actual.txt 183 | expect(output).toMatchSnapshot('02-default-output.txt'); 184 | expect(configOutput).not.toEqual(''); > 185 | expect(configOutput).toMatchSnapshot('default-config.txt'); | ^ 186 | }); 187 | 188 | test('defaults load when only source is in Store', async ({page}) => { at /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/page.spec.ts:185:24

Check failure on line 185 in compiler/apps/playground/__tests__/e2e/page.spec.ts

View workflow job for this annotation

GitHub Actions / Test playground

[chromium] › __tests__/e2e/page.spec.ts:155:5 › reset button works

1) [chromium] › __tests__/e2e/page.spec.ts:155:5 › reset button works ──────────────────────────── Error: expect(string).toMatchSnapshot(expected) @@ -1,5 +1,5 @@ import type { PluginOptions } from  'babel-plugin-react-compiler/dist'; ({   //compilationMode: "all" -} satisfies Partial<PluginOptions>); +} satisfies PluginOptions); Expected: /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/default-config.txt Received: /home/runner/work/lib-react/lib-react/compiler/apps/playground/test-results/page-reset-button-works-chromium/default-config-actual.txt 183 | expect(output).toMatchSnapshot('02-default-output.txt'); 184 | expect(configOutput).not.toEqual(''); > 185 | expect(configOutput).toMatchSnapshot('default-config.txt'); | ^ 186 | }); 187 | 188 | test('defaults load when only source is in Store', async ({page}) => { at /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/page.spec.ts:185:24
});

test('defaults load when only source is in Store', async ({page}) => {
// Test for backwards compatibility
const partial = {
source: TEST_SOURCE,
};
const hash = encodeStore(partial as Store);
await page.goto(`/#${hash}`, {waitUntil: 'networkidle'});
await page.waitForFunction(isMonacoLoaded);
await expandConfigs(page);

await page.screenshot({
fullPage: true,
path: 'test-results/03-missing-defaults.png',
});

// Config editor has default config
const configText =
(await page.locator('.monaco-editor-config').allInnerTexts()) ?? [];
const configOutput = configText.join('');

expect(configOutput).not.toEqual('');
expect(configOutput).toMatchSnapshot('default-config.txt');

Check failure on line 209 in compiler/apps/playground/__tests__/e2e/page.spec.ts

View workflow job for this annotation

GitHub Actions / Test playground

[chromium] › __tests__/e2e/page.spec.ts:188:5 › defaults load when only source is in Store

2) [chromium] › __tests__/e2e/page.spec.ts:188:5 › defaults load when only source is in Store ──── Retry #3 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(string).toMatchSnapshot(expected) @@ -1,5 +1,5 @@ import type { PluginOptions } from  'babel-plugin-react-compiler/dist'; ({   //compilationMode: "all" -} satisfies Partial<PluginOptions>); +} satisfies PluginOptions); Expected: /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/default-config.txt Received: /home/runner/work/lib-react/lib-react/compiler/apps/playground/test-results/page-defaults-load-when-only-source-is-in-Store-chromium-retry3/default-config-actual.txt 207 | 208 | expect(configOutput).not.toEqual(''); > 209 | expect(configOutput).toMatchSnapshot('default-config.txt'); | ^ 210 | 211 | const checkbox = page.locator('label.show-internals'); 212 | await expect(checkbox).not.toBeChecked(); at /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/page.spec.ts:209:24

Check failure on line 209 in compiler/apps/playground/__tests__/e2e/page.spec.ts

View workflow job for this annotation

GitHub Actions / Test playground

[chromium] › __tests__/e2e/page.spec.ts:188:5 › defaults load when only source is in Store

2) [chromium] › __tests__/e2e/page.spec.ts:188:5 › defaults load when only source is in Store ──── Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(string).toMatchSnapshot(expected) @@ -1,5 +1,5 @@ import type { PluginOptions } from  'babel-plugin-react-compiler/dist'; ({   //compilationMode: "all" -} satisfies Partial<PluginOptions>); +} satisfies PluginOptions); Expected: /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/default-config.txt Received: /home/runner/work/lib-react/lib-react/compiler/apps/playground/test-results/page-defaults-load-when-only-source-is-in-Store-chromium-retry2/default-config-actual.txt 207 | 208 | expect(configOutput).not.toEqual(''); > 209 | expect(configOutput).toMatchSnapshot('default-config.txt'); | ^ 210 | 211 | const checkbox = page.locator('label.show-internals'); 212 | await expect(checkbox).not.toBeChecked(); at /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/page.spec.ts:209:24

Check failure on line 209 in compiler/apps/playground/__tests__/e2e/page.spec.ts

View workflow job for this annotation

GitHub Actions / Test playground

[chromium] › __tests__/e2e/page.spec.ts:188:5 › defaults load when only source is in Store

2) [chromium] › __tests__/e2e/page.spec.ts:188:5 › defaults load when only source is in Store ──── Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(string).toMatchSnapshot(expected) @@ -1,5 +1,5 @@ import type { PluginOptions } from  'babel-plugin-react-compiler/dist'; ({   //compilationMode: "all" -} satisfies Partial<PluginOptions>); +} satisfies PluginOptions); Expected: /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/default-config.txt Received: /home/runner/work/lib-react/lib-react/compiler/apps/playground/test-results/page-defaults-load-when-only-source-is-in-Store-chromium-retry1/default-config-actual.txt 207 | 208 | expect(configOutput).not.toEqual(''); > 209 | expect(configOutput).toMatchSnapshot('default-config.txt'); | ^ 210 | 211 | const checkbox = page.locator('label.show-internals'); 212 | await expect(checkbox).not.toBeChecked(); at /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/page.spec.ts:209:24

Check failure on line 209 in compiler/apps/playground/__tests__/e2e/page.spec.ts

View workflow job for this annotation

GitHub Actions / Test playground

[chromium] › __tests__/e2e/page.spec.ts:188:5 › defaults load when only source is in Store

2) [chromium] › __tests__/e2e/page.spec.ts:188:5 › defaults load when only source is in Store ──── Error: expect(string).toMatchSnapshot(expected) @@ -1,5 +1,5 @@ import type { PluginOptions } from  'babel-plugin-react-compiler/dist'; ({   //compilationMode: "all" -} satisfies Partial<PluginOptions>); +} satisfies PluginOptions); Expected: /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/default-config.txt Received: /home/runner/work/lib-react/lib-react/compiler/apps/playground/test-results/page-defaults-load-when-only-source-is-in-Store-chromium/default-config-actual.txt 207 | 208 | expect(configOutput).not.toEqual(''); > 209 | expect(configOutput).toMatchSnapshot('default-config.txt'); | ^ 210 | 211 | const checkbox = page.locator('label.show-internals'); 212 | await expect(checkbox).not.toBeChecked(); at /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/page.spec.ts:209:24

Check failure on line 209 in compiler/apps/playground/__tests__/e2e/page.spec.ts

View workflow job for this annotation

GitHub Actions / Test playground

[chromium] › __tests__/e2e/page.spec.ts:188:5 › defaults load when only source is in Store

2) [chromium] › __tests__/e2e/page.spec.ts:188:5 › defaults load when only source is in Store ──── Retry #3 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(string).toMatchSnapshot(expected) @@ -1,5 +1,5 @@ import type { PluginOptions } from  'babel-plugin-react-compiler/dist'; ({   //compilationMode: "all" -} satisfies Partial<PluginOptions>); +} satisfies PluginOptions); Expected: /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/default-config.txt Received: /home/runner/work/lib-react/lib-react/compiler/apps/playground/test-results/page-defaults-load-when-only-source-is-in-Store-chromium-retry3/default-config-actual.txt 207 | 208 | expect(configOutput).not.toEqual(''); > 209 | expect(configOutput).toMatchSnapshot('default-config.txt'); | ^ 210 | 211 | const checkbox = page.locator('label.show-internals'); 212 | await expect(checkbox).not.toBeChecked(); at /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/page.spec.ts:209:24

Check failure on line 209 in compiler/apps/playground/__tests__/e2e/page.spec.ts

View workflow job for this annotation

GitHub Actions / Test playground

[chromium] › __tests__/e2e/page.spec.ts:188:5 › defaults load when only source is in Store

2) [chromium] › __tests__/e2e/page.spec.ts:188:5 › defaults load when only source is in Store ──── Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(string).toMatchSnapshot(expected) @@ -1,5 +1,5 @@ import type { PluginOptions } from  'babel-plugin-react-compiler/dist'; ({   //compilationMode: "all" -} satisfies Partial<PluginOptions>); +} satisfies PluginOptions); Expected: /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/default-config.txt Received: /home/runner/work/lib-react/lib-react/compiler/apps/playground/test-results/page-defaults-load-when-only-source-is-in-Store-chromium-retry2/default-config-actual.txt 207 | 208 | expect(configOutput).not.toEqual(''); > 209 | expect(configOutput).toMatchSnapshot('default-config.txt'); | ^ 210 | 211 | const checkbox = page.locator('label.show-internals'); 212 | await expect(checkbox).not.toBeChecked(); at /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/page.spec.ts:209:24

Check failure on line 209 in compiler/apps/playground/__tests__/e2e/page.spec.ts

View workflow job for this annotation

GitHub Actions / Test playground

[chromium] › __tests__/e2e/page.spec.ts:188:5 › defaults load when only source is in Store

2) [chromium] › __tests__/e2e/page.spec.ts:188:5 › defaults load when only source is in Store ──── Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(string).toMatchSnapshot(expected) @@ -1,5 +1,5 @@ import type { PluginOptions } from  'babel-plugin-react-compiler/dist'; ({   //compilationMode: "all" -} satisfies Partial<PluginOptions>); +} satisfies PluginOptions); Expected: /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/default-config.txt Received: /home/runner/work/lib-react/lib-react/compiler/apps/playground/test-results/page-defaults-load-when-only-source-is-in-Store-chromium-retry1/default-config-actual.txt 207 | 208 | expect(configOutput).not.toEqual(''); > 209 | expect(configOutput).toMatchSnapshot('default-config.txt'); | ^ 210 | 211 | const checkbox = page.locator('label.show-internals'); 212 | await expect(checkbox).not.toBeChecked(); at /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/page.spec.ts:209:24

Check failure on line 209 in compiler/apps/playground/__tests__/e2e/page.spec.ts

View workflow job for this annotation

GitHub Actions / Test playground

[chromium] › __tests__/e2e/page.spec.ts:188:5 › defaults load when only source is in Store

2) [chromium] › __tests__/e2e/page.spec.ts:188:5 › defaults load when only source is in Store ──── Error: expect(string).toMatchSnapshot(expected) @@ -1,5 +1,5 @@ import type { PluginOptions } from  'babel-plugin-react-compiler/dist'; ({   //compilationMode: "all" -} satisfies Partial<PluginOptions>); +} satisfies PluginOptions); Expected: /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/__snapshots__/page.spec.ts/default-config.txt Received: /home/runner/work/lib-react/lib-react/compiler/apps/playground/test-results/page-defaults-load-when-only-source-is-in-Store-chromium/default-config-actual.txt 207 | 208 | expect(configOutput).not.toEqual(''); > 209 | expect(configOutput).toMatchSnapshot('default-config.txt'); | ^ 210 | 211 | const checkbox = page.locator('label.show-internals'); 212 | await expect(checkbox).not.toBeChecked(); at /home/runner/work/lib-react/lib-react/compiler/apps/playground/__tests__/e2e/page.spec.ts:209:24

const checkbox = page.locator('label.show-internals');
await expect(checkbox).not.toBeChecked();
const ssaTab = page.locator('text=SSA');
await expect(ssaTab).not.toBeVisible();
});

test('show internals button toggles correctly', async ({page}) => {
await page.goto(`/`, {waitUntil: 'networkidle'});
await page.waitForFunction(isMonacoLoaded);

// show internals should be off
const checkbox = page.locator('label.show-internals');
await checkbox.click();

await page.screenshot({
fullPage: true,
path: 'test-results/04-show-internals-on.png',
});

await expect(checkbox).toBeChecked();

const ssaTab = page.locator('text=SSA');
await expect(ssaTab).toBeVisible();
});

test('error is displayed when config has syntax error', async ({page}) => {
const store: Store = {
source: TEST_SOURCE,
config: `compilationMode: `,
showInternals: false,
};
const hash = encodeStore(store);
await page.goto(`/#${hash}`, {waitUntil: 'networkidle'});
await page.waitForFunction(isMonacoLoaded);
await expandConfigs(page);
await page.screenshot({
fullPage: true,
path: 'test-results/05-config-syntax-error.png',
});

const text =
(await page.locator('.monaco-editor-output').allInnerTexts()) ?? [];
const output = text.join('');

// Remove hidden chars
expect(output.replace(/\s+/g, ' ')).toContain('Invalid override format');
});

test('error is displayed when config has validation error', async ({page}) => {
const store: Store = {
source: TEST_SOURCE,
config: `import type { PluginOptions } from 'babel-plugin-react-compiler/dist';

({
compilationMode: "123"
} satisfies Partial<PluginOptions>);`,
showInternals: false,
};
const hash = encodeStore(store);
await page.goto(`/#${hash}`, {waitUntil: 'networkidle'});
await page.waitForFunction(isMonacoLoaded);
await expandConfigs(page);
await page.screenshot({
fullPage: true,
path: 'test-results/06-config-validation-error.png',
});

const text =
(await page.locator('.monaco-editor-output').allInnerTexts()) ?? [];
const output = text.join('');

expect(output.replace(/\s+/g, ' ')).toContain('Unexpected compilationMode');
});

test('disableMemoizationForDebugging flag works as expected', async ({
page,
}) => {
const store: Store = {
source: TEST_SOURCE,
config: `import type { PluginOptions } from 'babel-plugin-react-compiler/dist';

({
environment: {
disableMemoizationForDebugging: true
}
} satisfies Partial<PluginOptions>);`,
showInternals: false,
};
const hash = encodeStore(store);
await page.goto(`/#${hash}`, {waitUntil: 'networkidle'});
await page.waitForFunction(isMonacoLoaded);
await expandConfigs(page);
await page.screenshot({
fullPage: true,
path: 'test-results/07-config-disableMemoizationForDebugging-flag.png',
});

const text =
(await page.locator('.monaco-editor-output').allInnerTexts()) ?? [];
const output = await formatPrint(text);

expect(output).not.toEqual('');
expect(output).toMatchSnapshot('disableMemoizationForDebugging-output.txt');
});

TEST_CASE_INPUTS.forEach((t, idx) =>
test(`playground compiles: ${t.name}`, async ({page}) => {
const store: Store = {
source: t.input,
config: defaultConfig,
showInternals: false,
};
const hash = encodeStore(store);
await page.goto(`/#${hash}`, {waitUntil: 'networkidle'});
await page.waitForFunction(isMonacoLoaded);
await page.screenshot({
fullPage: true,
path: `test-results/03-0${idx}-${t.name}.png`,
path: `test-results/08-0${idx}-${t.name}.png`,
});

const text =
(await page.locator('.monaco-editor').nth(3).allInnerTexts()) ?? [];
(await page.locator('.monaco-editor-output').allInnerTexts()) ?? [];
let output: string;
if (t.noFormat) {
output = text.join('');
Expand Down
4 changes: 3 additions & 1 deletion compiler/apps/playground/components/Editor/ConfigEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import MonacoEditor, {loader, type Monaco} from '@monaco-editor/react';
import {PluginOptions} from 'babel-plugin-react-compiler';
import type {editor} from 'monaco-editor';
import * as monaco from 'monaco-editor';
import React, {useState, useRef, useEffect} from 'react';
import React, {useState, useRef} from 'react';
import {Resizable} from 're-resizable';
import {useStore, useStoreDispatch} from '../StoreContext';
import {monacoOptions} from './monacoOptions';
Expand Down Expand Up @@ -145,6 +145,7 @@ function ExpandedEditor({
onMount={handleMount}
onChange={handleChange}
loading={''}
className="monaco-editor-config"
options={{
...monacoOptions,
lineNumbers: 'off',
Expand All @@ -170,6 +171,7 @@ function ExpandedEditor({
language={'javascript'}
value={formattedAppliedOptions}
loading={''}
className="monaco-editor-applied-config"
options={{
...monacoOptions,
lineNumbers: 'off',
Expand Down
1 change: 1 addition & 0 deletions compiler/apps/playground/components/Editor/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export default function Input({errors, language}: Props): JSX.Element {
value={store.source}
onMount={handleMount}
onChange={handleChange}
className="monaco-editor-input"
options={monacoOptions}
loading={''}
/>
Expand Down
1 change: 1 addition & 0 deletions compiler/apps/playground/components/Editor/Output.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ function TextTabContent({
language={language ?? 'javascript'}
value={output}
loading={''}
className="monaco-editor-output"
options={{
...monacoOptions,
readOnly: true,
Expand Down
2 changes: 1 addition & 1 deletion compiler/apps/playground/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function Header(): JSX.Element {
</div>
<div className="flex items-center text-[15px] gap-4">
<div className="flex items-center gap-2">
<label className="relative inline-block w-[34px] h-5">
<label className="show-internals relative inline-block w-[34px] h-5">
<input
type="checkbox"
checked={store.showInternals}
Expand Down
2 changes: 1 addition & 1 deletion compiler/apps/playground/lib/defaultStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type { PluginOptions } from 'babel-plugin-react-compiler/dist';

({
//compilationMode: "all"
} satisfies Partial<PluginOptions>);`;
} satisfies PluginOptions);`;

export const defaultStore: Store = {
source: index,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function runBabelPluginReactCompiler(
text: string,
file: string,
language: 'flow' | 'typescript',
options: Partial<PluginOptions> | null,
options: PluginOptions | null,
includeAst: boolean = false,
): BabelCore.BabelFileResult {
const ast = BabelParser.parse(text, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
import {getOrInsertWith} from '../Utils/utils';
import {ExternalFunction, isHookName} from '../HIR/Environment';
import {Err, Ok, Result} from '../Utils/Result';
import {LoggerEvent, PluginOptions} from './Options';
import {LoggerEvent, ParsedPluginOptions} from './Options';
import {BabelFn, getReactCompilerRuntimeModule} from './Program';
import {SuppressionRange} from './Suppression';

Expand Down Expand Up @@ -56,7 +56,7 @@ export function validateRestrictedImports(
type ProgramContextOptions = {
program: NodePath<t.Program>;
suppressions: Array<SuppressionRange>;
opts: PluginOptions;
opts: ParsedPluginOptions;
filename: string | null;
code: string | null;
hasModuleScopeOptOut: boolean;
Expand All @@ -66,7 +66,7 @@ export class ProgramContext {
* Program and environment context
*/
scope: BabelScope;
opts: PluginOptions;
opts: ParsedPluginOptions;
filename: string | null;
code: string | null;
reactRuntimeModule: string;
Expand Down
Loading
Loading