|
| 1 | +// Copyright (c) Jupyter Development Team. |
| 2 | +// Distributed under the terms of the Modified BSD License. |
| 3 | + |
| 4 | +import { galata, describe, test } from '@jupyterlab/galata'; |
| 5 | + |
| 6 | +import * as path from 'path'; |
| 7 | + |
| 8 | +jest.setTimeout(100000); |
| 9 | + |
| 10 | +describe('Voila Visual Regression', () => { |
| 11 | + beforeAll(async () => { |
| 12 | + await galata.resetUI(); |
| 13 | + galata.context.capturePrefix = 'voila'; |
| 14 | + }); |
| 15 | + |
| 16 | + afterAll(async () => { |
| 17 | + galata.context.capturePrefix = ''; |
| 18 | + }); |
| 19 | + |
| 20 | + test('Upload files to JupyterLab', async () => { |
| 21 | + await galata.contents.moveDirectoryToServer( |
| 22 | + path.resolve(__dirname, './notebooks'), |
| 23 | + 'uploaded' |
| 24 | + ); |
| 25 | + expect( |
| 26 | + await galata.contents.fileExists('uploaded/basics.ipynb') |
| 27 | + ).toBeTruthy(); |
| 28 | + }); |
| 29 | + |
| 30 | + test('Refresh File Browser', async () => { |
| 31 | + await galata.filebrowser.refresh(); |
| 32 | + }); |
| 33 | + |
| 34 | + test('Open directory uploaded', async () => { |
| 35 | + await galata.filebrowser.openDirectory('uploaded'); |
| 36 | + expect( |
| 37 | + await galata.filebrowser.isFileListedInBrowser('basics.ipynb') |
| 38 | + ).toBeTruthy(); |
| 39 | + }); |
| 40 | + |
| 41 | + test('Open basics.ipynb with the Voila preview', async () => { |
| 42 | + const notebook = 'basics.ipynb'; |
| 43 | + await galata.notebook.open(notebook); |
| 44 | + expect(await galata.notebook.isOpen(notebook)).toBeTruthy(); |
| 45 | + await galata.notebook.activate(notebook); |
| 46 | + expect(await galata.notebook.isActive(notebook)).toBeTruthy(); |
| 47 | + |
| 48 | + const page = galata.context.page; |
| 49 | + const previewSelector = '.jp-ToolbarButton .voilaRender'; |
| 50 | + const button = await page.$(previewSelector); |
| 51 | + button.click(); |
| 52 | + |
| 53 | + await galata.notebook.close(true); |
| 54 | + await galata.toggleSimpleMode(true); |
| 55 | + |
| 56 | + const iframe = await page.waitForSelector('iframe'); |
| 57 | + const contentFrame = await iframe.contentFrame(); |
| 58 | + |
| 59 | + await contentFrame.waitForSelector('.jupyter-widgets'); |
| 60 | + await contentFrame.waitForLoadState('networkidle'); |
| 61 | + // for the basics notebook we expect to find 2 MathJax element |
| 62 | + await contentFrame.waitForSelector('#MathJax-Element-1-Frame'); |
| 63 | + await contentFrame.waitForSelector('#MathJax-Element-2-Frame'); |
| 64 | + |
| 65 | + const imageName = 'basics'; |
| 66 | + await galata.capture.screenshot(imageName, iframe); |
| 67 | + expect(await galata.capture.compareScreenshot(imageName)).toBe('same'); |
| 68 | + }); |
| 69 | + |
| 70 | + test('Open home directory', async () => { |
| 71 | + await galata.filebrowser.openHomeDirectory(); |
| 72 | + }); |
| 73 | + |
| 74 | + test('Delete uploaded directory', async () => { |
| 75 | + await galata.contents.deleteDirectory('uploaded'); |
| 76 | + }); |
| 77 | +}); |
0 commit comments