Browse Source

feat(test-runtime): add TestSessions.updateSummary

The wire-echo stand-in for list-row settlement (title from the rename
unary response, running flips): benches mirror what the production
manager writes into the list store, so row re-label assertions need no
assembled app. Fixture ISession stubs must NOT call it re-entrantly —
they run inside a React event dispatch already wrapped in act, and a
nested act corrupts the global act queue (the next test renders an empty
tree); tests echo from their own top level instead.
imccyu 2 months ago
parent
commit
989b80791f
1 changed files with 14 additions and 0 deletions
  1. 14 0
      packages/client/test-runtime/src/sessions.ts

+ 14 - 0
packages/client/test-runtime/src/sessions.ts

@@ -237,6 +237,20 @@ export class TestSessions implements ISessions {
     await this.stabilize(() => { record.snapshot.update(mutate) })
   }
 
+  /**
+   * Update a session's list row (the wire-echo stand-in: title settles,
+   * running flips — components subscribed via useSessions re-render).
+   * @param id - session id.
+   * @param patch - summary fields to merge over the row.
+   */
+  async updateSummary(id: string, patch: Partial<Omit<SessionSummary, 'id'>>): Promise<void> {
+    const record = this.require(id)
+    record.summary = { ...record.summary, ...patch }
+    await this.stabilize(() => {
+      this.list.update((draft) => { draft.byId[id as SessionId] = record.summary })
+    })
+  }
+
   /**
    * Switch the current selection (undefined = the no-session empty state).
    * @param id - session id to select, or undefined to clear.