fix: codechef submit fixes and atcoder cleanup (#355)

## Problem

After the initial CodeChef implementation, submit silently swallowed
"contest not available for submission" errors, and the submit flow used
blind `wait_for_timeout` delays. AtCoder had an unnecessary 500ms settle
delay after file upload.

## Solution

Replace the initial page-load sleep in CodeChef submit with
`wait_for_selector`, replace the 3s post-click sleep with a proper
`wait_for_selector` on the result dialog, and extend the practice
fallback
check to catch both dialog variants. Remove AtCoder's
`BROWSER_SETTLE_DELAY`
and the constant from `timeouts.py`.
This commit is contained in:
Barrett Ruth 2026-03-06 23:40:12 -05:00 committed by GitHub
parent 3c11d609f5
commit 73e5c3f3f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13 additions and 11 deletions

View file

@ -178,16 +178,15 @@ def _submit_headless_codechef(
needs_relogin = True
return
try:
page.wait_for_timeout(2000)
page.wait_for_selector('[aria-haspopup="listbox"]', timeout=10000)
page.locator('[aria-haspopup="listbox"]').click()
page.wait_for_selector('[role="option"]', timeout=5000)
page.locator(f'[role="option"][data-value="{language_id}"]').click()
page.wait_for_timeout(2000)
page.wait_for_timeout(250)
page.locator(".ace_editor").click()
page.keyboard.press("Control+a")
page.wait_for_timeout(200)
page.evaluate(
"""(code) => {
const textarea = document.querySelector('.ace_text-input');
@ -199,20 +198,25 @@ def _submit_headless_codechef(
}""",
source_code,
)
page.wait_for_timeout(1000)
page.wait_for_timeout(125)
page.evaluate(
"() => document.getElementById('submit_btn').scrollIntoView({block:'center'})"
)
page.wait_for_timeout(200)
page.locator("#submit_btn").dispatch_event("click")
page.wait_for_timeout(3000)
try:
page.wait_for_selector('[role="dialog"], .swal2-popup', timeout=5000)
except Exception:
pass
dialog_text = page.evaluate("""() => {
const d = document.querySelector('[role="dialog"], .swal2-popup');
return d ? d.textContent.trim() : null;
}""")
if dialog_text and "not available for accepting solutions" in dialog_text:
if dialog_text and (
"not available for accepting solutions" in dialog_text
or "not available for submission" in dialog_text
):
submit_error = "PRACTICE_FALLBACK"
elif dialog_text:
submit_error = dialog_text