Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
test(desktop): 区分置顶拖拽夹具的显示模式
david683fe9b282f7
diff --git a/apps/desktop/scripts/check-pinned-native-drag.mjs b/apps/desktop/scripts/check-pinned-native-drag.mjsindex b2924721c4..281bab3742 100644--- a/apps/desktop/scripts/check-pinned-native-drag.mjs+++ b/apps/desktop/scripts/check-pinned-native-drag.mjs@@ -120,6 +120,7 @@ try {const order = async () => JSON.parse(await page.getByTestId('order').textContent());const initial = ['project-a', 'task', 'project-b', 'project-c'];for (const theme of ['light', 'dark']) {+ let textRowHeight;for (const [mode, columns] of [['text', 1],['list', 1],@@ -130,6 +131,17 @@ try {const url = `http://fixture.local/?theme=${theme}&mode=${mode}&columns=${columns}`;await page.goto(url);await page.getByTestId('order').waitFor();+ const rowHeight = (await page.getByTestId('task').boundingBox()).height;+ const preview = page.getByTestId('task-preview');+ if (mode === 'text') {+ assert.equal(await preview.count(), 0, 'compact text rows must not have a preview');+ textRowHeight = rowHeight;+ } else {+ assert.equal(await preview.textContent(), 'Latest task message preview');+ if (mode === 'list') {+ assert(rowHeight > textRowHeight, 'list rows must include a separate preview line');+ }+ }const title = page.getByTestId('project-a-title');await drag(title, page.getByTestId('project-c-title'));await page.waitForFunction(@@ -141,6 +153,20 @@ try {`${theme}/${mode}/${columns}: project must reorder`,);+ await page.goto(url);+ await drag(+ page.getByTestId(mode === 'text' ? 'task-title' : 'task-preview'),+ page.getByTestId('project-c-title'),+ );+ await page.waitForFunction(+ () => Number(document.querySelector('[data-testid="writes"]').textContent) > 0,+ );+ assert.notEqual(+ (await order()).indexOf('task'),+ initial.indexOf('task'),+ `${theme}/${mode}/${columns}: task title/preview must start a reorder`,+ );+await page.goto(url);await page.getByTestId('project-a')@@ -160,7 +186,7 @@ try {assert.deepEqual(await order(), initial, 'outside drops must not save');assert.equal(await page.getByTestId('writes').textContent(), '0');console.log(- `PASS ${theme}/${mode}/${columns}: reorder, controls, child boundary, Escape, outside drop`,+ `PASS ${theme}/${mode}/${columns}: row structure, project/task reorder, controls, child boundary, Escape, outside drop`,);}}diff --git a/apps/desktop/scripts/fixtures/pinned-native-drag.tsx b/apps/desktop/scripts/fixtures/pinned-native-drag.tsxindex 462a811f86..e148c11580 100644--- a/apps/desktop/scripts/fixtures/pinned-native-drag.tsx+++ b/apps/desktop/scripts/fixtures/pinned-native-drag.tsx@@ -17,37 +17,75 @@ function App() {const [items, setItems] = useState(['project-a', 'task', 'project-b', 'project-c']);const [writes, setWrites] = useState(0);const [clicks, setClicks] = useState(0);- const renderItem = (id: string) =>- id === 'task' ? (+ // Reduced row structures follow PinnedSection: SessionItem in text mode,+ // SessionCard's title/preview in list/card mode. Only sorting is production+ // mounted here; the complete session components are covered in Desktop QA.+ const renderTask = () => (+ <div+ data-testid="task"+ data-split-group-drag-source="true"+ draggable+ className={+ mode === 'text'+ ? 'flex h-8 items-center gap-2.5 rounded-lg px-3'+ : mode === 'list'+ ? 'relative w-full overflow-hidden rounded-lg px-3 py-2'+ : 'rounded-xl border border-[var(--cmd-palette-border)] bg-[var(--surface-elevated)] p-2'+ }+ >+ <div draggable={false} className="flex min-w-0 items-center gap-2">+ <span data-testid="task-title" className="min-w-0 truncate">+ Pinned task+ </span>+ </div>+ {mode !== 'text' && (+ <p+ data-testid="task-preview"+ draggable={false}+ className="mt-1 truncate text-xs leading-[1.45] text-[var(--text-secondary)]"+ >+ Latest task message preview+ </p>+ )}+ </div>+ );+ const renderProject = (id: string) => (+ <div data-testid={id} className="rounded-lg bg-[var(--surface-elevated)]"><div- data-testid={id}- data-split-group-drag-source="true"- draggable- className="flex h-10 items-center rounded-lg bg-[var(--surface-elevated)] px-3"+ data-project-header="true"+ role="button"+ tabIndex={0}+ className="flex h-10 select-none items-center gap-2 px-3">- Pinned task+ <span data-testid={`${id}-title`} className="min-w-0 flex-1">+ {id}+ </span>+ <button type="button" onClick={() => setClicks((n) => n + 1)}>+ Action+ </button></div>- ) : (- <div data-testid={id} className="rounded-lg bg-[var(--surface-elevated)]">- <div- data-project-header="true"- role="button"- tabIndex={0}- className="flex h-10 select-none items-center gap-2 px-3"- >- <span data-testid={`${id}-title`} className="min-w-0 flex-1">- {id}- </span>- <button type="button" onClick={() => setClicks((n) => n + 1)}>- Action- </button>- </div>- <div data-no-drag className="p-2">- <input aria-label={`${id} rename`} defaultValue="Rename" className="w-full" />- <div data-testid={`${id}-child`}>Child task</div>- </div>+ <div data-no-drag className="p-2">+ <input aria-label={`${id} rename`} defaultValue="Rename" className="w-full" />+ <div data-testid={`${id}-child`}>Child task</div>+ </div>+ </div>+ );+ const renderItem = (id: string) => {+ if (id === 'task') return renderTask();+ const project = renderProject(id);+ if (mode === 'text') return project;+ return (+ <div+ className={+ mode === 'list'+ ? 'border-b border-[var(--cmd-palette-border)] py-0.5'+ : 'rounded-xl border border-[var(--cmd-palette-border)] bg-[var(--surface-elevated)] p-1'+ }+ >+ {project}</div>);+ };const props = {items,getId: (id: string) => id,@@ -68,7 +106,7 @@ function App() {{mode === 'card' ? (<CardMasonry {...props} />) : (- <SortableList {...props} className="flex flex-col gap-1" />+ <SortableList {...props} className="flex flex-col gap-0.5" />)}</div><output data-testid="order">{JSON.stringify(items)}</output>