Skip to content

Commit b0bb363

Browse files
Hide output execution counts for inactive cells (#214)
* Hide output execution counts for inactive cells * Update Playwright Snapshots * Fix test * Lint * Revert "Update Playwright Snapshots" This reverts commit a91194b. * Add a test * Update Playwright Snapshots * Fix conflicts This partially reverts commit 9aa32d4. * Update Playwright Snapshots
1 parent a965bc6 commit b0bb363

File tree

3 files changed

+52
-5
lines changed

3 files changed

+52
-5
lines changed

style/base.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@
167167
visibility: hidden;
168168
}
169169

170-
.jp-Notebook .jp-Cell .jp-OutputPrompt {
170+
.jp-Notebook .jp-Cell:not(.jp-mod-active) .jp-OutputPrompt {
171+
visibility: hidden;
172+
}
173+
174+
.jp-Notebook .jp-Cell.jp-mod-active .jp-OutputPrompt {
171175
visibility: visible;
172176
}
173177

ui-tests/tests/jupytereverywhere.spec.ts

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,6 @@ test.describe('Per cell run buttons', () => {
738738
await expect(firstCell.locator('.jp-Cell-outputArea')).toBeVisible({ timeout: 10000 });
739739

740740
const inputIndicator = firstCell.locator('.jp-InputArea-prompt-indicator');
741-
const outputPrompt = firstCell.locator('.jp-OutputPrompt');
742741

743742
// When the first cell is active, the input indicator should be hidden
744743
await firstCell.click();
@@ -749,13 +748,57 @@ test.describe('Per cell run buttons', () => {
749748
await expect(inputIndicator).toBeVisible();
750749

751750
// Hover over the first cell; input indicator should get hidden again
752-
// However, the output prompt should remain visible at all times
753751
await firstCell.hover();
754752
await expect(inputIndicator).toBeHidden();
755-
await expect(outputPrompt).toBeVisible();
756753
});
757754

758-
test('Run button is hidden on Raw cells and reappears on Code cells', async ({ page }) => {
755+
test('For non-active/non-focused cells with an input execution count, there should not be an output execution count', async ({
756+
page
757+
}) => {
758+
await page.waitForSelector('.jp-NotebookPanel');
759+
760+
// Ensure three cells so we can toggle active state cleanly.
761+
await runCommand(page, 'notebook:insert-cell-below');
762+
await runCommand(page, 'notebook:insert-cell-below');
763+
const firstCell = page.locator('.jp-CodeCell').first();
764+
const secondCell = page.locator('.jp-CodeCell').nth(1);
765+
const thirdCell = page.locator('.jp-CodeCell').nth(2);
766+
767+
// Put some code in the first two cells and run them to get input
768+
// execution counts and an output prompt in the second cell.
769+
await firstCell.getByRole('textbox').click();
770+
await firstCell.getByRole('textbox').fill('x = 5');
771+
await firstCell.locator('.je-cell-run-button').click();
772+
773+
await secondCell.getByRole('textbox').click();
774+
await secondCell.getByRole('textbox').fill('x');
775+
await secondCell.locator('.je-cell-run-button').click();
776+
777+
// Go to the third cell so the first two are not active/focused
778+
await thirdCell.getByRole('textbox').click();
779+
780+
// Wait for the execution counts to appear. Now, the second cell (inactive)
781+
// should have an input prompt, but no output prompt.
782+
const output = secondCell.locator('.jp-Cell-outputArea');
783+
await expect(output).toBeVisible({ timeout: 30000 });
784+
await expect(output).toContainText('5', { timeout: 30000 });
785+
786+
const secondInputIndicator = secondCell.locator('.jp-InputPrompt');
787+
const secondOutputIndicator = secondCell.locator('.jp-OutputPrompt');
788+
await expect(secondInputIndicator).toBeVisible({ timeout: 10000 });
789+
await expect(secondOutputIndicator).toBeHidden({ timeout: 10000 });
790+
791+
expect(
792+
await page.locator('.jp-LabShell').screenshot({
793+
mask: [page.locator('.jp-KernelStatus-widget')],
794+
maskColor: '#fff'
795+
})
796+
).toMatchSnapshot('multiple-cells-prompt-indicators.png');
797+
});
798+
799+
test('Run button is hidden on Raw cells and reappears on Code/Markdown cells', async ({
800+
page
801+
}) => {
759802
await page.waitForSelector('.jp-NotebookPanel');
760803

761804
const cell = page.locator('.jp-Cell').first();
21.2 KB
Loading

0 commit comments

Comments
 (0)