Skip to content
Merged
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
4 changes: 4 additions & 0 deletions .jules/palette.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2024-07-15 - Dynamic Size formatting and Total Size Validation
**Learning:** Hardcoding human-readable sizes (like '5 GiB') in validation error messages is error-prone when the underlying constant changes. Moreover, failing to validate total upload size against backend limits (e.g., MAX_UPLOAD_BYTES) in batch file uploads frustrates users who wait for a large upload to finish only to get a server-side 413 Payload Too Large error.
**Action:** Always format backend byte limit constants dynamically (e.g., `formatBinaryBytes(MAX_UPLOAD_BYTES)`) on the client side to display accurate error messages. For multiple file inputs, ensure both the file count and the combined file size are validated against backend limits, giving immediate inline feedback via `setCustomValidity` and `aria-invalid`.

## 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
Expand Up @@ -4,3 +4,4 @@
### Added
- 닀쀑 파일 μ—…λ‘œλ“œ 선택 μ‹œ 즉각적인 파일 개수 ν”Όλ“œλ°± 및 μ œν•œ 초과 κ²½κ³  λ©”μ‹œμ§€ μΆ”κ°€
- 일괄 μ—…λ‘œλ“œ 폼에 λŒ€μƒ λ°”μ΄νŠΈ 프리셋 λ²„νŠΌκ³Ό 총 파일 크기 미리보기λ₯Ό μΆ”κ°€ν•˜μ—¬ μ‚¬μš©μ„±μ„ κ°œμ„ ν–ˆμŠ΅λ‹ˆλ‹€.
- ν΄λΌμ΄μ–ΈνŠΈ μΈ‘ 폼 검증 μ‹œ ν•˜λ“œμ½”λ”©λœ '5 GiB' ν…μŠ€νŠΈλ₯Ό λ™μ μœΌλ‘œ λ³€ν™˜λ˜λ„λ‘ μˆ˜μ •ν•˜κ³  일괄 μ—…λ‘œλ“œ 폼에 μ΅œλŒ€ 크기(MAX_UPLOAD_BYTES) 검증 ν”Όλ“œλ°±μ„ μΆ”κ°€ν–ˆμŠ΅λ‹ˆλ‹€.
14 changes: 12 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,15 @@ 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 file 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("File exceeds ' + limitText + ' limit.", html)
self.assertIn("Total file size exceeds ' + limitText + ' limit.", html)
self.assertIn("preview.style.color = '#0f6674';", html)
self.assertIn('onchange="updateFileSizePreview(this)"', html)

Expand Down
Loading