-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[change] Use relative URLs in notification widget #249
JS code to implement this change + one selenium test. Closes: #249 --------- Co-authored-by: Federico Capoano <[email protected]>
- Loading branch information
1 parent
22e6b1e
commit fea1fa3
Showing
4 changed files
with
79 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from django.contrib.staticfiles.testing import StaticLiveServerTestCase | ||
from selenium.webdriver.common.by import By | ||
from selenium.webdriver.support import expected_conditions as EC | ||
from selenium.webdriver.support.ui import WebDriverWait | ||
|
||
from openwisp_notifications.swapper import load_model | ||
from openwisp_notifications.utils import _get_object_link | ||
from openwisp_users.tests.utils import TestOrganizationMixin | ||
from openwisp_utils.test_selenium_mixins import SeleniumTestMixin | ||
|
||
Notification = load_model('Notification') | ||
|
||
|
||
class TestWidget( | ||
SeleniumTestMixin, | ||
TestOrganizationMixin, | ||
StaticLiveServerTestCase, | ||
): | ||
serve_static = True | ||
|
||
def setUp(self): | ||
self.admin = self._create_admin( | ||
username=self.admin_username, password=self.admin_password | ||
) | ||
|
||
def test_notification_relative_link(self): | ||
self.login() | ||
operator = super()._create_operator() | ||
data = dict( | ||
email_subject='Test Email subject', | ||
url='http://localhost:8000/admin/', | ||
) | ||
notification = Notification.objects.create( | ||
actor=self.admin, | ||
recipient=self.admin, | ||
description='Test Notification Description', | ||
verb='Test Notification', | ||
action_object=operator, | ||
target=operator, | ||
data=data, | ||
) | ||
self.web_driver.implicitly_wait(10) | ||
WebDriverWait(self.web_driver, 10).until( | ||
EC.visibility_of_element_located((By.ID, 'openwisp_notifications')) | ||
) | ||
self.web_driver.find_element(By.ID, 'openwisp_notifications').click() | ||
WebDriverWait(self.web_driver, 10).until( | ||
EC.visibility_of_element_located((By.CLASS_NAME, 'ow-notification-elem')) | ||
) | ||
notification_elem = self.web_driver.find_element( | ||
By.CLASS_NAME, 'ow-notification-elem' | ||
) | ||
data_location_value = notification_elem.get_attribute('data-location') | ||
self.assertEqual( | ||
data_location_value, _get_object_link(notification, 'target', False) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters