chore(stage-ui): prevent using node:assert
This commit is contained in:
+3
-3
@@ -2,8 +2,6 @@
|
||||
|
||||
import type { ChatHistoryItem } from '../../../../types/chat'
|
||||
|
||||
import assert from 'node:assert/strict'
|
||||
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { effectScope, nextTick, ref } from 'vue'
|
||||
|
||||
@@ -253,7 +251,9 @@ describe('useChatHistoryScroll', () => {
|
||||
scrollIntoView.mockClear()
|
||||
|
||||
const firstNode = container.querySelector('[data-chat-message-key="user-1"]')
|
||||
assert.ok(firstNode)
|
||||
expect(firstNode).not.toBeNull()
|
||||
if (!firstNode)
|
||||
throw new Error('Expected first chat node to exist.')
|
||||
firstNode.dispatchEvent(new PointerEvent('pointerover', { bubbles: true }))
|
||||
await flushDom()
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import type { ChatHistoryItem } from '../../../types/chat'
|
||||
|
||||
import assert from 'node:assert/strict'
|
||||
|
||||
import { describe, it } from 'vitest'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { getChatHistoryItemKey } from './utils'
|
||||
|
||||
@@ -13,8 +11,8 @@ describe('getChatHistoryItemKey', () => {
|
||||
const userMessage: ChatHistoryItem = { role: 'user', content: 'hi', createdAt, id: 'user-1' }
|
||||
const assistantMessage: ChatHistoryItem = { role: 'assistant', content: 'hello', createdAt, id: 'assistant-1', slices: [], tool_results: [] }
|
||||
|
||||
assert.equal(getChatHistoryItemKey(userMessage, 0), 'user-1')
|
||||
assert.equal(getChatHistoryItemKey(assistantMessage, 1), 'assistant-1')
|
||||
expect(getChatHistoryItemKey(userMessage, 0)).toBe('user-1')
|
||||
expect(getChatHistoryItemKey(assistantMessage, 1)).toBe('assistant-1')
|
||||
})
|
||||
|
||||
it('falls back to a role + timestamp + index composite when ids are missing', () => {
|
||||
@@ -23,20 +21,20 @@ describe('getChatHistoryItemKey', () => {
|
||||
const userMessage: ChatHistoryItem = { role: 'user', content: 'hi', createdAt }
|
||||
const assistantMessage: ChatHistoryItem = { role: 'assistant', content: 'hello', createdAt, slices: [], tool_results: [] }
|
||||
|
||||
assert.equal(getChatHistoryItemKey(userMessage, 0), 'user:1700000000000:0')
|
||||
assert.equal(getChatHistoryItemKey(assistantMessage, 1), 'assistant:1700000000000:1')
|
||||
expect(getChatHistoryItemKey(userMessage, 0)).toBe('user:1700000000000:0')
|
||||
expect(getChatHistoryItemKey(assistantMessage, 1)).toBe('assistant:1700000000000:1')
|
||||
})
|
||||
|
||||
it('falls back to index when message is missing', () => {
|
||||
assert.equal(getChatHistoryItemKey(undefined, 0), 0)
|
||||
assert.equal(getChatHistoryItemKey(undefined, 1), 1)
|
||||
expect(getChatHistoryItemKey(undefined, 0)).toBe(0)
|
||||
expect(getChatHistoryItemKey(undefined, 1)).toBe(1)
|
||||
})
|
||||
|
||||
it('falls back to a role + index composite when ids and timestamps are missing', () => {
|
||||
const userMessage: ChatHistoryItem = { role: 'user', content: 'hi' }
|
||||
const assistantMessage: ChatHistoryItem = { role: 'assistant', content: 'hello', slices: [], tool_results: [] }
|
||||
|
||||
assert.equal(getChatHistoryItemKey(userMessage, 0), 'user:0')
|
||||
assert.equal(getChatHistoryItemKey(assistantMessage, 1), 'assistant:1')
|
||||
expect(getChatHistoryItemKey(userMessage, 0)).toBe('user:0')
|
||||
expect(getChatHistoryItemKey(assistantMessage, 1)).toBe('assistant:1')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -39,10 +39,12 @@ describe('stage-ui exports contract', () => {
|
||||
'./stores/analytics/posthog',
|
||||
'./stores/analytics/privacy-policy',
|
||||
'./stores/character',
|
||||
'./stores/character/orchestrator/spark-notify-agent',
|
||||
'./stores/modules/vision',
|
||||
'./stores/providers/aliyun',
|
||||
'./stores/settings',
|
||||
'./stores/settings/analytics',
|
||||
'./tools/mcp',
|
||||
'./types',
|
||||
'./types/*',
|
||||
'./utils',
|
||||
@@ -58,6 +60,7 @@ describe('stage-ui exports contract', () => {
|
||||
|
||||
expect(exportsMap['./stores']).toBe('./src/stores/index.ts')
|
||||
expect(exportsMap['./stores/*']).toBe('./src/stores/*.ts')
|
||||
expect(exportsMap['./tools/mcp']).toBe('./src/tools/mcp.ts')
|
||||
expect(exportsMap['./types']).toBe('./src/types/index.ts')
|
||||
expect(exportsMap['./types/*']).toBe('./src/types/*.ts')
|
||||
})
|
||||
|
||||
@@ -11,6 +11,7 @@ describe('tools/character/orchestrator/spark-notify', () => {
|
||||
onCommands: () => undefined,
|
||||
})
|
||||
|
||||
expect(tools).toHaveLength(2)
|
||||
for (const name of ['builtIn_sparkNoResponse', 'builtIn_sparkCommand']) {
|
||||
const entry = tools.find(tool => tool.function.name === name)
|
||||
expect(entry, `missing tool: ${name}`).toBeDefined()
|
||||
@@ -93,4 +94,22 @@ describe('tools/character/orchestrator/spark-notify', () => {
|
||||
expect(schema.properties).toEqual({})
|
||||
expect(schema.additionalProperties).toBe(false)
|
||||
})
|
||||
|
||||
it('can disable no-response and spark-command tools independently', async () => {
|
||||
const onlyCommand = await createSparkNotifyTools({
|
||||
onNoResponse: () => undefined,
|
||||
onCommands: () => undefined,
|
||||
allowNoResponse: false,
|
||||
allowSparkCommand: true,
|
||||
})
|
||||
expect(onlyCommand.tools.map(tool => tool.function.name)).toEqual(['builtIn_sparkCommand'])
|
||||
|
||||
const none = await createSparkNotifyTools({
|
||||
onNoResponse: () => undefined,
|
||||
onCommands: () => undefined,
|
||||
allowNoResponse: false,
|
||||
allowSparkCommand: false,
|
||||
})
|
||||
expect(none.tools).toHaveLength(0)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user