fix(tui): preserve global form ownership
This commit is contained in:
parent
684d288b9c
commit
57dd2fba7d
5 changed files with 58 additions and 13 deletions
|
|
@ -155,6 +155,11 @@ const formNotification: TuiAttentionNotifyInput = {
|
|||
sound: { name: "question", when: "always" },
|
||||
}
|
||||
|
||||
const globalFormNotification: TuiAttentionNotifyInput = {
|
||||
...formNotification,
|
||||
title: undefined,
|
||||
}
|
||||
|
||||
const permissionNotification: TuiAttentionNotifyInput = {
|
||||
title: "Demo session",
|
||||
message: "Permission needs input",
|
||||
|
|
@ -173,12 +178,12 @@ describe("internal notifications TUI plugin", () => {
|
|||
expect(harness.notifications).toEqual([formNotification, questionNotification, permissionNotification])
|
||||
})
|
||||
|
||||
test("ignores global forms until the TUI can render them", async () => {
|
||||
test("notifies for global forms once the TUI can render them", async () => {
|
||||
const harness = await setup()
|
||||
|
||||
harness.emit({ id: "event-1", created: 0, type: "form.created", data: { form: form("form-1", "global") } })
|
||||
|
||||
expect(harness.notifications).toEqual([])
|
||||
expect(harness.notifications).toEqual([globalFormNotification])
|
||||
})
|
||||
|
||||
test("dedupes pending forms, questions, and permissions until they are resolved", async () => {
|
||||
|
|
|
|||
|
|
@ -914,13 +914,23 @@ test("tracks global forms by location", async () => {
|
|||
expect(data.session.form.list("global", { directory }) ?? []).toEqual([])
|
||||
|
||||
events.emit({
|
||||
id: "evt_form_replied_global",
|
||||
id: "evt_form_created_global_default",
|
||||
created: 1,
|
||||
location: { directory },
|
||||
type: "form.created",
|
||||
data: { form: { id: "frm_global", sessionID: "global", mode: "form", fields: [] } },
|
||||
})
|
||||
await wait(() => data.session.form.list("global", { directory })?.length === 1)
|
||||
|
||||
events.emit({
|
||||
id: "evt_form_replied_global",
|
||||
created: 2,
|
||||
location: other,
|
||||
type: "form.replied",
|
||||
data: { id: "frm_global", sessionID: "global", answer: {} },
|
||||
})
|
||||
await wait(() => data.session.form.list("global", other)?.length === 0)
|
||||
expect(data.session.form.list("global", { directory })?.map((form) => form.id)).toEqual(["frm_global"])
|
||||
} finally {
|
||||
app.renderer.destroy()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue