SurfSense/surfsense_web/tests/helpers/api/workspaces.ts
Anish Sarkar a8c1fb660d feat(rename): complete searchSpace to workspace transition across frontend and backend
- Introduced a comprehensive specification for renaming `searchSpace` to `workspace` in `surfsense_web` and `surfsense_desktop`, ensuring all TypeScript identifiers, React props, and local data structures are updated.
- Implemented migration shims for persisted local state to prevent data loss during the transition.
- Updated observability metrics and IPC channels to reflect the new naming convention.
- Removed legacy `active-search-space` module and replaced it with `active-workspace` to maintain consistency.
- Ensured no behavioral changes or data loss for users during the renaming process.
2026-07-06 15:12:40 +05:30

40 lines
1.1 KiB
TypeScript

import type { APIRequestContext } from "@playwright/test";
import { authHeaders, BACKEND_URL } from "./auth";
export type WorkspaceRow = {
id: number;
name: string;
description: string | null;
};
export async function createWorkspace(
request: APIRequestContext,
token: string,
name: string,
description = "E2E test workspace"
): Promise<WorkspaceRow> {
const response = await request.post(`${BACKEND_URL}/api/v1/workspaces`, {
headers: authHeaders(token),
data: { name, description },
});
if (!response.ok()) {
throw new Error(`createWorkspace failed (${response.status()}): ${await response.text()}`);
}
return (await response.json()) as WorkspaceRow;
}
export async function deleteWorkspace(
request: APIRequestContext,
token: string,
id: number
): Promise<void> {
const response = await request.delete(`${BACKEND_URL}/api/v1/workspaces/${id}`, {
headers: authHeaders(token),
});
if (!response.ok() && response.status() !== 404) {
// 404 is acceptable: the test may have already deleted the space.
throw new Error(
`deleteWorkspace(${id}) failed (${response.status()}): ${await response.text()}`
);
}
}