test(desktop): store-level dismiss/restore round-trip for auto projects
Adds a layout-store test beside the existing menu test: dismiss hides the row, restore brings it back, restore is idempotent. Also drops an unused helper the salvaged test file left behind.
This commit is contained in:
@@ -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 —
|
||||
|
||||
@@ -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([])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user