Files
Yichen Jiang 6435463edc test(agent-presets): prove the write override where it is introduced
The regression for `PresetTree.write` lived two layers up, so this layer's own
assertion could not fail: it checked the file after an ordinary teardown, and
the Loader's unload listener returns early when the whole tree is being
disposed, so the override never ran. Moves the self-disposing-row test down to
the layer that adds the override, in a temp root so a committed fixture cannot
be damaged by the run that proves the bug.
2026-08-07 15:04:23 +08:00

10 lines
419 B
JavaScript

// Disposes itself once active. The Loader treats a self-disposing entry as a
// config change and writes the tree back through `EntryTree.write()`, which is
// the exact path that once truncated a preset file to `[]`.
export const name = 'self-dispose'
export function apply(ctx) {
globalThis.__SELF_DISPOSED__ = new Promise((resolve) => {
setTimeout(() => { ctx.fiber.dispose(); resolve(undefined) }, 0)
})
}