Skip to content

Commit cefc2bd

Browse files
fix: show oversized upload error when mime type is missing (#7757)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 78473bf commit cefc2bd

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

apps/web/modules/ui/components/file-input/lib/utils.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ describe("File Input Utils", () => {
6767
expect(toast.error).toHaveBeenCalledWith(expect.stringContaining("File exceeds 5 MB size limit."));
6868
});
6969

70+
test("should show size error for oversized files even when mime type is empty", async () => {
71+
const files = [new File(["x".repeat(101000)], "large.ico", { type: "" })];
72+
73+
const result = await getAllowedFiles(files, ["ico"], 0.1);
74+
75+
expect(result).toHaveLength(0);
76+
expect(toast.error).toHaveBeenCalledWith(expect.stringContaining("File exceeds 0.1 MB size limit."));
77+
});
78+
7079
test("should convert HEIC files to JPEG", async () => {
7180
const heicFile = new File(["test"], "test.heic", { type: "image/heic" });
7281
const mockConvertedFile = new File(["converted"], "test.jpg", { type: "image/jpeg" });

apps/web/modules/ui/components/file-input/lib/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const getAllowedFiles = async (
2121
const convertedFiles: File[] = [];
2222

2323
for (const file of files) {
24-
if (!file || !file.type) {
24+
if (!file) {
2525
continue;
2626
}
2727

0 commit comments

Comments
 (0)