Skip to content

Commit c77ebdc

Browse files
tuncbkosejtpio
andauthored
Enable add a cell button (#6872)
* Enable add a cell button * workaround for Firefox * Lint --------- Co-authored-by: Jeremy Tuloup <[email protected]>
1 parent 1728681 commit c77ebdc

File tree

4 files changed

+33
-11
lines changed

4 files changed

+33
-11
lines changed

packages/notebook-extension/style/base.css

-2
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ body[data-notebook='notebooks']
124124

125125
/* Tweak the notebook footer (to add a new cell) */
126126
body[data-notebook='notebooks'] .jp-Notebook-footer {
127-
/* TODO: re-enable */
128-
display: none;
129127
width: 100%;
130128
margin-left: unset;
131129
background: unset;

ui-tests/test/general.spec.ts

+14-8
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import { expect } from '@playwright/test';
77

88
import { test } from './fixtures';
99

10-
import { waitForKernelReady } from './utils';
10+
import { hideAddCellButton, waitForKernelReady } from './utils';
1111

1212
test.describe('General', () => {
13-
test('The notebook should render', async ({ page, tmpPath }) => {
13+
test('The notebook should render', async ({ page, tmpPath, browserName }) => {
1414
const notebook = 'simple.ipynb';
1515
await page.contents.uploadFile(
1616
path.resolve(__dirname, `./notebooks/${notebook}`),
@@ -35,13 +35,19 @@ test.describe('General', () => {
3535
(element) => (element.innerHTML = 'Last Checkpoint: 3 seconds ago')
3636
);
3737

38-
// force switching back to command mode to avoid capturing the cursor in the screenshot
39-
await page.evaluate(async () => {
40-
await window.jupyterapp.commands.execute('notebook:enter-command-mode');
41-
});
38+
// check the notebook footer shows up on hover
39+
const notebookFooter = '.jp-Notebook-footer';
40+
await page.hover(notebookFooter);
41+
await page.waitForSelector(notebookFooter);
4242

43-
// make sure the mouse does not hover on the footer
44-
await page.mouse.move(0, 0);
43+
// hover somewhere else to make the add cell disappear
44+
await page.hover('#jp-top-bar');
45+
46+
// special case for firefox headless issue
47+
// see https://github.com/jupyter/notebook/pull/6872#issuecomment-1549594166 for more details
48+
if (browserName === 'firefox') {
49+
await hideAddCellButton(page);
50+
}
4551

4652
expect(await page.screenshot()).toMatchSnapshot('notebook.png');
4753
});

ui-tests/test/mobile.spec.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { expect } from '@playwright/test';
77

88
import { test } from './fixtures';
99

10-
import { waitForKernelReady } from './utils';
10+
import { hideAddCellButton, waitForKernelReady } from './utils';
1111

1212
test.use({ autoGoto: false });
1313

@@ -30,6 +30,7 @@ test.describe('Mobile', () => {
3030
test('The layout should be more compact on the notebook page', async ({
3131
page,
3232
tmpPath,
33+
browserName,
3334
}) => {
3435
const notebook = 'empty.ipynb';
3536
await page.contents.uploadFile(
@@ -50,6 +51,11 @@ test.describe('Mobile', () => {
5051
await window.jupyterapp.commands.execute('notebook:enter-command-mode');
5152
});
5253

54+
// TODO: remove
55+
if (browserName === 'firefox') {
56+
await hideAddCellButton(page);
57+
}
58+
5359
expect(await page.screenshot()).toMatchSnapshot('notebook.png');
5460
});
5561
});

ui-tests/test/utils.ts

+12
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,15 @@ export async function waitForKernelReady(
3434
});
3535
await page.waitForSelector('.jp-DebuggerBugButton[aria-disabled="false"]');
3636
}
37+
38+
/**
39+
* Special case for firefox headless issue
40+
* See https://github.com/jupyter/notebook/pull/6872#issuecomment-1549594166 for more details
41+
*/
42+
export async function hideAddCellButton(
43+
page: IJupyterLabPageFixture
44+
): Promise<void> {
45+
await page
46+
.locator('.jp-Notebook-footer')
47+
.evaluate((element) => (element.style.display = 'none'));
48+
}

0 commit comments

Comments
 (0)