11import { h , render , rerender } from "preact" ;
22import { testBrowser } from "../tools/tester" ;
3+ import { NotebookPage , ProfilePage } from "./app" ;
34import { cellExecuteQueue } from "./components/cell" ;
45import { Notebook } from "./components/notebook" ;
56import * as db from "./db" ;
6- import * as nb from "./notebook_root" ;
77import { assert , assertEqual , createResolvable , delay } from "./util" ;
88
99const DOC_TITLE = "Anonymous Notebook" ;
1010
11- testBrowser ( async function notebook_NotebookRoot ( ) {
12- const mdb = db . enableMock ( ) ;
13- resetPage ( ) ;
14- const el = h ( nb . NotebookRoot , { } ) ;
15- render ( el , document . body ) ;
16- await flush ( ) ;
17- assertEqual ( mdb . counts , { queryLatest : 1 } ) ;
18- const c = document . body . getElementsByTagName ( "div" ) [ 0 ] ;
19- assertEqual ( c . className , "notebook" ) ;
20- } ) ;
21-
2211testBrowser ( async function notebook_Notebook ( ) {
2312 const mdb = db . enableMock ( ) ;
2413 await renderAnonNotebook ( ) ;
@@ -140,7 +129,7 @@ testBrowser(async function notebook_profile() {
140129} ) ;
141130
142131testBrowser ( async function notebook_executeQueue ( ) {
143- const { notebookRef } = await renderAnonNotebook ( ) ;
132+ const notebookRef = await renderAnonNotebook ( ) ;
144133 // All the cells must be executed now.
145134 assertEqual ( cellExecuteQueue . length , 0 ) ;
146135 const cell1 = await notebookRef . insertCell ( 2 , "a = 0" ) ;
@@ -163,7 +152,7 @@ testBrowser(async function notebook_executeQueue() {
163152
164153testBrowser ( async function notebook_urlImport ( ) {
165154 db . enableMock ( ) ;
166- const { notebookRef } = await renderAnonNotebook ( ) ;
155+ const notebookRef = await renderAnonNotebook ( ) ;
167156 const testdataUrl = `${ location . origin } /repo/src/testdata` ;
168157
169158 const cell1 = await notebookRef . insertCell ( 1 , `
@@ -196,27 +185,32 @@ function resetPage() {
196185function renderProfile ( profileUid : string ) {
197186 const promise = createResolvable ( ) ;
198187 resetPage ( ) ;
199- const el = h ( nb . NotebookRoot , {
200- onReady : promise . resolve ,
201- profileUid
188+ const el = h ( ProfilePage , {
189+ matches : {
190+ userId : profileUid
191+ } ,
192+ onReady : promise . resolve
202193 } ) ;
203194 render ( el , document . body ) ;
204195 return promise ;
205196}
206197
207- async function renderAnonNotebook ( ) : Promise < nb . NotebookRoot > {
198+ async function renderAnonNotebook ( ) : Promise < Notebook > {
208199 const promise = createResolvable ( ) ;
209200 resetPage ( ) ;
210- let notebookRoot : nb . NotebookRoot ;
211- const el = h ( nb . NotebookRoot , {
212- nbId : "default" ,
201+ let notebookRoot ;
202+ const el = h ( NotebookPage , {
203+ matches : {
204+ nbId : "default"
205+ } ,
213206 onReady : promise . resolve ,
214- ref : n => ( notebookRoot = n )
207+ ref : ref => ( notebookRoot = ref )
215208 } ) ;
216209 render ( el , document . body ) ;
217210 await promise ;
218- await notebookRoot . notebookRef . isReady ;
219- return notebookRoot ;
211+ const notebookRef = notebookRoot . componentRef ;
212+ await notebookRef . isReady ;
213+ return notebookRef ;
220214}
221215
222216async function renderNotebook ( ) : Promise < Notebook > {
0 commit comments