From 054b0aa82beeae96b4ab8e5acbcfcf01d509b28f Mon Sep 17 00:00:00 2001 From: Disco DeDisco Date: Wed, 13 May 2026 00:00:57 -0400 Subject: [PATCH] =?UTF-8?q?test=5Fadmin=20FT:=20wait=20on=20post-login=20c?= =?UTF-8?q?ontent,=20not=20on=20``=20itself=20=E2=80=94=20pipeline?= =?UTF-8?q?=20#300=20caught=20the=20flake=20(`AssertionError:=20'Site=20ad?= =?UTF-8?q?ministration'=20not=20found=20in=20'Django=20administration\nTo?= =?UTF-8?q?ggle=20theme...\nEmail:\nPassword:'`);=20the=20pre-fix=20`body?= =?UTF-8?q?=20=3D=20self.wait=5Ffor(lambda:=20self.browser.find=5Felement(?= =?UTF-8?q?By.TAG=5FNAME,=20"body"))`=20resolved=20on=20the=20FIRST=20``=20Selenium=20found=20=E2=80=94=20which=20exists=20on=20the?= =?UTF-8?q?=20login=20page=20too=20=E2=80=94=20so=20on=20a=20slow=20CI=20r?= =?UTF-8?q?unner=20the=20form=20submit=20hadn't=20navigated=20yet=20by=20t?= =?UTF-8?q?he=20time=20wait=5Ffor=20completed,=20the=20assertion=20ran=20a?= =?UTF-8?q?gainst=20the=20still-stale=20login-page=20body,=20and=20the=20t?= =?UTF-8?q?est=20failed;=20locally=20the=20submit=20always=20completes=20i?= =?UTF-8?q?nside=20the=20wait=20window=20(10s=20MAX=5FWAIT)=20so=20this=20?= =?UTF-8?q?never=20reproduces;=20fix:=20wait=5Ffor=20the=20`"Site=20admini?= =?UTF-8?q?stration"`=20substring=20directly=20via=20`assertIn`=20(the=20`?= =?UTF-8?q?wait`=20decorator=20retries=20on=20AssertionError=20til=20MAX?= =?UTF-8?q?=5FWAIT,=20so=20the=20loop=20keeps=20polling=20the=20body's=20t?= =?UTF-8?q?ext=20content=20until=20the=20admin=20home=20page=20actually=20?= =?UTF-8?q?renders),=20THEN=20read=20body.text=20once=20+=20run=20the=20re?= =?UTF-8?q?maining=20Users=20/=20Tokens=20assertions=20inline=20=E2=80=94?= =?UTF-8?q?=20same=20shape=20as=20the=20working=20test=5Fadmin=5Ftarot=20/?= =?UTF-8?q?=20test=5Fadmin=5Fpost=5Freadonly=20login=20flows;=201=20FT=20g?= =?UTF-8?q?reen=20locally=20w.=20no=20other=20changes=20=E2=80=94=20TDD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Code architected by Disco DeDisco Git commit message Co-Authored-By: Claude Opus 4.7 --- src/functional_tests/test_admin.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/functional_tests/test_admin.py b/src/functional_tests/test_admin.py index 9f73b9a..898652e 100644 --- a/src/functional_tests/test_admin.py +++ b/src/functional_tests/test_admin.py @@ -20,9 +20,15 @@ class AdminLoginTest(FunctionalTest): self.browser.find_element(By.ID, "id_password").send_keys("correct-password") self.browser.find_element(By.CSS_SELECTOR, "input[type=submit]").click() - body = self.wait_for( - lambda: self.browser.find_element(By.TAG_NAME, "body") - ) - self.assertIn("Site administration", body.text) + # Wait on the post-login content, not on `body` itself — body exists + # on the login page too, so a slow CI runner can grab the pre-submit + # body before the form submit navigates and miss `Site administration` + # entirely. Pipeline #300 ate this flake; locally the submit always + # completes first. wait_for retries on AssertionError up to MAX_WAIT. + self.wait_for(lambda: self.assertIn( + "Site administration", + self.browser.find_element(By.TAG_NAME, "body").text, + )) + body = self.browser.find_element(By.TAG_NAME, "body") self.assertIn("Users", body.text) self.assertIn("Tokens", body.text)