|
1 | 1 | import { expect, test } from '@playwright/test' |
2 | | -import { type Fixture, useFixture } from './fixture' |
| 2 | +import { setupInlineFixture, type Fixture, useFixture } from './fixture' |
3 | 3 | import { |
4 | 4 | expectNoReload, |
5 | 5 | testNoJs, |
@@ -42,6 +42,107 @@ test.describe('build-no-ssr', () => { |
42 | 42 | }) |
43 | 43 | }) |
44 | 44 |
|
| 45 | +test.describe(() => { |
| 46 | + const root = 'examples/e2e/temp/react-compiler' |
| 47 | + |
| 48 | + test.beforeAll(async () => { |
| 49 | + await setupInlineFixture({ |
| 50 | + src: 'examples/starter', |
| 51 | + dest: root, |
| 52 | + files: { |
| 53 | + 'vite.config.ts': /* js */ ` |
| 54 | + import rsc from '@vitejs/plugin-rsc' |
| 55 | + import react from '@vitejs/plugin-react' |
| 56 | + import { defineConfig } from 'vite' |
| 57 | +
|
| 58 | + export default defineConfig({ |
| 59 | + plugins: [ |
| 60 | + react({ |
| 61 | + babel: { plugins: ['babel-plugin-react-compiler'] }, |
| 62 | + }).map((p) => ({ |
| 63 | + ...p, |
| 64 | + applyToEnvironment: (e) => e.name === 'client', |
| 65 | + })), |
| 66 | + rsc({ |
| 67 | + entries: { |
| 68 | + client: './src/framework/entry.browser.tsx', |
| 69 | + ssr: './src/framework/entry.ssr.tsx', |
| 70 | + rsc: './src/framework/entry.rsc.tsx', |
| 71 | + } |
| 72 | + }), |
| 73 | + ], |
| 74 | + }) |
| 75 | + `, |
| 76 | + }, |
| 77 | + }) |
| 78 | + }) |
| 79 | + |
| 80 | + test.describe('dev-react-compiler', () => { |
| 81 | + const f = useFixture({ root, mode: 'dev' }) |
| 82 | + defineTest(f) |
| 83 | + |
| 84 | + test('verify react compiler', async ({ page }) => { |
| 85 | + await page.goto(f.url()) |
| 86 | + await waitForHydration_(page) |
| 87 | + const res = await page.request.get(f.url('src/client.tsx')) |
| 88 | + expect(await res.text()).toContain('react.memo_cache_sentinel') |
| 89 | + }) |
| 90 | + }) |
| 91 | + |
| 92 | + test.describe('build-react-compiler', () => { |
| 93 | + const f = useFixture({ root, mode: 'build' }) |
| 94 | + defineTest(f) |
| 95 | + }) |
| 96 | +}) |
| 97 | + |
| 98 | +test.describe(() => { |
| 99 | + const root = 'examples/e2e/temp/base' |
| 100 | + |
| 101 | + test.beforeAll(async () => { |
| 102 | + await setupInlineFixture({ |
| 103 | + src: 'examples/starter', |
| 104 | + dest: root, |
| 105 | + files: { |
| 106 | + 'vite.config.ts': /* js */ ` |
| 107 | + import rsc from '@vitejs/plugin-rsc' |
| 108 | + import react from '@vitejs/plugin-react' |
| 109 | + import { defineConfig } from 'vite' |
| 110 | +
|
| 111 | + export default defineConfig({ |
| 112 | + base: '/custom-base/', |
| 113 | + plugins: [ |
| 114 | + react(), |
| 115 | + rsc({ |
| 116 | + entries: { |
| 117 | + client: './src/framework/entry.browser.tsx', |
| 118 | + ssr: './src/framework/entry.ssr.tsx', |
| 119 | + rsc: './src/framework/entry.rsc.tsx', |
| 120 | + } |
| 121 | + }), |
| 122 | + ], |
| 123 | + }) |
| 124 | + `, |
| 125 | + }, |
| 126 | + }) |
| 127 | + }) |
| 128 | + |
| 129 | + test.describe('dev-base', () => { |
| 130 | + const f = useFixture({ root, mode: 'dev' }) |
| 131 | + defineTest({ |
| 132 | + ...f, |
| 133 | + url: (url) => new URL(url ?? './', f.url('./custom-base/')).href, |
| 134 | + }) |
| 135 | + }) |
| 136 | + |
| 137 | + test.describe('build-base', () => { |
| 138 | + const f = useFixture({ root, mode: 'build' }) |
| 139 | + defineTest({ |
| 140 | + ...f, |
| 141 | + url: (url) => new URL(url ?? './', f.url('./custom-base/')).href, |
| 142 | + }) |
| 143 | + }) |
| 144 | +}) |
| 145 | + |
45 | 146 | function defineTest(f: Fixture, variant?: 'no-ssr') { |
46 | 147 | const waitForHydration: typeof waitForHydration_ = (page) => |
47 | 148 | waitForHydration_(page, variant === 'no-ssr' ? '#root' : 'body') |
|
0 commit comments