diff --git a/apps/desktop/src/app/chat/sidebar/projects/project-menu.test.tsx b/apps/desktop/src/app/chat/sidebar/projects/project-menu.test.tsx index 8a2bb99fae..ecec22bb68 100644 --- a/apps/desktop/src/app/chat/sidebar/projects/project-menu.test.tsx +++ b/apps/desktop/src/app/chat/sidebar/projects/project-menu.test.tsx @@ -97,8 +97,6 @@ const autoProject = { path: '/auto/repo' } as unknown as SidebarProjectTree -const tipTrigger = (el: HTMLElement) => el.closest('[data-slot="tooltip-trigger"]') - const openTriggerMenu = (trigger: HTMLElement) => { // Radix's dropdown trigger opens on pointerdown (a synthetic 'click' fireEvent // alone won't do it), so fire the full mouse sequence a real click produces — diff --git a/apps/desktop/src/store/layout-dismissed-projects.test.ts b/apps/desktop/src/store/layout-dismissed-projects.test.ts index 1bfb210f7a..a8f5dad27d 100644 --- a/apps/desktop/src/store/layout-dismissed-projects.test.ts +++ b/apps/desktop/src/store/layout-dismissed-projects.test.ts @@ -1,6 +1,10 @@ -import { describe, expect, it } from 'vitest' +import { beforeEach, describe, expect, it } from 'vitest' -import { filterVisibleProjects } from './layout' +import { $dismissedAutoProjectIds, dismissAutoProject, filterVisibleProjects, restoreAutoProject } from './layout' + +beforeEach(() => { + $dismissedAutoProjectIds.set([]) +}) const auto = (id: string) => ({ id, isAuto: true as const }) const explicit = (id: string) => ({ id, isAuto: false as const }) @@ -21,4 +25,21 @@ describe('filterVisibleProjects', () => { const tree = [explicit('p_real'), auto('/www/gone')] expect(filterVisibleProjects(tree, ['p_real', '/www/gone']).map(p => p.id)).toEqual(['p_real']) }) + + it('restores a dismissed auto project (Undo round-trip) and is idempotent', () => { + const tree = [auto('/www/hide-me'), auto('/www/stays')] + dismissAutoProject('/www/hide-me') + expect(filterVisibleProjects(tree, $dismissedAutoProjectIds.get()).map(p => p.id)).toEqual(['/www/stays']) + + restoreAutoProject('/www/hide-me') + expect($dismissedAutoProjectIds.get()).toEqual([]) + expect(filterVisibleProjects(tree, $dismissedAutoProjectIds.get()).map(p => p.id)).toEqual([ + '/www/hide-me', + '/www/stays' + ]) + + // Restoring an id that isn't dismissed must not throw or mutate the list. + restoreAutoProject('/www/hide-me') + expect($dismissedAutoProjectIds.get()).toEqual([]) + }) })