fleet/frontend/components/MDM/AndroidLatestVersionWithTooltip/AndroidLatestVersionWithTooltip.tests.tsx
Martin Angers 5a8e2774bf
Feature branch: Android Setup Experience support (#35951)
Feature branch for
https://github.com/fleetdm/fleet/issues/33761#issuecomment-3548996114


---------

Co-authored-by: RachelElysia <71795832+RachelElysia@users.noreply.github.com>
2025-12-02 12:27:20 -05:00

29 lines
1.2 KiB
TypeScript

import React from "react";
import { screen, waitFor } from "@testing-library/react";
import { renderWithSetup } from "test/test-utils";
import { ANDROID_PLAY_STORE_URL } from "utilities/constants";
import AndroidLatestVersionWithTooltip from "./AndroidLatestVersionWithTooltip";
describe("AndroidLatestVersionWithTooltip", () => {
const playStoreAppId = "com.example.app";
const playStoreUrl = `${ANDROID_PLAY_STORE_URL}?id=${playStoreAppId}`;
it('renders "Latest" text with tooltip with Play Store link', async () => {
const { user } = renderWithSetup(
<AndroidLatestVersionWithTooltip androidPlayStoreId={playStoreAppId} />
);
user.hover(screen.getByText("Latest"));
await waitFor(() => {
expect(
screen.getByText(/See latest version on the/i)
).toBeInTheDocument();
expect(screen.getByText(/Play Store/i)).toBeInTheDocument();
});
// Looks for <a> with correct href and text
const playStoreLink = screen.getByRole("link", { name: /Play Store/i });
expect(playStoreLink).toHaveAttribute("href", playStoreUrl);
expect(playStoreLink).toHaveAttribute("target", "_blank");
expect(playStoreLink).toHaveTextContent("Play Store");
});
});