test: repair v2 CI failures (#40803)

Co-authored-by: Aiden Cline <rekram1-node@users.noreply.github.com>
This commit is contained in:
opencode-agent[bot] 2026-08-05 23:38:38 -05:00 committed by GitHub
parent ae494ffce5
commit a15ec425de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 32 additions and 22 deletions

View file

@ -111,6 +111,7 @@
"@types/luxon": "catalog:",
"@types/node": "catalog:",
"@typescript/native-preview": "catalog:",
"happy-dom": "20.11.1",
"tw-animate-css": "1.4.0",
"typescript": "catalog:",
"vite": "catalog:",

View file

@ -40,6 +40,7 @@
"@types/luxon": "catalog:",
"@types/node": "catalog:",
"@typescript/native-preview": "catalog:",
"happy-dom": "20.11.1",
"tw-animate-css": "1.4.0",
"typescript": "catalog:",
"vite": "catalog:",

View file

@ -1,5 +1,6 @@
import { expect, test } from "bun:test"
import { type Virtualizer } from "@tanstack/solid-virtual"
import { Window } from "happy-dom"
import { mutationNodesContainElement, observeElementOffsetReconnectAware } from "./observe-element-offset"
test("matches only the scroll element or an ancestor containing it", () => {
@ -16,14 +17,15 @@ test("matches only the scroll element or an ancestor containing it", () => {
})
test("reports a divergent native offset once and ignores equal offsets and unrelated mutations", async () => {
const route = document.createElement("section")
const viewport = document.createElement("div")
const unrelated = document.createElement("div")
const targetWindow = new Window()
const route = targetWindow.document.createElement("section")
const viewport = targetWindow.document.createElement("div")
const unrelated = targetWindow.document.createElement("div")
route.append(viewport)
document.body.append(route)
targetWindow.document.body.append(route)
const instance = {
scrollElement: viewport,
targetWindow: window,
targetWindow,
scrollOffset: 79_400,
options: {
horizontal: false,
@ -38,24 +40,24 @@ test("reports a divergent native offset once and ignores equal offsets and unrel
instance.scrollOffset = offset
})
document.body.append(unrelated)
targetWindow.document.body.append(unrelated)
unrelated.remove()
await frames(2)
await frames(2, targetWindow)
expect(calls).toEqual([])
route.remove()
document.body.append(route)
await waitFor(() => calls.length === 1)
targetWindow.document.body.append(route)
await waitFor(() => calls.length === 1, targetWindow)
expect(calls).toEqual([[0, false]])
route.remove()
document.body.append(route)
targetWindow.document.body.append(route)
await new Promise((resolve) => setTimeout(resolve, 0))
await frames(3)
await frames(3, targetWindow)
expect(calls).toEqual([[0, false]])
cleanup?.()
route.remove()
await targetWindow.happyDOM.close()
})
test("keeps checking until stale reset-delay callbacks can no longer win", async () => {
@ -191,13 +193,18 @@ test("cleanup cancels reconnect checks and delegated offset observation", async
route.remove()
})
async function frames(count: number) {
type FrameWindow = {
requestAnimationFrame(callback: () => void): unknown
performance: { now(): number }
}
async function frames(count: number, targetWindow: FrameWindow = window) {
for (let index = 0; index < count; index++) {
await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()))
await new Promise<void>((resolve) => targetWindow.requestAnimationFrame(() => resolve()))
}
}
async function waitFor(condition: () => boolean) {
const deadline = performance.now() + 1_000
while (!condition() && performance.now() < deadline) await frames(1)
async function waitFor(condition: () => boolean, targetWindow: FrameWindow = window) {
const deadline = targetWindow.performance.now() + 1_000
while (!condition() && targetWindow.performance.now() < deadline) await frames(1, targetWindow)
}

View file

@ -53,6 +53,7 @@ describe("config plugin reloads", () => {
expect(yield* catalog.provider.get(Provider.ID.make("first"))).toBeDefined()
yield* test.setEntries([config("second")])
yield* Effect.yieldNow
yield* bus.publish(ConfigSchema.Event.Updated, {})
yield* waitUntil(
Effect.gen(function* () {

View file

@ -35,7 +35,9 @@ describe("EventLogger", () => {
Effect.runPromise,
)
expect(output.map((entry) => entry.message)).toEqual([
expect(
output.flatMap((entry) => (Array.isArray(entry.message) && entry.message[0] === "event" ? [entry.message] : [])),
).toEqual([
["event", { event: expect.objectContaining({ type: "agent.updated" }) }],
["event", { event: expect.objectContaining({ type: "catalog.updated" }) }],
["event", { event: expect.objectContaining({ type: "command.updated" }) }],

View file

@ -46,9 +46,7 @@ describe("Session.log", () => {
const items = Array.from(yield* Stream.runCollect(session.log({ sessionID: created.id })))
// Session creation commits a non-public durable event, so the marker's
// seq covers more of the aggregate than the public events emitted.
expect(items.map((item) => item.type)).toEqual(["session.renamed", "log.synced"])
expect(items.map((item) => item.type)).toEqual(["session.created", "session.renamed", "log.synced"])
expect(items.at(-1)).toEqual({ type: "log.synced", aggregateID: created.id, seq: Event.Seq.make(1) })
}),
)

View file

@ -117,7 +117,7 @@ describe("SessionProjector", () => {
diff: "legacy patch",
files: [{ path: "src/old.ts", status: "modified", additions: 1, deletions: 0, patch: "@@" }],
})
yield* db.run(sql`update session set revert = ${legacy} where id = ${sessionID}`)
yield* db.run(sql`update session_v2 set revert = ${legacy} where id = ${sessionID}`)
const stored = yield* db.select().from(SessionTable).where(eq(SessionTable.id, sessionID)).get()
if (!stored) return yield* Effect.die("Session row missing")
const storedRevert = fromRow(stored).revert