mirror of
https://github.com/hanzoai/chat.git
synced 2026-09-30 20:51:17 +00:00
The two slices land together because neither is whole alone: the composer drops the model chip, and the header is where the replacement lives. Landing the composer by itself would have put model choice back behind the endpoint drill-down, which is the six clicks both slices exist to remove. Measured in Chromium, not argued: the picker opens onto THREE rows, each an answer rather than a provider to drill into, and a pick closes the menu — two clicks. A named model is one level deeper, behind `Advanced`, which is the whole of that disclosure. The composer row holds Add, Dictate and Send and nothing else. `e2e/specs/chrome/slice.spec.ts` is 15/15 on this commit. CURATION, where the two slices met: - `chrome.spec.ts` TOP_ROW is membership checked against Header's imports. Two files left it and neither was deleted: `Chat/PanelControls` renders nowhere at all now (it is still the only place this app defines a keyboard shortcut, so unmounting it is a decision about those shortcuts, not about this row), and `Menus/OpenSidebar` is mounted by `Agents/Marketplace` — a different surface with its own row. A file that draws no control here cannot disagree with this row's geometry, so scanning it passed for the wrong reason. ModelSelector and ConvoMenu joined; both are in the row. - Filenames now match their exports: `CanvasToggle` → `Sources`, `ExportAndShareMenu` → `Share`. `Menus/Endpoints/` held one component and an icon after the endpoint menu went, and its last outside importer left with the Settings model row, so it is flattened into `Menus/` rather than renamed to a second wrong word. - `Providers/BadgeRowContext` → `ToolsContext`. The badge row is gone; the state it held was never the row's — it is the ephemeral agent's, one field per tool, which the server reads back. TWELVE locale keys, en only, inserted as text so the other 1,691 keep their order. `com_ui_web_search` and `com_nav_settings` already existed and are reused rather than named twice. DEAD, and measured before removing: the `+` command wrote `showPlusPopoverFamily` and nothing read it — the popover it opened left with `AddedConvo`, so typing `+` set a boolean with no reader. Its atom, its permission check, its toggle and `saveBadgesState` (whose `if` block was empty) go with it, plus `store.speechToText`, `store.languageSTT` and the `BadgeItem` type, none of which had a reader. `useHandleKeyUp.spec.ts` is deleted rather than repaired: it reports `Tests: 0 total` on main — it dies at import against a module that does not exist, so it has never run, and it describes a hook signature the source never had. Typecheck is line-for-line unchanged against main with positions and the TranslationKeys union normalized: zero new error lines, six gone.
125 lines
4.9 KiB
TypeScript
125 lines
4.9 KiB
TypeScript
import { expect, test } from '@playwright/test';
|
|
import type { Locator, Page } from '@playwright/test';
|
|
import {
|
|
MOCK_ENDPOINTS,
|
|
NEW_CHAT_PATH,
|
|
messagesView,
|
|
replyPrompt,
|
|
replyText,
|
|
selectModel,
|
|
sendMessage,
|
|
} from './helpers';
|
|
|
|
const firstConversation = (page: Page) => page.getByTestId('convo-item').first();
|
|
|
|
function uniqueLabel(prefix: string) {
|
|
return `${prefix}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
}
|
|
|
|
async function openMockChat(page: Page) {
|
|
await page.goto(NEW_CHAT_PATH, { timeout: 10000 });
|
|
await selectModel(page, MOCK_ENDPOINTS[0].label);
|
|
}
|
|
|
|
async function sendAndExpectReply(page: Page, label: string) {
|
|
const prompt = replyPrompt(label);
|
|
const reply = replyText(label);
|
|
const response = await sendMessage(page, prompt);
|
|
expect(response.ok()).toBeTruthy();
|
|
await expect(messagesView(page).getByText(prompt)).toBeVisible();
|
|
await expect(messagesView(page).getByText(reply)).toBeVisible();
|
|
return { prompt, reply };
|
|
}
|
|
|
|
async function openConversationMenu(conversation: Locator) {
|
|
await conversation.hover();
|
|
await conversation.getByRole('button', { name: 'Conversation Menu Options' }).click();
|
|
}
|
|
|
|
async function renameConversation(page: Page, conversation: Locator, title: string) {
|
|
await openConversationMenu(conversation);
|
|
await page.getByRole('menuitem', { name: 'Rename' }).click();
|
|
const titleInput = conversation.getByRole('textbox', { name: 'New Conversation Title' });
|
|
await expect(titleInput).toBeVisible();
|
|
await titleInput.fill(title);
|
|
await conversation.getByRole('button', { name: 'Save' }).click();
|
|
await expect(conversation).toContainText(title);
|
|
}
|
|
|
|
test.describe('conversation management', () => {
|
|
test('loads a past sidebar conversation with its message history', async ({ page }) => {
|
|
const firstLabel = uniqueLabel('sidebar-history-first');
|
|
const secondLabel = uniqueLabel('sidebar-history-second');
|
|
|
|
await openMockChat(page);
|
|
const firstTurn = await sendAndExpectReply(page, firstLabel);
|
|
const secondTurn = await sendAndExpectReply(page, secondLabel);
|
|
const conversationUrl = page.url();
|
|
|
|
await expect(page).toHaveURL(/\/c\/[0-9a-fA-F-]{36}$/);
|
|
await expect(firstConversation(page)).toBeVisible();
|
|
|
|
await page.goto(NEW_CHAT_PATH, { timeout: 10000 });
|
|
await expect(page).toHaveURL(/\/c\/new$/);
|
|
await expect(messagesView(page).getByText(firstTurn.prompt)).toHaveCount(0);
|
|
await expect(messagesView(page).getByText(secondTurn.prompt)).toHaveCount(0);
|
|
|
|
await firstConversation(page).click();
|
|
await expect(page).toHaveURL(conversationUrl);
|
|
await expect(messagesView(page).getByText(firstTurn.prompt)).toBeVisible();
|
|
await expect(messagesView(page).getByText(firstTurn.reply)).toBeVisible();
|
|
await expect(messagesView(page).getByText(secondTurn.prompt)).toBeVisible();
|
|
await expect(messagesView(page).getByText(secondTurn.reply)).toBeVisible();
|
|
});
|
|
|
|
test('renames a conversation from the sidebar', async ({ page }) => {
|
|
const label = uniqueLabel('sidebar-rename');
|
|
const renamedTitle = `Renamed ${label}`;
|
|
|
|
await openMockChat(page);
|
|
await sendAndExpectReply(page, label);
|
|
|
|
await renameConversation(page, firstConversation(page), renamedTitle);
|
|
await page.reload({ timeout: 10000 });
|
|
await expect(page.getByTestId('convo-item').filter({ hasText: renamedTitle })).toBeVisible();
|
|
});
|
|
|
|
test('deletes a conversation, clears its messages, and blocks direct URL access', async ({
|
|
page,
|
|
}) => {
|
|
const label = uniqueLabel('sidebar-delete');
|
|
const renamedTitle = `Delete ${label}`;
|
|
|
|
await openMockChat(page);
|
|
const turn = await sendAndExpectReply(page, label);
|
|
const conversationUrl = page.url();
|
|
|
|
const conversation = firstConversation(page);
|
|
await renameConversation(page, conversation, renamedTitle);
|
|
await openConversationMenu(conversation);
|
|
await page.getByRole('menuitem', { name: 'Delete' }).click();
|
|
|
|
const dialog = page.getByRole('dialog', { name: 'Delete chat?' });
|
|
await expect(dialog).toBeVisible();
|
|
const [deleteResponse] = await Promise.all([
|
|
page.waitForResponse(
|
|
(response) =>
|
|
response.request().method() === 'DELETE' && response.url().includes('/v1/chat/convos'),
|
|
{ timeout: 30000 },
|
|
),
|
|
dialog.getByRole('button', { name: 'Delete' }).click(),
|
|
]);
|
|
expect(deleteResponse.ok()).toBeTruthy();
|
|
|
|
await expect(page).toHaveURL(/\/c\/new$/);
|
|
await expect(page.getByTestId('convo-item').filter({ hasText: renamedTitle })).toHaveCount(0);
|
|
await expect(messagesView(page).getByText(turn.prompt)).toHaveCount(0);
|
|
await expect(messagesView(page).getByText(turn.reply)).toHaveCount(0);
|
|
|
|
await page.goto(conversationUrl, { timeout: 10000 });
|
|
await expect(page.getByRole('textbox', { name: 'Message input' })).toBeVisible();
|
|
await expect(messagesView(page).getByText(turn.prompt)).toHaveCount(0);
|
|
await expect(messagesView(page).getByText(turn.reply)).toHaveCount(0);
|
|
});
|
|
});
|