Skip to content

Commit 75913e6

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

File tree

1 file changed

+52
-2
lines changed

1 file changed

+52
-2
lines changed

ui-tests/tests/jupytereverywhere.spec.ts

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,39 @@ 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+
metadata: {},
28+
source: [`# This is a test notebook`]
29+
}
30+
],
31+
metadata: {
32+
kernelspec: {
33+
display_name: 'Python 3 (ipykernel)',
34+
language: 'python',
35+
name: 'python3'
36+
},
37+
language_info: {
38+
codemirror_mode: {
39+
name: 'ipython',
40+
version: 3
41+
},
42+
file_extension: '.py',
43+
mimetype: 'text/x-python',
44+
name: 'python',
45+
nbconvert_exporter: 'python',
46+
pygments_lexer: 'ipython3'
47+
}
48+
},
49+
nbformat: 4,
50+
nbformat_minor: 5
51+
};
52+
2053
test.beforeEach(async ({ page }) => {
2154
await page.goto('lab/index.html');
2255
await page.waitForSelector('.jp-LabShell');
@@ -33,8 +66,25 @@ test.describe('General', () => {
3366
).toMatchSnapshot('application-shell.png');
3467
});
3568

36-
test('Should load a read-only notebook', async ({ page }) => {
37-
await page.goto('lab/index.html?notebook=test');
69+
test('Should load a view-only notebook', async ({ page }) => {
70+
await page.route('**/api/v1/auth/issue', async route => {
71+
const json = { token: 'test-token' };
72+
await route.fulfill({ json });
73+
});
74+
const notebookId = 'e3b0c442-98fc-1fc2-9c9f-8b6d6ed08a1d';
75+
76+
await page.route('**/api/v1/notebooks/*', async route => {
77+
const json = {
78+
id: notebookId,
79+
domain_id: 'domain',
80+
readable_id: null,
81+
content: TEST_NOTEBOOK
82+
};
83+
await route.fulfill({ json });
84+
});
85+
86+
await page.goto(`lab/index.html?notebook=${notebookId}`);
87+
3888
expect(
3989
await page.locator('.jp-NotebookPanel').screenshot({
4090
mask: [page.locator('.jp-KernelStatus')],

0 commit comments

Comments
 (0)