Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable add a cell button #6872

Merged
merged 3 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'));
}