new test_dashboard FT (part 1) for username applet on dashboard; apps/dashboard/home.html gained new applet section to support additions; new urlpatterns in apps.dash.urls; tweaks to .views, including the @login_required decorator and set_profile() FBV; new ITs in .tests.integrated.test_views
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -65,7 +65,7 @@ class FunctionalTest(StaticLiveServerTestCase):
|
||||
def dump_html(self):
|
||||
path = SCREEN_DUMP_LOCATION / self._get_filename("html")
|
||||
print("dumping page html to", path)
|
||||
path.write_text(self.browser.page_source)
|
||||
path.write_text(self.browser.page_source, encoding="utf-8")
|
||||
|
||||
def _get_filename(self, extension):
|
||||
timestamp = datetime.now().isoformat().replace(":", ".")
|
||||
|
||||
39
src/functional_tests/test_dashboard.py
Normal file
39
src/functional_tests/test_dashboard.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
|
||||
from .base import FunctionalTest
|
||||
|
||||
|
||||
class DashboardMaintenanceTest(FunctionalTest):
|
||||
def test_user_without_username_can_claim_unclaimed_username(self):
|
||||
# 1. Create a pre-authenticated session for discoman@example.com
|
||||
self.create_pre_authenticated_session("discoman@example.com")
|
||||
# 2. Navigate to self.live_server_url + "/"
|
||||
self.browser.get(self.live_server_url)
|
||||
# 3. Find the username applet on the page; look for a <section> or <div> with id="id_username_applet"
|
||||
self.browser.find_element(By.ID, "id_applet_username")
|
||||
# 4. Assert it shows the current display name (truncated email: di…an@e…e.com)
|
||||
self.assertIn("di…an@e…e.com", self.browser.find_element(By.ID, "id_applet_username").text)
|
||||
# 5. Find the username input field inside the applet & type a username
|
||||
username_input = self.browser.find_element(By.CSS_SELECTOR, "#id_new_username")
|
||||
# 6. Type a username, e.g., discoman
|
||||
username_input.send_keys("discoman")
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, "#id_new_username:valid")
|
||||
)
|
||||
# 7. Submit the form (click a btn or press Enter)
|
||||
username_input.send_keys(Keys.ENTER)
|
||||
# 8. Without a page reload, wait for the navbar to update; user wait_for() to check that the navbar text now contains "discoman"
|
||||
self.wait_for(
|
||||
lambda: self.assertIn(
|
||||
"discoman",
|
||||
self.browser.find_element(By.CLASS_NAME, "navbar-text").text
|
||||
)
|
||||
)
|
||||
# 9. Also assert the applet input now shows "discoman" as its value
|
||||
self.wait_for(
|
||||
lambda: self.assertEqual(
|
||||
"discoman",
|
||||
self.browser.find_element(By.CSS_SELECTOR, "#id_new_username").get_attribute("value")
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user