refactor(schema): extract public event definitions (#33579)
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import { LegacyEvent } from "../src/legacy-event"
|
||||
import { PermissionV1 } from "../src/permission-v1"
|
||||
import { QuestionV1 } from "../src/question-v1"
|
||||
import { Project } from "../src/project"
|
||||
import { SessionV1 } from "../src/session-v1"
|
||||
|
||||
describe("legacy public event schemas", () => {
|
||||
test("owns all SessionV1 definitions", () => {
|
||||
expect(SessionV1.Event.Definitions.map((event) => event.type)).toEqual([
|
||||
"session.created",
|
||||
"session.updated",
|
||||
"session.deleted",
|
||||
"message.updated",
|
||||
"message.removed",
|
||||
"message.part.updated",
|
||||
"message.part.removed",
|
||||
"message.part.delta",
|
||||
"session.diff",
|
||||
"session.error",
|
||||
])
|
||||
const durable = SessionV1.Event.Definitions.filter((event) => event.durable !== undefined)
|
||||
expect(durable).toHaveLength(7)
|
||||
expect(durable.every((event) => event.durable?.aggregate === "sessionID")).toBe(true)
|
||||
expect(durable.every((event) => event.durable?.version === 1)).toBe(true)
|
||||
})
|
||||
|
||||
test("owns the legacy transient public definitions", () => {
|
||||
expect([
|
||||
SessionV1.PartDelta.type,
|
||||
SessionV1.Diff.type,
|
||||
SessionV1.Error.type,
|
||||
PermissionV1.Event.Asked.type,
|
||||
PermissionV1.Event.Replied.type,
|
||||
QuestionV1.Event.Asked.type,
|
||||
QuestionV1.Event.Replied.type,
|
||||
QuestionV1.Event.Rejected.type,
|
||||
Project.Event.Updated.type,
|
||||
LegacyEvent.CommandExecuted.type,
|
||||
]).toEqual([
|
||||
"message.part.delta",
|
||||
"session.diff",
|
||||
"session.error",
|
||||
"permission.asked",
|
||||
"permission.replied",
|
||||
"question.asked",
|
||||
"question.replied",
|
||||
"question.rejected",
|
||||
"project.updated",
|
||||
"command.executed",
|
||||
])
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user