|
6 | 6 | TimeoutException, |
7 | 7 | UnexpectedAlertPresentException, |
8 | 8 | ) |
| 9 | +from selenium.webdriver.common.action_chains import ActionChains |
9 | 10 | from selenium.webdriver.common.alert import Alert |
10 | 11 | from selenium.webdriver.common.by import By |
| 12 | +from selenium.webdriver.common.keys import Keys |
11 | 13 | from selenium.webdriver.support import expected_conditions as EC |
12 | 14 | from selenium.webdriver.support.ui import Select, WebDriverWait |
13 | 15 |
|
@@ -130,6 +132,39 @@ def test_create_new_device(self): |
130 | 132 | 'The Device “11:22:33:44:55:66” was added successfully.', |
131 | 133 | ) |
132 | 134 |
|
| 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 | + |
133 | 168 | def test_unsaved_changes(self): |
134 | 169 | self.login() |
135 | 170 | device = self._create_config(organization=self._get_org()).device |
|
0 commit comments