Skip to content

Commit bc18488

Browse files
committed
Fix "go back" button in djDebugWindow
Regression introduced in 344baae where the return statement in visible() mistakenly went missing. A new Selenium test was added to help ensure the regression doesn't return.
1 parent 24df791 commit bc18488

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

debug_toolbar/static/debug_toolbar/js/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const $$ = {
2121
}
2222
},
2323
visible: function (element) {
24-
element.classList.contains("djdt-hidden");
24+
return !element.classList.contains("djdt-hidden");
2525
},
2626
executeScripts: function (scripts) {
2727
scripts.forEach(function (script) {

tests/test_integration.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
try:
2323
from selenium import webdriver
2424
from selenium.common.exceptions import NoSuchElementException
25+
from selenium.webdriver.common.by import By
2526
from selenium.webdriver.firefox.options import Options
27+
from selenium.webdriver.support import expected_conditions as EC
2628
from selenium.webdriver.support.wait import WebDriverWait
2729
except ImportError:
2830
webdriver = None
@@ -442,6 +444,33 @@ def test_django_cached_template_loader(self):
442444
)
443445
)
444446

447+
def test_sql_action_and_go_back(self):
448+
self.selenium.get(self.live_server_url + "/execute_sql/")
449+
sql_panel = self.selenium.find_element_by_id("SQLPanel")
450+
debug_window = self.selenium.find_element_by_id("djDebugWindow")
451+
452+
# Click to show the SQL panel
453+
self.selenium.find_element_by_class_name("SQLPanel").click()
454+
455+
# SQL panel loads
456+
button = WebDriverWait(self.selenium, timeout=3).until(
457+
EC.visibility_of_element_located((By.CSS_SELECTOR, ".remoteCall"))
458+
)
459+
button.click()
460+
461+
# SQL selected window loads
462+
WebDriverWait(self.selenium, timeout=3).until(EC.visibility_of(debug_window))
463+
self.assertIn("SQL selected", debug_window.text)
464+
465+
# Close the SQL selected window
466+
debug_window.find_element_by_class_name("djDebugClose").click()
467+
WebDriverWait(self.selenium, timeout=3).until(
468+
EC.invisibility_of_element(debug_window)
469+
)
470+
471+
# SQL panel is still visible
472+
self.assertTrue(sql_panel.is_displayed())
473+
445474

446475
@override_settings(DEBUG=True)
447476
class DebugToolbarSystemChecksTestCase(SimpleTestCase):

0 commit comments

Comments
 (0)