Unverified 提交 667fc42a authored 作者: Will Chen's avatar Will Chen 提交者: GitHub

Import e2e (#311)

上级 4997a8f2
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dyad-generated-app</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
{
"name": "vite_react_shadcn_ts",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"build:dev": "vite build --mode development",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@types/node": "^22.5.5",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react-swc": "^3.9.0",
"typescript": "^5.5.3",
"vite": "^6.3.4"
}
}
const App = () => <div>Minimal imported app</div>;
export default App;
import { createRoot } from "react-dom/client";
import App from "./App.tsx";
createRoot(document.getElementById("root")!).render(<App />);
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitAny": false,
"noFallthroughCasesInSwitch": false,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["src"]
}
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
},
"noImplicitAny": false,
"noUnusedParameters": false,
"skipLibCheck": true,
"allowJs": true,
"noUnusedLocals": false,
"strictNullChecks": false
}
}
{
"compilerOptions": {
"target": "ES2022",
"lib": ["ES2023"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
/* Linting */
"strict": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noFallthroughCasesInSwitch": true
},
"include": ["vite.config.ts"]
}
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import path from "path";
export default defineConfig(() => ({
server: {
host: "::",
port: 8080,
},
plugins: [react()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
}));
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dyad-generated-app</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
{
"name": "vite_react_shadcn_ts",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"build:dev": "vite build --mode development",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@types/node": "^22.5.5",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react-swc": "^3.9.0",
"typescript": "^5.5.3",
"vite": "^6.3.4"
}
}
const App = () => <div>Minimal imported app</div>;
export default App;
import { createRoot } from "react-dom/client";
import App from "./App.tsx";
createRoot(document.getElementById("root")!).render(<App />);
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitAny": false,
"noFallthroughCasesInSwitch": false,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["src"]
}
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
},
"noImplicitAny": false,
"noUnusedParameters": false,
"skipLibCheck": true,
"allowJs": true,
"noUnusedLocals": false,
"strictNullChecks": false
}
}
{
"compilerOptions": {
"target": "ES2022",
"lib": ["ES2023"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
/* Linting */
"strict": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noFallthroughCasesInSwitch": true
},
"include": ["vite.config.ts"]
}
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import path from "path";
export default defineConfig(() => ({
server: {
host: "::",
port: 8080,
},
plugins: [react()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
}));
......@@ -10,6 +10,7 @@ class PageObject {
private userDataDir: string;
constructor(
public electronApp: ElectronApplication,
public page: Page,
{ userDataDir }: { userDataDir: string },
) {
......@@ -243,7 +244,7 @@ class PageObject {
if (!currentAppName) {
throw new Error("No current app name found");
}
return path.join("/tmp", "dyad-apps-test", currentAppName);
return path.join(this.userDataDir, "dyad-apps", currentAppName);
}
////////////////////////////////
......@@ -358,7 +359,7 @@ export const test = base.extend<{
async ({ electronApp }, use) => {
const page = await electronApp.firstWindow();
const po = new PageObject(page, {
const po = new PageObject(electronApp, page, {
userDataDir: (electronApp as any).$dyadUserDataDir,
});
await use(po);
......
import path from "path";
import { test } from "./helpers/test_helper";
import * as eph from "electron-playwright-helpers";
test("import app", async ({ po }) => {
await po.setUp();
await po.page.getByRole("button", { name: "Import App" }).click();
await eph.stubDialog(po.electronApp, "showOpenDialog", {
filePaths: [path.join(__dirname, "fixtures", "import-app", "minimal")],
});
await po.page.getByRole("button", { name: "Select Folder" }).click();
await po.page.getByRole("textbox", { name: "Enter new app name" }).click();
await po.page
.getByRole("textbox", { name: "Enter new app name" })
.fill("minimal-imported-app");
await po.page.getByRole("button", { name: "Import" }).click();
await po.snapshotPreview();
await po.snapshotMessages();
});
test("import app with AI rules", async ({ po }) => {
await po.setUp();
await po.page.getByRole("button", { name: "Import App" }).click();
await eph.stubDialog(po.electronApp, "showOpenDialog", {
filePaths: [
path.join(__dirname, "fixtures", "import-app", "minimal-with-ai-rules"),
],
});
await po.page.getByRole("button", { name: "Select Folder" }).click();
await po.page.getByRole("textbox", { name: "Enter new app name" }).click();
await po.page
.getByRole("textbox", { name: "Enter new app name" })
.fill("minimal-imported-app");
await po.page.getByRole("button", { name: "Import" }).click();
await po.snapshotPreview();
await po.sendPrompt("[dump]");
await po.snapshotServerDump();
await po.snapshotMessages({ replaceDumpPath: true });
});
- text: Minimal imported app
\ No newline at end of file
- paragraph: /Generate an AI_RULES\.md file for this app\. Describe the tech stack in 5-\d+ bullet points and describe clear rules about what libraries to use for what\./
- 'button "Thinking `<dyad-write>`: I''ll think about the problem and write a bug report. <dyad-write> <dyad-write path=\"file1.txt\"> Fake dyad write </dyad-write>"':
- img
- img
- paragraph:
- code: "`<dyad-write>`"
- text: ": I'll think about the problem and write a bug report."
- paragraph: <dyad-write>
- paragraph: <dyad-write path="file1.txt"> Fake dyad write </dyad-write>
- img
- text: file1.txt
- img
- text: file1.txt
- paragraph: More EOM
- button "Retry":
- img
\ No newline at end of file
- text: Minimal imported app
\ No newline at end of file
- paragraph: "[dump]"
- paragraph: "[[dyad-dump-path=*]]"
- button "Retry":
- img
\ No newline at end of file
......@@ -3,7 +3,8 @@ import os from "node:os";
export function getDyadAppPath(appPath: string): string {
if (process.env.E2E_TEST_BUILD) {
return path.join("/tmp", "dyad-apps-test", appPath);
const electron = getElectron();
return path.join(electron!.app.getPath("userData"), "dyad-apps", appPath);
}
return path.join(os.homedir(), "dyad-apps", appPath);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论