diff --git a/src/Layout.test.tsx b/src/Layout.test.tsx
new file mode 100644
index 0000000..4b913c0
--- /dev/null
+++ b/src/Layout.test.tsx
@@ -0,0 +1,50 @@
+import { render, screen } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+import { createMemoryRouter, RouterProvider } from 'react-router'
+import { expect, test } from 'vitest'
+import { BaoClient } from './api/bao'
+import { SessionProvider } from './api/session'
+import { useSession } from './api/useSession'
+import { Layout } from './Layout'
+import { Providers } from './test/providers'
+
+function SignIn() {
+ const { connect } = useSession()
+ return (
+
+ )
+}
+
+function setup() {
+ const router = createMemoryRouter([{ path: '/', element: , children: [{ index: true, element: }, { path: 'connect', element:
connect page
}] }])
+ render(
+
+
+
+
+ ,
+ )
+ return userEvent.setup()
+}
+
+test('offers Connect only while signed out', async () => {
+ const user = setup()
+ const nav = screen.getByRole('navigation', { name: 'Main' })
+ expect(nav).toHaveTextContent('Connect')
+ expect(screen.getByRole('link', { name: 'Connect' })).toHaveAttribute('href', '/connect')
+
+ await user.click(screen.getByRole('button', { name: 'sign in' }))
+ expect(screen.queryByRole('link', { name: 'Connect' })).not.toBeInTheDocument()
+ expect(screen.queryByRole('link', { name: 'Connection' })).not.toBeInTheDocument()
+})
+
+test('while signed in, the signed-in name links to the connection details', async () => {
+ const user = setup()
+ await user.click(screen.getByRole('button', { name: 'sign in' }))
+ const me = screen.getByRole('link', { name: 'alice' })
+ expect(me).toHaveAttribute('href', '/connect')
+ await user.click(me)
+ expect(screen.getByText('connect page')).toBeInTheDocument()
+})
diff --git a/src/Layout.tsx b/src/Layout.tsx
index 30023cb..f930ee7 100644
--- a/src/Layout.tsx
+++ b/src/Layout.tsx
@@ -26,10 +26,16 @@ export function Layout() {
{l.label}
))}
- {client && tokenInfo && {tokenInfo.display_name || 'token'}}
-
- {client ? 'Connection' : 'Connect'}
-
+ {client ? (
+ // Signed in: the name is the way back to the connection details and Disconnect.
+
+ {tokenInfo?.display_name || 'token'}
+
+ ) : (
+
+ Connect
+
+ )}
{notice && (
diff --git a/src/features/graph/GraphEdge.tsx b/src/features/graph/GraphEdge.tsx
index a54467d..e5d6d6c 100644
--- a/src/features/graph/GraphEdge.tsx
+++ b/src/features/graph/GraphEdge.tsx
@@ -4,6 +4,10 @@ export interface GrantEdgeData {
label: string
/** Vertical nudge so labels on edges into the same node don't sit on top of each other. */
offset: number
+ /** Touches the selected node. */
+ linked?: boolean
+ /** Another node is selected and this edge isn't one of its links. */
+ dim?: boolean
onSelect: () => void
}
@@ -12,7 +16,7 @@ export interface GrantEdgeData {
* fanned out to different rows, instead of at the midpoint where edges from one policy bunch up.
*/
export function GrantEdge({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, markerEnd, selected, data }: EdgeProps) {
- const { label, offset, onSelect } = data as unknown as GrantEdgeData
+ const { label, offset, linked, dim, onSelect } = data as unknown as GrantEdgeData
const [path] = getBezierPath({ sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition })
return (
<>
@@ -20,7 +24,7 @@ export function GrantEdge({ id, sourceX, sourceY, targetX, targetY, sourcePositi