@@ -298,7 +298,133 @@ test.describe('Notebook entry tests', () => {
298
298
await page . locator ( '.c-notebook__drag-area' ) . click ( ) ;
299
299
await expect ( page . getByLabel ( 'Notebook Entry Input' ) ) . toBeVisible ( ) ;
300
300
await expect ( page . getByLabel ( 'Notebook Entry' , { exact : true } ) ) . toHaveClass ( / i s - s e l e c t e d / ) ;
301
+ await expect ( page . getByLabel ( 'Save notebook entry' ) ) . toBeVisible ( ) ;
301
302
} ) ;
303
+
304
+ test ( "A new entry that's being created can be saved via ctrl+enter shortcut" , async ( {
305
+ page
306
+ } ) => {
307
+ // Navigate to the notebook object
308
+ await page . goto ( notebookObject . url ) ;
309
+
310
+ // Click .c-notebook__drag-area to create a new notebook entry
311
+ await page . locator ( '.c-notebook__drag-area' ) . click ( ) ;
312
+
313
+ //verify visible elements
314
+ await expect ( page . getByLabel ( 'Notebook Entry Input' ) ) . toBeVisible ( ) ;
315
+ await expect ( page . getByLabel ( 'Delete this entry' ) ) . toBeHidden ( ) ;
316
+ await expect ( page . getByLabel ( 'Notebook Entry' , { exact : true } ) ) . toHaveClass ( / i s - s e l e c t e d / ) ;
317
+ await expect ( page . getByLabel ( 'Save notebook entry' ) ) . toBeVisible ( ) ;
318
+
319
+ //add text to textarea
320
+ const testText = 'test text' ;
321
+ await page . getByLabel ( 'Notebook Entry Input' ) . fill ( testText ) ;
322
+
323
+ const textareaVal = await page . getByLabel ( 'Notebook Entry Input' ) . inputValue ( ) ;
324
+ await expect ( textareaVal ) . toBe ( testText ) ;
325
+
326
+ //press "Control+Enter" to save
327
+ await nbUtils . commitEntryViaShortcutKey ( page ) ;
328
+
329
+ //verify notebook entry is saved
330
+ await expect ( page . locator ( '.c-ne__input' ) ) . toBeHidden ( ) ;
331
+ await expect ( page . getByLabel ( 'Notebook Entry Input' ) ) . toBeHidden ( ) ;
332
+ await expect ( page . getByLabel ( 'Save notebook entry' ) ) . toBeHidden ( ) ;
333
+
334
+ await expect ( page . getByLabel ( 'Delete this entry' ) ) . toBeVisible ( ) ;
335
+ await expect ( page . getByLabel ( 'Notebook Entry Display' ) ) . toBeVisible ( ) ;
336
+ await expect ( page . getByLabel ( 'Notebook Entry Display' ) ) . toContainText ( testText ) ;
337
+ } ) ;
338
+
339
+ test ( "A new entry that's being created can be canceled via the escape key" , async ( { page } ) => {
340
+ // Navigate to the notebook object
341
+ await page . goto ( notebookObject . url ) ;
342
+
343
+ // Click .c-notebook__drag-area to create a new notebook entry
344
+ await page . locator ( '.c-notebook__drag-area' ) . click ( ) ;
345
+
346
+ //verify visible elements
347
+ await expect ( page . getByLabel ( 'Notebook Entry Input' ) ) . toBeVisible ( ) ;
348
+ await expect ( page . getByLabel ( 'Delete this entry' ) ) . toBeHidden ( ) ;
349
+ await expect ( page . getByLabel ( 'Notebook Entry' , { exact : true } ) ) . toHaveClass ( / i s - s e l e c t e d / ) ;
350
+ await expect ( page . getByLabel ( 'Save notebook entry' ) ) . toBeVisible ( ) ;
351
+
352
+ //add text to textarea
353
+ const testText = 'test text' ;
354
+ await page . getByLabel ( 'Notebook Entry Input' ) . fill ( testText ) ;
355
+
356
+ const textareaVal = await page . getByLabel ( 'Notebook Entry Input' ) . inputValue ( ) ;
357
+ await expect ( textareaVal ) . toBe ( testText ) ;
358
+
359
+ //press "Escape" key to cancel
360
+ await nbUtils . cancelEntry ( page ) ;
361
+
362
+ //verify notebook entry is gone
363
+ await expect ( page . locator ( '.c-ne__input' ) ) . toBeHidden ( ) ;
364
+ await expect ( page . getByLabel ( 'Notebook Entry Input' ) ) . toBeHidden ( ) ;
365
+ await expect ( page . getByLabel ( 'Delete this entry' ) ) . toBeHidden ( ) ;
366
+ await expect ( page . getByLabel ( 'Save notebook entry' ) ) . toBeHidden ( ) ;
367
+ } ) ;
368
+
369
+ test ( "An existing entry that's being edited can be canceled via the escape key" , async ( {
370
+ page
371
+ } ) => {
372
+ // Navigate to the notebook object
373
+ await page . goto ( notebookObject . url ) ;
374
+
375
+ const testText = 'test text' ;
376
+ const otherText = 'other text' ;
377
+
378
+ //create notebook entry
379
+ await nbUtils . enterTextEntry ( page , testText ) ;
380
+
381
+ //verify entry
382
+ await expect ( page . getByLabel ( 'Notebook Entry' , { exact : true } ) ) . toBeVisible ( ) ;
383
+ await expect ( page . getByLabel ( 'Notebook Entry Display' ) ) . toContainText ( testText ) ;
384
+
385
+ //make entry the active selection
386
+ await page . getByLabel ( 'Notebook Entry' , { exact : true } ) . click ( ) ;
387
+
388
+ //edit entry (make textarea visible for editing)
389
+ await page . getByLabel ( 'Notebook Entry Display' , { exact : true } ) . click ( ) ;
390
+ await expect ( page . getByLabel ( 'Notebook Entry Input' ) ) . toBeVisible ( ) ;
391
+
392
+ //edit textarea value
393
+ await page . getByLabel ( 'Notebook Entry Input' ) . fill ( otherText ) ;
394
+ const textareaVal = await page . getByLabel ( 'Notebook Entry Input' ) . inputValue ( ) ;
395
+ await expect ( textareaVal ) . toBe ( otherText ) ;
396
+
397
+ //press "Escape" key
398
+ await nbUtils . cancelEntry ( page ) ;
399
+
400
+ //verify entry reverts back to the original value
401
+ await expect ( page . getByLabel ( 'Notebook Entry Input' ) ) . toBeHidden ( ) ;
402
+ await expect ( page . getByLabel ( 'Notebook Entry Display' ) ) . toContainText ( testText ) ;
403
+ await expect ( page . getByLabel ( 'Notebook Entry Display' ) ) . not . toContainText ( otherText ) ;
404
+ } ) ;
405
+
406
+ test ( 'The trashcan is not visible when notebook entry is in edit mode' , async ( { page } ) => {
407
+ // Navigate to the notebook object
408
+ await page . goto ( notebookObject . url ) ;
409
+
410
+ const testText = 'test text' ;
411
+
412
+ //create notebook entry
413
+ await nbUtils . enterTextEntry ( page , testText ) ;
414
+
415
+ //verify entry
416
+ await expect ( page . getByLabel ( 'Notebook Entry' , { exact : true } ) ) . toBeVisible ( ) ;
417
+ await expect ( page . getByLabel ( 'Delete this entry' , { exact : true } ) ) . toBeVisible ( ) ;
418
+
419
+ //make entry the active selection
420
+ await page . getByLabel ( 'Notebook Entry' , { exact : true } ) . click ( ) ;
421
+
422
+ //edit entry (make textarea visible for editing)
423
+ await page . getByLabel ( 'Notebook Entry Display' , { exact : true } ) . click ( ) ;
424
+ await expect ( page . getByLabel ( 'Notebook Entry Input' ) ) . toBeVisible ( ) ;
425
+ await expect ( page . getByLabel ( 'Delete this entry' , { exact : true } ) ) . toBeHidden ( ) ;
426
+ } ) ;
427
+
302
428
test ( 'When an object is dropped into a notebook, a new entry is created and it should be focused' , async ( {
303
429
page
304
430
} ) => {
@@ -351,7 +477,38 @@ test.describe('Notebook entry tests', () => {
351
477
await expect ( embed ) . toHaveClass ( / i c o n - p l o t - o v e r l a y / ) ;
352
478
expect ( embedName ) . toBe ( overlayPlot . name ) ;
353
479
} ) ;
354
- test . fixme ( 'new entries persist through navigation events without save' , async ( { page } ) => { } ) ;
480
+
481
+ test ( 'new entries persist through navigation events without save' , async ( { page } ) => {
482
+ // Navigate to the notebook object
483
+ await page . goto ( notebookObject . url ) ;
484
+
485
+ // Click .c-notebook__drag-area to create a new notebook entry
486
+ await page . locator ( '.c-notebook__drag-area' ) . click ( ) ;
487
+
488
+ //verify visible elements
489
+ await expect ( page . getByLabel ( 'Notebook Entry' , { exact : true } ) ) . toBeVisible ( ) ;
490
+ await expect ( page . getByLabel ( 'Notebook Entry Input' ) ) . toBeVisible ( ) ;
491
+
492
+ //add text to textarea
493
+ const testText = 'test text' ;
494
+ await page . getByLabel ( 'Notebook Entry Input' ) . fill ( testText ) ;
495
+
496
+ const textareaVal = await page . getByLabel ( 'Notebook Entry Input' ) . inputValue ( ) ;
497
+ await expect ( textareaVal ) . toBe ( testText ) ;
498
+
499
+ //navigate away from notebook without saving the new notebook entry
500
+ await page . getByLabel ( 'Navigate up to parent' ) . click ( ) ;
501
+ await page . goto ( './' , { waitUntil : 'domcontentloaded' } ) ;
502
+
503
+ await expect ( page . getByLabel ( 'Notebook Entry' , { exact : true } ) ) . toBeHidden ( ) ;
504
+
505
+ //navigate back to notebook
506
+ await page . goto ( notebookObject . url ) ;
507
+
508
+ await expect ( page . getByLabel ( 'Notebook Entry' , { exact : true } ) ) . toBeVisible ( ) ;
509
+ await expect ( page . getByLabel ( 'Notebook Entry Display' ) ) . toContainText ( testText ) ;
510
+ } ) ;
511
+
355
512
test ( 'previous and new entries can be deleted' , async ( { page } ) => {
356
513
// Navigate to the notebook object
357
514
await page . goto ( notebookObject . url ) ;
0 commit comments