fix: show oversized upload error when mime type is missing (#7757)

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
This commit is contained in:
Johannes
2026-04-20 00:00:41 -07:00
committed by GitHub
parent 78473bf3d0
commit cefc2bdf60
2 changed files with 10 additions and 1 deletions
@@ -67,6 +67,15 @@ describe("File Input Utils", () => {
expect(toast.error).toHaveBeenCalledWith(expect.stringContaining("File exceeds 5 MB size limit."));
});
test("should show size error for oversized files even when mime type is empty", async () => {
const files = [new File(["x".repeat(101000)], "large.ico", { type: "" })];
const result = await getAllowedFiles(files, ["ico"], 0.1);
expect(result).toHaveLength(0);
expect(toast.error).toHaveBeenCalledWith(expect.stringContaining("File exceeds 0.1 MB size limit."));
});
test("should convert HEIC files to JPEG", async () => {
const heicFile = new File(["test"], "test.heic", { type: "image/heic" });
const mockConvertedFile = new File(["converted"], "test.jpg", { type: "image/jpeg" });
@@ -21,7 +21,7 @@ export const getAllowedFiles = async (
const convertedFiles: File[] = [];
for (const file of files) {
if (!file || !file.type) {
if (!file) {
continue;
}