Skip to content

Commit

Permalink
Test/create-post (#644)
Browse files Browse the repository at this point in the history
* replace devgovgigs.near with devhub.near

* create idea spec

* test: reply to a post in the feed with a comment

* select first announcement, don't replace devgovgigs for blog yet
  • Loading branch information
petersalomonsen authored Jan 23, 2024
1 parent 43f4646 commit ba685dd
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 2 deletions.
2 changes: 1 addition & 1 deletion playwright-tests/tests/announcements.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ test.describe("Admin wallet is connected", () => {
await page.goto(
"/devhub.near/widget/app?page=community&handle=devhub-test"
);
const postLocator = page.locator(".post");
const postLocator = page.locator(".post").first();
await postLocator.focus();
});

Expand Down
35 changes: 35 additions & 0 deletions playwright-tests/tests/create.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,41 @@ test.describe("Wallet is connected", () => {
);
expect(newToken).toBeTruthy();
});
test("should create idea post", async ({ page }) => {
await page.goto("/devhub.near/widget/app?page=create");
await page.click('button:has-text("Idea")');
await page.getByTestId("name-editor").fill("A test idea");

await page
.frameLocator("iframe")
.locator(".CodeMirror textarea")
.fill("My description of the idea");

const labelsInput = await page.locator(".rbt-input-multi");
await labelsInput.focus();
await labelsInput.pressSequentially("ai", { delay: 100 });
await labelsInput.press("Tab");
await labelsInput.pressSequentially("webassemblymus", { delay: 100 });
await labelsInput.press("Tab");

await page.getByTestId("submit-create-post").click();
await expect(page.locator("div.modal-body code")).toHaveText(
JSON.stringify(
{
parent_id: null,
labels: ["ai", "webassemblymusic"],
body: {
name: "A test idea",
description: "My description of the idea",
idea_version: "V1",
post_type: "Idea",
},
},
null,
1
)
);
});
});

test.describe("Admin is connected", () => {
Expand Down
43 changes: 42 additions & 1 deletion playwright-tests/tests/feed.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test } from "@playwright/test";
import { expect, test } from "@playwright/test";

test("should show post history for posts in the feed", async ({ page }) => {
await page.goto("/devhub.near/widget/app?page=feed");
Expand Down Expand Up @@ -127,4 +127,45 @@ test.describe("Wallet is connected", () => {
state: "hidden",
});
});
test("should reply to a post in the feed with a comment", async ({
page,
}) => {
await page.goto("/devhub.near/widget/app?page=feed");
const authorSearchInput = await page.getByPlaceholder("Search by author");
await authorSearchInput.fill("petersalomonsen.near");
await authorSearchInput.press("Tab");
const tagSearchInput = await page.getByPlaceholder("Search by tag");
await tagSearchInput.fill("webassemblymusi");
await tagSearchInput.press("Tab");
await page.getByRole("button", { name: "Reply" }).last().click();
await page.getByRole("button", { name: "Comment" }).click();
await page
.frameLocator("iframe")
.locator(".CodeMirror textarea")
.fill("The comment to the idea");

const labelsInput = await page.locator(".rbt-input-multi");
await labelsInput.focus();
await labelsInput.pressSequentially("ai", { delay: 100 });
await labelsInput.press("Tab");
await labelsInput.pressSequentially("webassemblymus", { delay: 100 });
await labelsInput.press("Tab");

await page.getByTestId("submit-create-post").click();
await expect(page.locator("div.modal-body code")).toHaveText(
JSON.stringify(
{
parent_id: 2489,
labels: ["ai", "webassemblymusic"],
body: {
description: "The comment to the idea",
comment_version: "V2",
post_type: "Comment",
},
},
null,
1
)
);
});
});

0 comments on commit ba685dd

Please sign in to comment.