Skip to content

Commit ce0429e

Browse files
remove wrangler e2e and test React with C3, also add React in the c3 menu
1 parent 524330b commit ce0429e

File tree

24 files changed

+83
-400
lines changed

24 files changed

+83
-400
lines changed

packages/create-cloudflare/e2e/helpers/framework-helpers.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,43 @@ export async function verifyTypes(
355355
}
356356
}
357357

358+
export async function verifyCloudflareVitePluginConfigured(
359+
{ verifyCloudflareVitePluginConfigured: verify }: FrameworkTestConfig,
360+
projectPath: string,
361+
) {
362+
if (verify === false) {
363+
return;
364+
}
365+
366+
const viteConfigTsPAth = join(projectPath, `vite.config.ts`);
367+
const viteConfigJsPath = join(projectPath, `vite.config.js`);
368+
369+
let viteConfigPath: string;
370+
371+
if (existsSync(viteConfigTsPAth)) {
372+
viteConfigPath = viteConfigTsPAth;
373+
} else if (existsSync(viteConfigJsPath)) {
374+
viteConfigPath = viteConfigJsPath;
375+
} else {
376+
throw new Error("Could not find Vite config file to modify");
377+
}
378+
379+
const prePackageJson = JSON.parse(
380+
readFile(join(projectPath, "package.json")),
381+
) as { devDependencies: Record<string, string> };
382+
383+
expect(
384+
prePackageJson.devDependencies?.["@cloudflare/vite-plugin"],
385+
).not.toBeUndefined();
386+
387+
const viteConfig = readFile(viteConfigPath);
388+
389+
expect(viteConfig).toContain(
390+
'import { cloudflare } from "@cloudflare/vite-plugin"',
391+
);
392+
expect(viteConfig).toMatch(/plugins:\s*?\[.*?cloudflare.*?]/);
393+
}
394+
358395
export function shouldRunTest(testConfig: FrameworkTestConfig) {
359396
return (
360397
// Skip if the test is quarantined

packages/create-cloudflare/e2e/helpers/run-c3.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,13 @@ export type RunnerConfig = {
6060
};
6161
};
6262
/**
63-
* Specifies whether to verify generated types for the project
63+
* Specifies whether to verify generated types for the project.
6464
*/
6565
verifyTypes?: boolean;
66+
/**
67+
* Verifies whether the Cloudflare Vite plugin has been installed and configured.
68+
*/
69+
verifyCloudflareVitePluginConfigured?: boolean;
6670
};
6771

6872
export const runC3 = async (

packages/create-cloudflare/e2e/tests/frameworks/frameworks.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
runC3ForFrameworkTest,
1717
shouldRunTest,
1818
testGitCommitMessage,
19+
verifyCloudflareVitePluginConfigured,
1920
verifyDeployment,
2021
verifyDevScript,
2122
verifyPreviewScript,
@@ -150,6 +151,11 @@ describe
150151
);
151152

152153
await verifyTypes(testConfig, frameworkConfig, project.path);
154+
155+
await verifyCloudflareVitePluginConfigured(
156+
testConfig,
157+
project.path,
158+
);
153159
} catch (e) {
154160
expect.fail(
155161
"Failed due to an exception while running C3. See logs for more details. Error: " +

packages/create-cloudflare/e2e/tests/frameworks/test-config.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,38 @@ function getExperimentalFrameworkTestConfig(
818818
nodeCompat: true,
819819
verifyTypes: false,
820820
},
821+
{
822+
name: "react:workers",
823+
argv: ["--platform", "workers"],
824+
promptHandlers: [
825+
{
826+
matcher: /Select a variant:/,
827+
input: [keys.enter],
828+
},
829+
],
830+
unsupportedOSs: ["win32"],
831+
testCommitMessage: true,
832+
verifyDeploy: {
833+
route: "/",
834+
// Note that this is the text in the static HTML that is returned
835+
// This React SPA will change this at runtime but we are only making a fetch request
836+
// not actually running the client side JS.
837+
expectedText: "Vite + React + TS",
838+
},
839+
verifyPreview: {
840+
route: "/",
841+
// We need to run the preview on the specific IP address on which we make the request.
842+
// By default `vite preview` runs on `localhost` that doesn't always include 127.0.0.1.
843+
previewArgs: ["--host=127.0.0.1"],
844+
// Note that this is the text in the static HTML that is returned
845+
// This React SPA will change this at runtime but we are only making a fetch request
846+
// not actually running the client side JS.
847+
expectedText: "Vite + React + TS",
848+
},
849+
verifyCloudflareVitePluginConfigured: true,
850+
nodeCompat: false,
851+
verifyTypes: false,
852+
},
821853
];
822854
}
823855

packages/create-cloudflare/src/helpers/packages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export const installWrangler = async () => {
136136
const { npm } = detectPackageManager();
137137

138138
// Even if Wrangler is already installed, make sure we install the latest version, as some framework CLIs are pinned to an older version
139-
await installPackages([`wrangler@latest`], {
139+
await installPackages([`/Users/dario/Repos/workers-sdk/packages/wrangler`], {
140140
dev: true,
141141
startText: `Installing wrangler ${dim(
142142
"A command line tool for building Cloudflare Workers",

packages/create-cloudflare/src/templates.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ export function getFrameworkMap({ experimental = false }): TemplateMap {
244244
angular: angularTemplate,
245245
solid: solidTemplate,
246246
qwik: qwikTemplate,
247+
react: reactTemplate,
247248
};
248249
} else {
249250
return {

packages/wrangler/e2e/autoconfig/fixtures/vite-react-spa/.gitignore

Lines changed: 0 additions & 24 deletions
This file was deleted.

packages/wrangler/e2e/autoconfig/fixtures/vite-react-spa/README.md

Lines changed: 0 additions & 73 deletions
This file was deleted.

packages/wrangler/e2e/autoconfig/fixtures/vite-react-spa/__alternative-vite-configs/with-cloudflare-plugin.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

packages/wrangler/e2e/autoconfig/fixtures/vite-react-spa/eslint.config.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)