Skip to content

Commit 211bebc

Browse files
dee077nemesifier
andauthored
[tests] Added selenium test for config preview keyboard shortcuts #868
Closes #868 --------- Co-authored-by: Federico Capoano <[email protected]>
1 parent 98fd7b1 commit 211bebc

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

openwisp_controller/config/tests/test_selenium.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
TimeoutException,
77
UnexpectedAlertPresentException,
88
)
9+
from selenium.webdriver.common.action_chains import ActionChains
910
from selenium.webdriver.common.alert import Alert
1011
from selenium.webdriver.common.by import By
12+
from selenium.webdriver.common.keys import Keys
1113
from selenium.webdriver.support import expected_conditions as EC
1214
from selenium.webdriver.support.ui import Select, WebDriverWait
1315

@@ -130,6 +132,39 @@ def test_create_new_device(self):
130132
'The Device “11:22:33:44:55:66” was added successfully.',
131133
)
132134

135+
def test_device_preview_keyboard_shortcuts(self):
136+
device = self._create_config(device=self._create_device(name='Test')).device
137+
self.login()
138+
self.open(reverse('admin:config_device_changelist'))
139+
try:
140+
self.open(reverse('admin:config_device_change', args=[device.id]))
141+
except TimeoutException:
142+
self.fail('Device detail page did not load in time')
143+
144+
with self.subTest('press ALT + P and expect overlay to be shown'):
145+
actions = ActionChains(self.web_driver)
146+
actions.key_down(Keys.ALT).send_keys('p').key_up(Keys.ALT).perform()
147+
try:
148+
WebDriverWait(self.web_driver, 1).until(
149+
EC.visibility_of_element_located(
150+
(By.CSS_SELECTOR, '.djnjc-overlay:not(.loading)')
151+
)
152+
)
153+
except TimeoutException:
154+
self.fail('The preview overlay is unexpectedly not visible')
155+
156+
with self.subTest('press ESC to close preview overlay'):
157+
actions = ActionChains(self.web_driver)
158+
actions.send_keys(Keys.ESCAPE).perform()
159+
try:
160+
WebDriverWait(self.web_driver, 1).until(
161+
EC.invisibility_of_element_located(
162+
(By.CSS_SELECTOR, '.djnjc-overlay:not(.loading)')
163+
)
164+
)
165+
except TimeoutException:
166+
self.fail('The preview overlay has not been closed as expected')
167+
133168
def test_unsaved_changes(self):
134169
self.login()
135170
device = self._create_config(organization=self._get_org()).device

0 commit comments

Comments
 (0)