forked from EduCraft/curriculum-project-hub
feat: add deployable alpha silo
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
import { DEFAULT_ORG_ID, prisma, resetDb, testSecretEnvelope } from "./helpers.js";
|
||||
import { addOrgMember } from "../../src/org/members.js";
|
||||
import { addTeamMember, archiveTeam, createTeam, updateTeam } from "../../src/org/teams.js";
|
||||
import { FeishuApplicationConnectionService } from "../../src/connections/feishuApplicationConnections.js";
|
||||
|
||||
const SESSION_SECRET = "integration-test-session-secret";
|
||||
|
||||
@@ -51,6 +52,14 @@ describe("admin members + teams API", () => {
|
||||
|
||||
it("adds members and enforces last-OWNER protection", async () => {
|
||||
const token = await seedOwner();
|
||||
const connection = await new FeishuApplicationConnectionService(prisma, testSecretEnvelope, async () => {})
|
||||
.rotateCustomerApplication({
|
||||
organizationId: DEFAULT_ORG_ID,
|
||||
actorUserId: "u-owner",
|
||||
appId: "cli_members",
|
||||
appSecret: "members-secret",
|
||||
botOpenId: "ou_members_bot",
|
||||
});
|
||||
const app = await buildApp();
|
||||
try {
|
||||
const cookie = sessionCookieHeader(token);
|
||||
@@ -64,6 +73,14 @@ describe("admin members + teams API", () => {
|
||||
expect(add.statusCode).toBe(201);
|
||||
const teacher = add.json() as { userId: string; role: string };
|
||||
expect(teacher.role).toBe("ADMIN");
|
||||
await expect(prisma.feishuUserIdentity.findUnique({
|
||||
where: {
|
||||
connectionId_openId: {
|
||||
connectionId: connection.id,
|
||||
openId: "ou_teacher",
|
||||
},
|
||||
},
|
||||
})).resolves.not.toBeNull();
|
||||
|
||||
const list = await app.inject({
|
||||
method: "GET",
|
||||
@@ -71,7 +88,18 @@ describe("admin members + teams API", () => {
|
||||
headers: { cookie },
|
||||
});
|
||||
expect(list.statusCode).toBe(200);
|
||||
expect((list.json() as { members: unknown[] }).members).toHaveLength(2);
|
||||
const members = (list.json() as {
|
||||
members: Array<{ userId: string; feishuOpenId: string | null; identityStatus: string }>;
|
||||
}).members;
|
||||
expect(members).toHaveLength(2);
|
||||
expect(members.find((member) => member.userId === "u-owner")).toMatchObject({
|
||||
feishuOpenId: null,
|
||||
identityStatus: "UNLINKED",
|
||||
});
|
||||
expect(members.find((member) => member.userId === teacher.userId)).toMatchObject({
|
||||
feishuOpenId: "ou_teacher",
|
||||
identityStatus: "SCOPED",
|
||||
});
|
||||
|
||||
const refuse = await app.inject({
|
||||
method: "POST",
|
||||
|
||||
Reference in New Issue
Block a user