fleet/frontend/components/LastUpdatedText/LastUpdatedText.tests.tsx
jacobshandling 06c48216f7
UI: Add Tooltip show delay across app (#33091)
## For #31869

- Add fine grain controls for tooltip show and hide delay behavior
- Default to 250ms show delay across app
- Update ~30 unit tests to expect new delay
- See
[note](https://github.com/fleetdm/fleet/issues/31869#issuecomment-3300660487)


https://github.com/user-attachments/assets/5969e0f7-c137-491f-8430-6f21d01b9350

- [x] Changes file added for user-visible changes in `changes/`
- [x] QA'd all new/changed functionality manually

---------

Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2025-09-18 09:42:30 -07:00

41 lines
1.1 KiB
TypeScript

import React from "react";
import { render, screen, waitFor } from "@testing-library/react";
import { renderWithSetup } from "test/test-utils";
import LastUpdatedText from ".";
describe("Last updated text", () => {
it("renders updated text", () => {
const currentDate = new Date();
currentDate.setDate(currentDate.getDate() - 2);
const twoDaysAgo = currentDate.toISOString();
render(
<LastUpdatedText whatToRetrieve="software" lastUpdatedAt={twoDaysAgo} />
);
const text = screen.getByText("Updated 2 days ago");
expect(text).toBeInTheDocument();
});
it("renders never if missing timestamp", () => {
render(<LastUpdatedText whatToRetrieve="software" />);
const text = screen.getByText("Updated never");
expect(text).toBeInTheDocument();
});
it("renders tooltip on hover", async () => {
const { user } = renderWithSetup(
<LastUpdatedText whatToRetrieve="software" />
);
const updatedNeverText = screen.getByText("Updated never");
await user.hover(updatedNeverText);
await waitFor(() => {
expect(screen.getByText(/to retrieve software/i)).toBeInTheDocument();
});
});
});