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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openstack-uicore-foundation",
"version": "5.0.44",
"version": "5.0.47-beta.0",
"description": "ui reactjs components for openstack marketing site",
"main": "lib/openstack-uicore-foundation.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,11 @@ describe('UploadInputV3', () => {
expect(screen.getByText(/Complete/)).toBeInTheDocument();
});

test('shows default size when size is not provided', () => {
test('does not show file size when size is not provided', () => {
const files = [{ filename: 'no-size.pdf' }];
render(<UploadInputV3 {...defaultProps} value={files} />);
expect(screen.getByText(/0 KB/)).toBeInTheDocument();
expect(screen.queryByText(/KB|MB/)).not.toBeInTheDocument();
expect(screen.getByText(/Complete/)).toBeInTheDocument();
});

test('formats file size correctly', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/upload-input-v3/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ const UploadInputV3 = ({
{filename}
</Typography>
<Typography variant="caption" color="text.secondary">
{fileSize} · {T.translate("upload_input_v3.complete")}
{file?.size ? `${fileSize} ·` : ''} {T.translate("upload_input_v3.complete")}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Preserve the size for zero-byte files.

formatFileSize returns 0 KB when file.size is 0, but this truthiness check hides it. A valid empty file will display only Complete. Check for missing metadata instead and add a zero-byte test.

Proposed fix
-                    {file?.size ? `${fileSize} ·` : ''} {T.translate("upload_input_v3.complete")}
+                    {file?.size != null ? `${fileSize} ·` : ''} {T.translate("upload_input_v3.complete")}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{file?.size ? `${fileSize} ·` : ''} {T.translate("upload_input_v3.complete")}
{file?.size != null ? `${fileSize} ·` : ''} {T.translate("upload_input_v3.complete")}
🧰 Tools
🪛 ast-grep (0.45.0)

[warning] 476-478: A list component should have a key to prevent re-rendering
Context:
{file?.size ? ${fileSize} · : ''} {T.translate("upload_input_v3.complete")}

Note: [CWE-710] Improper Adherence to Coding Standards. Security best practice.

(list-component-needs-key)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/inputs/upload-input-v3/index.js` at line 478, Update the
file-size display in the upload completion rendering near formatFileSize so
zero-byte files retain and show “0 KB ·”. Replace the truthiness check on
file.size with a missing-metadata check that only omits the size when file or
its size is unavailable, and add a test covering a zero-byte file.

</Typography>
</Box>

Expand Down
Loading