mirror of
https://github.com/stablyai/orca.git
synced 2026-10-21 08:03:33 +00:00
fix: preserve root separator in filename-first paths
This commit is contained in:
@@ -69,4 +69,20 @@ describe('EntryActionRow', () => {
|
||||
expect(text.indexOf('SecondaryNav.tsx')).toBeLessThan(text.indexOf('app/src/components/'))
|
||||
expect(container.querySelector('[data-tooltip-content]')?.textContent).toBe(filePath)
|
||||
})
|
||||
|
||||
it('does not duplicate the root separator for absolute root-level files', () => {
|
||||
act(() => {
|
||||
root.render(
|
||||
createElement(EntryActionRow, {
|
||||
id: 'root-file-result',
|
||||
onClick: vi.fn(),
|
||||
option: makeFileOption('/foo'),
|
||||
selected: false
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
expect(container.querySelector('button')?.textContent).toContain('foo/')
|
||||
expect(container.querySelector('button')?.textContent).not.toContain('foo//')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -96,7 +96,12 @@ export function EntryActionRow({
|
||||
function FilenameFirstPath({ path }: { path: string }): React.JSX.Element {
|
||||
const filename = basename(path)
|
||||
const directory = dirname(path)
|
||||
const directoryLabel = directory === '.' ? '' : `${directory}${path.includes('\\') ? '\\' : '/'}`
|
||||
const directoryLabel =
|
||||
directory === '.'
|
||||
? ''
|
||||
: directory.endsWith('/') || directory.endsWith('\\')
|
||||
? directory
|
||||
: `${directory}${path.includes('\\') ? '\\' : '/'}`
|
||||
|
||||
return (
|
||||
<span className="flex min-w-0 flex-1 items-center gap-1">
|
||||
|
||||
@@ -3,7 +3,8 @@ import path from 'node:path'
|
||||
import { expect, test } from './helpers/orca-app'
|
||||
import { ensureTerminalVisible, waitForActiveWorktree, waitForSessionReady } from './helpers/store'
|
||||
|
||||
const relativeFilePath = 'app/src/components/SecondaryNav.tsx'
|
||||
const relativeFilePath =
|
||||
'packages/orca/src/renderer/src/components/navigation/worktree/secondary-nav/SecondaryNav.tsx'
|
||||
|
||||
test('new-tab file results prioritize the filename and reveal the full path on hover', async ({
|
||||
orcaPage,
|
||||
@@ -26,10 +27,10 @@ test('new-tab file results prioritize the filename and reveal the full path on h
|
||||
const row = orcaPage.locator('[role="option"]').filter({ hasText: 'Open file' }).first()
|
||||
await expect(row).toBeVisible()
|
||||
await expect(row).toContainText('SecondaryNav.tsx')
|
||||
await expect(row).toContainText('app/src/components/')
|
||||
await expect(row).toContainText('packages/orca/src/renderer/src/components/navigation/')
|
||||
const rowText = await row.textContent()
|
||||
expect(rowText?.indexOf('SecondaryNav.tsx')).toBeLessThan(
|
||||
rowText?.indexOf('app/src/components/') ?? -1
|
||||
rowText?.indexOf('packages/orca/src/renderer/src/components/navigation/') ?? -1
|
||||
)
|
||||
|
||||
await row.hover({ force: true })
|
||||
|
||||
Reference in New Issue
Block a user