Test cases: - [x] create-ts-errors - [x] with auto-fix - [x] without auto-fix - [x] create-unfixable-ts-errors - [x] manually edit file & click recheck - [x] fix all - [x] delete and rename case THINGS - [x] error handling for checkProblems isn't working as expected - [x] make sure it works for both default templates (add tests) - [x] fix bad animation - [x] change file context (prompt/files) IF everything passes in Windows AND defensive try catch... then enable by default - [x] enable auto-fix by default
146 lines
4.0 KiB
TypeScript
146 lines
4.0 KiB
TypeScript
import { test, testSkipIfWindows } from "./helpers/test_helper";
|
|
import { expect } from "@playwright/test";
|
|
import fs from "fs";
|
|
import path from "path";
|
|
|
|
const MINIMAL_APP = "minimal-with-ai-rules";
|
|
|
|
testSkipIfWindows("problems auto-fix - enabled", async ({ po }) => {
|
|
await po.setUp();
|
|
await po.importApp(MINIMAL_APP);
|
|
await po.expectPreviewIframeIsVisible();
|
|
|
|
await po.sendPrompt("tc=create-ts-errors");
|
|
|
|
await po.snapshotServerDump("all-messages", { dumpIndex: -2 });
|
|
await po.snapshotServerDump("all-messages", { dumpIndex: -1 });
|
|
|
|
await po.snapshotMessages({ replaceDumpPath: true });
|
|
});
|
|
|
|
testSkipIfWindows(
|
|
"problems auto-fix - gives up after 2 attempts",
|
|
async ({ po }) => {
|
|
await po.setUp();
|
|
await po.importApp(MINIMAL_APP);
|
|
await po.expectPreviewIframeIsVisible();
|
|
|
|
await po.sendPrompt("tc=create-unfixable-ts-errors");
|
|
|
|
await po.snapshotServerDump("all-messages", { dumpIndex: -2 });
|
|
await po.snapshotServerDump("all-messages", { dumpIndex: -1 });
|
|
|
|
await po.page.getByTestId("problem-summary").last().click();
|
|
await expect(
|
|
po.page.getByTestId("problem-summary").last(),
|
|
).toMatchAriaSnapshot();
|
|
await po.snapshotMessages({ replaceDumpPath: true });
|
|
},
|
|
);
|
|
|
|
testSkipIfWindows(
|
|
"problems auto-fix - complex delete-rename-write",
|
|
async ({ po }) => {
|
|
await po.setUp();
|
|
await po.importApp(MINIMAL_APP);
|
|
await po.expectPreviewIframeIsVisible();
|
|
|
|
await po.sendPrompt("tc=create-ts-errors-complex");
|
|
|
|
await po.snapshotServerDump("all-messages", { dumpIndex: -2 });
|
|
await po.snapshotServerDump("all-messages", { dumpIndex: -1 });
|
|
|
|
await po.snapshotMessages({ replaceDumpPath: true });
|
|
},
|
|
);
|
|
|
|
test("problems auto-fix - disabled", async ({ po }) => {
|
|
await po.setUp({ disableAutoFixProblems: true });
|
|
await po.importApp(MINIMAL_APP);
|
|
await po.expectPreviewIframeIsVisible();
|
|
|
|
await po.sendPrompt("tc=create-ts-errors");
|
|
|
|
await po.snapshotMessages();
|
|
});
|
|
|
|
test("problems - fix all", async ({ po }) => {
|
|
await po.setUp({ disableAutoFixProblems: true });
|
|
await po.importApp(MINIMAL_APP);
|
|
const appPath = await po.getCurrentAppPath();
|
|
const badFilePath = path.join(appPath, "src", "bad-file.tsx");
|
|
fs.writeFileSync(
|
|
badFilePath,
|
|
`const App = () => <div>Minimal imported app</div>;
|
|
nonExistentFunction1();
|
|
nonExistentFunction2();
|
|
nonExistentFunction3();
|
|
|
|
export default App;
|
|
`,
|
|
);
|
|
await po.runPnpmInstall();
|
|
|
|
await po.sendPrompt("tc=create-ts-errors");
|
|
await po.selectPreviewMode("problems");
|
|
await po.clickFixAllProblems();
|
|
|
|
await po.snapshotServerDump("last-message");
|
|
await po.snapshotMessages({ replaceDumpPath: true });
|
|
});
|
|
|
|
test("problems - manual edit (react/vite)", async ({ po }) => {
|
|
await po.setUp();
|
|
await po.sendPrompt("tc=1");
|
|
|
|
const appPath = await po.getCurrentAppPath();
|
|
const badFilePath = path.join(appPath, "src", "bad-file.tsx");
|
|
fs.writeFileSync(
|
|
badFilePath,
|
|
`const App = () => <div>Minimal imported app</div>;
|
|
nonExistentFunction();
|
|
|
|
export default App;
|
|
`,
|
|
);
|
|
await po.runPnpmInstall();
|
|
await po.clickTogglePreviewPanel();
|
|
|
|
await po.selectPreviewMode("problems");
|
|
await po.clickRecheckProblems();
|
|
await po.snapshotProblemsPane();
|
|
|
|
fs.unlinkSync(badFilePath);
|
|
|
|
await po.clickRecheckProblems();
|
|
await po.snapshotProblemsPane();
|
|
});
|
|
|
|
test("problems - manual edit (next.js)", async ({ po }) => {
|
|
await po.setUp();
|
|
await po.selectHubTemplate("Next.js Template");
|
|
await po.sendPrompt("tc=1");
|
|
|
|
const appPath = await po.getCurrentAppPath();
|
|
const badFilePath = path.join(appPath, "src", "bad-file.tsx");
|
|
fs.writeFileSync(
|
|
badFilePath,
|
|
`const App = () => <div>Minimal imported app</div>;
|
|
nonExistentFunction();
|
|
|
|
export default App;
|
|
`,
|
|
);
|
|
await po.runPnpmInstall();
|
|
await po.clickTogglePreviewPanel();
|
|
|
|
await po.selectPreviewMode("problems");
|
|
await po.clickRecheckProblems();
|
|
await po.snapshotProblemsPane();
|
|
|
|
fs.unlinkSync(badFilePath);
|
|
|
|
await po.clickRecheckProblems();
|
|
await po.snapshotProblemsPane();
|
|
});
|