test(web): scope retry status assertion
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||||
import { Profiler } from 'react'
|
import { Profiler } from 'react'
|
||||||
import { act, cleanup, fireEvent, render } from '@testing-library/react'
|
import { act, cleanup, fireEvent, render, within } from '@testing-library/react'
|
||||||
import type {
|
import type {
|
||||||
AssistantMessageNode, CommandNode, ConversationNode, ConversationSnapshot,
|
AssistantMessageNode, CommandNode, ConversationNode, ConversationSnapshot,
|
||||||
ModelRetryNode, RunningToolCall, SessionId, SessionListState, ToolResultNode,
|
ModelRetryNode, RunningToolCall, SessionId, SessionListState, ToolResultNode,
|
||||||
@@ -254,16 +254,16 @@ describe('ChatView', () => {
|
|||||||
} as const satisfies ConversationNode
|
} as const satisfies ConversationNode
|
||||||
const h = makeHarness({ nodes: [user(1, 'try'), retryNode], running: true })
|
const h = makeHarness({ nodes: [user(1, 'try'), retryNode], running: true })
|
||||||
const view = render(<h.ChatView {...h.props} />)
|
const view = render(<h.ChatView {...h.props} />)
|
||||||
const disclosure = view.container.querySelector('details')
|
const disclosure = view.container.querySelector('details') as HTMLDetailsElement
|
||||||
expect(disclosure?.dataset.active).toBe('true')
|
expect(disclosure.dataset.active).toBe('true')
|
||||||
expect(view.getByRole('status').textContent).toBe('正在重试模型请求(1/2) · 1s')
|
expect(within(disclosure).getByRole('status').textContent).toBe('正在重试模型请求(1/2) · 1s')
|
||||||
|
|
||||||
act(() => {
|
act(() => {
|
||||||
h.set({ nodes: [user(1, 'try'), retryNode, nextRetry] })
|
h.set({ nodes: [user(1, 'try'), retryNode, nextRetry] })
|
||||||
})
|
})
|
||||||
expect(view.getAllByRole('status')).toHaveLength(1)
|
expect(within(disclosure).getAllByRole('status')).toHaveLength(1)
|
||||||
expect(view.container.querySelector('details')).toBe(disclosure)
|
expect(view.container.querySelector('details')).toBe(disclosure)
|
||||||
expect(view.getByRole('status').textContent).toBe('正在重试模型请求(2/2) · 1s')
|
expect(within(disclosure).getByRole('status').textContent).toBe('正在重试模型请求(2/2) · 1s')
|
||||||
|
|
||||||
act(() => {
|
act(() => {
|
||||||
h.set({
|
h.set({
|
||||||
@@ -277,14 +277,15 @@ describe('ChatView', () => {
|
|||||||
running: false,
|
running: false,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
expect(disclosure?.dataset.active).toBeUndefined()
|
expect(disclosure.dataset.active).toBeUndefined()
|
||||||
expect(view.getByRole('status').textContent).toBe('已重试模型请求(2/2) · 1s')
|
expect(within(disclosure).getByRole('status').textContent).toBe('已重试模型请求(2/2) · 1s')
|
||||||
|
|
||||||
act(() => {
|
act(() => {
|
||||||
h.set({ nodes: [user(1, 'try'), { ...retry(6), retryState: 'cancelled' }], running: true })
|
h.set({ nodes: [user(1, 'try'), { ...retry(6), retryState: 'cancelled' }], running: true })
|
||||||
})
|
})
|
||||||
expect(disclosure?.dataset.active).toBeUndefined()
|
const cancelledDisclosure = view.container.querySelector('details') as HTMLDetailsElement
|
||||||
expect(view.getByRole('status').textContent).toContain('重试已取消')
|
expect(cancelledDisclosure.dataset.active).toBeUndefined()
|
||||||
|
expect(within(cancelledDisclosure).getByRole('status').textContent).toContain('重试已取消')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('the expanded row Inspect pill hands the call id to inspectCall', () => {
|
it('the expanded row Inspect pill hands the call id to inspectCall', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user