33import assert from 'node:assert/strict' ;
44import test from 'node:test' ;
55import type { AuthModule } from '../auth/types.js' ;
6- import type { ProjectNote } from '../notes/notesTypes.js' ;
6+ import type { ProjectNote , ProjectNoteHeader } from '../notes/notesTypes.js' ;
77import { diskd } from '../sdk/diskd.js' ;
88
99type FetchCall = { readonly url : string ; readonly init ?: RequestInit } ;
@@ -24,6 +24,16 @@ const stubNote: ProjectNote = {
2424 updatedAt : '2026-05-16T10:00:00.000Z' ,
2525} ;
2626
27+ const stubHeader : ProjectNoteHeader = {
28+ id : NOTE_ID ,
29+ projectId : PROJECT_ID ,
30+ name : 'Architecture note' ,
31+ contentPreview : '# Architecture' ,
32+ params : { pin : false , order : 0 } ,
33+ createdAt : '2026-05-16T10:00:00.000Z' ,
34+ updatedAt : '2026-05-16T10:00:00.000Z' ,
35+ } ;
36+
2737/** Build a deterministic auth module so Notes client tests assert SDK headers. */
2838const makeAuth = ( ) : AuthModule => ( {
2939 signIn : async ( ) => { } ,
@@ -118,6 +128,34 @@ test('notes.read sends GET with noteId path param and bound projectId query', as
118128 ) ;
119129} ) ;
120130
131+ test ( 'notes.list sends GET with bound projectId query and returns headers' , async ( ) => {
132+ /* REQUIREMENT enabling:dev/platform-api/sdk -- Notes list uses the project-scoped project-notes API. */
133+ const url = 'http://app-service:3000' ;
134+
135+ await withFetchMock (
136+ ( ) =>
137+ new Response ( JSON . stringify ( [ stubHeader ] ) , {
138+ status : 200 ,
139+ headers : { 'Content-Type' : 'application/json' } ,
140+ } ) ,
141+ async ( calls ) => {
142+ const client = diskd . platform . notes ( {
143+ auth : makeAuth ( ) ,
144+ scope : { scopeType : 'project' , projectId : PROJECT_ID } ,
145+ url,
146+ } ) ;
147+ const result = await client . list ( ) ;
148+
149+ assert . deepEqual ( result , [ stubHeader ] ) ;
150+ assert . equal (
151+ calls [ 0 ] ?. url ,
152+ `http://app-service:3000/api/project-notes?projectId=${ PROJECT_ID } `
153+ ) ;
154+ assert . equal ( calls [ 0 ] ?. init ?. method , 'GET' ) ;
155+ }
156+ ) ;
157+ } ) ;
158+
121159test ( 'notes client throws on HTTP error with parsed message' , async ( ) => {
122160 const url = 'http://app-service:3000' ;
123161
0 commit comments