mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-01 18:07:00 +01:00
test: provide identities for retained workspace admissions
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
59953d3101
commit
638dbd0790
2 files changed
+25
-1
No files matched your search
@@ -5,6 +5,7 @@ import { WebSocketServer } from "ws";
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest";
|
||||
import {
|
||||
agents,
|
||||
authUsers,
|
||||
agentWakeupRequests,
|
||||
chatActions,
|
||||
chatConversations,
|
||||
@@ -219,7 +220,10 @@ describeEmbeddedPostgres("heartbeat comment wake batching", () => {
|
||||
|
||||
async function grantFixtureWorkspaceAccess(companyId: string, userIds: string[]) {
|
||||
// Later admissions reauthorize the retained workspace for the responsible
|
||||
// user, so synthetic human commenters need real company membership too.
|
||||
// user, so synthetic human commenters need a real identity and membership.
|
||||
await db.insert(authUsers).values(userIds.map(id => ({
|
||||
id, name: "Fixture commenter", email: `${id}@example.test`, createdAt: new Date(), updatedAt: new Date(),
|
||||
}))).onConflictDoNothing();
|
||||
await db.insert(companyMemberships).values(userIds.map(principalId => ({
|
||||
companyId, principalId, principalType: "user", status: "active", membershipRole: "member",
|
||||
})));
|
||||
|
||||
@@ -140,6 +140,10 @@ describeEmbeddedPostgres("heartbeat responsible-user invariant", () => {
|
||||
issuePrefix: `R${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
|
||||
defaultResponsibleUserId: ownerUserId,
|
||||
});
|
||||
await db.insert(authUsers).values({
|
||||
id: ownerUserId, name: "Company owner", email: `${ownerUserId}@example.test`,
|
||||
createdAt: new Date(), updatedAt: new Date(),
|
||||
});
|
||||
await db.insert(companyMemberships).values({
|
||||
companyId,
|
||||
principalType: "user",
|
||||
@@ -165,6 +169,10 @@ describeEmbeddedPostgres("heartbeat responsible-user invariant", () => {
|
||||
it("dispatches an interrupted queue under the clicking operator through the real startup path", async () => {
|
||||
const { companyId, agentId, ownerUserId } = await seedCompany();
|
||||
const operatorId = `operator-${randomUUID()}`, issueId = randomUUID(), commentId = randomUUID(), queueId = randomUUID();
|
||||
await db.insert(authUsers).values({
|
||||
id: operatorId, name: "Clicking operator", email: `${operatorId}@example.test`,
|
||||
createdAt: new Date(), updatedAt: new Date(),
|
||||
});
|
||||
await db.insert(companyMemberships).values({ companyId, principalType: "user", principalId: operatorId,
|
||||
membershipRole: "operator", status: "active" });
|
||||
await db.insert(issues).values({ id: issueId, companyId, title: "Interrupted queue", status: "todo",
|
||||
@@ -194,6 +202,10 @@ describeEmbeddedPostgres("heartbeat responsible-user invariant", () => {
|
||||
it("keeps a board manual wake under its caller even when it adopts someone else's queue", async () => {
|
||||
const { companyId, agentId, ownerUserId } = await seedCompany();
|
||||
const operatorId = `operator-${randomUUID()}`, issueId = randomUUID(), commentId = randomUUID(), queueId = randomUUID();
|
||||
await db.insert(authUsers).values({
|
||||
id: operatorId, name: "Clicking operator", email: `${operatorId}@example.test`,
|
||||
createdAt: new Date(), updatedAt: new Date(),
|
||||
});
|
||||
await db.insert(companyMemberships).values({ companyId, principalType: "user", principalId: operatorId,
|
||||
membershipRole: "operator", status: "active" });
|
||||
await db.insert(issues).values({ id: issueId, companyId, title: "Manual wake", status: "todo",
|
||||
@@ -217,6 +229,10 @@ describeEmbeddedPostgres("heartbeat responsible-user invariant", () => {
|
||||
it("keeps the clicking user when a manual wake merges into an older deferred receipt", async () => {
|
||||
const { companyId, agentId, ownerUserId } = await seedCompany();
|
||||
const operatorId = `operator-${randomUUID()}`, issueId = randomUUID(), commentId = randomUUID(), queueId = randomUUID();
|
||||
await db.insert(authUsers).values({
|
||||
id: operatorId, name: "Clicking operator", email: `${operatorId}@example.test`,
|
||||
createdAt: new Date(), updatedAt: new Date(),
|
||||
});
|
||||
await db.insert(companyMemberships).values({ companyId, principalType: "user", principalId: operatorId,
|
||||
membershipRole: "operator", status: "active" });
|
||||
await db.insert(issues).values({ id: issueId, companyId, title: "Deferred manual wake", status: "todo",
|
||||
@@ -254,6 +270,10 @@ describeEmbeddedPostgres("heartbeat responsible-user invariant", () => {
|
||||
it("starts an unscoped manual wake with its own user instead of joining another user's run", async () => {
|
||||
const { companyId, agentId, ownerUserId } = await seedCompany();
|
||||
const operatorId = `operator-${randomUUID()}`;
|
||||
await db.insert(authUsers).values({
|
||||
id: operatorId, name: "Clicking operator", email: `${operatorId}@example.test`,
|
||||
createdAt: new Date(), updatedAt: new Date(),
|
||||
});
|
||||
await db.insert(companyMemberships).values({ companyId, principalType: "user", principalId: operatorId,
|
||||
membershipRole: "operator", status: "active" });
|
||||
let finish!: () => void;
|
||||
|
||||
Reference in new issue
Block a user