fleet/frontend/pages/SoftwarePage/SoftwareTitleDetailsPage/SoftwareInstallerCard/InstallerStatusTable/InstallerStatusTable.tests.tsx
RachelElysia c9e66b221e
Frontend: Lint warning cleanup part 1 (#43411)
## Issue
- First batch of @iansltx 's work of cleaning up lint warnings #43387 

## Description
- Quick PR review and grabbed as many confirmed low-risk quick wins as I
could `git checkout lint-cleanup <file/path/1> <file/path/2>`

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Release Notes

This release contains internal code improvements with one minor UI
tweak:

* **Style**
* Dropdown menu background color adjusted for clearer contrast in action
lists
* **Refactor**
* Improved type safety across the codebase with stricter TypeScript
annotations
  * Removed unused imports and constants to reduce code clutter
* Enhanced React hook dependency arrays for more consistent component
behavior
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Rachel Perkins <rachel@Rachels-MacBook-Pro.local>
Co-authored-by: Ian Littman <iansltx@gmail.com>
2026-04-10 19:49:52 -05:00

185 lines
4.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React from "react";
import { screen, waitFor } from "@testing-library/react";
import { createCustomRenderer } from "test/test-utils";
import InstallerStatusTable from "./InstallerStatusTable";
describe("InstallerStatusTable", () => {
const render = createCustomRenderer();
it("renders columns and links for statuses", () => {
render(
<InstallerStatusTable
softwareId={123}
teamId={5}
status={{ installed: 0, pending: 1, failed: 3 }}
/>
);
// Check cell values (always "hosts", even for 1)
const cells = screen.getAllByRole("cell");
const installedLink = cells[0].querySelector("a.link-cell");
const pendingLink = cells[1].querySelector("a.link-cell");
const failedLink = cells[2].querySelector("a.link-cell");
expect(installedLink).toHaveTextContent("0 hosts");
expect(pendingLink).toHaveTextContent("1 host");
expect(failedLink).toHaveTextContent("3 hosts");
});
it("renders correct header titles for install vs script package", () => {
const { rerender } = render(
<InstallerStatusTable
softwareId={1}
teamId={1}
status={{ installed: 0, pending: 0, failed: 0 }}
isScriptPackage={false}
/>
);
let headers = screen.getAllByRole("columnheader");
expect(headers[0]).toHaveTextContent("Installed");
expect(headers[1]).toHaveTextContent("Pending");
expect(headers[2]).toHaveTextContent("Failed");
rerender(
<InstallerStatusTable
softwareId={1}
teamId={1}
status={{ installed: 0, pending: 0, failed: 0 }}
isScriptPackage
/>
);
headers = screen.getAllByRole("columnheader");
expect(headers[0]).toHaveTextContent("Ran");
expect(headers[1]).toHaveTextContent("Pending");
expect(headers[2]).toHaveTextContent("Failed");
});
it("renders different tooltips for Android Play Store vs non-Android for pending", async () => {
// non-Android: pending install/uninstall message
const { user, rerender } = render(
<InstallerStatusTable
softwareId={1}
teamId={1}
status={{ installed: 0, pending: 0, failed: 0 }}
isAndroidPlayStoreApp={false}
/>
);
let pendingHeader = screen.getByText(/pending/i);
await user.hover(pendingHeader);
await waitFor(() => {
expect(
screen.getByText(/Fleet is installing\/uninstalling or will/i)
).toBeInTheDocument();
});
// Android: Play Storestyle message
rerender(
<InstallerStatusTable
softwareId={1}
teamId={1}
status={{ installed: 0, pending: 0, failed: 0 }}
isAndroidPlayStoreApp
/>
);
pendingHeader = screen.getByText(/pending/i);
await user.hover(pendingHeader);
await waitFor(() => {
expect(
screen.getByText(/Software will be installed or configuration will/i)
).toBeInTheDocument();
});
});
it("hides installed tooltip for Android Play Store app", async () => {
const { user, rerender } = render(
<InstallerStatusTable
softwareId={1}
teamId={1}
status={{ installed: 0, pending: 0, failed: 0 }}
isAndroidPlayStoreApp={false}
/>
);
let installedHeader = screen.getByText(/installed/i);
await user.hover(installedHeader);
await waitFor(() => {
expect(
screen.getByText(/Software is installed on these hosts/i)
).toBeInTheDocument();
});
rerender(
<InstallerStatusTable
softwareId={1}
teamId={1}
status={{ installed: 0, pending: 0, failed: 0 }}
isAndroidPlayStoreApp
/>
);
installedHeader = screen.getByText(/installed/i);
await user.hover(installedHeader);
// Installed tooltip returns null for Android Play Store
await waitFor(() => {
expect(
screen.queryByText(/Software is installed on these hosts/i)
).not.toBeInTheDocument();
});
});
it("renders failed tooltip text correctly for Android vs non-Android", async () => {
const { user, rerender } = render(
<InstallerStatusTable
softwareId={1}
teamId={1}
status={{ installed: 0, pending: 0, failed: 0 }}
isAndroidPlayStoreApp={false}
/>
);
let failedHeader = screen.getByText(/failed/i);
await user.hover(failedHeader);
await waitFor(() => {
expect(
screen.getByText(/These hosts failed to install\/uninstall software/i)
).toBeInTheDocument();
});
rerender(
<InstallerStatusTable
softwareId={1}
teamId={1}
status={{ installed: 0, pending: 0, failed: 0 }}
isAndroidPlayStoreApp
/>
);
failedHeader = screen.getByText(/failed/i);
await user.hover(failedHeader);
await waitFor(() => {
expect(
screen.getByText(
/Software failed to install or configuration failed to apply/i
)
).toBeInTheDocument();
});
});
});