mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
test: remove low-value copy, inventory, and runner assertions
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { test } from 'node:test'
|
||||
|
||||
const here = new URL('./', import.meta.url)
|
||||
const action = readFileSync(new URL('action.yml', here), 'utf8')
|
||||
|
||||
test('is a node24 JavaScript action with an always-run post step', () => {
|
||||
// A composite action has no `post:`, so the lease could never be released on cancel or failure.
|
||||
assert.match(action, /^ {2}using: node24$/m)
|
||||
assert.doesNotMatch(action, /using: composite/)
|
||||
assert.match(action, /^ {2}main: main\.mjs$/m)
|
||||
assert.match(action, /^ {2}post: post\.mjs$/m)
|
||||
assert.match(action, /^ {2}post-if: always\(\)$/m)
|
||||
})
|
||||
|
||||
test('declares the inputs the wave-chain callers depend on', () => {
|
||||
for (const input of ['bucket:', 'object:', 'holder-key:', 'release:']) {
|
||||
assert.match(action, new RegExp(`^ {2}${input}$`, 'm'), input)
|
||||
}
|
||||
assert.match(action, /default: \$\{\{ github\.repository \}\}\/\$\{\{ github\.run_id \}\}/)
|
||||
assert.match(action, /default: 'true'/)
|
||||
})
|
||||
@@ -234,18 +234,6 @@ test('fails closed when the bucket answers 5xx', async () => {
|
||||
assert.equal(storage.state.requests.filter((request) => request.method !== 'GET').length, 0)
|
||||
})
|
||||
|
||||
test('fails closed when permission is denied', async () => {
|
||||
const storage = fakeStorage({
|
||||
faults: [{ when: (request) => request.method === 'GET', status: 403 }]
|
||||
})
|
||||
|
||||
const error = await leaseFor(storage)
|
||||
.acquire(HOLDER)
|
||||
.catch((thrown) => thrown)
|
||||
|
||||
assert.match(error.message, /lease inspection failed: 403/)
|
||||
})
|
||||
|
||||
test('treats an unreadable record as held, not free', async () => {
|
||||
const storage = fakeStorage({
|
||||
object: { generation: '1500', body: { holder_key: 'stablyai/orca/9001' } }
|
||||
|
||||
@@ -110,8 +110,7 @@ for (const [name, options] of [
|
||||
{ env: { ORCA_IDLE_REHOME_POSTGRES_URL: 'postgres://localhost:55440/relay' } }
|
||||
],
|
||||
['application database', { env: { DATABASE_URL: databaseUrl } }],
|
||||
['one CPU', { parallelism: 1 }],
|
||||
['two CPUs', { parallelism: 2 }]
|
||||
['one CPU', { parallelism: 1 }]
|
||||
]) {
|
||||
test(`retains the original single run for ${name}`, async (t) => {
|
||||
const h = start(t, options)
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import { expect, it } from 'vitest'
|
||||
import { ORCAD_ARTIFACTS } from '../../../../src/shared/orcad-artifacts.ts'
|
||||
import { ORCAD_CHILD_ENTRY_POINTS, orcadChildOutputFilename } from './orcad-entry-build.mjs'
|
||||
|
||||
// A child built but not listed never reaches remote hosts, so its client fails there.
|
||||
it.each(Object.entries(ORCAD_CHILD_ENTRY_POINTS))(
|
||||
'ships the %s child bundle as an orcad artifact',
|
||||
(_name, entryPoint) => {
|
||||
const filenames = ORCAD_ARTIFACTS.map((artifact) => artifact.filename)
|
||||
expect(filenames).toContain(orcadChildOutputFilename(entryPoint))
|
||||
}
|
||||
)
|
||||
@@ -3,16 +3,11 @@ import { readFile, readdir } from 'node:fs/promises'
|
||||
import { existsSync } from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import test from 'node:test'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
|
||||
const siteRoot = path.resolve(import.meta.dirname, '..')
|
||||
const contentRoot = path.join(siteRoot, 'content', 'docs')
|
||||
const publicRoot = path.join(siteRoot, 'public')
|
||||
|
||||
async function read(relativePath) {
|
||||
return readFile(path.join(siteRoot, relativePath), 'utf8')
|
||||
}
|
||||
|
||||
async function walkFiles(directory, extension) {
|
||||
const entries = await readDirectory(directory)
|
||||
const files = []
|
||||
@@ -40,19 +35,6 @@ function isMediaPath(urlPath) {
|
||||
return /\.(?:gif|jpe?g|png|webp|mp4|svg|ico)$/i.test(urlPath.split(/[?#]/, 1)[0])
|
||||
}
|
||||
|
||||
test('docs content and navigation metadata are discoverable', async () => {
|
||||
const pages = await walkFiles(contentRoot, '.mdx')
|
||||
assert.ok(pages.length > 0, 'expected docs content pages')
|
||||
|
||||
const navigationFiles = await walkFiles(contentRoot, 'meta.json')
|
||||
assert.ok(navigationFiles.length > 0, 'expected navigation metadata')
|
||||
for (const file of navigationFiles) {
|
||||
const metadata = JSON.parse(await readFile(file, 'utf8'))
|
||||
assert.ok(metadata.title, `navigation title missing in ${file}`)
|
||||
assert.ok(Array.isArray(metadata.pages), `navigation pages missing in ${file}`)
|
||||
}
|
||||
})
|
||||
|
||||
test('every local media URL referenced by docs resolves in public assets', async () => {
|
||||
const files = await walkFiles(contentRoot, '.mdx')
|
||||
const localUrls = new Set()
|
||||
@@ -84,29 +66,3 @@ test('docs content does not link to routes that only exist on the marketing site
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
test('GIF media helpers use the shared poster and video variants', async () => {
|
||||
const media = await import(pathToFileURL(path.join(siteRoot, 'src', 'lib', 'demoMedia.mjs')).href)
|
||||
assert.equal(media.posterFor('/docs/orca-design-mode.gif'), '/docs/posters/orca-design-mode.jpg')
|
||||
assert.equal(media.videoFor('/docs/orca-design-mode.gif'), '/docs/videos/orca-design-mode.mp4')
|
||||
assert.equal(media.posterFor('/docs/tab-split.gif'), '/docs/posters/tab-split.jpg')
|
||||
assert.equal(media.videoFor('/docs/tab-split.gif'), '/docs/videos/tab-split.mp4')
|
||||
|
||||
for (const name of ['orca-design-mode', 'tab-split']) {
|
||||
assert.ok(existsSync(path.join(publicRoot, 'docs', 'posters', `${name}.jpg`)))
|
||||
assert.ok(existsSync(path.join(publicRoot, 'docs', 'videos', `${name}.mp4`)))
|
||||
}
|
||||
})
|
||||
|
||||
test('OG image fonts ship with their required third-party notice', async () => {
|
||||
for (const filename of ['Geist-Regular.ttf', 'Geist-Bold.ttf', 'Geist-Variable.woff2']) {
|
||||
assert.ok(
|
||||
existsSync(path.join(siteRoot, 'src', 'assets', 'fonts', filename)),
|
||||
`missing font: ${filename}`
|
||||
)
|
||||
}
|
||||
|
||||
const notice = await read('THIRD_PARTY_NOTICES.md')
|
||||
assert.match(notice, /SIL OPEN FONT LICENSE Version 1\.1/)
|
||||
assert.match(notice, /Copyright \(c\) 2023 Vercel/)
|
||||
})
|
||||
|
||||
@@ -1,22 +1,7 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
import { runInNewContext } from 'node:vm'
|
||||
import { stripSearchExcerptMarkdown } from '../src/components/docs/search-excerpt.mjs'
|
||||
|
||||
test('unterminated escaped link destinations do not backtrack exponentially', () => {
|
||||
for (const prefix of [' {
|
||||
const input = prefix + '\\('.repeat(32_768)
|
||||
const result = runInNewContext(
|
||||
'strip(input)',
|
||||
{ strip: stripSearchExcerptMarkdown, input },
|
||||
{
|
||||
timeout: 250
|
||||
}
|
||||
)
|
||||
assert.equal(result, input.replace(/\\\(/g, '('))
|
||||
}
|
||||
})
|
||||
|
||||
test('link destinations retain escaped closing parentheses and literal escapes', () => {
|
||||
for (const prefix of [' {
|
||||
assert.equal(stripSearchExcerptMarkdown(prefix + 'https://example.com/a\\)b)'), 'label')
|
||||
@@ -60,16 +45,6 @@ test('search excerpts preserve highlighted matches inside Markdown', () => {
|
||||
)
|
||||
})
|
||||
|
||||
test('unclosed angles finish within the excerpt budget without changing text', () => {
|
||||
const input = '<'.repeat(131_072)
|
||||
const result = runInNewContext(
|
||||
'strip(input)',
|
||||
{ strip: stripSearchExcerptMarkdown, input },
|
||||
{ timeout: 250 }
|
||||
)
|
||||
assert.equal(result, input)
|
||||
})
|
||||
|
||||
test('tag guards preserve malformed markup, protected code and highlighted matches', () => {
|
||||
const cases = [
|
||||
['<em>**bold**</em>', 'bold'],
|
||||
@@ -99,13 +74,3 @@ test('tag guards preserve malformed markup, protected code and highlighted match
|
||||
assert.equal(stripSearchExcerptMarkdown(input), expected, input)
|
||||
}
|
||||
})
|
||||
|
||||
test('unclosed brackets finish within the excerpt budget without changing text', () => {
|
||||
const input = '['.repeat(131_072)
|
||||
const result = runInNewContext(
|
||||
'strip(input)',
|
||||
{ strip: stripSearchExcerptMarkdown, input },
|
||||
{ timeout: 250 }
|
||||
)
|
||||
assert.equal(result, input)
|
||||
})
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { createRequire } from 'node:module'
|
||||
import { dirname, join } from 'node:path'
|
||||
import test from 'node:test'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
|
||||
const require = createRequire(import.meta.url)
|
||||
const vercelRequire = createRequire(require.resolve('vercel/package.json'))
|
||||
const backendsRequire = createRequire(vercelRequire.resolve('@vercel/backends/package.json'))
|
||||
const zodRoot = dirname(backendsRequire.resolve('zod/package.json'))
|
||||
|
||||
for (const extension of ['cjs', 'js']) {
|
||||
for (const entry of ['index', 'v3/index', 'v4/index']) {
|
||||
test(`Vercel Zod rejects oversized collections before parsing elements (${entry}.${extension})`, async () => {
|
||||
const path = join(zodRoot, `${entry}.${extension}`)
|
||||
const z = extension === 'cjs' ? require(path) : await import(pathToFileURL(path).href)
|
||||
let parsed = 0
|
||||
const element = z.preprocess((value) => {
|
||||
parsed += 1
|
||||
return value
|
||||
}, z.string())
|
||||
for (const [schema, value, valid] of [
|
||||
[z.array(element).max(2), Array(1_000).fill(0), ['a']],
|
||||
[z.array(element).length(2), Array(1_000).fill(0), ['a', 'b']],
|
||||
[z.set(element).max(2), new Set([1, 2, 3]), new Set(['a'])],
|
||||
[z.set(element).size(2), new Set([1, 2, 3]), new Set(['a', 'b'])]
|
||||
]) {
|
||||
parsed = 0
|
||||
for (const result of [schema.safeParse(value), await schema.safeParseAsync(value)]) {
|
||||
assert.equal(result.success, false)
|
||||
assert.deepEqual(
|
||||
result.error.issues.map((issue) => issue.code),
|
||||
['too_big']
|
||||
)
|
||||
}
|
||||
assert.equal(parsed, 0)
|
||||
assert.deepEqual(schema.parse(valid), valid)
|
||||
assert.deepEqual(await schema.parseAsync(valid), valid)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
test('docs Zod 4 keeps valid schemas working after the security upgrade', async () => {
|
||||
const { z } = await import('zod')
|
||||
const schema = z.array(z.string()).max(2)
|
||||
assert.deepEqual(schema.parse(['a']), ['a'])
|
||||
assert.deepEqual(
|
||||
schema.safeParse([1, 2, 3]).error.issues.map((issue) => issue.code),
|
||||
['too_big']
|
||||
)
|
||||
})
|
||||
@@ -132,18 +132,6 @@ describe('AutomationsPage refresh', () => {
|
||||
expect(reads()).toHaveLength(beforeEvents + 2)
|
||||
}
|
||||
)
|
||||
|
||||
it('does not re-run the whole refresh when the settings identity changes', async () => {
|
||||
const { rerender } = await renderPage()
|
||||
expect(api.automations.list).toHaveBeenCalledTimes(1)
|
||||
|
||||
mocks.state.settings = { ...(mocks.state.settings as Record<string, unknown>) }
|
||||
await rerender()
|
||||
|
||||
// Settings no longer aim the list, so a new settings object is not a reason
|
||||
// to re-fetch every host.
|
||||
expect(api.automations.list).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('AutomationsPage selection', () => {
|
||||
|
||||
@@ -1,46 +1,17 @@
|
||||
// @vitest-environment happy-dom
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { act, cleanup, render, screen } from '@testing-library/react'
|
||||
import type * as KeybindingsModule from '../../../shared/keybindings'
|
||||
import type { KeybindingOverrides } from '../../../shared/keybindings'
|
||||
|
||||
const counters = vi.hoisted(() => ({ effective: 0, formatList: 0, formatBinding: 0 }))
|
||||
const platformRef = vi.hoisted(() => ({ current: 'darwin' as NodeJS.Platform }))
|
||||
|
||||
vi.mock('../lib/shortcut-platform', () => ({
|
||||
getShortcutPlatform: () => platformRef.current
|
||||
}))
|
||||
|
||||
vi.mock('../../../shared/keybindings', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof KeybindingsModule>()
|
||||
return {
|
||||
...actual,
|
||||
getEffectiveKeybindingsForAction: (
|
||||
...args: Parameters<typeof actual.getEffectiveKeybindingsForAction>
|
||||
) => {
|
||||
counters.effective++
|
||||
return actual.getEffectiveKeybindingsForAction(...args)
|
||||
},
|
||||
formatKeybindingList: (...args: Parameters<typeof actual.formatKeybindingList>) => {
|
||||
counters.formatList++
|
||||
return actual.formatKeybindingList(...args)
|
||||
},
|
||||
formatKeybinding: (...args: Parameters<typeof actual.formatKeybinding>) => {
|
||||
counters.formatBinding++
|
||||
return actual.formatKeybinding(...args)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const { formatShortcutLabel, useShortcutLabel } = await import('./useShortcutLabel')
|
||||
const { useAppStore } = await import('@/store')
|
||||
|
||||
function resetCounters(): void {
|
||||
counters.effective = 0
|
||||
counters.formatList = 0
|
||||
counters.formatBinding = 0
|
||||
}
|
||||
|
||||
// A fresh overrides object per test keeps each case on its own cache entry, exactly as a real edit does.
|
||||
function overridesFor(binding: string): KeybindingOverrides {
|
||||
return { 'tab.close': [binding] }
|
||||
@@ -49,7 +20,6 @@ function overridesFor(binding: string): KeybindingOverrides {
|
||||
describe('shortcut label memoization', () => {
|
||||
beforeEach(() => {
|
||||
platformRef.current = 'darwin'
|
||||
resetCounters()
|
||||
})
|
||||
|
||||
it('keys the cache by platform so Mac and Windows glyphs never cross', () => {
|
||||
@@ -69,7 +39,6 @@ function CloseLabel(): React.JSX.Element {
|
||||
describe('useShortcutLabel', () => {
|
||||
beforeEach(() => {
|
||||
platformRef.current = 'darwin'
|
||||
resetCounters()
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
@@ -77,19 +46,6 @@ describe('useShortcutLabel', () => {
|
||||
useAppStore.setState({ keybindings: {} })
|
||||
})
|
||||
|
||||
it('does not recompute the label on re-render', () => {
|
||||
useAppStore.setState({ keybindings: overridesFor('Mod+Shift+K') })
|
||||
const { rerender } = render(<CloseLabel />)
|
||||
expect(screen.getByTestId('close-label').textContent).toBe('⌘⇧K')
|
||||
resetCounters()
|
||||
for (let index = 0; index < 25; index++) {
|
||||
rerender(<CloseLabel />)
|
||||
}
|
||||
expect(screen.getByTestId('close-label').textContent).toBe('⌘⇧K')
|
||||
expect(counters.effective).toBe(0)
|
||||
expect(counters.formatList).toBe(0)
|
||||
})
|
||||
|
||||
it('shows an edited keybinding immediately, with no stale-cache window', () => {
|
||||
useAppStore.setState({ keybindings: overridesFor('Mod+Shift+K') })
|
||||
render(<CloseLabel />)
|
||||
|
||||
@@ -16,7 +16,6 @@ import * as rendererI18n from './i18n'
|
||||
import { useLanguageReadiness } from './language-readiness'
|
||||
import * as languageReadiness from './language-readiness'
|
||||
import { usePluginLanguagePackStore } from '../store/plugins/localization/plugin-language-packs'
|
||||
import { pluginLanguageResourceId } from '../../../shared/plugins/artifacts/plugin-language-pack-artifact'
|
||||
import { I18nProvider } from './I18nProvider'
|
||||
|
||||
// Wait for async settings before selecting the OS locale, or an in-flight load can override the persisted preference.
|
||||
@@ -203,38 +202,3 @@ it('continues in English while plugin discovery is pending without changing the
|
||||
expect(usePluginLanguagePackStore.getState().loaded).toBe(false)
|
||||
expect(useAppStore.getState().settings?.uiLanguage).toBe('plugin:example.missing/de')
|
||||
})
|
||||
|
||||
it("re-applies a plugin language only when the selected pack's content changes", async () => {
|
||||
const id = 'plugin:example.german/de-DE' as const
|
||||
const pack = (save: string) => ({
|
||||
id,
|
||||
resourceLanguage: pluginLanguageResourceId(id),
|
||||
pluginKey: 'example.german',
|
||||
coverage: 100,
|
||||
locale: 'de-DE',
|
||||
catalog: { common: { save } }
|
||||
})
|
||||
let listed = [pack('Speichern')]
|
||||
Object.defineProperty(window, 'api', {
|
||||
configurable: true,
|
||||
value: { plugins: { listLanguagePacks: async () => structuredClone(listed) } }
|
||||
})
|
||||
usePluginLanguagePackStore.setState({ entries: [], loaded: false })
|
||||
useAppStore.setState({ settings: { ...getDefaultSettings('/tmp'), uiLanguage: id } })
|
||||
await renderProvider()
|
||||
await act(() => usePluginLanguagePackStore.getState().fetchEntries())
|
||||
await vi.waitFor(() => expect(i18n.language).toBe(pluginLanguageResourceId(id)))
|
||||
const changeLanguage = vi.spyOn(i18n, 'changeLanguage')
|
||||
const removeBundle = vi.spyOn(i18n, 'removeResourceBundle')
|
||||
|
||||
// Plugin-change refreshes rebuild every registration over IPC, even when nothing changed.
|
||||
await act(() => usePluginLanguagePackStore.getState().fetchEntries())
|
||||
await vi.waitFor(() => expect(useLanguageReadiness.getState().loading).toBe(false))
|
||||
expect(changeLanguage).not.toHaveBeenCalled()
|
||||
expect(removeBundle).not.toHaveBeenCalled()
|
||||
|
||||
listed = [pack('Sichern')]
|
||||
await act(() => usePluginLanguagePackStore.getState().fetchEntries())
|
||||
await vi.waitFor(() => expect(changeLanguage).toHaveBeenCalledWith(pluginLanguageResourceId(id)))
|
||||
expect(rendererI18n.translate('common.save', 'Save')).toBe('Sichern')
|
||||
})
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const { mockIntlLocale } = vi.hoisted(() => ({ mockIntlLocale: { value: 'en' } }))
|
||||
|
||||
vi.mock('./i18n', () => ({ getIntlLocale: () => mockIntlLocale.value }))
|
||||
|
||||
import { getUiRelativeTimeFormatter } from './relative-time-format'
|
||||
|
||||
beforeEach(() => {
|
||||
mockIntlLocale.value = 'en'
|
||||
})
|
||||
|
||||
describe('getUiRelativeTimeFormatter', () => {
|
||||
it('rebuilds the formatter after a runtime language switch', () => {
|
||||
const english = getUiRelativeTimeFormatter()
|
||||
mockIntlLocale.value = 'ko'
|
||||
const korean = getUiRelativeTimeFormatter()
|
||||
expect(korean).not.toBe(english)
|
||||
expect(korean.format(-1, 'day')).toBe('어제')
|
||||
})
|
||||
})
|
||||
@@ -1,15 +0,0 @@
|
||||
import { afterEach, expect, it } from 'vitest'
|
||||
import { i18n, loadRendererUiLanguage } from './i18n'
|
||||
import { uiNumberFormat } from './ui-intl-formatters'
|
||||
|
||||
const GROUPED: Intl.NumberFormatOptions = {}
|
||||
|
||||
afterEach(async () => {
|
||||
await i18n.changeLanguage('en')
|
||||
})
|
||||
|
||||
it('rebuilds a shared formatter when the UI language changes', async () => {
|
||||
expect(uiNumberFormat(GROUPED).format(1234.5)).toBe('1,234.5')
|
||||
await i18n.changeLanguage(await loadRendererUiLanguage('de'))
|
||||
expect(uiNumberFormat(GROUPED).format(1234.5)).toBe('1.234,5')
|
||||
})
|
||||
@@ -1,34 +0,0 @@
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { i18n } from '@/i18n/i18n'
|
||||
import es from '@/i18n/locales/es.json'
|
||||
import { textGenerationFailure } from '../../../shared/text-generation-failure-copy'
|
||||
import { localizeTextGenerationResult, textGenerationErrorText } from './text-generation-error-copy'
|
||||
|
||||
const originalLanguage = i18n.language
|
||||
const errors = es.sourceControl.textGeneration.errors
|
||||
|
||||
afterEach(async () => {
|
||||
await i18n.changeLanguage(originalLanguage)
|
||||
})
|
||||
|
||||
describe('textGenerationErrorText', () => {
|
||||
it('localizes a coded failure and keeps the agent label and CLI output verbatim', async () => {
|
||||
i18n.addResourceBundle('es', 'translation', es)
|
||||
await i18n.changeLanguage('es')
|
||||
const failed = textGenerationFailure('cliFailedWithDetail', {
|
||||
label: 'Codex',
|
||||
exitCode: 2,
|
||||
detail: 'unauthorized {{label}}'
|
||||
})
|
||||
expect(failed.error).toBe('Codex CLI command failed with code 2: unauthorized {{label}}')
|
||||
expect(textGenerationErrorText(failed)).toBe(
|
||||
errors.cliFailedWithDetail
|
||||
.replace('{{label}}', 'Codex')
|
||||
.replace('{{exitCode}}', '2')
|
||||
.replace('{{detail}}', 'unauthorized {{label}}')
|
||||
)
|
||||
expect(
|
||||
localizeTextGenerationResult({ success: false, ...textGenerationFailure('noStagedChanges') })
|
||||
).toEqual({ success: false, error: errors.noStagedChanges, errorCode: 'noStagedChanges' })
|
||||
})
|
||||
})
|
||||
+2
-12
@@ -13,7 +13,7 @@ const ok: RuntimeRpcResponse<unknown> = {
|
||||
_meta: { runtimeId: 'r' }
|
||||
}
|
||||
|
||||
function setup(probe: Probe, shouldProbe: () => boolean = () => true) {
|
||||
function setup(probe: Probe) {
|
||||
const onUnresponsive = vi.fn()
|
||||
const onRecovered = vi.fn()
|
||||
const probeSpy = vi.fn<Probe>(probe)
|
||||
@@ -22,7 +22,7 @@ function setup(probe: Probe, shouldProbe: () => boolean = () => true) {
|
||||
{
|
||||
probe: probeSpy,
|
||||
isCurrent: () => true,
|
||||
shouldProbe,
|
||||
shouldProbe: () => true,
|
||||
onUnresponsive,
|
||||
onRecovered
|
||||
}
|
||||
@@ -129,16 +129,6 @@ describe('shared control app heartbeat', () => {
|
||||
heartbeat.stop()
|
||||
})
|
||||
|
||||
it('does not probe an asleep host', async () => {
|
||||
const { heartbeat, probe } = setup(
|
||||
() => Promise.resolve(ok),
|
||||
() => false
|
||||
)
|
||||
await vi.advanceTimersByTimeAsync(5_000)
|
||||
expect(probe).not.toHaveBeenCalled()
|
||||
heartbeat.stop()
|
||||
})
|
||||
|
||||
it('restarts the silence window after this process stalls instead of blaming the host', async () => {
|
||||
let now = 0
|
||||
const probe = vi.fn<Probe>(() => Promise.resolve(ok))
|
||||
|
||||
Reference in New Issue
Block a user