test_auth.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. from selenium.webdriver.common.by import By
  2. from sentry.testutils import AcceptanceTestCase
  3. class AuthTest(AcceptanceTestCase):
  4. def enter_auth(self, username, password):
  5. self.browser.get("/auth/login/")
  6. self.browser.driver.execute_script(
  7. "document.addEventListener('invalid', function(e) { e.preventDefault(); }, true);"
  8. )
  9. self.browser.find_element(by=By.ID, value="id_username").send_keys(username)
  10. self.browser.find_element(by=By.ID, value="id_password").send_keys(password)
  11. self.browser.find_element(
  12. by=By.XPATH, value="//button[contains(text(), 'Continue')]"
  13. ).click()
  14. def test_renders(self):
  15. self.browser.get("/auth/login/")
  16. self.browser.snapshot(name="login")
  17. def test_no_credentials(self):
  18. self.enter_auth("", "")
  19. self.browser.snapshot(name="login fields required")
  20. def test_invalid_credentials(self):
  21. self.enter_auth("bad-username", "bad-username")
  22. self.browser.snapshot(name="login fields invalid")
  23. def test_success(self):
  24. email = "dummy@example.com"
  25. password = "dummy"
  26. user = self.create_user(email=email)
  27. user.set_password(password)
  28. user.save()
  29. self.enter_auth(email, password)
  30. self.browser.wait_until_not(".loading")
  31. self.browser.snapshot(name="login success")