mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-12 09:12:40 +02:00
test(web): add shared Playwright E2E helpers and search-space fixture
This commit is contained in:
parent
a2976ee0b6
commit
ae0caad292
10 changed files with 673 additions and 0 deletions
51
surfsense_web/tests/fixtures/search-space.fixture.ts
vendored
Normal file
51
surfsense_web/tests/fixtures/search-space.fixture.ts
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import { test as base } from "@playwright/test";
|
||||
import { loginAsTestUser } from "../helpers/api/auth";
|
||||
import { uniqueSearchSpaceName } from "../helpers/canary";
|
||||
import {
|
||||
createSearchSpace,
|
||||
deleteSearchSpace,
|
||||
type SearchSpaceRow,
|
||||
} from "../helpers/api/search-spaces";
|
||||
|
||||
export type SearchSpaceFixtures = {
|
||||
/**
|
||||
* 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 search space for the current test. Cleaned up
|
||||
* automatically after the test finishes.
|
||||
*/
|
||||
searchSpace: SearchSpaceRow;
|
||||
};
|
||||
|
||||
export const searchSpaceFixtures = base.extend<SearchSpaceFixtures, { apiTokenWorker: string }>({
|
||||
apiTokenWorker: [
|
||||
async ({ playwright }, use) => {
|
||||
const ctx = await playwright.request.newContext();
|
||||
try {
|
||||
const token = await loginAsTestUser(ctx);
|
||||
await use(token);
|
||||
} finally {
|
||||
await ctx.dispose();
|
||||
}
|
||||
},
|
||||
{ scope: "worker" },
|
||||
],
|
||||
apiToken: async ({ apiTokenWorker }, use) => {
|
||||
await use(apiTokenWorker);
|
||||
},
|
||||
searchSpace: async ({ request, apiToken }, use) => {
|
||||
const space = await createSearchSpace(
|
||||
request,
|
||||
apiToken,
|
||||
uniqueSearchSpaceName("composio-drive-e2e")
|
||||
);
|
||||
try {
|
||||
await use(space);
|
||||
} finally {
|
||||
await deleteSearchSpace(request, apiToken, space.id);
|
||||
}
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue