From 19b6249de38780dbc91054ecf44fbc89ae80d378 Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Thu, 27 Jun 2024 13:57:30 +0200 Subject: [PATCH] Remove httpd-client tests relying on rad-web --- http-client/tests/project.test.ts | 173 --------------------------- http-client/tests/session.test.ts | 38 ------ http-client/tests/support/httpd.ts | 30 ----- http-client/tests/support/support.ts | 31 ----- 4 files changed, 272 deletions(-) delete mode 100644 http-client/tests/session.test.ts delete mode 100644 http-client/tests/support/httpd.ts diff --git a/http-client/tests/project.test.ts b/http-client/tests/project.test.ts index 69f1d49771..666ca66f5b 100644 --- a/http-client/tests/project.test.ts +++ b/http-client/tests/project.test.ts @@ -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, - ); - }, - ); }); diff --git a/http-client/tests/session.test.ts b/http-client/tests/session.test.ts deleted file mode 100644 index 31183a704d..0000000000 --- a/http-client/tests/session.test.ts +++ /dev/null @@ -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); - }); -}); diff --git a/http-client/tests/support/httpd.ts b/http-client/tests/support/httpd.ts deleted file mode 100644 index 77fd4b56dc..0000000000 --- a/http-client/tests/support/httpd.ts +++ /dev/null @@ -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 { - 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; -} diff --git a/http-client/tests/support/support.ts b/http-client/tests/support/support.ts index b7f80ac8f1..cd876b234c 100644 --- a/http-client/tests/support/support.ts +++ b/http-client/tests/support/support.ts @@ -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,