From d7df4002acdea639412df396ee51c09c7a282c2e Mon Sep 17 00:00:00 2001 From: RachelElysia Date: Fri, 27 Sep 2024 08:48:07 -0700 Subject: [PATCH] Fleet UI: Add support for .rpm packages --- changes/20537-rpm-fe | 1 + .../components/PackageForm/PackageForm.tsx | 2 +- frontend/utilities/file/fileUtils.tests.ts | 23 ++++++++++++------- 3 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 changes/20537-rpm-fe diff --git a/changes/20537-rpm-fe b/changes/20537-rpm-fe new file mode 100644 index 000000000000..d21510598e9c --- /dev/null +++ b/changes/20537-rpm-fe @@ -0,0 +1 @@ +- Add support for .rpm files in add/edit software diff --git a/frontend/pages/SoftwarePage/components/PackageForm/PackageForm.tsx b/frontend/pages/SoftwarePage/components/PackageForm/PackageForm.tsx index 545a5a3881cb..4e9d7aa74de0 100644 --- a/frontend/pages/SoftwarePage/components/PackageForm/PackageForm.tsx +++ b/frontend/pages/SoftwarePage/components/PackageForm/PackageForm.tsx @@ -173,7 +173,7 @@ const PackageForm = ({ canEdit={isEditingSoftware} graphicName={"file-pkg"} accept={ACCEPTED_EXTENSIONS} - message=".pkg, .msi, .exe, .deb or .rpm" + message=".pkg, .msi, .exe, .deb, or .rpm" onFileUpload={onFileSelect} buttonMessage="Choose file" buttonType="link" diff --git a/frontend/utilities/file/fileUtils.tests.ts b/frontend/utilities/file/fileUtils.tests.ts index 8d650638920a..f21f84001959 100644 --- a/frontend/utilities/file/fileUtils.tests.ts +++ b/frontend/utilities/file/fileUtils.tests.ts @@ -2,15 +2,22 @@ import { getPlatformDisplayName } from "./fileUtils"; describe("fileUtils", () => { describe("getPlatformDisplayName", () => { - it("should return the correct platform display name depending on the file extension", () => { - const file = new File([""], "test.pkg"); - expect(getPlatformDisplayName(file)).toEqual("macOS"); + const testCases = [ + { extension: "pkg", platform: "macOS" }, + { extension: "json", platform: "macOS" }, + { extension: "mobileconfig", platform: "macOS" }, + { extension: "exe", platform: "Windows" }, + { extension: "msi", platform: "Windows" }, + { extension: "xml", platform: "Windows" }, + { extension: "deb", platform: "Linux" }, + { extension: "rpm", platform: "Linux" }, + ]; - const file2 = new File([""], "test.exe"); - expect(getPlatformDisplayName(file2)).toEqual("Windows"); - - const file3 = new File([""], "test.deb"); - expect(getPlatformDisplayName(file3)).toEqual("linux"); + testCases.forEach(({ extension, platform }) => { + it(`should return ${platform} for .${extension} files`, () => { + const file = new File([""], `test.${extension}`); + expect(getPlatformDisplayName(file)).toEqual(platform); + }); }); }); });