Skip to content

Commit 628f7b1

Browse files
committed
Mock API for view-only notebook test
1 parent 6871ebb commit 628f7b1

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

ui-tests/tests/jupytereverywhere.spec.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,38 @@ async function runCommand(page: Page, command: string, args: JSONObject = {}) {
1717
);
1818
}
1919

20+
const TEST_NOTEBOOK = {
21+
cells: [
22+
{
23+
cell_type: 'code',
24+
execution_count: null,
25+
id: '55eb9a2d-401d-4abd-b0eb-373ded5b408d',
26+
outputs: [],
27+
source: [`# This is a test notebook`]
28+
}
29+
],
30+
metadata: {
31+
kernelspec: {
32+
display_name: 'Python 3 (ipykernel)',
33+
language: 'python',
34+
name: 'python3'
35+
},
36+
language_info: {
37+
codemirror_mode: {
38+
name: 'ipython',
39+
version: 3
40+
},
41+
file_extension: '.py',
42+
mimetype: 'text/x-python',
43+
name: 'python',
44+
nbconvert_exporter: 'python',
45+
pygments_lexer: 'ipython3'
46+
}
47+
},
48+
nbformat: 4,
49+
nbformat_minor: 5
50+
};
51+
2052
test.beforeEach(async ({ page }) => {
2153
await page.goto('lab/index.html');
2254
await page.waitForSelector('.jp-LabShell');
@@ -34,6 +66,18 @@ test.describe('General', () => {
3466
});
3567

3668
test('Should load a read-only notebook', async ({ page }) => {
69+
await page.route('*/**/api/v1/notebooks/*', async route => {
70+
const json = [
71+
{
72+
id: 'dummy-notebook-id',
73+
domain_id: 'domain',
74+
readable_id: null,
75+
content: TEST_NOTEBOOK
76+
}
77+
];
78+
await route.fulfill({ json });
79+
});
80+
3781
await page.goto('lab/index.html?notebook=test');
3882
expect(
3983
await page.locator('.jp-NotebookPanel').screenshot({

0 commit comments

Comments
 (0)