story-kit: merge 168_bug_agent_message_queue_limited_to_one_line
This commit is contained in:
@@ -811,7 +811,7 @@ describe("Chat message queue (Story 155)", () => {
|
||||
expect((input as HTMLTextAreaElement).value).toBe("Edit me back");
|
||||
});
|
||||
|
||||
it("subsequent submissions replace the queued message (AC5)", async () => {
|
||||
it("subsequent submissions are appended to the queue (Bug 168)", async () => {
|
||||
render(<Chat projectPath="/tmp/project" onCloseProject={vi.fn()} />);
|
||||
|
||||
await waitFor(() => expect(capturedWsHandlers).not.toBeNull());
|
||||
@@ -826,9 +826,9 @@ describe("Chat message queue (Story 155)", () => {
|
||||
fireEvent.keyDown(input, { key: "Enter", shiftKey: false });
|
||||
});
|
||||
|
||||
// Queue first replacement
|
||||
// Queue first message
|
||||
await act(async () => {
|
||||
fireEvent.change(input, { target: { value: "Original queue" } });
|
||||
fireEvent.change(input, { target: { value: "Queue 1" } });
|
||||
});
|
||||
await act(async () => {
|
||||
fireEvent.keyDown(input, { key: "Enter", shiftKey: false });
|
||||
@@ -836,17 +836,70 @@ describe("Chat message queue (Story 155)", () => {
|
||||
|
||||
await screen.findByTestId("queued-message-indicator");
|
||||
|
||||
// Queue second replacement — should overwrite the first
|
||||
// Queue second message — should be appended, not overwrite the first
|
||||
await act(async () => {
|
||||
fireEvent.change(input, { target: { value: "Replaced queue" } });
|
||||
fireEvent.change(input, { target: { value: "Queue 2" } });
|
||||
});
|
||||
await act(async () => {
|
||||
fireEvent.keyDown(input, { key: "Enter", shiftKey: false });
|
||||
});
|
||||
|
||||
const indicator = await screen.findByTestId("queued-message-indicator");
|
||||
expect(indicator).toHaveTextContent("Replaced queue");
|
||||
expect(indicator).not.toHaveTextContent("Original queue");
|
||||
// Both messages should be visible
|
||||
const indicators = await screen.findAllByTestId("queued-message-indicator");
|
||||
expect(indicators).toHaveLength(2);
|
||||
expect(indicators[0]).toHaveTextContent("Queue 1");
|
||||
expect(indicators[1]).toHaveTextContent("Queue 2");
|
||||
});
|
||||
|
||||
it("queued messages are delivered in order (Bug 168)", async () => {
|
||||
render(<Chat projectPath="/tmp/project" onCloseProject={vi.fn()} />);
|
||||
|
||||
await waitFor(() => expect(capturedWsHandlers).not.toBeNull());
|
||||
|
||||
const input = screen.getByPlaceholderText("Send a message...");
|
||||
|
||||
// Send first message to start loading
|
||||
await act(async () => {
|
||||
fireEvent.change(input, { target: { value: "First" } });
|
||||
});
|
||||
await act(async () => {
|
||||
fireEvent.keyDown(input, { key: "Enter", shiftKey: false });
|
||||
});
|
||||
|
||||
// Queue two messages
|
||||
await act(async () => {
|
||||
fireEvent.change(input, { target: { value: "Second" } });
|
||||
});
|
||||
await act(async () => {
|
||||
fireEvent.keyDown(input, { key: "Enter", shiftKey: false });
|
||||
});
|
||||
await act(async () => {
|
||||
fireEvent.change(input, { target: { value: "Third" } });
|
||||
});
|
||||
await act(async () => {
|
||||
fireEvent.keyDown(input, { key: "Enter", shiftKey: false });
|
||||
});
|
||||
|
||||
// Both messages should be visible in order
|
||||
const indicators = await screen.findAllByTestId("queued-message-indicator");
|
||||
expect(indicators).toHaveLength(2);
|
||||
expect(indicators[0]).toHaveTextContent("Second");
|
||||
expect(indicators[1]).toHaveTextContent("Third");
|
||||
|
||||
// Simulate first response completing — "Second" is sent next
|
||||
act(() => {
|
||||
capturedWsHandlers?.onUpdate([
|
||||
{ role: "user", content: "First" },
|
||||
{ role: "assistant", content: "Response 1." },
|
||||
]);
|
||||
});
|
||||
|
||||
// "Third" should remain queued; "Second" was consumed
|
||||
await waitFor(() => {
|
||||
const remaining = screen.queryAllByTestId("queued-message-indicator");
|
||||
expect(remaining).toHaveLength(1);
|
||||
expect(remaining[0]).toHaveTextContent("Third");
|
||||
});
|
||||
});
|
||||
|
||||
it("does not auto-send queued message when generation is cancelled (AC6)", async () => {
|
||||
|
||||
Reference in New Issue
Block a user