Skip to content
Closed
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
2 changes: 1 addition & 1 deletion src/components/layout/node-preview-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ export function NodePreviewPanel({ node, onBack, schemas }: NodePreviewPanelProp
{dateStr && (
<span className="text-[11px] font-mono text-muted-foreground">{dateStr}</span>
)}
{sats !== null && (
{!hideBoost && sats !== null && (
<div className="flex items-center gap-1 text-[11px] font-mono text-amber-400">
<Zap className="h-3 w-3" />
<span>{sats}</span>
Expand Down
25 changes: 24 additions & 1 deletion src/lib/__tests__/my-content-page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ describe("MyContentPanel", () => {
beforeEach(() => {
vi.clearAllMocks()
myContentUserOverrides = {}
mockGetL402Value = ""
})

it("renders items with processing banner", async () => {
Expand Down Expand Up @@ -189,7 +190,7 @@ describe("MyContentPanel", () => {
expect(screen.queryByText("sats")).not.toBeInTheDocument()
})

it("hides boost sats display when isAdmin is true", async () => {
it("hides boost sats display for admin", async () => {
mockApiGet.mockResolvedValue({
nodes: [
{
Expand All @@ -213,6 +214,28 @@ describe("MyContentPanel", () => {
})
expect(screen.queryByText("sats")).not.toBeInTheDocument()
})

it("hides boost sats display for L402-only user (no pubkey)", async () => {
mockApiGet.mockResolvedValue({
nodes: [
{
node_type: "Tweet",
ref_id: "ref-1",
properties: { name: "Bitcoin is freedom", status: "complete", boost: 75 },
},
],
totalCount: 1,
totalProcessing: 0,
})
// L402-only: no pubKey but has a valid L402 token
myContentUserOverrides = { pubKey: "", routeHint: "", isAdmin: false }
mockGetL402Value = "l402-token-abc"
render(<MyContentPanel onClose={() => {}} />)
await waitFor(() => {
expect(screen.getByText("Bitcoin is freedom")).toBeInTheDocument()
})
expect(screen.queryByText("sats")).not.toBeInTheDocument()
})
})

describe("MyContentPanel – Stakwork badge link", () => {
Expand Down
29 changes: 28 additions & 1 deletion src/lib/__tests__/node-preview-panel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,10 @@ describe("NodePreviewPanel – core property rendering", () => {
})
})

it("shows sats counter when boost is a positive number", async () => {
it("shows sats counter when boost is a positive number (non-contributor, non-admin)", async () => {
const node = makeUnlockedNode({ boost: 50 })
mockApiGet.mockResolvedValue(makeGraphData(node))
userStoreOverrides = { pubKey: "03other", routeHint: "", isAdmin: false }

render(<NodePreviewPanel node={BASE_NODE} onBack={vi.fn()} schemas={[]} />)

Expand All @@ -397,6 +398,32 @@ describe("NodePreviewPanel – core property rendering", () => {
})
})

it("hides sats counter when contributor (hideBoost=true)", async () => {
const nodeWithPubkey = makeUnlockedNode({ boost: 50, pubkey: "03abc" })
mockApiGet.mockResolvedValue(makeGraphData(nodeWithPubkey))
userStoreOverrides = { pubKey: "03abc", routeHint: "", isAdmin: false }

render(<NodePreviewPanel node={{ ref_id: "abc", node_type: "Topic", properties: { name: "Test Node", pubkey: "03abc" } }} onBack={vi.fn()} schemas={[]} />)

await waitFor(() => {
expect(screen.getByText("Test Node")).toBeInTheDocument()
})
expect(screen.queryByText("sats")).toBeNull()
})

it("hides sats counter when admin (hideBoost=true)", async () => {
const node = makeUnlockedNode({ boost: 99 })
mockApiGet.mockResolvedValue(makeGraphData(node))
userStoreOverrides = { pubKey: "03admin", routeHint: "", isAdmin: true }

render(<NodePreviewPanel node={BASE_NODE} onBack={vi.fn()} schemas={[]} />)

await waitFor(() => {
expect(screen.getByText("Test Node")).toBeInTheDocument()
})
expect(screen.queryByText("sats")).toBeNull()
})

it("does not render core properties row when none of status/date/boost are present", async () => {
const node = makeUnlockedNode({})
mockApiGet.mockResolvedValue(makeGraphData(node))
Expand Down
Loading