Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/palette.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2026-07-29 - Dynamic File Size Limits and Batch Validation
**Learning:** Hardcoding server limit variables like `MAX_UPLOAD_BYTES` in client-side error strings creates a brittle UX that goes out of sync. Furthermore, omitting total size checks for batch uploads forces users to wait for server-side rejection rather than getting immediate feedback.
**Action:** Always dynamically format backend limits for client-side error strings using shared utilities, and implement inline validation with `setCustomValidity` and `aria-invalid` for both single and batch upload scenarios.
## 2024-07-12 - Intercepting batch form submissions for testing visual loading states
**Learning:** Extending the learning from 2024-06-13, intercepting form submissions using `e.preventDefault()` via `page.evaluate()` is essential for capturing screenshot and video evidence of loading states (e.g., button disabling, spinner appearing) on forms like batch upload where the submission would normally reload the page or download an archive.
**Action:** When testing visual loading states with Playwright, always inject an event listener using `page.evaluate()` to call `e.preventDefault()` on the form's `submit` event to freeze the UI in its loading state for verification.
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* 🎨 Palette: [UX improvement] ν΄λΌμ΄μ–ΈνŠΈ μΈ‘ 폼 검증 μ‹œ 동적인 파일 크기 μ œν•œ λ©”μ‹œμ§€λ₯Ό μ œκ³΅ν•˜κ³ , 일괄 μ—…λ‘œλ“œμ˜ 총 μš©λŸ‰ μ œν•œμ— λŒ€ν•œ 인라인 μ—λŸ¬ ν”Όλ“œλ°±μ„ μΆ”κ°€ν–ˆμŠ΅λ‹ˆλ‹€.
# Changelog

## [Unreleased]
Expand Down
15 changes: 13 additions & 2 deletions saas_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,10 @@ async def add_security_headers(request: Request, call_next):
}
const text = formatBinaryBytes(file.size);
if (file.size > MAX_UPLOAD_BYTES) {
input.setCustomValidity('File exceeds 5 GiB limit.');
const limitText = formatBinaryBytes(MAX_UPLOAD_BYTES);
input.setCustomValidity('File exceeds ' + limitText + ' limit.');
input.setAttribute('aria-invalid', 'true');
preview.innerText = 'Selected file size: ' + text + ' (exceeds 5 GiB limit)';
preview.innerText = 'Selected file size: ' + text + ' (exceeds ' + limitText + ' limit)';
preview.style.color = '#dc3545';
return;
}
Expand Down Expand Up @@ -325,6 +326,16 @@ async def add_security_headers(request: Request, call_next):
preview.style.color = '#dc3545';
return;
}

if (totalSize > MAX_UPLOAD_BYTES) {
const limitText = formatBinaryBytes(MAX_UPLOAD_BYTES);
input.setCustomValidity('Total size exceeds ' + limitText + ' limit.');
input.setAttribute('aria-invalid', 'true');
preview.innerText = 'Selected ' + files.length + ' file(s) (' + formatBinaryBytes(totalSize) + ', exceeds ' + limitText + ' limit)';
preview.style.color = '#dc3545';
return;
}

preview.innerText = 'Selected ' + files.length + ' file(s) (' + formatBinaryBytes(totalSize) + ')';
}

Expand Down
4 changes: 3 additions & 1 deletion tests/test_saas_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ def test_get_ui_includes_binary_file_size_validation(self):

self.assertIn("const MAX_UPLOAD_BYTES = 5 * 1024 * 1024 * 1024;", html)
self.assertIn("['B', 'KiB', 'MiB', 'GiB']", html)
self.assertIn("File exceeds 5 GiB limit.", html)
self.assertIn("const limitText = formatBinaryBytes(MAX_UPLOAD_BYTES);", html)
self.assertIn("input.setCustomValidity('File exceeds ' + limitText + ' limit.');", html)
self.assertIn("input.setCustomValidity('Total size exceeds ' + limitText + ' limit.');", html)
self.assertIn("preview.style.color = '#0f6674';", html)
self.assertIn('onchange="updateFileSizePreview(this)"', html)

Expand Down
Loading