mirror of
https://github.com/jupyter/notebook.git
synced 2025-04-24 14:20:54 +08:00
* Add component to provide file browser actions * Fix usesignal * Lint * Flex display * CSS fixes * Undo unrelated change * Patch methods directly * Fix folder selection * Update Playwright Snapshots * Update Playwright Snapshots * Add link to the upstream issue * Add UI tests * Lint * Tweak delete button color * Move to a separate plugin --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
85 lines
2.5 KiB
TypeScript
85 lines
2.5 KiB
TypeScript
// Copyright (c) Jupyter Development Team.
|
|
// Distributed under the terms of the Modified BSD License.
|
|
|
|
import path from 'path';
|
|
|
|
import { expect } from '@playwright/test';
|
|
|
|
import { test } from './fixtures';
|
|
|
|
test.describe('File Browser', () => {
|
|
test.beforeEach(async ({ page, tmpPath }) => {
|
|
await page.contents.uploadFile(
|
|
path.resolve(__dirname, './notebooks/empty.ipynb'),
|
|
`${tmpPath}/empty.ipynb`
|
|
);
|
|
await page.contents.createDirectory(`${tmpPath}/folder1`);
|
|
await page.contents.createDirectory(`${tmpPath}/folder2`);
|
|
});
|
|
|
|
test('Select one folder', async ({ page, tmpPath }) => {
|
|
await page.filebrowser.refresh();
|
|
|
|
await page.getByText('folder1').last().click();
|
|
|
|
const toolbar = page.getByRole('navigation');
|
|
|
|
expect(toolbar.getByText('Rename')).toBeVisible();
|
|
expect(toolbar.getByText('Delete')).toBeVisible();
|
|
});
|
|
|
|
test('Select one file', async ({ page, tmpPath }) => {
|
|
await page.filebrowser.refresh();
|
|
|
|
await page.getByText('empty.ipynb').last().click();
|
|
|
|
const toolbar = page.getByRole('navigation');
|
|
|
|
['Rename', 'Delete', 'Open', 'Download', 'Delete'].forEach(async (text) => {
|
|
expect(toolbar.getByText(text)).toBeVisible();
|
|
});
|
|
});
|
|
|
|
test('Select files and folders', async ({ page, tmpPath }) => {
|
|
await page.filebrowser.refresh();
|
|
|
|
await page.keyboard.down('Control');
|
|
await page.getByText('folder1').last().click();
|
|
await page.getByText('folder2').last().click();
|
|
await page.getByText('empty.ipynb').last().click();
|
|
|
|
const toolbar = page.getByRole('navigation');
|
|
|
|
expect(toolbar.getByText('Rename')).toBeHidden();
|
|
expect(toolbar.getByText('Open')).toBeHidden();
|
|
expect(toolbar.getByText('Delete')).toBeVisible();
|
|
});
|
|
|
|
test('Select files and open', async ({ page, tmpPath }) => {
|
|
// upload an additional notebook
|
|
await page.contents.uploadFile(
|
|
path.resolve(__dirname, './notebooks/simple.ipynb'),
|
|
`${tmpPath}/simple.ipynb`
|
|
);
|
|
await page.filebrowser.refresh();
|
|
|
|
await page.keyboard.down('Control');
|
|
await page.getByText('simple.ipynb').last().click();
|
|
await page.getByText('empty.ipynb').last().click();
|
|
|
|
const toolbar = page.getByRole('navigation');
|
|
|
|
const [nb1, nb2] = await Promise.all([
|
|
page.waitForEvent('popup'),
|
|
page.waitForEvent('popup'),
|
|
toolbar.getByText('Open').last().click(),
|
|
]);
|
|
|
|
await nb1.waitForLoadState();
|
|
await nb1.close();
|
|
|
|
await nb2.waitForLoadState();
|
|
await nb2.close();
|
|
});
|
|
});
|