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

chore: relative url for notification links #266

Merged
merged 11 commits into from
Apr 22, 2024

Conversation

Dhanus3133
Copy link
Member

Fixes: #249

image

Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

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

Thank you @Dhanus3133, it looks good.

Here's a few things to improve, see below.

The REST API is returning relative URLs as shown in the following screenshot:

Screenshot from 2024-03-07 16-29-40

That's unintended, we only want this new behavior in the admin widget, the API may be hosted on a different domain and hence must return the full URL.

Please also add a new unit test which tests the new methods that allow returning the relative URLs.

Watch out also from build failures because of failed QA checks, please read the build output to find out how to run qa checks locally and how to fix common formatting and commit message format issues.

openwisp_notifications/base/models.py Outdated Show resolved Hide resolved
@Dhanus3133 Dhanus3133 force-pushed the issues/249-allow-relative-paths branch from acc534e to 66700a2 Compare March 8, 2024 08:17
@Dhanus3133
Copy link
Member Author

Updated with just the required notification widget changes, although the QA checks for the CSS files are failing for some reason.

@Dhanus3133 Dhanus3133 requested a review from nemesifier March 8, 2024 15:33
Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

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

Works as expected now, thanks!
Take a look at the comments below for some minor code improvements.

If you can add a selenium browser test for this it would be great, let me know!

@Dhanus3133 Dhanus3133 force-pushed the issues/249-allow-relative-paths branch from 9db0fef to 2dc4a4b Compare March 13, 2024 14:36
@Dhanus3133 Dhanus3133 force-pushed the issues/249-allow-relative-paths branch from 2dc4a4b to 875b419 Compare March 13, 2024 14:39
@Dhanus3133
Copy link
Member Author

@nemesifier, I tried adding Selenium tests, but when the notification tab is clicked, it just loads. When I look into the console, it says it cannot find WS and returns 404 in the network.
image
Could you help me here? Thanks.

@nemesifier
Copy link
Member

it just loads

Did you mean "it doesn't load"?

@Dhanus3133
Copy link
Member Author

Did you mean "it doesn't load"?

I meant the WebSocket connection is not found, so in the front end, it just waits, causing the spinning UI.

recording.mp4

Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

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

The base test class StaticLiveServerTestCase does not support websockets.

Here's a rough outline of how we might structure these tests:

from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from channels.testing import ChannelsLiveServerTestCase

class SeleniumTestNotifications(StaticLiveServerTestCase, ChannelsLiveServerTestCase):
    # ... etc ...

Please consults these links for more information:

@Dhanus3133 Dhanus3133 force-pushed the issues/249-allow-relative-paths branch from cfb5d69 to 743599f Compare March 22, 2024 14:11
@Dhanus3133 Dhanus3133 requested a review from nemesifier March 23, 2024 07:40
Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

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

@Dhanus3133 I missed the latest updates on this, will review asap.

Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

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

Great work @Dhanus3133, I left some comments below, I am doing some quick tests locally to verify some of my comments.

openwisp_notifications/tests/test_notifications.py Outdated Show resolved Hide resolved
requirements-test.txt Outdated Show resolved Hide resolved
tests/openwisp2/settings.py Outdated Show resolved Hide resolved
Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

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

@Dhanus3133 I pushed some improvements, feel free to review the changes. Once the build passes I will merge. 👍

@nemesifier nemesifier merged commit af4f504 into openwisp:master Apr 22, 2024
10 checks passed
@Dhanus3133 Dhanus3133 deleted the issues/249-allow-relative-paths branch April 23, 2024 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[change] Allow relative paths
2 participants