6ede33ccdb
Build and Push Docker Images / create_manifest (web, surfsense-web, , cpu) (push) Has been cancelled
Build and Push Docker Images / finalize_release (push) Has been cancelled
Obsidian Plugin Lint / lint (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_web, cpu, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-24.04-arm, linux/arm64, arm64, , runner, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_web, cpu, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-latest, linux/amd64, amd64, , runner, false, cpu) (push) Has been cancelled
Build and Push Docker Images / compute_version (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cpu, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, , production, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cpu, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, , production, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu126, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, -cuda126, production, true, cuda126) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu126, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, -cuda126, production, true, cuda126) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu128, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, -cuda, production, true, cuda) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu128, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, -cuda, production, true, cuda) (push) Has been cancelled
Build and Push Docker Images / verify_digests (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, , cpu) (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, -cuda, cuda) (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, -cuda126, cuda126) (push) Has been cancelled
78 lines
2.2 KiB
TypeScript
78 lines
2.2 KiB
TypeScript
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { test as base } from "@playwright/test";
|
|
import { acquireTestToken } from "../helpers/api/auth";
|
|
import { createWorkspace, deleteWorkspace, type WorkspaceRow } from "../helpers/api/workspaces";
|
|
import { uniqueWorkspaceName } from "../helpers/canary";
|
|
|
|
export type WorkspaceFixtures = {
|
|
/**
|
|
* Bearer token for the seeded test user. Worker-scoped so we only
|
|
* log in once per worker (logins are cheap, but caching is cheaper).
|
|
*/
|
|
apiToken: string;
|
|
/**
|
|
* A fresh, named workspace for the current test. Cleaned up
|
|
* automatically after the test finishes.
|
|
*/
|
|
workspace: WorkspaceRow;
|
|
};
|
|
|
|
const SESSION_COOKIE_NAME = process.env.SESSION_COOKIE_NAME || "surfsense_session";
|
|
|
|
// Reuse the session cookie written by tests/auth.setup.ts; on cache miss we
|
|
// mint a fresh one via /__e2e__/auth/token (rate-limit-free).
|
|
const AUTH_STATE_PATH = path.join(__dirname, "..", "..", "playwright", ".auth", "user.json");
|
|
|
|
function loadCachedSessionToken(): string | null {
|
|
try {
|
|
const raw = fs.readFileSync(AUTH_STATE_PATH, "utf8");
|
|
const parsed = JSON.parse(raw) as {
|
|
cookies?: Array<{ name?: string; value?: string }>;
|
|
};
|
|
for (const cookie of parsed.cookies ?? []) {
|
|
if (cookie.name === SESSION_COOKIE_NAME && cookie.value) {
|
|
return cookie.value;
|
|
}
|
|
}
|
|
} catch {
|
|
// Fall back to a fresh login.
|
|
}
|
|
return null;
|
|
}
|
|
|
|
export const workspaceFixtures = base.extend<WorkspaceFixtures, { apiTokenWorker: string }>({
|
|
apiTokenWorker: [
|
|
async ({ playwright }, use) => {
|
|
const cached = loadCachedSessionToken();
|
|
if (cached) {
|
|
await use(cached);
|
|
return;
|
|
}
|
|
const ctx = await playwright.request.newContext();
|
|
try {
|
|
const token = await acquireTestToken(ctx);
|
|
await use(token);
|
|
} finally {
|
|
await ctx.dispose();
|
|
}
|
|
},
|
|
{ scope: "worker" },
|
|
],
|
|
apiToken: async ({ apiTokenWorker }, use) => {
|
|
await use(apiTokenWorker);
|
|
},
|
|
workspace: async ({ request, apiToken }, use) => {
|
|
const space = await createWorkspace(
|
|
request,
|
|
apiToken,
|
|
uniqueWorkspaceName("composio-drive-e2e")
|
|
);
|
|
try {
|
|
await use(space);
|
|
} finally {
|
|
await deleteWorkspace(request, apiToken, space.id);
|
|
}
|
|
},
|
|
});
|