From fc73f0734fb91cbf38ef4bd6f6a92ea60ee2d596 Mon Sep 17 00:00:00 2001 From: Meriem-BenIsmail Date: Mon, 18 Nov 2024 13:13:08 +0100 Subject: [PATCH 01/11] fixed error with base url --- packages/docprovider/src/component.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/docprovider/src/component.tsx b/packages/docprovider/src/component.tsx index 50533c53..84ca21e7 100644 --- a/packages/docprovider/src/component.tsx +++ b/packages/docprovider/src/component.tsx @@ -20,6 +20,7 @@ type Props = { contentType: string; format: string; }; +const DOCUMENT_TIMELINE_URL = 'api/collaboration/timeline'; export const TimelineSliderComponent: React.FC = ({ apiURL, @@ -147,16 +148,21 @@ export const TimelineSliderComponent: React.FC = ({ function determineAction(currentTimestamp: number): 'undo' | 'redo' { return currentTimestamp < currentTimestampIndex ? 'undo' : 'redo'; } - function extractFilenameFromURL(url: string): string { try { const parsedURL = new URL(url); const pathname = parsedURL.pathname; - const segments = pathname.split('/'); - return segments.slice(4 - segments.length).join('/'); + const apiIndex = pathname.indexOf(DOCUMENT_TIMELINE_URL); + if (apiIndex === -1) { + throw new Error( + `API segment "${DOCUMENT_TIMELINE_URL}" not found in URL.` + ); + } + + return pathname.slice(apiIndex + DOCUMENT_TIMELINE_URL.length); } catch (error) { - console.error('Invalid URL:', error); + console.error('Invalid URL or unable to extract filename:', error); return ''; } } From 504edf2a6689018deaf48ec8532e28cfb5d47e0f Mon Sep 17 00:00:00 2001 From: Meriem-BenIsmail Date: Tue, 19 Nov 2024 11:13:15 +0100 Subject: [PATCH 02/11] modified filename extraction method. --- packages/docprovider/src/component.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/docprovider/src/component.tsx b/packages/docprovider/src/component.tsx index 84ca21e7..823b1c71 100644 --- a/packages/docprovider/src/component.tsx +++ b/packages/docprovider/src/component.tsx @@ -153,7 +153,7 @@ export const TimelineSliderComponent: React.FC = ({ const parsedURL = new URL(url); const pathname = parsedURL.pathname; - const apiIndex = pathname.indexOf(DOCUMENT_TIMELINE_URL); + const apiIndex = pathname.lastIndexOf(DOCUMENT_TIMELINE_URL); if (apiIndex === -1) { throw new Error( `API segment "${DOCUMENT_TIMELINE_URL}" not found in URL.` From 6b9045a81d20adf087180f0ca404d2b6e8024983 Mon Sep 17 00:00:00 2001 From: Meriem-BenIsmail Date: Fri, 22 Nov 2024 11:16:35 +0100 Subject: [PATCH 03/11] ui test timeline --- .../docprovider-extension/src/filebrowser.ts | 3 ++- packages/docprovider/src/TimelineSlider.tsx | 6 ++++- packages/docprovider/src/component.tsx | 11 ++++---- .../jupyter_server_test_config_timeline.py | 20 ++++++++++++++ ui-tests/package.json | 4 ++- ui-tests/playwright.timeline.config.js | 27 +++++++++++++++++++ ui-tests/tests/timeline-slider.spec.ts | 22 ++++++++++++--- 7 files changed, 82 insertions(+), 11 deletions(-) create mode 100644 ui-tests/jupyter_server_test_config_timeline.py create mode 100644 ui-tests/playwright.timeline.config.js diff --git a/packages/docprovider-extension/src/filebrowser.ts b/packages/docprovider-extension/src/filebrowser.ts index d68ecd90..ee3af263 100644 --- a/packages/docprovider-extension/src/filebrowser.ts +++ b/packages/docprovider-extension/src/filebrowser.ts @@ -182,7 +182,8 @@ export const statusBarTimeline: JupyterFrontEndPlugin = { fullPath, provider, provider.contentType, - provider.format + provider.format, + DOCUMENT_TIMELINE_URL ); const elt = document.getElementById('jp-slider-status-bar'); diff --git a/packages/docprovider/src/TimelineSlider.tsx b/packages/docprovider/src/TimelineSlider.tsx index f999fe7e..c59599f8 100644 --- a/packages/docprovider/src/TimelineSlider.tsx +++ b/packages/docprovider/src/TimelineSlider.tsx @@ -13,18 +13,21 @@ export class TimelineWidget extends ReactWidget { private provider: IForkProvider; private contentType: string; private format: string; + private documentTimelineUrl: string; constructor( apiURL: string, provider: IForkProvider, contentType: string, - format: string + format: string, + documentTimelineUrl: string ) { super(); this.apiURL = apiURL; this.provider = provider; this.contentType = contentType; this.format = format; + this.documentTimelineUrl = documentTimelineUrl this.addClass('jp-timelineSliderWrapper'); } @@ -36,6 +39,7 @@ export class TimelineWidget extends ReactWidget { provider={this.provider} contentType={this.contentType} format={this.format} + documentTimelineUrl= {this.documentTimelineUrl} /> ); } diff --git a/packages/docprovider/src/component.tsx b/packages/docprovider/src/component.tsx index 823b1c71..13351aa3 100644 --- a/packages/docprovider/src/component.tsx +++ b/packages/docprovider/src/component.tsx @@ -19,14 +19,15 @@ type Props = { provider: IForkProvider; contentType: string; format: string; + documentTimelineUrl: string; }; -const DOCUMENT_TIMELINE_URL = 'api/collaboration/timeline'; export const TimelineSliderComponent: React.FC = ({ apiURL, provider, contentType, - format + format, + documentTimelineUrl }) => { const [data, setData] = useState({ roomId: '', @@ -153,14 +154,14 @@ export const TimelineSliderComponent: React.FC = ({ const parsedURL = new URL(url); const pathname = parsedURL.pathname; - const apiIndex = pathname.lastIndexOf(DOCUMENT_TIMELINE_URL); + const apiIndex = pathname.lastIndexOf(documentTimelineUrl); if (apiIndex === -1) { throw new Error( - `API segment "${DOCUMENT_TIMELINE_URL}" not found in URL.` + `API segment "${documentTimelineUrl}" not found in URL.` ); } - return pathname.slice(apiIndex + DOCUMENT_TIMELINE_URL.length); + return pathname.slice(apiIndex + documentTimelineUrl.length); } catch (error) { console.error('Invalid URL or unable to extract filename:', error); return ''; diff --git a/ui-tests/jupyter_server_test_config_timeline.py b/ui-tests/jupyter_server_test_config_timeline.py new file mode 100644 index 00000000..403befcd --- /dev/null +++ b/ui-tests/jupyter_server_test_config_timeline.py @@ -0,0 +1,20 @@ +# Copyright (c) Jupyter Development Team. +# Distributed under the terms of the Modified BSD License. + +"""Server configuration for integration tests. + +!! Never use this configuration in production because it +opens the server to the world and provides access to JupyterLab +JavaScript objects through the global window variable. +""" +from typing import Any + +from jupyterlab.galata import configure_jupyter_server + +c: Any +configure_jupyter_server(c) # noqa + +c.ServerApp.base_url = "/api/collaboration/timeline/" + +# Uncomment to set server log level to debug level +# c.ServerApp.log_level = "DEBUG" diff --git a/ui-tests/package.json b/ui-tests/package.json index 6ba72f06..0df8b150 100644 --- a/ui-tests/package.json +++ b/ui-tests/package.json @@ -5,7 +5,9 @@ "private": true, "scripts": { "start": "jupyter lab --config jupyter_server_test_config.py", - "test": "npx playwright test", + "start:timeline": "jupyter lab --config jupyter_server_test_config_timeline.py", + "test": "npx playwright test --config=playwright.config.js", + "test:timeline": "npx playwright test --config=playwright.timeline.config.js", "test:update": "npx playwright test --update-snapshots" }, "devDependencies": { diff --git a/ui-tests/playwright.timeline.config.js b/ui-tests/playwright.timeline.config.js new file mode 100644 index 00000000..c993f0d8 --- /dev/null +++ b/ui-tests/playwright.timeline.config.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) Jupyter Development Team. + * Distributed under the terms of the Modified BSD License. + */ + +/** + * Configuration for Playwright using default from @jupyterlab/galata + */ +const baseConfig = require('@jupyterlab/galata/lib/playwright-config'); + +module.exports = { + ...baseConfig, + // Force one worker as global awareness will contaminate parallel tests. + workers: 1, + webServer: { + command: 'jlpm start:timeline', + url: 'http://localhost:8888/api/collaboration/timeline/lab', + timeout: 120 * 1000, + reuseExistingServer: !process.env.CI + }, + expect: { + toMatchSnapshot: { + maxDiffPixelRatio: 0.01 + } + } +}; + diff --git a/ui-tests/tests/timeline-slider.spec.ts b/ui-tests/tests/timeline-slider.spec.ts index 4a052787..5068a52b 100644 --- a/ui-tests/tests/timeline-slider.spec.ts +++ b/ui-tests/tests/timeline-slider.spec.ts @@ -23,17 +23,33 @@ async function openNotebook(page: Page, notebookPath: string) { await page.waitForSelector('.jp-Notebook', { state: 'visible' }); } -test.describe('Open from Path', () => { - +test.describe('Open from Path and Timeline Slider', () => { test('should fail if there are console errors', async ({ page, tmpPath }) => { const pageErrors = await capturePageErrors(page); await page.notebook.createNew(); - await page.notebook.save(); await page.notebook.close(); await openNotebook(page, `${tmpPath}/Untitled.ipynb`); expect(pageErrors).toHaveLength(0); }); +/* + test('should display timeline slider without console errors', async ({ page, baseURL }) => { + expect(baseURL).toContain('/api/collaboration'); + + const pageErrors = await capturePageErrors(page); + + await page.notebook.createNew(); + + const historyIcon = page.locator('.jp-TimelineSlider-icon'); + await expect(historyIcon).toBeVisible(); + + await historyIcon.click(); + + const slider = page.locator('.jp-TimelineSlider'); + await expect(slider).toBeVisible(); + + expect(pageErrors).toHaveLength(0); + }); */ }); From 437f1e7c4da79bfb8c808ce1da9dc0bd8c023145 Mon Sep 17 00:00:00 2001 From: Meriem-BenIsmail Date: Mon, 25 Nov 2024 11:02:56 +0100 Subject: [PATCH 04/11] ui test config done. --- .../jupyter_server_test_config_timeline.py | 6 +++ ui-tests/playwright.timeline.config.js | 46 +++++++++++++------ ui-tests/tests/timeline-slider.spec.ts | 34 ++++++++++---- 3 files changed, 64 insertions(+), 22 deletions(-) diff --git a/ui-tests/jupyter_server_test_config_timeline.py b/ui-tests/jupyter_server_test_config_timeline.py index 403befcd..41714c17 100644 --- a/ui-tests/jupyter_server_test_config_timeline.py +++ b/ui-tests/jupyter_server_test_config_timeline.py @@ -7,7 +7,11 @@ opens the server to the world and provides access to JupyterLab JavaScript objects through the global window variable. """ +import os +from tempfile import mkdtemp from typing import Any +import logging + from jupyterlab.galata import configure_jupyter_server @@ -16,5 +20,7 @@ c.ServerApp.base_url = "/api/collaboration/timeline/" + # Uncomment to set server log level to debug level # c.ServerApp.log_level = "DEBUG" + diff --git a/ui-tests/playwright.timeline.config.js b/ui-tests/playwright.timeline.config.js index c993f0d8..a50644ed 100644 --- a/ui-tests/playwright.timeline.config.js +++ b/ui-tests/playwright.timeline.config.js @@ -1,27 +1,45 @@ -/* - * Copyright (c) Jupyter Development Team. - * Distributed under the terms of the Modified BSD License. - */ - -/** - * Configuration for Playwright using default from @jupyterlab/galata - */ +const fs = require('fs'); +const path = require('path'); const baseConfig = require('@jupyterlab/galata/lib/playwright-config'); +// Directory for timeline tests +const timelineTestDir = path.resolve( + process.env.TIMELINE_TEST_DIR || '/tmp/galata-timeline-tests' +); + +// Ensure the test directory exists +if (!fs.existsSync(timelineTestDir)) { + fs.mkdirSync(timelineTestDir, { recursive: true }); + console.log(`Created timeline test directory: ${timelineTestDir}`); +} + module.exports = { ...baseConfig, - // Force one worker as global awareness will contaminate parallel tests. workers: 1, webServer: { command: 'jlpm start:timeline', url: 'http://localhost:8888/api/collaboration/timeline/lab', timeout: 120 * 1000, - reuseExistingServer: !process.env.CI + reuseExistingServer: !process.env.CI, }, expect: { toMatchSnapshot: { - maxDiffPixelRatio: 0.01 - } - } + maxDiffPixelRatio: 0.01, + }, + }, + projects: [ + { + name: 'timeline-tests', + testMatch: 'tests/**/timeline-*.spec.ts', + testIgnore: '**/.ipynb_checkpoints/**', + retries: process.env.CI ? 2 : 0, + timeout: 90000, + use: { + launchOptions: { + slowMo: 30, + }, + tmpPath: timelineTestDir, // Set dynamic tmpPath + }, + }, + ], }; - diff --git a/ui-tests/tests/timeline-slider.spec.ts b/ui-tests/tests/timeline-slider.spec.ts index 5068a52b..03786afc 100644 --- a/ui-tests/tests/timeline-slider.spec.ts +++ b/ui-tests/tests/timeline-slider.spec.ts @@ -23,33 +23,51 @@ async function openNotebook(page: Page, notebookPath: string) { await page.waitForSelector('.jp-Notebook', { state: 'visible' }); } -test.describe('Open from Path and Timeline Slider', () => { - test('should fail if there are console errors', async ({ page, tmpPath }) => { + +const isTimelineEnv = process.env.TIMELINE_FEATURE || "0"; +const isTimeline = parseInt(isTimelineEnv) + +test.describe('Timeline Slider', () => { + + isTimeline && test.use({ autoGoto: false }) + + test('should fail if there are console errors when opening from path', async ({ page, tmpPath }) => { + if (isTimeline) { + console.log('Skipping this test.'); + return; + } const pageErrors = await capturePageErrors(page); await page.notebook.createNew(); await page.notebook.close(); + if(!isTimeline) await openNotebook(page, `${tmpPath}/Untitled.ipynb`); expect(pageErrors).toHaveLength(0); }); -/* - test('should display timeline slider without console errors', async ({ page, baseURL }) => { - expect(baseURL).toContain('/api/collaboration'); + + test('should display without console errors when baseUrl is set', async ({ page, baseURL }) => { + + if (!isTimeline) { + console.log('Skipping this test.'); + return; + } + + await page.goto('http://localhost:8888/api/collaboration/timeline') const pageErrors = await capturePageErrors(page); await page.notebook.createNew(); - const historyIcon = page.locator('.jp-TimelineSlider-icon'); + const historyIcon = page.locator('.jp-mod-highlighted[title="Document Timeline"]'); await expect(historyIcon).toBeVisible(); await historyIcon.click(); - const slider = page.locator('.jp-TimelineSlider'); + const slider = page.locator('.jp-timestampDisplay'); await expect(slider).toBeVisible(); expect(pageErrors).toHaveLength(0); - }); */ + }); }); From 0a96d4d4edb41067e2fa2402091b46dfffe5ae48 Mon Sep 17 00:00:00 2001 From: Meriem-BenIsmail Date: Mon, 25 Nov 2024 11:15:08 +0100 Subject: [PATCH 05/11] ui test for baseurl issue --- .../jupyter_server_test_config_timeline.py | 6 +--- ui-tests/playwright.timeline.config.js | 30 ++++++------------- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/ui-tests/jupyter_server_test_config_timeline.py b/ui-tests/jupyter_server_test_config_timeline.py index 41714c17..4578db61 100644 --- a/ui-tests/jupyter_server_test_config_timeline.py +++ b/ui-tests/jupyter_server_test_config_timeline.py @@ -4,14 +4,10 @@ """Server configuration for integration tests. !! Never use this configuration in production because it -opens the server to the world and provides access to JupyterLab +opens the server to the world and provide access to JupyterLab JavaScript objects through the global window variable. """ -import os -from tempfile import mkdtemp from typing import Any -import logging - from jupyterlab.galata import configure_jupyter_server diff --git a/ui-tests/playwright.timeline.config.js b/ui-tests/playwright.timeline.config.js index a50644ed..1aca6f4a 100644 --- a/ui-tests/playwright.timeline.config.js +++ b/ui-tests/playwright.timeline.config.js @@ -1,17 +1,12 @@ -const fs = require('fs'); -const path = require('path'); -const baseConfig = require('@jupyterlab/galata/lib/playwright-config'); - -// Directory for timeline tests -const timelineTestDir = path.resolve( - process.env.TIMELINE_TEST_DIR || '/tmp/galata-timeline-tests' -); +/* + * Copyright (c) Jupyter Development Team. + * Distributed under the terms of the Modified BSD License. + */ -// Ensure the test directory exists -if (!fs.existsSync(timelineTestDir)) { - fs.mkdirSync(timelineTestDir, { recursive: true }); - console.log(`Created timeline test directory: ${timelineTestDir}`); -} +/** + * Configuration for Playwright using default from @jupyterlab/galata + */ +const baseConfig = require('@jupyterlab/galata/lib/playwright-config'); module.exports = { ...baseConfig, @@ -32,14 +27,7 @@ module.exports = { name: 'timeline-tests', testMatch: 'tests/**/timeline-*.spec.ts', testIgnore: '**/.ipynb_checkpoints/**', - retries: process.env.CI ? 2 : 0, - timeout: 90000, - use: { - launchOptions: { - slowMo: 30, - }, - tmpPath: timelineTestDir, // Set dynamic tmpPath - }, + timeout: 120 * 1000, }, ], }; From 65c4f281045e4090f3c6e15dbb93d5084b08f8e7 Mon Sep 17 00:00:00 2001 From: Meriem-BenIsmail Date: Mon, 25 Nov 2024 11:20:08 +0100 Subject: [PATCH 06/11] ui test for baseurl --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a9bca493..4c5883a7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -295,6 +295,7 @@ jobs: working-directory: ui-tests run: | jlpm test + TIMELINE_FEATURE=1 jlpm test:timeline - name: Upload Playwright Test report if: always() uses: actions/upload-artifact@v3 From 6fe41749c254a5e58dae830c89bd2ce97532b0f7 Mon Sep 17 00:00:00 2001 From: Meriem-BenIsmail Date: Mon, 25 Nov 2024 11:27:49 +0100 Subject: [PATCH 07/11] pre-commit --- packages/docprovider/src/TimelineSlider.tsx | 4 ++-- ui-tests/jupyter_server_test_config_timeline.py | 1 - ui-tests/playwright.timeline.config.js | 12 ++++++------ ui-tests/tests/timeline-slider.spec.ts | 6 +++--- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/docprovider/src/TimelineSlider.tsx b/packages/docprovider/src/TimelineSlider.tsx index c59599f8..c81615b4 100644 --- a/packages/docprovider/src/TimelineSlider.tsx +++ b/packages/docprovider/src/TimelineSlider.tsx @@ -27,7 +27,7 @@ export class TimelineWidget extends ReactWidget { this.provider = provider; this.contentType = contentType; this.format = format; - this.documentTimelineUrl = documentTimelineUrl + this.documentTimelineUrl = documentTimelineUrl; this.addClass('jp-timelineSliderWrapper'); } @@ -39,7 +39,7 @@ export class TimelineWidget extends ReactWidget { provider={this.provider} contentType={this.contentType} format={this.format} - documentTimelineUrl= {this.documentTimelineUrl} + documentTimelineUrl={this.documentTimelineUrl} /> ); } diff --git a/ui-tests/jupyter_server_test_config_timeline.py b/ui-tests/jupyter_server_test_config_timeline.py index 4578db61..10546ca9 100644 --- a/ui-tests/jupyter_server_test_config_timeline.py +++ b/ui-tests/jupyter_server_test_config_timeline.py @@ -19,4 +19,3 @@ # Uncomment to set server log level to debug level # c.ServerApp.log_level = "DEBUG" - diff --git a/ui-tests/playwright.timeline.config.js b/ui-tests/playwright.timeline.config.js index 1aca6f4a..dd33d732 100644 --- a/ui-tests/playwright.timeline.config.js +++ b/ui-tests/playwright.timeline.config.js @@ -15,19 +15,19 @@ module.exports = { command: 'jlpm start:timeline', url: 'http://localhost:8888/api/collaboration/timeline/lab', timeout: 120 * 1000, - reuseExistingServer: !process.env.CI, + reuseExistingServer: !process.env.CI }, expect: { toMatchSnapshot: { - maxDiffPixelRatio: 0.01, - }, + maxDiffPixelRatio: 0.01 + } }, projects: [ { name: 'timeline-tests', testMatch: 'tests/**/timeline-*.spec.ts', testIgnore: '**/.ipynb_checkpoints/**', - timeout: 120 * 1000, - }, - ], + timeout: 120 * 1000 + } + ] }; diff --git a/ui-tests/tests/timeline-slider.spec.ts b/ui-tests/tests/timeline-slider.spec.ts index 03786afc..ba5326e3 100644 --- a/ui-tests/tests/timeline-slider.spec.ts +++ b/ui-tests/tests/timeline-slider.spec.ts @@ -34,7 +34,7 @@ test.describe('Timeline Slider', () => { test('should fail if there are console errors when opening from path', async ({ page, tmpPath }) => { if (isTimeline) { console.log('Skipping this test.'); - return; + return; } const pageErrors = await capturePageErrors(page); @@ -51,7 +51,7 @@ test.describe('Timeline Slider', () => { if (!isTimeline) { console.log('Skipping this test.'); - return; + return; } await page.goto('http://localhost:8888/api/collaboration/timeline') @@ -69,5 +69,5 @@ test.describe('Timeline Slider', () => { await expect(slider).toBeVisible(); expect(pageErrors).toHaveLength(0); - }); + }); }); From dc4f8ff819750a9f42461ece10e50d48af201b0b Mon Sep 17 00:00:00 2001 From: Meriem-BenIsmail Date: Mon, 25 Nov 2024 11:50:56 +0100 Subject: [PATCH 08/11] test info --- ui-tests/tests/timeline-slider.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-tests/tests/timeline-slider.spec.ts b/ui-tests/tests/timeline-slider.spec.ts index ba5326e3..a6b090da 100644 --- a/ui-tests/tests/timeline-slider.spec.ts +++ b/ui-tests/tests/timeline-slider.spec.ts @@ -47,7 +47,7 @@ test.describe('Timeline Slider', () => { expect(pageErrors).toHaveLength(0); }); - test('should display without console errors when baseUrl is set', async ({ page, baseURL }) => { + test('should display in status bar without console errors when baseUrl is set', async ({ page, baseURL }) => { if (!isTimeline) { console.log('Skipping this test.'); From c8296cc06993dc94030288c8c10b276d0a81fbf6 Mon Sep 17 00:00:00 2001 From: Meriem-BenIsmail Date: Mon, 25 Nov 2024 15:43:51 +0100 Subject: [PATCH 09/11] modified script for ui tests --- .../jupyter_server_test_config_timeline.py | 21 ------------------- ui-tests/package.json | 2 +- 2 files changed, 1 insertion(+), 22 deletions(-) delete mode 100644 ui-tests/jupyter_server_test_config_timeline.py diff --git a/ui-tests/jupyter_server_test_config_timeline.py b/ui-tests/jupyter_server_test_config_timeline.py deleted file mode 100644 index 10546ca9..00000000 --- a/ui-tests/jupyter_server_test_config_timeline.py +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (c) Jupyter Development Team. -# Distributed under the terms of the Modified BSD License. - -"""Server configuration for integration tests. - -!! Never use this configuration in production because it -opens the server to the world and provide access to JupyterLab -JavaScript objects through the global window variable. -""" -from typing import Any - -from jupyterlab.galata import configure_jupyter_server - -c: Any -configure_jupyter_server(c) # noqa - -c.ServerApp.base_url = "/api/collaboration/timeline/" - - -# Uncomment to set server log level to debug level -# c.ServerApp.log_level = "DEBUG" diff --git a/ui-tests/package.json b/ui-tests/package.json index 0df8b150..f40c4830 100644 --- a/ui-tests/package.json +++ b/ui-tests/package.json @@ -5,7 +5,7 @@ "private": true, "scripts": { "start": "jupyter lab --config jupyter_server_test_config.py", - "start:timeline": "jupyter lab --config jupyter_server_test_config_timeline.py", + "start:timeline": "jupyter lab --config jupyter_server_test_config.py --ServerApp.base_url=/api/collaboration/timeline/", "test": "npx playwright test --config=playwright.config.js", "test:timeline": "npx playwright test --config=playwright.timeline.config.js", "test:update": "npx playwright test --update-snapshots" From 63348fe16f6b7039192f39c415e440eae71edf83 Mon Sep 17 00:00:00 2001 From: Meriem-BenIsmail Date: Mon, 25 Nov 2024 18:24:59 +0100 Subject: [PATCH 10/11] removed unused cnd --- ui-tests/tests/timeline-slider.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/ui-tests/tests/timeline-slider.spec.ts b/ui-tests/tests/timeline-slider.spec.ts index a6b090da..490244fb 100644 --- a/ui-tests/tests/timeline-slider.spec.ts +++ b/ui-tests/tests/timeline-slider.spec.ts @@ -41,7 +41,6 @@ test.describe('Timeline Slider', () => { await page.notebook.createNew(); await page.notebook.close(); - if(!isTimeline) await openNotebook(page, `${tmpPath}/Untitled.ipynb`); expect(pageErrors).toHaveLength(0); From 71752029d0a31f57e16e75302435b1eb57b1a801 Mon Sep 17 00:00:00 2001 From: David Brochart Date: Tue, 26 Nov 2024 09:43:49 +0100 Subject: [PATCH 11/11] Test on main --- .../docprovider-extension/src/filebrowser.ts | 3 +-- packages/docprovider/src/TimelineSlider.tsx | 6 +----- packages/docprovider/src/component.tsx | 17 +++++------------ 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/packages/docprovider-extension/src/filebrowser.ts b/packages/docprovider-extension/src/filebrowser.ts index ee3af263..d68ecd90 100644 --- a/packages/docprovider-extension/src/filebrowser.ts +++ b/packages/docprovider-extension/src/filebrowser.ts @@ -182,8 +182,7 @@ export const statusBarTimeline: JupyterFrontEndPlugin = { fullPath, provider, provider.contentType, - provider.format, - DOCUMENT_TIMELINE_URL + provider.format ); const elt = document.getElementById('jp-slider-status-bar'); diff --git a/packages/docprovider/src/TimelineSlider.tsx b/packages/docprovider/src/TimelineSlider.tsx index c81615b4..f999fe7e 100644 --- a/packages/docprovider/src/TimelineSlider.tsx +++ b/packages/docprovider/src/TimelineSlider.tsx @@ -13,21 +13,18 @@ export class TimelineWidget extends ReactWidget { private provider: IForkProvider; private contentType: string; private format: string; - private documentTimelineUrl: string; constructor( apiURL: string, provider: IForkProvider, contentType: string, - format: string, - documentTimelineUrl: string + format: string ) { super(); this.apiURL = apiURL; this.provider = provider; this.contentType = contentType; this.format = format; - this.documentTimelineUrl = documentTimelineUrl; this.addClass('jp-timelineSliderWrapper'); } @@ -39,7 +36,6 @@ export class TimelineWidget extends ReactWidget { provider={this.provider} contentType={this.contentType} format={this.format} - documentTimelineUrl={this.documentTimelineUrl} /> ); } diff --git a/packages/docprovider/src/component.tsx b/packages/docprovider/src/component.tsx index 13351aa3..50533c53 100644 --- a/packages/docprovider/src/component.tsx +++ b/packages/docprovider/src/component.tsx @@ -19,15 +19,13 @@ type Props = { provider: IForkProvider; contentType: string; format: string; - documentTimelineUrl: string; }; export const TimelineSliderComponent: React.FC = ({ apiURL, provider, contentType, - format, - documentTimelineUrl + format }) => { const [data, setData] = useState({ roomId: '', @@ -149,21 +147,16 @@ export const TimelineSliderComponent: React.FC = ({ function determineAction(currentTimestamp: number): 'undo' | 'redo' { return currentTimestamp < currentTimestampIndex ? 'undo' : 'redo'; } + function extractFilenameFromURL(url: string): string { try { const parsedURL = new URL(url); const pathname = parsedURL.pathname; + const segments = pathname.split('/'); - const apiIndex = pathname.lastIndexOf(documentTimelineUrl); - if (apiIndex === -1) { - throw new Error( - `API segment "${documentTimelineUrl}" not found in URL.` - ); - } - - return pathname.slice(apiIndex + documentTimelineUrl.length); + return segments.slice(4 - segments.length).join('/'); } catch (error) { - console.error('Invalid URL or unable to extract filename:', error); + console.error('Invalid URL:', error); return ''; } }