Compare commits

...

1 Commits

Author SHA1 Message Date
christian-byrne
f1f49bda1f test: stop flaky teardown error in AssetBrowserModal test
AssetBrowserModal mounts useModelTypes, which calls api.getModelFolders().
The test mocked the asset store and child components but not this composable,
so every render fired a real fetch to localhost:3000/api/experiment/models.
The request failed with ECONNREFUSED and useModelTypes logged via console.error
asynchronously, after the test had already finished. Under CI load that late
console write raced with vitest worker teardown, surfacing as:

  EnvironmentTeardownError: Closing rpc while "onUserConsoleLog" was pending

Vitest counts these as unhandled errors and fails the whole run even though
every test passes - a nondeterministic failure (e.g. run 27791561006, the
core/1.46 backport of #12804).

Mock useModelTypes so mounting performs no network I/O and emits no late logs.
2026-06-19 16:07:06 -07:00

View File

@@ -39,6 +39,18 @@ vi.mock('@/stores/modelToNodeStore', () => ({
})
}))
// Stub model-type fetching so mounting the modal does not fire a real
// `api.getModelFolders()` network request. The unmocked call hit
// http://localhost:3000/api/experiment/models, failed with ECONNREFUSED, and
// logged via console.error asynchronously after the test had finished —
// racing with vitest worker teardown and surfacing as a flaky
// "EnvironmentTeardownError: Closing rpc while onUserConsoleLog was pending".
vi.mock('@/platform/assets/composables/useModelTypes', () => ({
useModelTypes: () => ({
fetchModelTypes: vi.fn().mockResolvedValue(undefined)
})
}))
vi.mock('@/components/common/SearchBox.vue', () => ({
default: {
name: 'SearchBox',