Skip to content

Commit

Permalink
Enable add a cell button (#6872)
Browse files Browse the repository at this point in the history
* Enable add a cell button

* workaround for Firefox

* Lint

---------

Co-authored-by: Jeremy Tuloup <[email protected]>
  • Loading branch information
tuncbkose and jtpio authored May 16, 2023
1 parent 1728681 commit c77ebdc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
2 changes: 0 additions & 2 deletions packages/notebook-extension/style/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ body[data-notebook='notebooks']

/* Tweak the notebook footer (to add a new cell) */
body[data-notebook='notebooks'] .jp-Notebook-footer {
/* TODO: re-enable */
display: none;
width: 100%;
margin-left: unset;
background: unset;
Expand Down
22 changes: 14 additions & 8 deletions ui-tests/test/general.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { expect } from '@playwright/test';

import { test } from './fixtures';

import { waitForKernelReady } from './utils';
import { hideAddCellButton, waitForKernelReady } from './utils';

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

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

// make sure the mouse does not hover on the footer
await page.mouse.move(0, 0);
// hover somewhere else to make the add cell disappear
await page.hover('#jp-top-bar');

// special case for firefox headless issue
// see https://github.com/jupyter/notebook/pull/6872#issuecomment-1549594166 for more details
if (browserName === 'firefox') {
await hideAddCellButton(page);
}

expect(await page.screenshot()).toMatchSnapshot('notebook.png');
});
Expand Down
8 changes: 7 additions & 1 deletion ui-tests/test/mobile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { expect } from '@playwright/test';

import { test } from './fixtures';

import { waitForKernelReady } from './utils';
import { hideAddCellButton, waitForKernelReady } from './utils';

test.use({ autoGoto: false });

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

// TODO: remove
if (browserName === 'firefox') {
await hideAddCellButton(page);
}

expect(await page.screenshot()).toMatchSnapshot('notebook.png');
});
});
12 changes: 12 additions & 0 deletions ui-tests/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,15 @@ export async function waitForKernelReady(
});
await page.waitForSelector('.jp-DebuggerBugButton[aria-disabled="false"]');
}

/**
* Special case for firefox headless issue
* See https://github.com/jupyter/notebook/pull/6872#issuecomment-1549594166 for more details
*/
export async function hideAddCellButton(
page: IJupyterLabPageFixture
): Promise<void> {
await page
.locator('.jp-Notebook-footer')
.evaluate((element) => (element.style.display = 'none'));
}

0 comments on commit c77ebdc

Please sign in to comment.