Approve & reject proposal e2e (#298)
This commit is contained in:
16
e2e-tests/approve.spec.ts
Normal file
16
e2e-tests/approve.spec.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { test } from "./helpers/test_helper";
|
||||
import { expect } from "@playwright/test";
|
||||
|
||||
test("write to index, approve, check preview", async ({ po }) => {
|
||||
await po.setUp();
|
||||
await po.sendPrompt("tc=write-index");
|
||||
await po.snapshotMessages();
|
||||
await po.approveProposal();
|
||||
|
||||
// Should be slightly different from above, because it will say "approved"
|
||||
await po.snapshotMessages();
|
||||
|
||||
// This can be pretty slow because it's waiting for the app to build.
|
||||
await expect(po.getPreviewIframeElement()).toBeVisible({ timeout: 15_000 });
|
||||
await po.snapshotPreview();
|
||||
});
|
||||
15
e2e-tests/fixtures/write-index.md
Normal file
15
e2e-tests/fixtures/write-index.md
Normal file
@@ -0,0 +1,15 @@
|
||||
OK, I'm going to do some writing now...
|
||||
|
||||
<dyad-write path="src/pages/Index.tsx" description="write-description">
|
||||
const Index = () => {
|
||||
return (
|
||||
<div>
|
||||
Testing:write-index!
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Index;
|
||||
</dyad-write>
|
||||
|
||||
And it's done!
|
||||
@@ -20,6 +20,23 @@ class PageObject {
|
||||
await expect(this.page.getByTestId("messages-list")).toMatchAriaSnapshot();
|
||||
}
|
||||
|
||||
async approveProposal() {
|
||||
await this.page.getByTestId("approve-proposal-button").click();
|
||||
}
|
||||
|
||||
async rejectProposal() {
|
||||
await this.page.getByTestId("reject-proposal-button").click();
|
||||
}
|
||||
|
||||
getPreviewIframeElement() {
|
||||
return this.page.getByTestId("preview-iframe-element");
|
||||
}
|
||||
|
||||
async snapshotPreview() {
|
||||
const iframe = this.getPreviewIframeElement();
|
||||
await expect(iframe.contentFrame().locator("body")).toMatchAriaSnapshot();
|
||||
}
|
||||
|
||||
async snapshotServerDump() {
|
||||
// Get the text content of the messages list
|
||||
const messagesListText = await this.page
|
||||
@@ -199,11 +216,12 @@ export const test = base.extend<{
|
||||
{ auto: true },
|
||||
],
|
||||
attachScreenshotsToReport: [
|
||||
async ({ page }, use, testInfo) => {
|
||||
async ({ electronApp }, use, testInfo) => {
|
||||
await use();
|
||||
|
||||
// After the test we can check whether the test passed or failed.
|
||||
if (testInfo.status !== testInfo.expectedStatus) {
|
||||
const page = await electronApp.firstWindow();
|
||||
const screenshot = await page.screenshot();
|
||||
await testInfo.attach("screenshot", {
|
||||
body: screenshot,
|
||||
|
||||
14
e2e-tests/reject.spec.ts
Normal file
14
e2e-tests/reject.spec.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { test } from "./helpers/test_helper";
|
||||
import { expect } from "@playwright/test";
|
||||
|
||||
test("reject", async ({ po }) => {
|
||||
await po.setUp();
|
||||
await po.sendPrompt("tc=write-index");
|
||||
await po.snapshotMessages();
|
||||
await po.rejectProposal();
|
||||
|
||||
// Should be slightly different from above, because it will say "rejected"
|
||||
await po.snapshotMessages();
|
||||
|
||||
await expect(po.getPreviewIframeElement()).not.toBeVisible();
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
- paragraph: tc=write-index
|
||||
- paragraph: OK, I'm going to do some writing now...
|
||||
- img
|
||||
- text: Index.tsx
|
||||
- img
|
||||
- text: "src/pages/Index.tsx Summary: write-description"
|
||||
- paragraph: And it's done!
|
||||
- button "Retry":
|
||||
- img
|
||||
@@ -0,0 +1,13 @@
|
||||
- paragraph: tc=write-index
|
||||
- paragraph: OK, I'm going to do some writing now...
|
||||
- img
|
||||
- text: Index.tsx
|
||||
- img
|
||||
- text: "src/pages/Index.tsx Summary: write-description"
|
||||
- paragraph: And it's done!
|
||||
- img
|
||||
- text: Approved
|
||||
- button "Undo":
|
||||
- img
|
||||
- button "Retry":
|
||||
- img
|
||||
@@ -0,0 +1,4 @@
|
||||
- region "Notifications (F8)":
|
||||
- list
|
||||
- region "Notifications alt+T"
|
||||
- text: Testing:write-index!
|
||||
9
e2e-tests/snapshots/reject.spec.ts_reject-1.aria.yml
Normal file
9
e2e-tests/snapshots/reject.spec.ts_reject-1.aria.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
- paragraph: tc=write-index
|
||||
- paragraph: OK, I'm going to do some writing now...
|
||||
- img
|
||||
- text: Index.tsx
|
||||
- img
|
||||
- text: "src/pages/Index.tsx Summary: write-description"
|
||||
- paragraph: And it's done!
|
||||
- button "Retry":
|
||||
- img
|
||||
11
e2e-tests/snapshots/reject.spec.ts_reject-2.aria.yml
Normal file
11
e2e-tests/snapshots/reject.spec.ts_reject-2.aria.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
- paragraph: tc=write-index
|
||||
- paragraph: OK, I'm going to do some writing now...
|
||||
- img
|
||||
- text: Index.tsx
|
||||
- img
|
||||
- text: "src/pages/Index.tsx Summary: write-description"
|
||||
- paragraph: And it's done!
|
||||
- img
|
||||
- text: Rejected
|
||||
- button "Retry":
|
||||
- img
|
||||
Reference in New Issue
Block a user