test(host): cover the native flow's re-arm guard

A fresh injected face while the same request is open re-fires the effect;
the armed guard must not relaunch the chooser (the uncovered branch CI's
per-file gate flagged).
This commit is contained in:
creatixchu
2026-07-28 22:37:19 +08:00
parent 95a8e3f949
commit 7c9d688a82

View File

@@ -83,6 +83,11 @@ describe('directory-picker-native client half', () => {
const second = owner()
view.rerender(<NativeDirectoryFlow {...second} busy pick={pick} />)
expect(pick).toHaveBeenCalledOnce()
// Even a fresh injected face (re-registration re-runs the inject factory)
// must not relaunch while the same request is still open.
const replacedPick = vi.fn(() => new Promise<string | null>(() => {}))
view.rerender(<NativeDirectoryFlow {...second} busy pick={replacedPick} />)
expect(replacedPick).not.toHaveBeenCalled()
await act(async () => { resolve('/tmp/project') })
expect(second.onPicked).toHaveBeenCalledWith('/tmp/project')
expect(first.onPicked).not.toHaveBeenCalled()