Skip to content

The agent that grows with you

test(desktop): stop the unread-tile test timing out on loaded CI

anhtahaylove49fc4911a9ff
diff --git a/apps/desktop/src/store/session-unread-tile.test.ts b/apps/desktop/src/store/session-unread-tile.test.ts
index c93480dced1..8fea033760b 100644
--- a/apps/desktop/src/store/session-unread-tile.test.ts
+++ b/apps/desktop/src/store/session-unread-tile.test.ts
@@ -1,16 +1,18 @@
-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { afterEach, describe, expect, it } from 'vitest'
// The completed-unread dot is keyed on the FOCUSED session, not the selected
// one. A tile is never $selectedStoredSessionId, so keying either half on the
// selection left a tiled session's dot green with no way to clear it.
describe('completed-unread dot follows the focused session', () => {
- beforeEach(() => {
- vi.resetModules()
- })
+ const disposers: (() => void)[] = []
afterEach(() => {
- vi.resetModules()
+ // Undo the registrations and store writes this file makes, so the next
+ // test starts clean without paying to rebuild the module graph.
+ while (disposers.length > 0) {
+ disposers.pop()?.()
+ }
})
async function setup() {
@@ -21,14 +23,23 @@ describe('completed-unread dot follows the focused session', () => {
const session = await import('./session')
const states = await import('./session-states')
+ // `declareDefaultTree` only seeds `$layoutTree` when it is empty, so the
+ // layout has to be cleared here or the second test would adopt the first
+ // test's tree instead of the one it declares.
+ tree.$layoutTree.set(null)
+ tree.$activeTreeGroup.set(null)
+
for (const id of ['workspace', 'session-tile:tiled']) {
- registry.register({
- area: 'panes',
- data: id === 'workspace' ? { placement: 'main', uncloseable: true } : { placement: 'main' },
- id,
- render: () => null,
- title: id
- })
+ disposers.push(
+ registry.register({
+ area: 'panes',
+ data:
+ id === 'workspace' ? { placement: 'main', uncloseable: true } : { placement: 'main' },
+ id,
+ render: () => null,
+ title: id
+ })
+ )
}
// The workspace holds the primary chat, a second zone holds the tile.