mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 04:11:10 -05:00
Improving test coverage
This commit is contained in:
@@ -107,21 +107,31 @@ describe('ChatView', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('Streaming State', () => {
|
describe('Streaming State', () => {
|
||||||
it('should show cancel button while streaming', () => {
|
it('should show cancel button while streaming and trigger cancel on click', async () => {
|
||||||
mockState.clineMessages = [
|
mockState.clineMessages = [
|
||||||
{
|
{
|
||||||
type: 'say',
|
type: 'say',
|
||||||
|
say: 'task',
|
||||||
|
ts: Date.now(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'say',
|
||||||
|
say: 'text',
|
||||||
partial: true,
|
partial: true,
|
||||||
ts: Date.now(),
|
ts: Date.now(),
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
renderChatView()
|
renderChatView()
|
||||||
|
|
||||||
const buttons = screen.queryAllByRole('button')
|
const cancelButton = screen.getByText('Cancel')
|
||||||
expect(buttons.length).toBeGreaterThan(0)
|
await userEvent.click(cancelButton)
|
||||||
|
|
||||||
|
expect(vscode.postMessage).toHaveBeenCalledWith({
|
||||||
|
type: 'cancelTask'
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should show terminate button when task is paused', () => {
|
it('should show terminate button when task is paused and trigger terminate on click', async () => {
|
||||||
mockState.clineMessages = [
|
mockState.clineMessages = [
|
||||||
{
|
{
|
||||||
type: 'ask',
|
type: 'ask',
|
||||||
@@ -131,22 +141,31 @@ describe('ChatView', () => {
|
|||||||
]
|
]
|
||||||
renderChatView()
|
renderChatView()
|
||||||
|
|
||||||
const buttons = screen.queryAllByRole('button')
|
const terminateButton = screen.getByText('Terminate')
|
||||||
expect(buttons.length).toBeGreaterThan(0)
|
await userEvent.click(terminateButton)
|
||||||
|
|
||||||
|
expect(vscode.postMessage).toHaveBeenCalledWith({
|
||||||
|
type: 'clearTask'
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should show retry button when API error occurs', () => {
|
it('should show retry button when API error occurs and trigger retry on click', async () => {
|
||||||
mockState.clineMessages = [
|
mockState.clineMessages = [
|
||||||
{
|
{
|
||||||
type: 'say',
|
type: 'ask',
|
||||||
say: 'error',
|
ask: 'api_req_failed',
|
||||||
ts: Date.now(),
|
ts: Date.now(),
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
renderChatView()
|
renderChatView()
|
||||||
|
|
||||||
const buttons = screen.queryAllByRole('button')
|
const retryButton = screen.getByText('Retry')
|
||||||
expect(buttons.length).toBeGreaterThan(0)
|
await userEvent.click(retryButton)
|
||||||
|
|
||||||
|
expect(vscode.postMessage).toHaveBeenCalledWith({
|
||||||
|
type: 'askResponse',
|
||||||
|
askResponse: 'yesButtonClicked'
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user