1
1
import { h , render , rerender } from "preact" ;
2
2
import { testBrowser } from "../tools/tester" ;
3
+ import { NotebookPage , ProfilePage } from "./app" ;
3
4
import { cellExecuteQueue } from "./components/cell" ;
4
5
import { Notebook } from "./components/notebook" ;
5
6
import * as db from "./db" ;
6
- import * as nb from "./notebook_root" ;
7
7
import { assert , assertEqual , createResolvable , delay } from "./util" ;
8
8
9
9
const DOC_TITLE = "Anonymous Notebook" ;
10
10
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
-
22
11
testBrowser ( async function notebook_Notebook ( ) {
23
12
const mdb = db . enableMock ( ) ;
24
13
await renderAnonNotebook ( ) ;
@@ -140,7 +129,7 @@ testBrowser(async function notebook_profile() {
140
129
} ) ;
141
130
142
131
testBrowser ( async function notebook_executeQueue ( ) {
143
- const { notebookRef } = await renderAnonNotebook ( ) ;
132
+ const notebookRef = await renderAnonNotebook ( ) ;
144
133
// All the cells must be executed now.
145
134
assertEqual ( cellExecuteQueue . length , 0 ) ;
146
135
const cell1 = await notebookRef . insertCell ( 2 , "a = 0" ) ;
@@ -163,7 +152,7 @@ testBrowser(async function notebook_executeQueue() {
163
152
164
153
testBrowser ( async function notebook_urlImport ( ) {
165
154
db . enableMock ( ) ;
166
- const { notebookRef } = await renderAnonNotebook ( ) ;
155
+ const notebookRef = await renderAnonNotebook ( ) ;
167
156
const testdataUrl = `${ location . origin } /repo/src/testdata` ;
168
157
169
158
const cell1 = await notebookRef . insertCell ( 1 , `
@@ -196,27 +185,32 @@ function resetPage() {
196
185
function renderProfile ( profileUid : string ) {
197
186
const promise = createResolvable ( ) ;
198
187
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
202
193
} ) ;
203
194
render ( el , document . body ) ;
204
195
return promise ;
205
196
}
206
197
207
- async function renderAnonNotebook ( ) : Promise < nb . NotebookRoot > {
198
+ async function renderAnonNotebook ( ) : Promise < Notebook > {
208
199
const promise = createResolvable ( ) ;
209
200
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
+ } ,
213
206
onReady : promise . resolve ,
214
- ref : n => ( notebookRoot = n )
207
+ ref : ref => ( notebookRoot = ref )
215
208
} ) ;
216
209
render ( el , document . body ) ;
217
210
await promise ;
218
- await notebookRoot . notebookRef . isReady ;
219
- return notebookRoot ;
211
+ const notebookRef = notebookRoot . componentRef ;
212
+ await notebookRef . isReady ;
213
+ return notebookRef ;
220
214
}
221
215
222
216
async function renderNotebook ( ) : Promise < Notebook > {
0 commit comments