Skip to content
Open
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-14 - Dynamic limits in inline client-side form validation
**Learning:** Hardcoding limit sizes (like "5 GiB") in client-side error and preview messages creates a maintenance risk when underlying constants (`MAX_UPLOAD_BYTES`) change. It also breaks a11y feedback if the text fails to accurately reflect the true limit.
**Action:** Always format backend-enforced size constants (e.g., `formatBinaryBytes(MAX_UPLOAD_BYTES)`) dynamically within client-side validation logic instead of hardcoding human-readable values.

## 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
- 닀쀑 파일 μ—…λ‘œλ“œ 선택 μ‹œ 즉각적인 파일 개수 ν”Όλ“œλ°± 및 μ œν•œ 초과 κ²½κ³  λ©”μ‹œμ§€ μΆ”κ°€
- 일괄 μ—…λ‘œλ“œ 폼에 λŒ€μƒ λ°”μ΄νŠΈ 프리셋 λ²„νŠΌκ³Ό 총 파일 크기 미리보기λ₯Ό μΆ”κ°€ν•˜μ—¬ μ‚¬μš©μ„±μ„ κ°œμ„ ν–ˆμŠ΅λ‹ˆλ‹€.
- ν΄λΌμ΄μ–ΈνŠΈ μ‚¬μ΄λ“œ 파일 크기 검증 λ‘œμ§μ—μ„œ ν•˜λ“œμ½”λ”©λœ μ—…λ‘œλ“œ μ œν•œ ν…μŠ€νŠΈλ₯Ό 동적 λ°”μ΄νŠΈ ν˜•μ‹μœΌλ‘œ λ³€κ²½ν•˜μ—¬ μ •ν™•ν•œ μ ‘κ·Όμ„± ν”Όλ“œλ°± 제곡
13 changes: 11 additions & 2 deletions saas_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,11 @@ async def add_security_headers(request: Request, call_next):
return;
}
const text = formatBinaryBytes(file.size);
const limitText = formatBinaryBytes(MAX_UPLOAD_BYTES);
if (file.size > MAX_UPLOAD_BYTES) {
input.setCustomValidity('File exceeds 5 GiB limit.');
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,14 @@ async def add_security_headers(request: Request, call_next):
preview.style.color = '#dc3545';
return;
}
const limitText = formatBinaryBytes(MAX_UPLOAD_BYTES);
if (totalSize > 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 total ' + limitText + ' limit)';
preview.style.color = '#dc3545';
return;
}
preview.innerText = 'Selected ' + files.length + ' file(s) (' + formatBinaryBytes(totalSize) + ')';
}

Expand Down
5 changes: 4 additions & 1 deletion tests/test_saas_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ 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("preview.innerText = 'Selected file size: ' + text + ' (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