Files
zeekay 1b367e2b62 chore: rebase the tree onto upstream master
The tree was a debranded snapshot of upstream taken around 2026-02-20, and
upstream has moved about five months since. This replaces it with upstream
master, mechanically re-derived: bin/debrand does the rename, and the
pipeline and squashed migrations are restored from the shipped tree.

Not a merge. The previous import replaced the tree wholesale in a single
commit, so there is no shared content history to merge against. Reproducing
the rename on the new tree is what actually converges.

What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints,
compose files, LLM.md, and insights/migrations. The squashed initial
migration is load-bearing — the live database records it by name, so
upstream's ~918 individual migrations cannot come back.

Nine products are dropped as unreferenced. Twenty-one more that we do not run
are kept anyway because the core app still imports them; unpicking those is a
refactor and does not belong in a rebase.

This base does not build yet, and the reasons are not in the rename:
upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against
our 4.2, and the dependency manifests still name upstream packages that we
republish under our own names. Those are decisions, not renames.
2026-08-01 15:44:40 -07:00

80 lines
3.5 KiB
TypeScript

import '@testing-library/jest-dom'
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
import { useActions } from 'kea'
import { Dialog } from '@hanzo/elements'
import { FileSystemEntry } from '~/queries/schema/schema-general'
import { DashboardsTreeFolderMenu } from './DashboardsTreeFolderMenu'
jest.mock('kea', () => ({ ...jest.requireActual('kea'), useActions: jest.fn() }))
jest.mock('@hanzo/elements', () => ({
...jest.requireActual('@hanzo/elements'),
Dialog: { openForm: jest.fn() },
}))
// Render each menu item as a plain clickable element so we don't need the Radix DropdownMenu context.
jest.mock('lib/ui/DropdownMenu/DropdownMenu', () => ({
DropdownMenuItem: ({ children, onClick }: any) => <div onClick={onClick}>{children}</div>,
}))
const folderEntry = (path: string): FileSystemEntry => ({ id: `fs-${path}`, type: 'folder', path }) as FileSystemEntry
describe('DashboardsTreeFolderMenu', () => {
const createFolder = jest.fn()
const renameFolder = jest.fn()
const deleteFolder = jest.fn()
const openMoveToModal = jest.fn()
const openForm = Dialog.openForm as jest.Mock
afterEach(cleanup)
beforeEach(() => {
;[createFolder, renameFolder, deleteFolder, openMoveToModal, openForm].forEach((m) => m.mockClear())
;(useActions as jest.Mock).mockReturnValue({ createFolder, renameFolder, deleteFolder, openMoveToModal })
})
it('shows the full menu for a real folder', () => {
render(<DashboardsTreeFolderMenu path="Marketing" entry={folderEntry('Marketing')} />)
expect(screen.getByText('New subfolder')).toBeInTheDocument()
expect(screen.getByText('Rename')).toBeInTheDocument()
expect(screen.getByText('Move to...')).toBeInTheDocument()
expect(screen.getByText('Delete')).toBeInTheDocument()
})
it('shows only New folder for the root (no entry)', () => {
render(<DashboardsTreeFolderMenu path="" />)
expect(screen.getByText('New folder')).toBeInTheDocument()
expect(screen.queryByText('Rename')).not.toBeInTheDocument()
expect(screen.queryByText('Move to...')).not.toBeInTheDocument()
expect(screen.queryByText('Delete')).not.toBeInTheDocument()
})
it('creates a subfolder under the clicked folder', () => {
render(<DashboardsTreeFolderMenu path="Marketing" entry={folderEntry('Marketing')} />)
fireEvent.click(screen.getByText('New subfolder'))
openForm.mock.calls[0][0].onSubmit({ folderName: 'Q1' })
expect(createFolder).toHaveBeenCalledWith('Q1', 'Marketing')
})
it('renames the folder to the submitted name', () => {
const entry = folderEntry('Marketing/Q1')
render(<DashboardsTreeFolderMenu path="Marketing/Q1" entry={entry} />)
fireEvent.click(screen.getByText('Rename'))
// The rename dialog pre-fills the last path segment.
expect(openForm.mock.calls[0][0].initialValues).toEqual({ folderName: 'Q1' })
openForm.mock.calls[0][0].onSubmit({ folderName: 'Q2' })
expect(renameFolder).toHaveBeenCalledWith(entry, 'Q2')
})
it('moves and deletes via the folder entry', () => {
const entry = folderEntry('Marketing')
render(<DashboardsTreeFolderMenu path="Marketing" entry={entry} />)
fireEvent.click(screen.getByText('Move to...'))
expect(openMoveToModal).toHaveBeenCalledWith([entry])
fireEvent.click(screen.getByText('Delete'))
expect(deleteFolder).toHaveBeenCalledWith(entry)
})
})