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