Provide a custom rendermime plugin to handle local links (#6885)
* Provide a custom rendermime plugin * Lint * Add UI tests for local links * Ignore check link in the test notebook * Improve tests
parent
00eed6292a
commit
9863625809
@ -0,0 +1,56 @@
|
||||
// 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';
|
||||
|
||||
const NOTEBOOK = 'local_links.ipynb';
|
||||
const SUBFOLDER = 'test';
|
||||
|
||||
test.describe('Local Links', () => {
|
||||
test.beforeEach(async ({ page, tmpPath }) => {
|
||||
await page.contents.uploadFile(
|
||||
path.resolve(__dirname, `./notebooks/${NOTEBOOK}`),
|
||||
`${tmpPath}/${NOTEBOOK}`
|
||||
);
|
||||
});
|
||||
|
||||
test('Open the current directory', async ({ page, tmpPath }) => {
|
||||
await page.goto(`notebooks/${tmpPath}/${NOTEBOOK}`);
|
||||
|
||||
const [current] = await Promise.all([
|
||||
page.waitForEvent('popup'),
|
||||
page.getByText('Current Directory').last().click(),
|
||||
]);
|
||||
|
||||
await current.waitForLoadState();
|
||||
await current.waitForSelector('.jp-DirListing-content');
|
||||
|
||||
// Check that the link opened in a new tab
|
||||
expect(current.url()).toContain(`tree/${tmpPath}`);
|
||||
await current.close();
|
||||
});
|
||||
|
||||
test('Open a folder', async ({ page, tmpPath }) => {
|
||||
// Create a test folder
|
||||
await page.contents.createDirectory(`${tmpPath}/${SUBFOLDER}`);
|
||||
|
||||
await page.goto(`notebooks/${tmpPath}/${NOTEBOOK}`);
|
||||
|
||||
const [folder] = await Promise.all([
|
||||
page.waitForEvent('popup'),
|
||||
page.getByText('Open Test Folder').last().click(),
|
||||
]);
|
||||
|
||||
await folder.waitForLoadState();
|
||||
await folder.waitForSelector('.jp-DirListing-content');
|
||||
|
||||
await folder.close();
|
||||
|
||||
// Check that the link opened in a new tab
|
||||
expect(folder.url()).toContain(`tree/${tmpPath}/${SUBFOLDER}`);
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,49 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Handle Local Links"
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"[Current Directory](./)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"[Open Test Folder](./test)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
||||
Loading…
Reference in new issue