From 50dccac915e7d4a216238d085146a0745716f120 Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" Date: Wed, 13 May 2026 15:06:14 +0000 Subject: [PATCH] chore: generate --- packages/opencode/test/file/watcher.test.ts | 166 +++++++++--------- .../opencode/test/mcp/oauth-browser.test.ts | 11 +- 2 files changed, 92 insertions(+), 85 deletions(-) diff --git a/packages/opencode/test/file/watcher.test.ts b/packages/opencode/test/file/watcher.test.ts index 1da896cc1c..6276e58f29 100644 --- a/packages/opencode/test/file/watcher.test.ts +++ b/packages/opencode/test/file/watcher.test.ts @@ -150,26 +150,28 @@ function ready(directory: string) { // --------------------------------------------------------------------------- describeWatcher("FileWatcher", () => { - it.instance("publishes root create, update, and delete events", () => - Effect.gen(function* () { - const test = yield* TestInstance - const fs = yield* AppFileSystem.Service - const file = path.join(test.directory, "watch.txt") - const cases = [ - { event: "add" as const, trigger: fs.writeFileString(file, "a") }, - { event: "change" as const, trigger: fs.writeFileString(file, "b") }, - { event: "unlink" as const, trigger: fs.remove(file) }, - ] + it.instance( + "publishes root create, update, and delete events", + () => + Effect.gen(function* () { + const test = yield* TestInstance + const fs = yield* AppFileSystem.Service + const file = path.join(test.directory, "watch.txt") + const cases = [ + { event: "add" as const, trigger: fs.writeFileString(file, "a") }, + { event: "change" as const, trigger: fs.writeFileString(file, "b") }, + { event: "unlink" as const, trigger: fs.remove(file) }, + ] - yield* withWatcher( - test.directory, - Effect.forEach(cases, ({ event, trigger }) => - nextUpdate(test.directory, (evt) => evt.file === file && evt.event === event, trigger).pipe( - Effect.tap((evt) => Effect.sync(() => expect(evt).toEqual({ file, event }))), + yield* withWatcher( + test.directory, + Effect.forEach(cases, ({ event, trigger }) => + nextUpdate(test.directory, (evt) => evt.file === file && evt.event === event, trigger).pipe( + Effect.tap((evt) => Effect.sync(() => expect(evt).toEqual({ file, event }))), + ), ), - ), - ) - }), + ) + }), { git: true }, ) @@ -181,77 +183,81 @@ describeWatcher("FileWatcher", () => { yield* withWatcher( test.directory, - nextUpdate( - test.directory, - (e) => e.file === file && e.event === "add", - fs.writeFileString(file, "plain"), - ).pipe(Effect.tap((evt) => Effect.sync(() => expect(evt).toEqual({ file, event: "add" })))), - ) - }), - ) - - it.instance("cleanup stops publishing events", () => - Effect.gen(function* () { - const test = yield* TestInstance - const fs = yield* AppFileSystem.Service - const file = path.join(test.directory, "after-dispose.txt") - - // Start and immediately stop the watcher (withWatcher disposes on exit). - yield* withWatcher(test.directory, Effect.void) - - // Now write a file - no watcher should be listening. - yield* noUpdate(test.directory, (e) => e.file === file, fs.writeFileString(file, "gone")).pipe( - provideInstance(test.directory), - ) - }), - { git: true }, - ) - - it.instance("ignores .git/index changes", () => - Effect.gen(function* () { - const test = yield* TestInstance - const fs = yield* AppFileSystem.Service - const git = yield* Git.Service - const gitIndex = path.join(test.directory, ".git", "index") - const edit = path.join(test.directory, "tracked.txt") - - yield* withWatcher( - test.directory, - noUpdate( - test.directory, - (e) => e.file === gitIndex, - fs.writeFileString(edit, "a").pipe(Effect.andThen(git.run(["add", "."], { cwd: test.directory }))), + nextUpdate(test.directory, (e) => e.file === file && e.event === "add", fs.writeFileString(file, "plain")).pipe( + Effect.tap((evt) => Effect.sync(() => expect(evt).toEqual({ file, event: "add" }))), ), ) }), + ) + + it.instance( + "cleanup stops publishing events", + () => + Effect.gen(function* () { + const test = yield* TestInstance + const fs = yield* AppFileSystem.Service + const file = path.join(test.directory, "after-dispose.txt") + + // Start and immediately stop the watcher (withWatcher disposes on exit). + yield* withWatcher(test.directory, Effect.void) + + // Now write a file - no watcher should be listening. + yield* noUpdate(test.directory, (e) => e.file === file, fs.writeFileString(file, "gone")).pipe( + provideInstance(test.directory), + ) + }), { git: true }, ) - it.instance("publishes .git/HEAD events", () => - Effect.gen(function* () { - const test = yield* TestInstance - const fs = yield* AppFileSystem.Service - const git = yield* Git.Service - const head = path.join(test.directory, ".git", "HEAD") - const branch = `watch-${Math.random().toString(36).slice(2)}` - yield* git.run(["branch", branch], { cwd: test.directory }) + it.instance( + "ignores .git/index changes", + () => + Effect.gen(function* () { + const test = yield* TestInstance + const fs = yield* AppFileSystem.Service + const git = yield* Git.Service + const gitIndex = path.join(test.directory, ".git", "index") + const edit = path.join(test.directory, "tracked.txt") - yield* withWatcher( - test.directory, - nextUpdate( + yield* withWatcher( test.directory, - (evt) => evt.file === head && evt.event !== "unlink", - fs.writeFileString(head, `ref: refs/heads/${branch}\n`), - ).pipe( - Effect.tap((evt) => - Effect.sync(() => { - expect(evt.file).toBe(head) - expect(["add", "change"]).toContain(evt.event) - }), + noUpdate( + test.directory, + (e) => e.file === gitIndex, + fs.writeFileString(edit, "a").pipe(Effect.andThen(git.run(["add", "."], { cwd: test.directory }))), ), - ), - ) - }), + ) + }), + { git: true }, + ) + + it.instance( + "publishes .git/HEAD events", + () => + Effect.gen(function* () { + const test = yield* TestInstance + const fs = yield* AppFileSystem.Service + const git = yield* Git.Service + const head = path.join(test.directory, ".git", "HEAD") + const branch = `watch-${Math.random().toString(36).slice(2)}` + yield* git.run(["branch", branch], { cwd: test.directory }) + + yield* withWatcher( + test.directory, + nextUpdate( + test.directory, + (evt) => evt.file === head && evt.event !== "unlink", + fs.writeFileString(head, `ref: refs/heads/${branch}\n`), + ).pipe( + Effect.tap((evt) => + Effect.sync(() => { + expect(evt.file).toBe(head) + expect(["add", "change"]).toContain(evt.event) + }), + ), + ), + ) + }), { git: true }, ) }) diff --git a/packages/opencode/test/mcp/oauth-browser.test.ts b/packages/opencode/test/mcp/oauth-browser.test.ts index 8c8c6ca3f5..f6222de43d 100644 --- a/packages/opencode/test/mcp/oauth-browser.test.ts +++ b/packages/opencode/test/mcp/oauth-browser.test.ts @@ -167,7 +167,11 @@ const trackBrowserOpenFailed = Effect.gen(function* () { const authenticateScoped = (name: string) => Effect.gen(function* () { const mcp = yield* service - yield* mcp.authenticate(name).pipe(Effect.ignore, Effect.catchCause(() => Effect.void), Effect.forkScoped) + yield* mcp.authenticate(name).pipe( + Effect.ignore, + Effect.catchCause(() => Effect.void), + Effect.forkScoped, + ) }) mcpTest.instance( @@ -180,10 +184,7 @@ mcpTest.instance( const event = yield* trackBrowserOpenFailed yield* authenticateScoped("test-oauth-server") - const failure = yield* awaitWithTimeout( - Deferred.await(event), - "Timed out waiting for BrowserOpenFailed event", - ) + const failure = yield* awaitWithTimeout(Deferred.await(event), "Timed out waiting for BrowserOpenFailed event") expect(failure.mcpName).toBe("test-oauth-server") expect(failure.url).toContain("https://")