@@ -16,10 +16,7 @@ afterEach(async () => await server?.close());
1616
1717it ( "creates, inspects, executes, and opens Sheet, Doc, and Slide units" , async ( ) => {
1818 server = await startServer ( ":memory:" ) ;
19- const created = JSON . parse ( await run ( "create" , "sheet" , "--name" , "Demo Sheet" ) ) as {
20- readonly unitId : string ;
21- } ;
22- const sheetId = created . unitId ;
19+ const sheetId = ( await run ( "create" , "sheet" , "--name" , "Demo Sheet" ) ) . trim ( ) ;
2320
2421 const before = await run (
2522 "inspect" ,
@@ -53,55 +50,51 @@ it("creates, inspects, executes, and opens Sheet, Doc, and Slide units", async (
5350 ) as Record < string , unknown > ;
5451 expect ( execution ) . toMatchObject ( { commit : "confirmed" , revision : 2 , value : "done" } ) ;
5552
56- const document = JSON . parse ( await run ( "create" , "doc" , "--name" , "Demo Doc" ) ) as {
57- readonly unitId : string ;
58- } ;
53+ const documentId = ( await run ( "create" , "doc" , "--name" , "Demo Doc" ) ) . trim ( ) ;
5954 expect (
60- JSON . parse ( await run ( "inspect" , "document" , "--unit" , document . unitId , "--json" ) ) ,
55+ JSON . parse ( await run ( "inspect" , "document" , "--unit" , documentId , "--json" ) ) ,
6156 ) . toMatchObject ( { kind : "document" , title : "Demo Doc" } ) ;
6257 expect (
6358 JSON . parse (
6459 await run (
6560 "execute" ,
6661 "--unit" ,
67- document . unitId ,
62+ documentId ,
6863 "--code" ,
6964 'await api.executeCommand("doc.mutation.rename-doc", { unitId: doc.getId(), name: "Updated Doc" }); return doc.getName();' ,
7065 ) ,
7166 ) ,
7267 ) . toMatchObject ( { commit : "confirmed" , revision : 2 , value : "Updated Doc" } ) ;
7368 expect (
74- JSON . parse ( await run ( "inspect" , "document" , "--unit" , document . unitId , "--json" ) ) ,
69+ JSON . parse ( await run ( "inspect" , "document" , "--unit" , documentId , "--json" ) ) ,
7570 ) . toMatchObject ( { title : "Updated Doc" } ) ;
7671
77- const presentation = JSON . parse ( await run ( "create" , "slide" , "--name" , "Demo Slide" ) ) as {
78- readonly unitId : string ;
79- } ;
72+ const presentationId = ( await run ( "create" , "slide" , "--name" , "Demo Slide" ) ) . trim ( ) ;
8073 expect (
81- JSON . parse ( await run ( "inspect" , "presentation" , "--unit" , presentation . unitId , "--json" ) ) ,
74+ JSON . parse ( await run ( "inspect" , "presentation" , "--unit" , presentationId , "--json" ) ) ,
8275 ) . toMatchObject ( { kind : "presentation" , name : "Demo Slide" } ) ;
8376 expect (
8477 JSON . parse (
8578 await run (
8679 "execute" ,
8780 "--unit" ,
88- presentation . unitId ,
81+ presentationId ,
8982 "--code" ,
9083 'presentation.setName("Updated Slide"); return presentation.getName();' ,
9184 ) ,
9285 ) ,
9386 ) . toMatchObject ( { commit : "confirmed" , revision : 2 , value : "Updated Slide" } ) ;
9487
95- for ( const unitId of [ sheetId , document . unitId , presentation . unitId ] ) {
88+ for ( const unitId of [ sheetId , documentId , presentationId ] ) {
9689 const url = await run ( "open" , "--unit" , unitId , "--no-launch" ) ;
9790 const page = await ( await fetch ( url . trim ( ) ) ) . text ( ) ;
9891 expect ( page ) . toContain ( 'id="sidebar"' ) ;
9992 expect ( page ) . toContain ( 'id="app"' ) ;
10093 }
10194 expect ( await ( await fetch ( `${ server . origin } /api/units` ) ) . json ( ) ) . toMatchObject ( [
10295 { name : "Demo Sheet" , unitId : sheetId , unitType : "sheet" } ,
103- { name : "Demo Doc" , unitId : document . unitId , unitType : "doc" } ,
104- { name : "Demo Slide" , unitId : presentation . unitId , unitType : "slide" } ,
96+ { name : "Demo Doc" , unitId : documentId , unitType : "doc" } ,
97+ { name : "Demo Slide" , unitId : presentationId , unitType : "slide" } ,
10598 ] ) ;
10699 expect ( await run ( "api" , "find" , "setValues" , "--unit" , "sheet" ) ) . toContain ( "FRange.setValues" ) ;
107100 expect ( await run ( "api" , "show" , "FRange.setValues" ) ) . toContain ( "setValues" ) ;
@@ -112,19 +105,18 @@ it("restores the file list and Unit from SQLite", async () => {
112105 const databaseFile = join ( directory , "content.sqlite" ) ;
113106 try {
114107 server = await startServer ( databaseFile ) ;
115- const created = JSON . parse ( await run ( "create" , "sheet" , "--name" , "Persistent" ) ) as {
116- readonly unitId : string ;
117- } ;
108+ const unitId = ( await run ( "create" , "sheet" , "--name" , "Persistent" ) ) . trim ( ) ;
118109 await server . close ( ) ;
119110 server = undefined ;
120111
121112 server = await startServer ( databaseFile ) ;
122113 expect ( await ( await fetch ( `${ server . origin } /api/units` ) ) . json ( ) ) . toMatchObject ( [
123- { name : "Persistent" , unitId : created . unitId , unitType : "sheet" } ,
114+ { name : "Persistent" , unitId, unitType : "sheet" } ,
124115 ] ) ;
125- expect (
126- JSON . parse ( await run ( "inspect" , "workbook" , "--unit" , created . unitId , "--json" ) ) ,
127- ) . toMatchObject ( { name : "Persistent" , unitId : created . unitId } ) ;
116+ expect ( JSON . parse ( await run ( "inspect" , "workbook" , "--unit" , unitId , "--json" ) ) ) . toMatchObject ( {
117+ name : "Persistent" ,
118+ unitId,
119+ } ) ;
128120 } finally {
129121 await server ?. close ( ) ;
130122 server = undefined ;
0 commit comments