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

Fix timeline feature error when base url is set #402

Merged
merged 11 commits into from
Nov 26, 2024

Conversation

Meriem-BenIsmail
Copy link
Contributor

This PR fixes #393

Copy link
Contributor

Binder 👈 Launch a Binder on branch Meriem-BenIsmail/jupyter-collaboration/baseurl-bug

@krassowski krassowski added the bug Something isn't working label Nov 18, 2024
@davidbrochart
Copy link
Collaborator

Failures seem to be unrelated (see #403).
I will look at that.

Copy link
Collaborator

@davidbrochart davidbrochart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since #393 seems to suggest an issue with the server base URL, should you make use of it in this PR? The baseUrl is available in JupyterLab's page config.

@Meriem-BenIsmail
Copy link
Contributor Author

Since #393 seems to suggest an issue with the server base URL, should you make use of it in this PR? The baseUrl is available in JupyterLab's page config.

The problem isn't actually with the baseUrl, it's just that the document name was being incorrectly extracted.

@davidbrochart
Copy link
Collaborator

Could you write a test that shows that this was indeed the cause of problem? In particular, I'd like to see that your fix works even if "api/collaboration/timeline" is present in the base URL.

@Meriem-BenIsmail
Copy link
Contributor Author

Currently, the updated logic ensures that only the last occurrence of api/collaboration/timeline is picked up, so it should handle the base URL scenario as expected. Given this, the fix seems okay for the mentioned issue.

Would you still like me to add a specific test to verify this behavior?

I also want to mention that there’s another open PR (#401) that creates a test file for the timeline slider. If I add a test here, it would create or modify the same file, potentially leading to conflicts later. Let me know how you'd like to proceed—whether to hold off on tests for this PR until #401 is merged or go ahead and add them now.

@@ -20,6 +20,7 @@ type Props = {
contentType: string;
format: string;
};
const DOCUMENT_TIMELINE_URL = 'api/collaboration/timeline';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have it here and here. Should it be in one place?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I will fix that. Thanks for the feedback !

@davidbrochart
Copy link
Collaborator

Yes it would be nice to have a test. I merged #401.

@@ -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",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can get rid of ui-tests/jupyter_server_test_config_timeline.py and do:

Suggested change
"start:timeline": "jupyter lab --config jupyter_server_test_config_timeline.py",
"start:timeline": "jupyter lab --ServerApp.base_url=/api/collaboration/timeline/",


isTimeline && test.use({ autoGoto: false })

test('should fail if there are console errors when opening from path', async ({ page, tmpPath }) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what this test does. It seems that you do nothing if isTimeline?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to execute this test in the added timeline test environment (with the set baseurl)
but this is the test for this PR that was merged #401

await openNotebook(page, `${tmpPath}/Untitled.ipynb`);

expect(pageErrors).toHaveLength(0);
});

test('should display in status bar without console errors when baseUrl is set', async ({ page, baseURL }) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

await page.notebook.close();

if(!isTimeline)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(!isTimeline)


test.describe('Timeline Slider', () => {

isTimeline && test.use({ autoGoto: false })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is it for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I found that even with different configuration, somehow playwright overwrites the baseurl and goes to the default one (http://localhost:8888) by default so we need to use this test.use({ autoGoto: false })

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the part isTimeline && ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isTimeline is the environment variable used to determine whether we are testing with the new environment or the default one. So we need to do this test.use({ autoGoto: false }) only if we are testing with the new env (when isTimeline is true like in here TIMELINE_FEATURE=1 jlpm test:timeline )

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain what you mean by "new environment" and "default environment"?

Copy link
Contributor Author

@Meriem-BenIsmail Meriem-BenIsmail Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "new environment" refers to the testing setup needed for this PR, which uses a custom baseUrl (/api/collaboration/timeline/) as opposed to the "default environment," where tests run with the standard baseUrl (/lab or /). The new environment is specifically configured to validate the Timeline functionality in isolation, whereas the default environment is used for general tests without the Timeline-specific context.

isTimeline is used to identify which environment is active. If isTimeline is true, we disable the automatic navigation (test.use({ autoGoto: false })) that Playwright performs, as this navigation doesn’t respect the custom baseUrl and defaults to http://localhost:8888. Disabling it allows us to manually control the navigation to the appropriate custom environment.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I think this is clearer:

Suggested change
isTimeline && test.use({ autoGoto: false })
if (isTimeline) {
test.use({ autoGoto: false });
}

Copy link
Collaborator

@davidbrochart davidbrochart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidbrochart davidbrochart merged commit 9802fd3 into jupyterlab:main Nov 26, 2024
27 checks passed
@Meriem-BenIsmail Meriem-BenIsmail deleted the baseurl-bug branch December 5, 2024 10:00
@Meriem-BenIsmail Meriem-BenIsmail restored the baseurl-bug branch January 6, 2025 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Timeline slider not shown when base_url is set
3 participants