Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test/create-post #644

Merged
merged 4 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

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
)
);
});
});