Skip to content

Commit f9f430e

Browse files
authored
Add Preview label with tooltip to chatbot header (#1761)
Introduces an orange 'Preview' label with an info icon and tooltip to the chatbot header actions, indicating the feature is in Developer Preview. Updates tests to verify the label's presence, attributes, and correct placement in the UI.
1 parent b9055e6 commit f9f430e

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

ansible_ai_connect_chatbot/src/AnsibleChatbot/AnsibleChatbot.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import {
66
DropdownList,
77
DropdownItem,
88
ExpandableSection,
9+
Label,
10+
Tooltip,
911
} from "@patternfly/react-core";
1012

1113
import ChatbotContent from "@patternfly/chatbot/dist/dynamic/ChatbotContent";
@@ -22,6 +24,7 @@ import ChatbotHeader, {
2224
ChatbotHeaderTitle,
2325
} from "@patternfly/chatbot/dist/dynamic/ChatbotHeader";
2426

27+
import InfoCircleIcon from "@patternfly/react-icons/dist/esm/icons/info-circle-icon";
2528
import lightspeedLogo from "../assets/lightspeed.svg";
2629
import lightspeedLogoDark from "../assets/lightspeed_dark.svg";
2730

@@ -294,6 +297,16 @@ export const AnsibleChatbot: React.FunctionComponent = () => {
294297
</ChatbotHeaderTitle>
295298
</ChatbotHeaderMain>
296299
<ChatbotHeaderActions>
300+
<Tooltip
301+
content="This is a Developer Preview feature containing functionality that Red Hat is considering for possible inclusion into supported versions. Developer Preview versions are not fully tested and are not intended for production use. Features may change or be removed at any time."
302+
position="left"
303+
maxWidth="25rem"
304+
isContentLeftAligned
305+
>
306+
<Label color="orange" icon={<InfoCircleIcon />}>
307+
Preview
308+
</Label>
309+
</Tooltip>
297310
<InventoryDocumentationModal />
298311
{inDebugMode() && (
299312
<ChatbotHeaderSelectorDropdown

ansible_ai_connect_chatbot/src/App.test.tsx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,3 +1067,50 @@ test("Documentation modal can be closed and reopened", async () => {
10671067
// Verify modal is open again
10681068
await expect.element(modalTitle).toBeVisible();
10691069
});
1070+
1071+
test("Preview label is visible next to documentation link", async () => {
1072+
mockAxios(200);
1073+
const view = await renderApp();
1074+
1075+
// Check that the documentation link button is visible
1076+
const docButton = view.getByRole("button", {
1077+
name: "Generate Inventory File User Documentation",
1078+
});
1079+
expect(docButton).toBeVisible();
1080+
1081+
// Check that the Preview label is visible
1082+
const previewLabel = view.getByText("Preview");
1083+
expect(previewLabel).toBeVisible();
1084+
1085+
// Verify the label has the correct attributes by finding it in the container
1086+
const labelElement = view.container.querySelector(
1087+
".pf-v6-c-label.pf-m-orange",
1088+
);
1089+
expect(labelElement).toBeInTheDocument();
1090+
expect(labelElement).toHaveTextContent("Preview");
1091+
1092+
// Check that the info icon is present in the label
1093+
const infoIcon = labelElement?.querySelector("svg");
1094+
expect(infoIcon).toBeInTheDocument();
1095+
});
1096+
1097+
test("Preview label appears in the header actions area", async () => {
1098+
mockAxios(200);
1099+
const view = await renderApp();
1100+
1101+
// Find the header actions container
1102+
const headerActions =
1103+
view.container.querySelector("[class*='ChatbotHeaderActions']") ||
1104+
view.container.querySelector(".pf-chatbot__header-actions");
1105+
1106+
if (headerActions) {
1107+
// Check that the Preview label is within the header actions
1108+
const previewLabel = headerActions.querySelector(".pf-v6-c-label");
1109+
expect(previewLabel).toBeInTheDocument();
1110+
expect(previewLabel).toHaveTextContent("Preview");
1111+
} else {
1112+
// Fallback: just ensure the label exists somewhere in the component
1113+
const previewLabel = view.getByText("Preview");
1114+
expect(previewLabel).toBeVisible();
1115+
}
1116+
});

0 commit comments

Comments
 (0)