Remove tests relying on rad-web

This commit is contained in:
Sebastian Martinez
2024-06-28 08:55:13 +02:00
parent 0b1ccb5836
commit fda384bc14
15 changed files with 23 additions and 1128 deletions
-173
View File
@@ -4,19 +4,10 @@ import { HttpdClient } from "@http-client";
import {
aliceMainHead,
aliceRemote,
bobRemote,
cobRid,
defaultHttpdPort,
sourceBrowsingRid,
} from "@tests/support/fixtures.js";
import {
assertIssue,
assertPatch,
createIssueToBeModified,
createPatchToBeModified,
} from "@http-client/tests/support/support";
import { authenticate } from "@http-client/tests/support/httpd.js";
import { testFixture as testWithAPI } from "@http-client/tests/support/fixtures.js";
describe("project", () => {
const api = new HttpdClient({
@@ -114,114 +105,6 @@ describe("project", () => {
});
});
testWithAPI(
"#createIssue(id, { title, description, assignees, labels })",
async ({ httpd: { api, peer } }) => {
const sessionId = await authenticate(api, peer);
const { id: issueId } = await api.project.createIssue(
cobRid,
{
title: "aaa",
description: "bbb",
assignees: [],
embeds: [],
labels: ["bug", "documentation"],
},
sessionId,
);
await assertIssue(
issueId,
{
title: "aaa",
discussion: [{ body: "bbb" }],
assignees: [],
labels: ["bug", "documentation"],
},
api,
);
},
);
testWithAPI(
"#updateIssue(id, issueId, { type: 'edit' }, authToken)",
async ({ httpd: { api, peer } }) => {
const sessionId = await authenticate(api, peer);
const issueId = await createIssueToBeModified(api, sessionId);
await api.project.updateIssue(
cobRid,
issueId,
{ type: "edit", title: "ccc" },
sessionId,
);
await assertIssue(issueId, { title: "ccc" }, api);
},
);
testWithAPI(
"#updateIssue(id, issueId, { type: 'label' }, authToken)",
async ({ httpd: { api, peer } }) => {
const sessionId = await authenticate(api, peer);
const issueId = await createIssueToBeModified(api, sessionId);
await api.project.updateIssue(
cobRid,
issueId,
{ type: "label", labels: ["bug"] },
sessionId,
);
await assertIssue(issueId, { labels: ["bug"] }, api);
},
);
testWithAPI(
"#updateIssue(id, issueId, { type: 'assign' }, authToken)",
async ({ httpd: { api, peer } }) => {
const sessionId = await authenticate(api, peer);
const issueId = await createIssueToBeModified(api, sessionId);
await api.project.updateIssue(
cobRid,
issueId,
{
type: "assign",
assignees: [bobRemote],
},
sessionId,
);
await assertIssue(
issueId,
{
assignees: [
{
id: "did:key:z6Mkg49NtQR2LyYRDCQFK4w1VVHqhypZSSRo7HsyuN7SV7v5",
alias: "bob",
},
],
},
api,
);
},
);
testWithAPI(
"#updateIssue(id, issueId, { type: 'lifecycle' }, authToken)",
async ({ httpd: { api, peer } }) => {
const sessionId = await authenticate(api, peer);
const issueId = await createIssueToBeModified(api, sessionId);
await api.project.updateIssue(
cobRid,
issueId,
{ type: "lifecycle", state: { status: "closed", reason: "solved" } },
sessionId,
);
await assertIssue(
issueId,
{
state: { status: "closed", reason: "solved" },
},
api,
);
},
);
test("#getPatchById(id, patchId)", async () => {
await api.project.getPatchById(
cobRid,
@@ -232,60 +115,4 @@ describe("project", () => {
test("#getAllPatches(id)", async () => {
await api.project.getAllPatches(cobRid);
});
testWithAPI(
"#createPatch(id, patchCreate, authToken)",
async ({ httpd: { api, peer } }) => {
const sessionId = await authenticate(api, peer);
const { id: oid } = await api.project.createPatch(
cobRid,
{
title: "ppp",
description: "qqq",
target: "d7dd8cecae16b1108234e09dbdb5d64ae394bc25",
oid: "38c225e2a0b47ba59def211f4e4825c31d9463ec",
labels: [],
},
sessionId,
);
await assertPatch(
oid,
{
title: "ppp",
state: { status: "open" },
target: "delegates",
labels: [],
revisions: [
{
description: "qqq",
base: "d7dd8cecae16b1108234e09dbdb5d64ae394bc25",
oid: "38c225e2a0b47ba59def211f4e4825c31d9463ec",
},
],
},
api,
);
},
);
testWithAPI(
"#updatePatch(id, patchId, { type: 'edit' }, authToken)",
async ({ httpd: { api, peer } }) => {
const sessionId = await authenticate(api, peer);
const patchId = await createPatchToBeModified(api, sessionId);
await api.project.updatePatch(
cobRid,
patchId,
{ type: "label", labels: ["bug"] },
sessionId,
);
await assertPatch(
patchId,
{
labels: ["bug"],
},
api,
);
},
);
});
-38
View File
@@ -1,38 +0,0 @@
import * as FsSync from "node:fs";
import * as Path from "node:path";
import { describe, test } from "vitest";
import { HttpdClient } from "@http-client";
import { authenticate } from "@http-client/tests/support/httpd.js";
import { createPeerManager } from "@tests/support/peerManager.js";
import { gitOptions } from "@tests/support/fixtures.js";
import { tmpDir } from "@tests/support/support.js";
describe("session", async () => {
const peerManager = await createPeerManager({
dataDir: Path.resolve(Path.join(tmpDir, "peers")),
outputLog: FsSync.createWriteStream(
Path.join(tmpDir, "peerManager.log"),
).setMaxListeners(16),
});
const peer = await peerManager.createPeer({
name: "session",
gitOptions: gitOptions["alice"],
});
await peer.startHttpd();
const api = new HttpdClient(peer.httpdBaseUrl);
test("#getById(id)", async () => {
const id = await authenticate(api, peer);
await api.session.getById(id);
});
test("#update(id, {sig, pk})", async () => {
await authenticate(api, peer);
});
test("#delete(id)", async () => {
const id = await authenticate(api, peer);
await api.session.delete(id);
});
});
-30
View File
@@ -1,30 +0,0 @@
import type { HttpdClient } from "@http-client";
import type { RadiclePeer } from "@tests/support/peerManager.js";
import assert from "node:assert";
export async function authenticate(
api: HttpdClient,
peer: RadiclePeer,
): Promise<string> {
const { stdout } = await peer.spawn("rad-web", [
"http://localhost:3001",
"--no-open",
"--connect",
`${peer.httpdBaseUrl.hostname}:${peer.httpdBaseUrl.port}`,
]);
const match = stdout.match(/Visit (http:\/\/\S+) to connect/);
assert(
match !== null && match[1],
`Failed to get authentication URL from: ${stdout}`,
);
const authUrl = new URL(match[1]);
const sessionId = authUrl.pathname.split("/")[2];
await api.session.update(sessionId, {
sig: authUrl.searchParams.get("sig")!,
pk: authUrl.searchParams.get("pk")!,
});
return sessionId;
}
-31
View File
@@ -5,37 +5,6 @@ import isMatch from "lodash/isMatch";
import { cobRid } from "@tests/support/fixtures";
export async function createIssueToBeModified(
api: HttpdClient,
sessionId: string,
) {
const { id } = await api.project.createIssue(
cobRid,
{ title: "aaa", description: "bbb", embeds: [], assignees: [], labels: [] },
sessionId,
);
return id;
}
export async function createPatchToBeModified(
api: HttpdClient,
sessionId: string,
) {
const { id } = await api.project.createPatch(
cobRid,
{
title: "rrr",
description: "ttt",
target: "d7dd8cecae16b1108234e09dbdb5d64ae394bc25",
oid: "38c225e2a0b47ba59def211f4e4825c31d9463ec",
labels: [],
},
sessionId,
);
return id;
}
export async function assertIssue(
oid: string,
change: Record<string, unknown>,
-15
View File
@@ -1,5 +1,4 @@
import { expect, shortNodeRemote, test } from "@tests/support/fixtures.js";
import { createProject } from "@tests/support/project";
test("node metadata", async ({ page, peerManager }) => {
const peer = await peerManager.createPeer({
@@ -35,17 +34,3 @@ test("node projects", async ({ page }) => {
).toBeVisible();
}
});
test("seeding projects", async ({ page, authenticatedPeer }) => {
const { rid } = await createProject(authenticatedPeer, {
name: "seedProject",
});
await page.goto(authenticatedPeer.ridUrl(rid));
await page.getByRole("button", { name: "Seeding" }).click();
await page.getByRole("button", { name: "Stop seeding" }).click();
await expect(page.getByRole("button", { name: "Seed 1" })).toBeVisible();
await page.getByRole("button", { name: "Seed 1" }).click();
await expect(page.getByRole("button", { name: "Seeding" })).toBeVisible();
});
-70
View File
@@ -1,70 +0,0 @@
import { test, expect } from "@tests/support/fixtures.js";
import { createProject } from "@tests/support/project";
test("add and remove assignees", async ({ page, authenticatedPeer }) => {
await page.goto(authenticatedPeer.uiUrl());
const { rid, projectFolder } = await createProject(authenticatedPeer, {
name: "handle-assignees",
});
await authenticatedPeer.rad(
[
"issue",
"open",
"--title",
"This is an issue to test assignee handling",
"--description",
"We'll add and remove assignees to them",
],
{ cwd: projectFolder },
);
await page.goto(`${authenticatedPeer.uiUrl()}/${rid}/issues`);
await page
.getByRole("link", {
name: "This is an issue to test assignee handling",
})
.click();
await page.getByRole("button", { name: "add assignee" }).click();
await page
.getByPlaceholder("Add assignee")
.fill("z6MktULudTtAsAhRegYPiZ6631RV3viv12qd4GQF8z1xB22S");
await page.getByRole("button", { name: "discard assignee" }).click();
await page.getByRole("button", { name: "add assignee" }).click();
await page
.getByPlaceholder("Add assignee")
.fill("z6MktULudTtAsAhRegYPiZ6631RV3viv12qd4GQF8z1xB22S");
await page.keyboard.press("Enter");
await page.getByRole("button", { name: "add assignee" }).click();
await page
.getByPlaceholder("Add assignee")
.fill("z6MktULudTtAsAhRegYPiZ6631RV3viv12qd4GQF8z1xB22S");
await page.getByRole("button", { name: "save assignee" }).click();
await expect(page.getByText("This assignee is already added")).toBeVisible();
await page.getByPlaceholder("Add assignee").clear();
await expect(page.getByText("This assignee is already added")).toBeHidden();
await page
.getByPlaceholder("Add assignee")
.fill("z6MkkfM3tPXNPrPevKr3uSiQtHPuwnNhu2yUVjgd2jXVsVz5");
await page.keyboard.press("Enter");
await expect(
page.getByRole("button", { name: "avatar did:key:z6MktU…1xB22S" }),
).toBeVisible();
await expect(
page.getByRole("button", { name: "avatar did:key:z6Mkkf…XVsVz5" }),
).toBeVisible();
await page
.getByRole("button", { name: "avatar did:key:z6MktU…1xB22S" })
.click();
await page
.getByRole("button", { name: "remove assignee", exact: true })
.click();
await expect(
page.getByRole("button", { name: "avatar did:key:z6Mkkf…XVsVz5" }),
).toBeVisible();
await expect(
page.getByRole("button", { name: "avatar did:key:z6MktU…1xB22S" }),
).toBeHidden();
});
-201
View File
@@ -1,9 +1,4 @@
import { test, cobUrl, expect } from "@tests/support/fixtures.js";
import {
addEmbed,
createProject,
expectReactionsToWork,
} from "@tests/support/project";
test("navigate single issue", async ({ page }) => {
await page.goto(`${cobUrl}/issues`);
@@ -11,199 +6,3 @@ test("navigate single issue", async ({ page }) => {
await expect(page).toHaveURL(/\/issues\/[0-9a-f]{40}/);
});
test("test issue editing failing", async ({ page, authenticatedPeer }) => {
const { rid, projectFolder } = await createProject(authenticatedPeer, {
name: "issue-editing",
});
await authenticatedPeer.rad(
[
"issue",
"open",
"--title",
"This issue is going to fail",
"--description",
"Let's see",
],
{ cwd: projectFolder },
);
await page.route(
({ pathname }) => pathname.startsWith(`/api/v1/projects/${rid}/issues/`),
async route => {
if (route.request().method() === "PATCH") {
return route.fulfill({ status: 500 });
} else {
return route.fallback();
}
},
);
await page.goto(`${authenticatedPeer.uiUrl()}/${rid}/issues`);
await page.getByRole("link", { name: "This issue is going to fail" }).click();
await page.getByRole("button", { name: "Leave your comment" }).click();
await page.getByPlaceholder("Leave your comment").fill("This is a comment");
await page.getByRole("button", { name: "Comment" }).first().click();
await expect(page.getByText("Comment creation failed")).toBeVisible();
});
test("edit issue", async ({ page, authenticatedPeer }) => {
await page.goto(authenticatedPeer.uiUrl());
const { rid, projectFolder } = await createProject(authenticatedPeer, {
name: "edit-issue",
});
await authenticatedPeer.rad(
[
"issue",
"open",
"--title",
"This is an issue to edit its title",
"--description",
"We'll give it a description and edit it.",
],
{ cwd: projectFolder },
);
await page.goto(`${authenticatedPeer.uiUrl()}/${rid}/issues`);
await page
.getByRole("link", { name: "This is an issue to edit its title" })
.click();
await expect(
page.getByText("This is an issue to edit its title"),
).toBeVisible();
await expect(page.getByPlaceholder("Title")).toBeHidden();
await expect(
page.getByText("We'll give it a description and edit it."),
).toBeVisible();
await expect(page.getByPlaceholder("Leave a description")).toBeHidden();
await page.getByRole("button", { name: "Edit" }).click();
await page
.getByPlaceholder("Title")
.fill("This is a modified issue title to be dismissed");
await page
.getByPlaceholder("Leave a description")
.fill("This is a modified issue description to be dismissed");
await page.getByRole("button", { name: "Cancel" }).click();
await expect(
page.getByText("This is an issue to edit its title"),
).toBeVisible();
await expect(
page.getByText("We'll give it a description and edit it."),
).toBeVisible();
await page.getByRole("button", { name: "Edit" }).click();
await page.getByPlaceholder("Title").fill("This is a modified issue title");
await page
.getByPlaceholder("Leave a description")
.fill("This is a modified issue description");
await page.getByRole("button", { name: "Save" }).click();
await expect(page.getByRole("button", { name: "Save" })).toBeHidden();
await expect(page.getByText("This is a modified issue title")).toBeVisible();
await expect(
page.getByText("This is a modified issue description"),
).toBeVisible();
await page.reload({ waitUntil: "networkidle" });
await expect(page.getByText("This is a modified issue title")).toBeVisible();
await expect(
page.getByText("This is a modified issue description"),
).toBeVisible();
});
test("add and remove reactions", async ({ page, authenticatedPeer }) => {
const { rid, projectFolder } = await createProject(authenticatedPeer, {
name: "handle-reactions",
});
await authenticatedPeer.rad(
[
"issue",
"open",
"--title",
"This is an issue to test reactions",
"--description",
"We'll add and remove reactions to them",
],
{ cwd: projectFolder },
);
await page.goto(`${authenticatedPeer.uiUrl()}/${rid}/issues`);
await page
.getByRole("link", { name: "This is an issue to test reactions" })
.click();
const reactionsLocator = page.locator(".actions").first();
await expectReactionsToWork(page, reactionsLocator);
});
test("handling embeds", async ({ page, authenticatedPeer }) => {
const { rid } = await createProject(authenticatedPeer, { name: "embeds" });
await page.goto(
`/nodes/${authenticatedPeer.httpdBaseUrl.hostname}:${authenticatedPeer.httpdBaseUrl.port}/${rid}/issues/new`,
);
await page.getByPlaceholder("Title").fill("This is a title");
await page
.getByPlaceholder("Write a description")
.fill("Here is some text\n\n");
await addEmbed(
page,
"./public/images/radicle-228x228.png",
"radicle-228x228.png",
"image/png",
);
await expect(page.getByPlaceholder("Write a description")).toHaveValue(
"Here is some text\n\n![radicle-228x228.png](bae036309c2182c7304c97956969369823b5c6ad)\n",
);
await page.getByRole("button", { name: "Preview" }).click();
await expect(
page.getByRole("img", { name: "radicle-228x228.png" }),
).toBeVisible();
expect(
await page
.getByRole("img", { name: "radicle-228x228.png" })
.getAttribute("src"),
).toBe(
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOQAAADkCAYAAACIV4iNAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAkkSURBVHgB7dxNbttGGMbxoSQrqeS0cGAjDZCF4WaVLLrQBXyBLHWA3sQ36QF0CV9AB+iiQRbZBA5iFInUWl/s+445CkVLbpMq9OPq/wMm4odEzdB8NENKYRbumX4/z8MWDQZZFiBj1/++jQBABoEEhBBIQAiBBIQQSEAIgQSEEEhACIEEhBBIQAiBBIQQSEAIgQSEEEhACIEEhBBIQAiBBIQQSEAIgQSEEEhAyM7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KvhCRbizAKzbpgW5219sFDlV1dX1WFrqDx3+fw4cf2a2GNYuTo4OPjz8vLSD85Znuce1C8+QPv9fnMwGPgblNvrYYwjJBsqxucVdfW2BWtbrGOpnSvHSvGcZbtsG17vZXuq7Qur+628bZ+eFcWHqX+Gz8PzRdixQO7qfVkXz58/n1og40FmPcfUeo7YO3Y6ncyGSysBsh4qt9OaeFCl9d4T2MGUDrSseM7yNd5r+LwtD+m1oRLc0nvF80ebju/lwzt7TTxILYx+YMbh29eE0b18+TK/uLiY2nlkWjS1nrdpAW94HVMQU92KdpWnq4GM541FmGKdzY3nlfdbaR9Vt+3PWxTt9bb6Ywoi98zdEX4geG+4d3x87L1FJ1xf8EjlUSp27pWmvy8vX7N+07L9yvr9ddOl1/iyblGn1HM3iwP+azXK7X369Gmn/N52zra/rm2b2uTT69q9bn1pej9s2F82RF1p79nZWRqpYEdkpdK0izzeO3qJFz289Hq9PS/FspVSXp6m/bHYzt4/lXXbLb+fb8eHmV68jvn1zcH/ywFabq8f7M1NdSnXY90+SPMvXrxol5f7/Ib91b7tPYqS9n/DP3iKD5+dDCSfQqv+7f64MYQLm8+bblt+2/brsHY4Wlkfwprh9obtVF8XKq+/bb9tOnffKX8Dh1MvnjJRErgAAAAASUVORK5CYII=",
);
await page.getByRole("button", { name: "Submit" }).click();
await expect(page.getByRole("button", { name: "Submit" })).toBeHidden();
await expect(page.getByText("This is a title")).toBeVisible();
await expect(page.getByText("Here is some text")).toBeVisible();
await expect(
page.getByRole("img", { name: "radicle-228x228.png" }),
).toBeVisible();
const { scheme, hostname, port } = authenticatedPeer.httpdBaseUrl;
expect(
await page
.getByRole("img", { name: "radicle-228x228.png" })
.getAttribute("src"),
).toBe(
`${scheme}://${hostname}:${port}/raw/rad:z2J7s48EbCBckcEmj2dm5eaFVoBsy/blobs/bae036309c2182c7304c97956969369823b5c6ad?mime=image/png`,
);
await expect(
page.getByRole("button", { name: "radicle-228x228.png" }),
).toBeVisible();
await page.getByRole("button", { name: "Edit" }).click();
await page
.getByPlaceholder("Leave a description")
.fill(
"Here is some text\n\n![radicle-228x228.png](bae036309c2182c7304c97956969369823b5c6ad)\n\n",
);
await addEmbed(
page,
"./public/images/apple-touch-icon.png",
"apple-touch-icon.png",
"image/png",
);
await expect(page.getByPlaceholder("Leave a description")).toHaveValue(
"Here is some text\n\n![radicle-228x228.png](bae036309c2182c7304c97956969369823b5c6ad)\n\n![apple-touch-icon.png](c69a66fa4c414c92bf75365fb5c92453fa95dcca)\n",
);
await page.getByRole("button", { name: "Save" }).click();
await expect(page.getByRole("button", { name: "Submit" })).toBeHidden();
await expect(
page.getByRole("button", { name: "apple-touch-icon.png" }),
).toBeVisible();
await expect(
page.getByRole("button", { name: "radicle-228x228.png" }),
).toBeVisible();
});
+5 -55
View File
@@ -11,11 +11,11 @@ test("navigate issue listing", async ({ page }) => {
await expect(page).toHaveURL(`${cobUrl}/issues?state=closed`);
});
test("issue counters", async ({ page, authenticatedPeer }) => {
const { rid, projectFolder } = await createProject(authenticatedPeer, {
test("issue counters", async ({ page, peer }) => {
const { rid, projectFolder } = await createProject(peer, {
name: "issue-counters",
});
await authenticatedPeer.rad(
await peer.rad(
[
"issue",
"open",
@@ -26,8 +26,8 @@ test("issue counters", async ({ page, authenticatedPeer }) => {
],
{ cwd: projectFolder },
);
await page.goto(`${authenticatedPeer.uiUrl()}/${rid}/issues`);
await authenticatedPeer.rad(
await page.goto(`${peer.uiUrl()}/${rid}/issues`);
await peer.rad(
[
"issue",
"open",
@@ -49,54 +49,4 @@ test("issue counters", async ({ page, authenticatedPeer }) => {
await page
.getByRole("link", { name: "First issue to test counters" })
.click();
await page
.getByRole("button", { name: "Close issue as solved" })
.first()
.click();
await expect(page.getByRole("button", { name: "Issues 1" })).toBeVisible();
});
test("create a new issue", async ({ page, authenticatedPeer }) => {
const { rid } = await createProject(authenticatedPeer, {
name: "commenting",
});
await page.goto(
`/nodes/${authenticatedPeer.httpdBaseUrl.hostname}:${authenticatedPeer.httpdBaseUrl.port}/${rid}`,
);
await page.getByRole("link", { name: "Issues 0" }).click();
await page.getByRole("link", { name: "New issue" }).click();
await page.getByPlaceholder("Title").fill("This is a title");
await page
.getByPlaceholder("Write a description")
.fill("This is a description");
await page.getByRole("button", { name: "add assignee" }).click();
await page.getByPlaceholder("Add assignee").fill(authenticatedPeer.nodeId);
await page.keyboard.press("Enter");
await page.getByRole("button", { name: "add label" }).click();
await page.getByPlaceholder("Add label").fill("bug");
await page.keyboard.press("Enter");
await page.getByRole("button", { name: "add label" }).click();
await page.getByPlaceholder("Add label").fill("documentation");
await page.keyboard.press("Enter");
await page.getByRole("button", { name: "Submit" }).click();
await expect(page.getByText("This is a title")).toBeVisible();
await expect(page.getByText("This is a description")).toBeVisible();
await expect(
page.getByRole("button", {
name: `did:key:${authenticatedPeer.nodeId.substring(
0,
6,
)}…${authenticatedPeer.nodeId.slice(-6)}`,
}),
).toBeVisible();
await expect(
page.getByRole("button", { name: "documentation" }),
).toBeVisible();
await expect(page.getByRole("button", { name: "bug" })).toBeVisible();
});
-44
View File
@@ -1,44 +0,0 @@
import { test } from "@tests/support/fixtures.js";
import {
createProject,
expectLabelEditingToWork,
extractPatchId,
} from "@tests/support/project";
test("add and remove labels", async ({ page, authenticatedPeer }) => {
const { rid, projectFolder } = await createProject(authenticatedPeer, {
name: "handle-labels",
});
await authenticatedPeer.rad(
[
"issue",
"open",
"--title",
"This is an issue to test label handling",
"--description",
"We'll add and remove labels to them",
],
{ cwd: projectFolder },
);
await page.goto(`${authenticatedPeer.uiUrl()}/${rid}/issues`);
await page.getByRole("link", { name: "This is an issue to test" }).click();
await expectLabelEditingToWork(page);
await authenticatedPeer.git(["switch", "-c", "handle-labels"], {
cwd: projectFolder,
});
await authenticatedPeer.git(
["commit", "--allow-empty", "-m", "Some patch title"],
{
cwd: projectFolder,
},
);
const patchId = extractPatchId(
await authenticatedPeer.git(["push", "rad", "HEAD:refs/patches"], {
cwd: projectFolder,
}),
);
await page.goto(`${authenticatedPeer.uiUrl()}/${rid}/patches/${patchId}`);
await expectLabelEditingToWork(page);
});
-145
View File
@@ -1,5 +1,4 @@
import { test, cobUrl, expect } from "@tests/support/fixtures.js";
import { createProject, extractPatchId } from "@tests/support/project";
test("navigate patch details", async ({ page }) => {
await page.goto(`${cobUrl}/patches`);
@@ -118,147 +117,3 @@ test("view file navigation from changes tab", async ({ page }) => {
`${cobUrl}/tree/8c900d6cb38811e099efb3cbbdbfaba817bcf970/README.md`,
);
});
test("change patch state", async ({ page, authenticatedPeer }) => {
const { rid, projectFolder } = await createProject(authenticatedPeer, {
name: "lifecycle",
});
await authenticatedPeer.git(["switch", "-c", "feature-1"], {
cwd: projectFolder,
});
await authenticatedPeer.git(
["commit", "--allow-empty", "-m", "Some patch title"],
{
cwd: projectFolder,
},
);
const patchId = extractPatchId(
await authenticatedPeer.git(["push", "rad", "HEAD:refs/patches"], {
cwd: projectFolder,
}),
);
await page.goto(`${authenticatedPeer.uiUrl()}/${rid}/patches/${patchId}`);
await page.getByRole("button", { name: "Archive patch" }).first().click();
await expect(page.getByText("Archived", { exact: true })).toBeVisible();
await expect(page.getByRole("button", { name: "Patches 0" })).toBeVisible();
await page.getByLabel("stateToggle").first().click();
await page.getByText("Convert to draft").click();
await page.getByText("Convert to draft").click();
await expect(page.getByText("Draft", { exact: true })).toBeVisible();
await expect(page.getByRole("button", { name: "Patches 0" })).toBeVisible();
});
test("edit patch", async ({ page, authenticatedPeer }) => {
const { rid, projectFolder } = await createProject(authenticatedPeer, {
name: "edit-patch",
});
await authenticatedPeer.git(["switch", "-c", "edit-patch"], {
cwd: projectFolder,
});
await authenticatedPeer.git(
[
"commit",
"--allow-empty",
"-m",
"Some patch title",
"-m",
"This should be a description",
],
{
cwd: projectFolder,
},
);
const patchId = extractPatchId(
await authenticatedPeer.git(["push", "rad", "HEAD:refs/patches"], {
cwd: projectFolder,
}),
);
await page.goto(`${authenticatedPeer.uiUrl()}/${rid}/patches/${patchId}`);
const titleLocator = page.getByText("Some patch title").first();
const descriptionLocator = page.getByText("This should be a description");
await expect(titleLocator).toBeVisible();
await expect(descriptionLocator).toBeVisible();
await expect(page.getByPlaceholder("Title")).toBeHidden();
await expect(page.getByPlaceholder("Leave a description")).toBeHidden();
await page.getByRole("button", { name: "Edit", exact: true }).click();
await page
.getByPlaceholder("Title")
.fill("This is a modified patch title to be dismissed");
await page
.getByPlaceholder("Leave a description")
.fill("This is a modified patch description to be dismissed");
await page.getByRole("button", { name: "Cancel" }).click();
await expect(titleLocator).toBeVisible();
await expect(descriptionLocator).toBeVisible();
await page.getByRole("button", { name: "Edit", exact: true }).click();
await page.getByPlaceholder("Title").fill("This is a modified patch title");
await page
.getByPlaceholder("Leave a description")
.fill("This is a modified patch description");
await page.getByRole("button", { name: "Save" }).click();
await expect(page.getByRole("button", { name: "Save" })).toBeHidden();
await expect(page.getByText("This is a modified patch title")).toBeVisible();
await expect(
page.getByText("This is a modified patch description"),
).toBeVisible();
await page.reload();
await expect(page.getByText("This is a modified patch title")).toBeVisible();
await expect(
page.getByText("This is a modified patch description"),
).toBeVisible();
});
test("edit revision", async ({ page, authenticatedPeer }) => {
const { rid, projectFolder } = await createProject(authenticatedPeer, {
name: "edit-revision",
});
await authenticatedPeer.git(["switch", "-c", "edit-revision"], {
cwd: projectFolder,
});
await authenticatedPeer.git(
[
"commit",
"--allow-empty",
"-m",
"Some patch title",
"-m",
"This should be a description",
],
{
cwd: projectFolder,
},
);
const patchId = extractPatchId(
await authenticatedPeer.git(["push", "rad", "HEAD:refs/patches"], {
cwd: projectFolder,
}),
);
await authenticatedPeer.git(
[
"commit",
"--allow-empty",
"-m",
"Let's create a new revision",
"-m",
"More descriptions",
],
{
cwd: projectFolder,
},
);
await authenticatedPeer.git(["push", "rad"], { cwd: projectFolder });
await page.goto(`${authenticatedPeer.ridUrl(rid)}/patches/${patchId}`);
await page.getByRole("button", { name: "edit revision" }).click();
await page
.getByPlaceholder("Leave a description")
.fill("This is an edited second revision");
await page.getByRole("button", { name: "Save" }).click();
await expect(
page.getByText("This is an edited second revision"),
).toBeVisible();
});
+12 -13
View File
@@ -14,31 +14,30 @@ test("navigate patch listing", async ({ page }) => {
).toBeVisible();
});
test("patches counters", async ({ page, authenticatedPeer }) => {
const { rid, projectFolder, defaultBranch } = await createProject(
authenticatedPeer,
{ name: "patch-counters" },
);
await authenticatedPeer.git(["switch", "-c", "feature-1"], {
test("patches counters", async ({ page, peer }) => {
const { rid, projectFolder, defaultBranch } = await createProject(peer, {
name: "patch-counters",
});
await peer.git(["switch", "-c", "feature-1"], {
cwd: projectFolder,
});
await authenticatedPeer.git(["commit", "--allow-empty", "-m", "1th"], {
await peer.git(["commit", "--allow-empty", "-m", "1th"], {
cwd: projectFolder,
});
await authenticatedPeer.git(["push", "rad", "HEAD:refs/patches"], {
await peer.git(["push", "rad", "HEAD:refs/patches"], {
cwd: projectFolder,
});
await page.goto(`${authenticatedPeer.uiUrl()}/${rid}/patches`);
await authenticatedPeer.git(["switch", defaultBranch], {
await page.goto(`${peer.uiUrl()}/${rid}/patches`);
await peer.git(["switch", defaultBranch], {
cwd: projectFolder,
});
await authenticatedPeer.git(["switch", "-c", "feature-2"], {
await peer.git(["switch", "-c", "feature-2"], {
cwd: projectFolder,
});
await authenticatedPeer.git(["commit", "--allow-empty", "-m", "2nd"], {
await peer.git(["commit", "--allow-empty", "-m", "2nd"], {
cwd: projectFolder,
});
await authenticatedPeer.git(["push", "rad", "HEAD:refs/patches"], {
await peer.git(["push", "rad", "HEAD:refs/patches"], {
cwd: projectFolder,
});
await page.getByRole("button", { name: "filter-dropdown" }).first().click();
-163
View File
@@ -1,163 +0,0 @@
import { test, expect } from "@tests/support/fixtures.js";
import {
addEmbed,
createProject,
expectReactionsToWork,
expectThreadCommentingToWork,
extractPatchId,
} from "@tests/support/project";
test("leave comments and replies", async ({ page, authenticatedPeer }) => {
const { rid, projectFolder } = await createProject(authenticatedPeer, {
name: "commenting",
});
await authenticatedPeer.rad(
[
"issue",
"open",
"--title",
"This is an issue to write comments and replies",
"--description",
"We'll give it a few comments and replies.",
],
{ cwd: projectFolder },
);
await page.goto(`${authenticatedPeer.uiUrl()}/${rid}/issues`);
await page
.getByRole("link", {
name: "This is an issue to write comments and replies",
})
.click();
await expectThreadCommentingToWork(page);
await authenticatedPeer.git(["switch", "-c", "feature-1"], {
cwd: projectFolder,
});
await authenticatedPeer.git(
["commit", "--allow-empty", "-m", "Some patch title"],
{
cwd: projectFolder,
},
);
const patchId = extractPatchId(
await authenticatedPeer.git(["push", "rad", "HEAD:refs/patches"], {
cwd: projectFolder,
}),
);
await page.goto(`${authenticatedPeer.uiUrl()}/${rid}/patches/${patchId}`);
await expectThreadCommentingToWork(page);
});
test("add and remove reactions", async ({ page, authenticatedPeer }) => {
const { rid, projectFolder } = await createProject(authenticatedPeer, {
name: "reactions",
});
await authenticatedPeer.git(["switch", "-c", "feature-1"], {
cwd: projectFolder,
});
await authenticatedPeer.git(
["commit", "--allow-empty", "-m", "Some patch title"],
{
cwd: projectFolder,
},
);
const patchId = extractPatchId(
await authenticatedPeer.git(["push", "rad", "HEAD:refs/patches"], {
cwd: projectFolder,
}),
);
await page.goto(`${authenticatedPeer.uiUrl()}/${rid}/patches/${patchId}`);
const reactionsLocator = page.locator(".actions").first();
await expectReactionsToWork(page, reactionsLocator);
});
test("handling embeds", async ({ page, authenticatedPeer }) => {
const { rid, projectFolder } = await createProject(authenticatedPeer, {
name: "embeds",
});
await authenticatedPeer.rad(
[
"issue",
"open",
"--title",
"This is an issue to handle embeds",
"--description",
"We'll give it a few comments and replies with embeds.",
],
{ cwd: projectFolder },
);
await page.goto(`${authenticatedPeer.uiUrl()}/${rid}/issues`);
await page
.getByRole("link", {
name: "This is an issue to handle embeds",
})
.click();
await page.getByRole("button", { name: "Leave your comment" }).click();
await page
.getByPlaceholder("Leave your comment")
.fill("Here is some text\n\n");
await addEmbed(
page,
"./public/images/radicle-228x228.png",
"radicle-228x228.png",
"image/png",
);
await expect(page.getByPlaceholder("Leave your comment")).toHaveValue(
"Here is some text\n\n![radicle-228x228.png](bae036309c2182c7304c97956969369823b5c6ad)\n",
);
await page.getByRole("button", { name: "Preview" }).click();
await expect(
page.getByRole("img", { name: "radicle-228x228.png" }),
).toBeVisible();
expect(
await page
.getByRole("img", { name: "radicle-228x228.png" })
.getAttribute("src"),
).toBe(
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOQAAADkCAYAAACIV4iNAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAkkSURBVHgB7dxNbttGGMbxoSQrqeS0cGAjDZCF4WaVLLrQBXyBLHWA3sQ36QF0CV9AB+iiQRbZBA5iFInUWl/s+445CkVLbpMq9OPq/wMm4odEzdB8NENKYRbumX4/z8MWDQZZFiBj1/++jQBABoEEhBBIQAiBBIQQSEAIgQSEEEhACIEEhBBIQAiBBIQQSEAIgQSEEEhACIEEhBBIQAiBBIQQSEAIgQSEEEhAyM7fT4Z79Pw37L/toocEhBBIQAiBBIQQSEAIgQSEEEhACIEEhBBIQAiBBIQQSEAIgQSEEEhACIEEhBBIQAiBBIQQSEAIgQSEEEhACIEEhLQCtqrX+32r95g5OTkJ2/T69esAXfSQgBACCQghkIAQAgkIIZCAEAIJCCGQgBACCQghkIAQAgkIIZCAEAIJCCGQgBACCQghkIAQAgkIIZCAEAIJCCGQgJAs3DP9fr7Ve9bg/20wyO7VMU4PCQghkIAQAgkIIZCAEAIJCCGQgBACCQghkIAQAgkIIZCAEAIJCCGQgBACCQghkIAQAgkIIZCAEAIJCCGQgBACCQhphW9M/R44v/46Csp++aUblKnvvxC2e/x963v00EMCQggkIIRAAkIIJCCEQAJCCCQghEACQggkIIRAAkIIJCCEQAJCCCQghEACQggkIIRAAkIIJCCEQAJCCCQghEACQr75PXV2TVf8Hjjqdn3/0UMCQggkIIRAAkIIJCCEQAJCCCQghEACQggkIIRAAkIIJCCEQAJCCCQghEACQggkIIRAAkIIJCCEQAJCCCQghEACQrL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M1NdSnXY90+SPMvXrxol5f7/Ib91b7tPYqS9n/DP3iKD5+dDCSfQqv+7f64MYQLm8+bblt+2/brsHY4Wlkfwprh9obtVF8XKq+/bb9tOnffKX8Dh1MvnjJRErgAAAAASUVORK5CYII=",
);
await page.getByRole("button", { name: "Comment" }).click();
await expect(page.getByPlaceholder("Leave your comment")).toBeHidden();
await expect(page.getByText("Here is some text")).toBeVisible();
await expect(
page.getByRole("img", { name: "radicle-228x228.png" }),
).toBeVisible();
const { scheme, hostname, port } = authenticatedPeer.httpdBaseUrl;
expect(
await page
.getByRole("img", { name: "radicle-228x228.png" })
.getAttribute("src"),
).toBe(
`${scheme}://${hostname}:${port}/raw/rad:z2J7s48EbCBckcEmj2dm5eaFVoBsy/blobs/bae036309c2182c7304c97956969369823b5c6ad?mime=image/png`,
);
await expect(
page.getByRole("button", { name: "radicle-228x228.png" }),
).toBeVisible();
await page.getByRole("button", { name: "edit comment" }).click();
await page
.getByPlaceholder("Leave your comment")
.fill(
"Here is some text\n\n![radicle-228x228.png](bae036309c2182c7304c97956969369823b5c6ad)\n\n",
);
await addEmbed(
page,
"./public/images/apple-touch-icon.png",
"apple-touch-icon.png",
"image/png",
);
await expect(page.getByPlaceholder("Leave your comment")).toHaveValue(
"Here is some text\n\n![radicle-228x228.png](bae036309c2182c7304c97956969369823b5c6ad)\n\n![apple-touch-icon.png](c69a66fa4c414c92bf75365fb5c92453fa95dcca)\n",
);
await page.getByRole("button", { name: "Save" }).click();
await expect(page.getByRole("button", { name: "Save" })).toBeHidden();
await expect(
page.getByRole("button", { name: "apple-touch-icon.png" }),
).toBeVisible();
await expect(
page.getByRole("button", { name: "radicle-228x228.png" }),
).toBeVisible();
});
+3 -3
View File
@@ -128,12 +128,12 @@ test.describe("project page navigation", () => {
test("page title on project with empty description", async ({
page,
authenticatedPeer,
peer,
}) => {
const { rid } = await createProject(authenticatedPeer, {
const { rid } = await createProject(peer, {
name: "ProjectWithNoDescription",
});
await page.goto(authenticatedPeer.ridUrl(rid), {
await page.goto(peer.ridUrl(rid), {
waitUntil: "networkidle",
});
const title = await page.title();
+2 -18
View File
@@ -3,7 +3,6 @@ import type * as Stream from "node:stream";
import * as Fs from "node:fs/promises";
import * as Path from "node:path";
import assert from "node:assert";
import { fileURLToPath } from "node:url";
import { test as base, expect } from "@playwright/test";
import { execa } from "execa";
@@ -26,7 +25,7 @@ export const test = base.extend<{
forAllTests: void;
stateDir: string;
peerManager: PeerManager;
authenticatedPeer: RadiclePeer;
peer: RadiclePeer;
outputLog: Stream.Writable;
}>({
forAllTests: [
@@ -125,7 +124,7 @@ export const test = base.extend<{
await peerManager.shutdown();
},
authenticatedPeer: async ({ page, peerManager }, use) => {
peer: async ({ page, peerManager }, use) => {
await page.addInitScript(() => {
window.localStorage.setItem("experimental", "true");
});
@@ -136,21 +135,6 @@ export const test = base.extend<{
await peer.startNode();
await peer.startHttpd();
const { stdout } = await peer.spawn("rad-web", [
"http://localhost:3001",
"--no-open",
"--path",
"/",
"--connect",
`${peer.httpdBaseUrl.hostname}:${peer.httpdBaseUrl.port}`,
]);
const match = stdout.match(/Visit (http:\/\/\S+) to connect/);
assert(
match !== null && match[1],
`Failed to get authentication URL from: ${stdout}`,
);
await page.goto(match[1]);
await page.getByRole("button", { name: "avatar httpd" }).waitFor();
await use(peer);
},
+1 -129
View File
@@ -1,8 +1,6 @@
import type { Locator, Page } from "@playwright/test";
import type { Page } from "@playwright/test";
import type { RadiclePeer } from "@tests/support/peerManager";
import { expect } from "@playwright/test";
import { readFileSync } from "node:fs";
import * as Path from "node:path";
export async function changeBranch(peer: string, branch: string, page: Page) {
@@ -66,129 +64,3 @@ export function extractPatchId(cmdOutput: { stderr: string }) {
throw new Error("Could not get patch id");
}
}
export async function expectThreadCommentingToWork(page: Page) {
await page.getByRole("button", { name: "Leave your comment" }).click();
await page.getByPlaceholder("Leave your comment").fill("This is a comment");
await page.getByRole("button", { name: "Comment" }).click();
await expect(page.getByLabel("extended-textarea")).toBeHidden();
await expect(page.getByText("This is a comment")).toBeVisible();
await page.getByRole("button", { name: "edit comment" }).first().click();
await page
.getByPlaceholder("Leave your comment")
.fill("This is an edited comment");
await page.getByRole("button", { name: "Save" }).click();
await expect(page.getByLabel("extended-textarea")).toBeHidden();
await expect(page.getByText("This is an edited comment")).toBeVisible();
await page.getByRole("button", { name: "Reply to comment" }).click();
await page.getByPlaceholder("Reply to comment").fill("This is a reply");
await page.getByRole("button", { name: "Comment", exact: true }).click();
await expect(page.getByLabel("extended-textarea")).toBeHidden();
await expect(page.getByText("This is a reply")).toBeVisible();
await page.getByRole("button", { name: "edit comment" }).nth(1).click();
await page
.getByPlaceholder("Leave your comment")
.fill("This is an edited reply");
await page.getByRole("button", { name: "Save" }).click();
await expect(page.getByLabel("extended-textarea")).toBeHidden();
await expect(page.getByText("This is an edited reply")).toBeVisible();
}
export async function expectLabelEditingToWork(page: Page) {
await page.getByRole("button", { name: "add labels" }).click();
await page.getByPlaceholder("Add label").fill("bug");
await page.getByRole("button", { name: "discard label" }).click();
await page.getByRole("button", { name: "add labels" }).click();
await page.getByPlaceholder("Add label").fill("bug");
await page.keyboard.press("Enter");
await page.getByRole("button", { name: "add labels" }).click();
await page.getByPlaceholder("Add label").fill("bug");
await expect(page.getByText("This label is already added")).toBeVisible();
await page.getByPlaceholder("Add label").clear();
await expect(page.getByText("This label is already added")).toBeHidden();
await page.getByPlaceholder("Add label").fill("documentation");
await page.keyboard.press("Enter");
await expect(page.getByRole("button", { name: "bug" })).toBeVisible();
await expect(
page.getByRole("button", { name: "documentation" }),
).toBeVisible();
await page.getByRole("button", { name: "documentation" }).click();
await page.getByRole("button", { name: "remove label", exact: true }).click();
await expect(page.getByRole("button", { name: "bug" })).toBeVisible();
await expect(
page.getByRole("button", { name: "documentation" }),
).toBeHidden();
}
export async function expectReactionsToWork(
page: Page,
reactionsLocator: Locator,
) {
await page.getByRole("button", { name: "Leave your comment" }).click();
await page.getByPlaceholder("Leave your comment").fill("This is a comment");
await page.getByRole("button", { name: "Comment" }).click();
const reactionsToggleBtn = reactionsLocator.getByRole("button", {
name: "toggle-reaction-popover",
});
await reactionsToggleBtn.click();
await reactionsLocator.getByRole("button", { name: "👍" }).click();
await expect(
reactionsLocator.getByRole("button", { name: "👍 1" }),
).toBeVisible();
await reactionsToggleBtn.click();
await reactionsLocator.getByRole("button", { name: "🎉" }).click();
await expect(
reactionsLocator.getByRole("button", { name: "🎉 1" }),
).toBeVisible();
await expect(reactionsLocator.locator(".reaction")).toHaveCount(2);
await reactionsLocator.getByRole("button", { name: "👍" }).click();
await expect(
reactionsLocator.locator("span").filter({ hasText: "👍 1" }),
).toBeHidden();
await expect(reactionsLocator.locator(".reaction")).toHaveCount(1);
await reactionsToggleBtn.click();
await reactionsLocator
.getByRole("button", { name: "🎉", exact: true })
.click();
await expect(
reactionsLocator.getByRole("button", { name: "🎉 1" }),
).toBeHidden();
await expect(reactionsLocator.locator(".reaction")).toHaveCount(0);
}
export async function addEmbed(
page: Page,
url: string,
fileName: string,
fileType: string,
) {
const buffer = readFileSync(url).toString("base64");
const dataTransfer = await page.evaluateHandle(
({ buffer, localFileName, localFileType }) => {
const arrayBuffer = Uint8Array.from(atob(buffer), c => c.charCodeAt(0));
const dt = new DataTransfer();
const file = new File([arrayBuffer.buffer], localFileName, {
type: localFileType,
});
dt.items.add(file);
return dt;
},
{
buffer,
localFileName: fileName,
localFileType: fileType,
},
);
await page.dispatchEvent("textarea[aria-label=textarea-comment]", "drop", {
dataTransfer,
});
}