Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/components/modals/edit-node-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useUserStore } from "@/stores/user-store"
import { adminUpdateNode } from "@/lib/graph-api"
import { isMocksEnabled } from "@/lib/mock-data"
import { SYSTEM_ATTRIBUTES, fieldsForSchema } from "@/lib/node-schema-utils"
import { resolveNodeTitle } from "@/lib/node-display"
import {
computeMappings,
type ExactMapping,
Expand Down Expand Up @@ -377,13 +378,15 @@ export function EditNodeModal() {
// ----- Render -----
if (!isOpen || !editingNode) return null

const displayTitle = resolveNodeTitle(editingNode, schemas)

return (
<Dialog open={isOpen} onOpenChange={(open) => !open && close()}>
<DialogContent className="border-border/50 bg-card noise-bg sm:max-w-lg max-h-[90vh] flex flex-col overflow-hidden">
<DialogHeader className="shrink-0">
<DialogTitle className="font-heading text-lg tracking-wide">Edit Node</DialogTitle>
<DialogDescription className="text-sm text-muted-foreground">
Update properties for <span className="font-mono text-foreground/80">{editingNode.ref_id}</span>
Update properties for <span className="font-mono text-foreground/80">{displayTitle}</span>
</DialogDescription>
</DialogHeader>

Expand Down
36 changes: 36 additions & 0 deletions src/lib/__tests__/edit-node-modal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ import React from "react"
// Hoisted mocks
// ---------------------------------------------------------------------------

// node-display mock — controlled per test
let mockResolveNodeTitle = vi.fn((node: Record<string, unknown>) => node.ref_id as string)

vi.mock("@/lib/node-display", () => ({
resolveNodeTitle: (...args: unknown[]) => mockResolveNodeTitle(args[0] as Record<string, unknown>),
}))


const { mockAdminUpdateNode } = vi.hoisted(() => ({
mockAdminUpdateNode: vi.fn().mockResolvedValue({}),
}))
Expand Down Expand Up @@ -130,6 +138,7 @@ describe("EditNodeModal", () => {
beforeEach(() => {
vi.clearAllMocks()
mockAdminUpdateNode.mockResolvedValue({})
mockResolveNodeTitle = vi.fn((node: Record<string, unknown>) => node.ref_id as string)
closeModal()
})

Expand Down Expand Up @@ -367,6 +376,33 @@ describe("EditNodeModal", () => {
expect(mockClose).toHaveBeenCalledOnce()
})
})

// -------------------------------------------------------------------------
// DialogDescription — resolved title display
// -------------------------------------------------------------------------
describe("DialogDescription title resolution", () => {
it("shows resolved title (from title_key) in the description", () => {
mockResolveNodeTitle = vi.fn(() => "Alice")
openModal()
render(<EditNodeModal />)

expect(screen.getByText("Alice")).toBeDefined()
// Raw ref_id should NOT appear as the description span content
const description = screen.getByText(/Update properties for/)
expect(description.textContent).toContain("Alice")
expect(description.textContent).not.toContain("node-abc")
})

it("falls back to ref_id when no human-readable title exists", () => {
// Default mock already returns ref_id
mockResolveNodeTitle = vi.fn((node: Record<string, unknown>) => node.ref_id as string)
openModal()
render(<EditNodeModal />)

const description = screen.getByText(/Update properties for/)
expect(description.textContent).toContain("node-abc")
})
})
})


Loading