@@ -33,6 +33,29 @@ describe('WorkspacesClient.getMyWorkspaces', () => {
3333 expect ( workspaces [ 0 ] ! . createdAt . toISOString ( ) ) . toBe ( '2026-01-15T12:00:00.000Z' ) ;
3434 } ) ;
3535
36+ // Regression: the API sends `tdeiMetadata` inconsistently — sometimes a
37+ // JSON-encoded string, sometimes an already-parsed object. Blindly calling
38+ // JSON.parse() on the object form coerces it to "[object Object]" and throws
39+ // `SyntaxError: "[object Object]" is not valid JSON`, which used to blow up
40+ // the dashboard's <script setup>. Normalize must tolerate every form.
41+ it . each ( [
42+ [ 'a JSON-encoded string' , '{"metadata":{"foo":"bar"}}' , { metadata : { foo : 'bar' } } ] ,
43+ [ 'an already-parsed object' , { metadata : { foo : 'bar' } } , { metadata : { foo : 'bar' } } ] ,
44+ [ 'null' , null , { } ] ,
45+ [ 'an empty string' , '' , { } ] ,
46+ [ 'a malformed JSON string' , '{not json' , { } ]
47+ ] ) ( 'parses tdeiMetadata when the API returns %s' , async ( _label , raw , expected ) => {
48+ server . use (
49+ http . get ( `${ TEST_API_BASE } workspaces/mine` , ( ) => {
50+ return HttpResponse . json ( [ { id : 1 , title : 'W' , createdAt : '2026-01-15T12:00:00.000Z' , tdeiMetadata : raw } ] ) ;
51+ } )
52+ ) ;
53+
54+ const [ workspace ] = await makeClient ( ) . getMyWorkspaces ( ) ;
55+
56+ expect ( workspace ! . tdeiMetadata ) . toEqual ( expected ) ;
57+ } ) ;
58+
3659 it ( 'throws a WorkspacesClientError on a non-2xx response' , async ( ) => {
3760 // Per-test override: make the endpoint fail. Reset automatically afterEach.
3861 server . use (
0 commit comments