mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 01:18:42 +00:00
Fleet UI: Tarballz allow uninstall bug fix (#31607)
This commit is contained in:
parent
a19c2f7669
commit
30d60dce1a
2 changed files with 109 additions and 2 deletions
|
|
@ -578,4 +578,102 @@ describe("HostInstallerActionCell component", () => {
|
|||
expect(screen.getByTestId("trash-icon")).toBeInTheDocument();
|
||||
expect(uninstallBtn.closest("button")).toBeDisabled();
|
||||
});
|
||||
it("renders Reinstall and Uninstall buttons for tgz package with no installed_versions", () => {
|
||||
render(
|
||||
<HostInstallerActionCell
|
||||
software={{
|
||||
...defaultSoftware,
|
||||
source: "tgz_packages",
|
||||
ui_status: "installed",
|
||||
status: "installed",
|
||||
software_package: mockSoftwarePackage,
|
||||
installed_versions: [], // no versions ever show for tgz packages
|
||||
app_store_app: null,
|
||||
}}
|
||||
onClickInstallAction={noop}
|
||||
onClickUninstallAction={noop}
|
||||
baseClass={baseClass}
|
||||
hostScriptsEnabled
|
||||
hostMDMEnrolled
|
||||
/>
|
||||
);
|
||||
|
||||
const installBtn = screen.getByTestId(`${baseClass}__install-button--test`);
|
||||
expect(installBtn).toHaveTextContent("Reinstall");
|
||||
expect(screen.getByTestId("refresh-icon")).toBeInTheDocument();
|
||||
expect(installBtn.closest("button")).toBeEnabled();
|
||||
|
||||
const uninstallBtn = screen.getByTestId(
|
||||
`${baseClass}__uninstall-button--test`
|
||||
);
|
||||
expect(uninstallBtn).toHaveTextContent("Uninstall");
|
||||
expect(screen.getByTestId("trash-icon")).toBeInTheDocument();
|
||||
expect(uninstallBtn.closest("button")).toBeEnabled();
|
||||
});
|
||||
it("renders disabled Reinstall and disabled Uninstall buttons for tgz package with no installed_versions when uninstall pending", () => {
|
||||
render(
|
||||
<HostInstallerActionCell
|
||||
software={{
|
||||
...defaultSoftware,
|
||||
source: "tgz_packages",
|
||||
ui_status: "pending_uninstall",
|
||||
status: "pending_uninstall",
|
||||
software_package: mockSoftwarePackage,
|
||||
installed_versions: [], // no versions ever show for tgz packages
|
||||
app_store_app: null,
|
||||
}}
|
||||
onClickInstallAction={noop}
|
||||
onClickUninstallAction={noop}
|
||||
baseClass={baseClass}
|
||||
hostScriptsEnabled
|
||||
hostMDMEnrolled
|
||||
/>
|
||||
);
|
||||
|
||||
const installBtn = screen.getByTestId(`${baseClass}__install-button--test`);
|
||||
expect(installBtn).toHaveTextContent("Reinstall");
|
||||
expect(screen.getByTestId("refresh-icon")).toBeInTheDocument();
|
||||
expect(installBtn.closest("button")).toBeDisabled();
|
||||
|
||||
const uninstallBtn = screen.getByTestId(
|
||||
`${baseClass}__uninstall-button--test`
|
||||
);
|
||||
expect(uninstallBtn).toHaveTextContent("Uninstall");
|
||||
expect(screen.getByTestId("trash-icon")).toBeInTheDocument();
|
||||
expect(uninstallBtn.closest("button")).toBeDisabled();
|
||||
});
|
||||
it("renders Reinstall and Retry uninstall buttons for tgz package with no installed_versions when uninstall failed", () => {
|
||||
render(
|
||||
<HostInstallerActionCell
|
||||
software={{
|
||||
...defaultSoftware,
|
||||
source: "tgz_packages",
|
||||
ui_status: "failed_uninstall",
|
||||
status: "failed_uninstall",
|
||||
software_package: mockSoftwarePackage,
|
||||
installed_versions: [], // no versions ever show for tgz packages
|
||||
app_store_app: null,
|
||||
}}
|
||||
onClickInstallAction={noop}
|
||||
onClickUninstallAction={noop}
|
||||
baseClass={baseClass}
|
||||
hostScriptsEnabled
|
||||
hostMDMEnrolled
|
||||
/>
|
||||
);
|
||||
|
||||
const installBtn = screen.getByTestId(`${baseClass}__install-button--test`);
|
||||
expect(installBtn).toHaveTextContent("Reinstall");
|
||||
expect(installBtn.closest("button")).toBeEnabled();
|
||||
|
||||
const uninstallBtn = screen.getByTestId(
|
||||
`${baseClass}__uninstall-button--test`
|
||||
);
|
||||
expect(uninstallBtn).toHaveTextContent("Retry uninstall");
|
||||
expect(uninstallBtn.closest("button")).toBeEnabled();
|
||||
|
||||
// Both reinstall and retry uninstall have the same icon
|
||||
const refreshIcons = screen.getAllByTestId("refresh-icon");
|
||||
expect(refreshIcons).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -201,11 +201,20 @@ export const HostInstallerActionCell = ({
|
|||
}
|
||||
}, [status, ui_status]);
|
||||
|
||||
const installedVersionsDetected =
|
||||
installed_versions && installed_versions.length > 0;
|
||||
|
||||
const installedTgzPackageDetected =
|
||||
software.source === "tgz_packages" &&
|
||||
(ui_status === "installed" ||
|
||||
ui_status === "pending_uninstall" ||
|
||||
ui_status === "uninstalling" ||
|
||||
ui_status === "failed_uninstall");
|
||||
|
||||
const canUninstallSoftware =
|
||||
!app_store_app &&
|
||||
!!software_package &&
|
||||
installed_versions &&
|
||||
installed_versions.length > 0;
|
||||
(installedVersionsDetected || installedTgzPackageDetected);
|
||||
|
||||
return (
|
||||
<div className={`${baseClass}__item-actions`}>
|
||||
|
|
|
|||
Loading…
Reference in a new issue