Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,23 @@ describe("HostHeader", () => {
expect(screen.getByText("My device")).toBeInTheDocument();
expect(screen.getByText(/unavailable/i)).toBeInTheDocument();
});
it("does not render refetch button for Android", () => {
render(
it("renders a disabled refetch button with tooltip for Android", async () => {
const { user } = renderWithSetup(
<HostHeader
summaryData={{ ...defaultSummaryData, platform: "android" }}
showRefetchSpinner={false}
onRefetchHost={jest.fn()}
renderActionsDropdown={renderActionDropdown}
/>
);
expect(screen.queryByText("Refetch")).not.toBeInTheDocument();
const refetchButton = screen.getByRole("button", { name: /refetch/i });
expect(refetchButton).toBeDisabled();

await user.hover(screen.getByText("Refetch"));

expect(
await screen.findByText(/Android devices sync automatically/i)
).toBeInTheDocument();
});

it("disables refetch button when host is offline", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,14 @@ const HostHeader = ({

const renderRefetch = () => {
if (isAndroid(platform)) {
return null;
return (
<RefetchButton
isDisabled
isFetching={false}
tooltip={REFETCH_TOOLTIP_MESSAGES.android}
onRefetchHost={onRefetchHost}
/>
);
}

const isOnline = summaryData.status === "online";
Expand Down
11 changes: 10 additions & 1 deletion frontend/pages/hosts/details/cards/HostHeader/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,18 @@ export const DEVICE_STATUS_TAGS: DeviceStatusTagConfig = {

// We exclude "unlocked" as we dont display a tooltip for it.
export const REFETCH_TOOLTIP_MESSAGES: Record<
HostMdmDeviceStatusUIStateNoUnlock | "offline",
HostMdmDeviceStatusUIStateNoUnlock | "offline" | "android",
JSX.Element
> = {
android: (
<>
Android devices sync automatically. To manually
<br />
sync, go to <b>Settings &gt; Google &gt; Work profile</b>
<br />
<b>&gt; Device policy</b> on the device.
</>
),
offline: (
<>
You can&apos;t fetch data from <br /> an offline host.
Expand Down
Loading