Files
archie/e2e/checks/chat-dock-drafts.cjs
sam 3f092c0704
ci/woodpecker/pr/quality Pipeline was successful
Quality / check (pull_request) Canceled after 0s
test(e2e): chat dock browser checks (#1886)
2026-11-12 23:08:02 +11:00

43 lines
2.0 KiB
JavaScript

// Each conversation keeps its own unsent text and attached tasks. Starting a
// new chat opens an empty composer, switching back restores the earlier
// draft, and hiding and reopening the conversation loses nothing.
const assert = require('node:assert/strict');
const h = require('./helpers/chat-dock.cjs');
module.exports = async ({ page, go, shot }) => {
await page.route('**/api/tasks?*', (route) =>
route.fulfill({ contentType: 'application/json', body: JSON.stringify([{ id: 1861, title: 'Task picker', status: 'running' }]) }),
);
await h.load(page, go);
await h.expand(page);
const composer = h.composerOf(page);
const tags = page.getByRole('list', { name: 'Attached tasks' });
await composer.fill('draft for the first chat');
await composer.fill('#');
await page.getByRole('listbox', { name: 'Tasks' }).getByRole('option').first().click();
await tags.getByText('#1861').waitFor();
await composer.fill('draft for the first chat');
await page.getByRole('button', { name: 'New chat' }).click();
await h.until(async () => (await composer.inputValue()) === '' && (await tags.count()) === 0, 'a new chat inherited the first chat draft');
await composer.fill('draft for the second chat');
await h.hideOf(page).click();
await h.expand(page);
assert.equal(await composer.inputValue(), 'draft for the second chat', 'hiding the conversation lost the draft');
const pick = async (index) => {
await page.getByRole('combobox', { name: 'Conversation' }).click();
await page.getByRole('option').nth(index).click();
};
await pick(1);
await h.until(async () => (await composer.inputValue()) === 'draft for the first chat', 'switching back did not restore the first draft');
await tags.getByText('#1861').waitFor();
await shot('first-chat-draft');
await pick(0);
await h.until(async () => (await composer.inputValue()) === 'draft for the second chat', 'switching forward did not restore the second draft');
assert.equal(await tags.count(), 0, 'the first chat task tag leaked into the second chat');
};