"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const react_2 = require("@testing-library/react");
require("@testing-library/jest-dom");
const Message_1 = __importDefault(require("./Message"));
const user_event_1 = __importDefault(require("@testing-library/user-event"));
const monitor_sampleapp_quickstart_1 = require("./QuickStarts/monitor-sampleapp-quickstart");
const monitor_sampleapp_quickstart_with_image_1 = require("./QuickStarts/monitor-sampleapp-quickstart-with-image");
const rehype_external_links_1 = __importDefault(require("../__mocks__/rehype-external-links"));
const react_core_1 = require("@patternfly/react-core");
const ALL_ACTIONS = [
    { label: /Good response/i },
    { label: /Bad response/i },
    { label: /Copy/i },
    { label: /Edit/i },
    { label: /Share/i },
    { label: /Listen/i }
];
const UNORDERED_LIST = `
  Here is an unordered list:

  * Item 1
  * Item 2
  * Item 3
`;
const ORDERED_LIST = `
  Here is an ordered list:

  1. Item 1
  2. Item 2
  3. Item 3
`;
const CODE_MESSAGE = `
Here is some YAML code:

~~~yaml
apiVersion: helm.openshift.io/v1beta1/
kind: HelmChartRepository
metadata:
  name: azure-sample-repo0oooo00ooo
spec:
  connectionConfig:
  url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs
~~~`;
const CODE = `
apiVersion: helm.openshift.io/v1beta1/
kind: HelmChartRepository
metadata:
  name: azure-sample-repo0oooo00ooo
spec:
  connectionConfig:
  url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs
`;
const INLINE_CODE = `Here is an inline code - \`() => void\``;
const ORDERED_LIST_WITH_CODE = `
1. Item 1
2. Item 2

\`\`\`yaml
- name: Hello World Playbook
  hosts: localhost
  tasks:
    - name: Print Hello World
      ansible.builtin.debug:
        msg: "Hello, World!"
\`\`\`

3. Item 3
`;
const HEADING = `
# h1 Heading

## h2 Heading

### h3 Heading

#### h4 Heading

##### h5 Heading

###### h6 Heading
`;
const BLOCK_QUOTES = `> Blockquotes can also be nested...
>> ...by using additional greater-than signs (>) right next to each other...
> > > ...or with spaces between each sign.`;
const TABLE = `

 | Column 1 | Column 2 |
 |-|-|
 | Cell 1 | Cell 2 |
 | Cell 3 | Cell 4 |

 `;
const ONE_COLUMN_TABLE = `

 | Column 1 |
 |-|
 | Cell 1 | 
 | Cell 2 |

 `;
const ONE_CELL_TABLE = `

 | Column 1 |
 |-|
 | Cell 1 | 

 `;
const HEADERLESS_TABLE = `

 | |
 |-|
 | Cell 1 | 

 `;
const CHILDLESS_TABLE = `

 | Column 1 |
 |-|
 | | 

 `;
const EMPTY_TABLE = `

 | |
 |-|
 | | 

 `;
const FOOTNOTE = `This is some text with a footnote[^1] and here's a longer one.[^bignote]

 You can also reference the same footnote multiple times[^1].
 
   [^1]: This is the full footnote text. You can click the arrow to go back up. 
   
   [^bignote]: Here's one with multiple paragraphs and **formatting**.
 
       Indent paragraphs to include them in the footnote.
 
       Add as many paragraphs as you like. You can include *italic text*, **bold text**, and even \`code\`.
 
       > You can even include blockquotes in footnotes!`;
const IMAGE = `![Multi-colored wavy lines on a black background](https://cdn.dribbble.com/userupload/10651749/file/original-8a07b8e39d9e8bf002358c66fce1223e.gif)`;
const INLINE_IMAGE = `inline text ![Multi-colored wavy lines on a black background](https://cdn.dribbble.com/userupload/10651749/file/original-8a07b8e39d9e8bf002358c66fce1223e.gif)`;
const DEEP_THINKING = {
    toggleContent: 'Show thinking',
    subheading: 'Thought for 3 seconds',
    body: "Here's why I said this."
};
const ERROR = {
    title: 'Could not load chat',
    children: 'Wait a few minutes and check your network settings. If the issue persists: ',
    actionLinks: ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_core_1.AlertActionLink, { component: "a", href: "#", children: "Start a new chat" }), (0, jsx_runtime_1.jsx)(react_core_1.AlertActionLink, { component: "a", href: "#", children: "Contact support" })] }))
};
const checkListItemsRendered = () => {
    const items = ['Item 1', 'Item 2', 'Item 3'];
    expect(react_2.screen.getAllByRole('listitem')).toHaveLength(3);
    items.forEach((item) => {
        // list item text gets wrapped in a span by the third-party library so we can't just check the listitem
        expect(react_2.screen.getByText(item)).toBeTruthy();
    });
};
describe('Message', () => {
    beforeEach(() => {
        jest.clearAllMocks();
    });
    it('should render user messages correctly', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: "Hi" }));
        expect(react_2.screen.getByText('User')).toBeTruthy();
        expect(react_2.screen.getByText('Hi')).toBeTruthy();
        const date = new Date();
        const formattedDate = date.toLocaleDateString();
        expect(react_2.screen.getByText((content, element) => {
            const hasText = content.includes(formattedDate);
            const isVisible = (element === null || element === void 0 ? void 0 : element.tagName.toLowerCase()) !== 'script' && (element === null || element === void 0 ? void 0 : element.tagName.toLowerCase()) !== 'style';
            return hasText && isVisible;
        })).toBeInTheDocument();
        expect(react_2.screen.queryByText('Loading message')).toBeFalsy();
        expect(react_2.screen.getByRole('img')).toHaveAttribute('src', './img');
    });
    it('should render bot messages correctly', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "bot", name: "Bot", content: "Hi" }));
        expect(react_2.screen.getByText('Bot')).toBeTruthy();
        expect(react_2.screen.getByText('AI')).toBeTruthy();
        expect(react_2.screen.getByText('Hi')).toBeTruthy();
        const date = new Date();
        const formattedDate = date.toLocaleDateString();
        expect(react_2.screen.getByText((content, element) => {
            const hasText = content.includes(formattedDate);
            const isVisible = (element === null || element === void 0 ? void 0 : element.tagName.toLowerCase()) !== 'script' && (element === null || element === void 0 ? void 0 : element.tagName.toLowerCase()) !== 'style';
            return hasText && isVisible;
        })).toBeInTheDocument();
    });
    it('should render avatar correctly', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./testImg", role: "bot", name: "Bot", content: "Hi" }));
        expect(react_2.screen.getByRole('img')).toHaveAttribute('src', './testImg');
    });
    it('should not render avatar if no avatar prop is passed', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { role: "bot", name: "Bot", content: "Hi" }));
        expect(react_2.screen.queryByRole('img')).not.toBeInTheDocument();
    });
    it('should render botWord correctly', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", botWord: "\u4EBA\u5DE5\u77E5\u80FD" }));
        expect(react_2.screen.getByText('Bot')).toBeTruthy();
        expect(react_2.screen.getByText('人工知能')).toBeTruthy();
        expect(react_2.screen.queryByText('AI')).toBeFalsy();
        expect(react_2.screen.getByText('Hi')).toBeTruthy();
    });
    it('should render timestamps', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", timestamp: "2 hours ago" }));
        expect(react_2.screen.getByText('Bot')).toBeTruthy();
        expect(react_2.screen.getByText('AI')).toBeTruthy();
        expect(react_2.screen.getByText('Hi')).toBeTruthy();
        expect(react_2.screen.getByText('2 hours ago')).toBeTruthy();
        const date = new Date();
        const formattedDate = date.toLocaleDateString();
        expect(react_2.screen.queryByText((content, element) => {
            const hasText = content.includes(formattedDate);
            const isVisible = (element === null || element === void 0 ? void 0 : element.tagName.toLowerCase()) !== 'script' && (element === null || element === void 0 ? void 0 : element.tagName.toLowerCase()) !== 'style';
            return hasText && isVisible;
        })).not.toBeInTheDocument();
    });
    it('should render attachments', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", content: "Hi", attachments: [{ name: 'testAttachment' }] }));
        expect(react_2.screen.getByText('Hi')).toBeTruthy();
        expect(react_2.screen.getByText('testAttachment')).toBeTruthy();
    });
    it('should be able to click attachments', () => __awaiter(void 0, void 0, void 0, function* () {
        const spy = jest.fn();
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", content: "Hi", attachments: [{ name: 'testAttachment', onClick: spy }] }));
        expect(react_2.screen.getByText('Hi')).toBeTruthy();
        expect(react_2.screen.getByText('testAttachment')).toBeTruthy();
        yield user_event_1.default.click(react_2.screen.getByRole('button', { name: /testAttachment/i }));
        expect(spy).toHaveBeenCalledTimes(1);
    }));
    it('should be able to close attachments', () => __awaiter(void 0, void 0, void 0, function* () {
        const spy = jest.fn();
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", content: "Hi", attachments: [{ name: 'testAttachment', onClose: spy }] }));
        expect(react_2.screen.getByText('Hi')).toBeTruthy();
        expect(react_2.screen.getByText('testAttachment')).toBeTruthy();
        expect(react_2.screen.getByRole('button', { name: /close testAttachment/i })).toBeTruthy();
        yield user_event_1.default.click(react_2.screen.getByRole('button', { name: /close testAttachment/i }));
        expect(spy).toHaveBeenCalledTimes(1);
    }));
    it('should render loading state', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", isLoading: true }));
        expect(react_2.screen.getByText('Bot')).toBeTruthy();
        expect(react_2.screen.getByText('AI')).toBeTruthy();
        expect(react_2.screen.queryByText('Hi')).toBeFalsy();
        const date = new Date();
        const formattedDate = date.toLocaleDateString();
        expect(react_2.screen.getByText((content, element) => {
            const hasText = content.includes(formattedDate);
            const isVisible = (element === null || element === void 0 ? void 0 : element.tagName.toLowerCase()) !== 'script' && (element === null || element === void 0 ? void 0 : element.tagName.toLowerCase()) !== 'style';
            return hasText && isVisible;
        })).toBeInTheDocument();
        expect(react_2.screen.getByText('Loading message')).toBeTruthy();
    });
    it('should be able to show sources', () => __awaiter(void 0, void 0, void 0, function* () {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", sources: {
                sources: [
                    {
                        title: 'Getting started with Red Hat OpenShift',
                        link: '#',
                        body: 'Red Hat OpenShift on IBM Cloud is a managed offering to create your own cluster of compute hosts where you can deploy and manage containerized apps on IBM Cloud ...'
                    }
                ]
            } }));
        expect(react_2.screen.getByText('Getting started with Red Hat OpenShift')).toBeTruthy();
    }));
    it('should not show sources if loading', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", isLoading: true, sources: {
                sources: [
                    {
                        title: 'Getting started with Red Hat OpenShift',
                        link: '#',
                        body: 'Red Hat OpenShift on IBM Cloud is a managed offering to create your own cluster of compute hosts where you can deploy and manage containerized apps on IBM Cloud ...'
                    }
                ]
            } }));
        expect(react_2.screen.getByText('Loading message')).toBeTruthy();
        expect(react_2.screen.queryByText('Getting started with Red Hat OpenShift')).toBeFalsy();
    });
    it('should be able to show quick response', () => __awaiter(void 0, void 0, void 0, function* () {
        const spy = jest.fn();
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", quickResponses: [
                {
                    id: '1',
                    content: 'Yes',
                    onClick: spy,
                    className: 'test'
                }
            ] }));
        const quickResponse = react_2.screen.getByRole('button', { name: /Yes/i });
        expect(quickResponse).toBeTruthy();
        yield user_event_1.default.click(quickResponse);
        expect(spy).toHaveBeenCalledTimes(1);
    }));
    it('should be able to handle isCompact', () => __awaiter(void 0, void 0, void 0, function* () {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", quickResponses: [
                {
                    id: '1',
                    content: 'Yes',
                    onClick: jest.fn(),
                    className: 'test'
                }
            ], isCompact: true }));
        const parent = react_2.screen.getByRole('button', { name: /Yes/i }).parentNode;
        expect(parent).toHaveClass('pf-m-compact');
    }));
    it('should be able to show more than 1 quick response', () => __awaiter(void 0, void 0, void 0, function* () {
        const spy = jest.fn();
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", quickResponses: [
                {
                    id: '1',
                    content: 'Yes',
                    onClick: spy
                },
                {
                    id: '2',
                    content: 'No',
                    onClick: spy
                }
            ] }));
        expect(react_2.screen.getByRole('button', { name: /Yes/i })).toBeTruthy();
        expect(react_2.screen.getByRole('button', { name: /No/i })).toBeTruthy();
    }));
    it('should be able to spread quickResponseContainerProps', () => __awaiter(void 0, void 0, void 0, function* () {
        const spy = jest.fn();
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", quickResponses: [
                {
                    id: '1',
                    content: 'Yes',
                    onClick: spy
                },
                {
                    id: '2',
                    content: 'No',
                    onClick: spy
                }
            ], 
            // this is a LabelGroup prop that changes the default number shown
            // to be different than what we use in ChatBot
            quickResponseContainerProps: { numLabels: 1 } }));
        expect(react_2.screen.getByRole('button', { name: /Yes/i })).toBeTruthy();
        expect(react_2.screen.queryByRole('button', { name: /No/i })).toBeFalsy();
        expect(react_2.screen.getByRole('button', { name: /1 more/i }));
    }));
    it('Renders response actions when a single actions object is passed', () => __awaiter(void 0, void 0, void 0, function* () {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", actions: {
                // eslint-disable-next-line no-console
                positive: { onClick: () => console.log('Good response') },
                // eslint-disable-next-line no-console
                negative: { onClick: () => console.log('Bad response') },
                // eslint-disable-next-line no-console
                copy: { onClick: () => console.log('Copy') },
                // eslint-disable-next-line no-console
                edit: { onClick: () => console.log('Edit') },
                // eslint-disable-next-line no-console
                share: { onClick: () => console.log('Share') },
                // eslint-disable-next-line no-console
                download: { onClick: () => console.log('Download') },
                // eslint-disable-next-line no-console
                listen: { onClick: () => console.log('Listen') }
            } }));
        ALL_ACTIONS.forEach(({ label }) => {
            expect(react_2.screen.getByRole('button', { name: label })).toBeVisible();
        });
    }));
    it('Renders response actions when an array of actions objects is passed', () => __awaiter(void 0, void 0, void 0, function* () {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", actions: [
                {
                    // eslint-disable-next-line no-console
                    positive: { onClick: () => console.log('Good response') },
                    // eslint-disable-next-line no-console
                    negative: { onClick: () => console.log('Bad response') }
                },
                {
                    // eslint-disable-next-line no-console
                    copy: { onClick: () => console.log('Copy') },
                    // eslint-disable-next-line no-console
                    edit: { onClick: () => console.log('Edit') },
                    // eslint-disable-next-line no-console
                    share: { onClick: () => console.log('Share') },
                    // eslint-disable-next-line no-console
                    download: { onClick: () => console.log('Download') }
                },
                {
                    // eslint-disable-next-line no-console
                    listen: { onClick: () => console.log('Listen') }
                }
            ] }));
        ALL_ACTIONS.forEach(({ label }) => {
            expect(react_2.screen.getByRole('button', { name: label })).toBeVisible();
        });
    }));
    it('Renders response actions when an array of objects containing actions objects is passed', () => __awaiter(void 0, void 0, void 0, function* () {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", actions: [
                {
                    actions: {
                        // eslint-disable-next-line no-console
                        positive: { onClick: () => console.log('Good response') },
                        // eslint-disable-next-line no-console
                        negative: { onClick: () => console.log('Bad response') }
                    }
                },
                {
                    actions: {
                        // eslint-disable-next-line no-console
                        copy: { onClick: () => console.log('Copy') },
                        // eslint-disable-next-line no-console
                        edit: { onClick: () => console.log('Edit') },
                        // eslint-disable-next-line no-console
                        share: { onClick: () => console.log('Share') },
                        // eslint-disable-next-line no-console
                        download: { onClick: () => console.log('Download') }
                    }
                },
                {
                    actions: {
                        // eslint-disable-next-line no-console
                        listen: { onClick: () => console.log('Listen') }
                    }
                }
            ] }));
        ALL_ACTIONS.forEach(({ label }) => {
            expect(react_2.screen.getByRole('button', { name: label })).toBeVisible();
        });
    }));
    it('should handle persistActionSelection correctly when a single actions object is passed', () => __awaiter(void 0, void 0, void 0, function* () {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "bot", name: "Bot", content: "Test message", persistActionSelection: true, actions: {
                positive: { onClick: jest.fn() },
                negative: { onClick: jest.fn() }
            } }));
        const goodBtn = react_2.screen.getByRole('button', { name: /Good response/i });
        const badBtn = react_2.screen.getByRole('button', { name: /Bad response/i });
        yield user_event_1.default.click(goodBtn);
        expect(react_2.screen.getByRole('button', { name: /Good response recorded/i })).toHaveClass('pf-chatbot__button--response-action-clicked');
        yield user_event_1.default.click(react_2.screen.getByText('Test message'));
        expect(react_2.screen.getByRole('button', { name: /Good response recorded/i })).toHaveClass('pf-chatbot__button--response-action-clicked');
        yield user_event_1.default.click(badBtn);
        expect(react_2.screen.getByRole('button', { name: /Bad response recorded/i })).toHaveClass('pf-chatbot__button--response-action-clicked');
        expect(goodBtn).not.toHaveClass('pf-chatbot__button--response-action-clicked');
    }));
    it('should handle persistActionSelection correctly when an array of actions objects is passed', () => __awaiter(void 0, void 0, void 0, function* () {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "bot", name: "Bot", content: "Test message", persistActionSelection: true, actions: [
                {
                    positive: { onClick: jest.fn() },
                    negative: { onClick: jest.fn() }
                },
                {
                    copy: { onClick: jest.fn() }
                }
            ] }));
        const goodBtn = react_2.screen.getByRole('button', { name: /Good response/i });
        const copyBtn = react_2.screen.getByRole('button', { name: /Copy/i });
        yield user_event_1.default.click(goodBtn);
        expect(react_2.screen.getByRole('button', { name: /Good response recorded/i })).toHaveClass('pf-chatbot__button--response-action-clicked');
        yield user_event_1.default.click(react_2.screen.getByText('Test message'));
        expect(react_2.screen.getByRole('button', { name: /Good response recorded/i })).toHaveClass('pf-chatbot__button--response-action-clicked');
        yield user_event_1.default.click(copyBtn);
        expect(react_2.screen.getByRole('button', { name: /Copied/i })).toHaveClass('pf-chatbot__button--response-action-clicked');
        yield user_event_1.default.click(react_2.screen.getByText('Test message'));
        expect(react_2.screen.getByRole('button', { name: /Good response recorded/i })).toHaveClass('pf-chatbot__button--response-action-clicked');
        expect(react_2.screen.getByRole('button', { name: /Copied/i })).toHaveClass('pf-chatbot__button--response-action-clicked');
    }));
    it('should handle persistActionSelection correctly when an array of objects containing actions objects is passed', () => __awaiter(void 0, void 0, void 0, function* () {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "bot", name: "Bot", content: "Test message", actions: [
                {
                    actions: {
                        positive: { onClick: jest.fn() },
                        negative: { onClick: jest.fn() }
                    },
                    persistActionSelection: true
                },
                {
                    actions: {
                        copy: { onClick: jest.fn() }
                    },
                    persistActionSelection: false
                }
            ] }));
        const goodBtn = react_2.screen.getByRole('button', { name: /Good response/i });
        const copyBtn = react_2.screen.getByRole('button', { name: /Copy/i });
        yield user_event_1.default.click(goodBtn);
        expect(react_2.screen.getByRole('button', { name: /Good response recorded/i })).toHaveClass('pf-chatbot__button--response-action-clicked');
        yield user_event_1.default.click(copyBtn);
        expect(react_2.screen.getByRole('button', { name: /Copied/i })).toHaveClass('pf-chatbot__button--response-action-clicked');
        yield user_event_1.default.click(react_2.screen.getByText('Test message'));
        expect(react_2.screen.getByRole('button', { name: /Good response recorded/i })).toHaveClass('pf-chatbot__button--response-action-clicked');
        expect(copyBtn).not.toHaveClass('pf-chatbot__button--response-action-clicked');
    }));
    it('should not show actions if loading', () => __awaiter(void 0, void 0, void 0, function* () {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", isLoading: true, actions: {
                // eslint-disable-next-line no-console
                positive: { onClick: () => console.log('Good response') },
                // eslint-disable-next-line no-console
                negative: { onClick: () => console.log('Bad response') },
                // eslint-disable-next-line no-console
                copy: { onClick: () => console.log('Copy') },
                // eslint-disable-next-line no-console
                edit: { onClick: () => console.log('Edit') },
                // eslint-disable-next-line no-console
                share: { onClick: () => console.log('Share') },
                // eslint-disable-next-line no-console
                download: { onClick: () => console.log('Download') },
                // eslint-disable-next-line no-console
                listen: { onClick: () => console.log('Listen') }
            } }));
        expect(react_2.screen.getByText('Loading message')).toBeTruthy();
        ALL_ACTIONS.forEach(({ label }) => {
            expect(react_2.screen.queryByRole('button', { name: label })).toBeFalsy();
        });
    }));
    it('should not show actions if isEditable is true', () => __awaiter(void 0, void 0, void 0, function* () {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", isEditable: true, actions: {
                // eslint-disable-next-line no-console
                positive: { onClick: () => console.log('Good response') },
                // eslint-disable-next-line no-console
                negative: { onClick: () => console.log('Bad response') },
                // eslint-disable-next-line no-console
                copy: { onClick: () => console.log('Copy') },
                // eslint-disable-next-line no-console
                edit: { onClick: () => console.log('Edit') },
                // eslint-disable-next-line no-console
                share: { onClick: () => console.log('Share') },
                // eslint-disable-next-line no-console
                download: { onClick: () => console.log('Download') },
                // eslint-disable-next-line no-console
                listen: { onClick: () => console.log('Listen') }
            } }));
        ALL_ACTIONS.forEach(({ label }) => {
            expect(react_2.screen.queryByRole('button', { name: label })).toBeFalsy();
        });
    }));
    it('should render unordered lists correctly', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: UNORDERED_LIST }));
        expect(react_2.screen.getByText('Here is an unordered list:')).toBeTruthy();
        checkListItemsRendered();
    });
    it('should render ordered lists correctly', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: ORDERED_LIST }));
        expect(react_2.screen.getByText('Here is an ordered list:')).toBeTruthy();
        checkListItemsRendered();
    });
    it('should render ordered lists correctly if there is interstitial content', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: ORDERED_LIST_WITH_CODE }));
        checkListItemsRendered();
        const list = react_2.screen.getAllByRole('list')[1];
        expect(list).toHaveAttribute('start', '3');
    });
    it('should render inline code', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: INLINE_CODE }));
        expect(react_2.screen.getByText(/() => void/i)).toBeTruthy();
        expect(react_2.screen.queryByRole('button', { name: 'Copy code button' })).toBeFalsy();
    });
    it('should render code correctly', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: CODE_MESSAGE }));
        expect(react_2.screen.getByText('Here is some YAML code:')).toBeTruthy();
        expect(react_2.screen.getByRole('button', { name: 'Copy code' })).toBeTruthy();
        expect(react_2.screen.getByText(/yaml/)).toBeTruthy();
        expect(react_2.screen.getByText(/apiVersion:/i)).toBeTruthy();
        expect(react_2.screen.getByText(/helm.openshift.io\/v1beta1/i)).toBeTruthy();
        expect(react_2.screen.getByText(/metadata:/i)).toBeTruthy();
        expect(react_2.screen.getByText(/name:/i)).toBeTruthy();
        expect(react_2.screen.getByText(/azure-sample-repo0oooo00ooo/i)).toBeTruthy();
        expect(react_2.screen.getByText(/spec/i)).toBeTruthy();
        expect(react_2.screen.getByText(/connectionConfig:/i)).toBeTruthy();
        expect(react_2.screen.getByText(/url:/i)).toBeTruthy();
        expect(react_2.screen.getByText(/https:\/\/raw.githubusercontent.com\/Azure-Samples\/helm-charts\/master\/docs/i)).toBeTruthy();
    });
    it('should render expandable code correctly', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: CODE_MESSAGE, codeBlockProps: { isExpandable: true } }));
        expect(react_2.screen.getByText('Here is some YAML code:')).toBeTruthy();
        expect(react_2.screen.getByRole('button', { name: 'Copy code' })).toBeTruthy();
        expect(react_2.screen.getByText(/yaml/)).toBeTruthy();
        expect(react_2.screen.getByText(/apiVersion/i)).toBeTruthy();
        expect(react_2.screen.getByRole('button', { name: /Show more/i })).toBeTruthy();
    });
    it('should handle click on expandable code correctly', () => __awaiter(void 0, void 0, void 0, function* () {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: CODE_MESSAGE, codeBlockProps: { isExpandable: true } }));
        const button = react_2.screen.getByRole('button', { name: /Show more/i });
        yield user_event_1.default.click(button);
        expect(react_2.screen.getByRole('button', { name: /Show less/i })).toBeTruthy();
        expect(react_2.screen.getByText(/yaml/)).toBeTruthy();
        expect(react_2.screen.getByText(/apiVersion:/i)).toBeTruthy();
        expect(react_2.screen.getByText(/helm.openshift.io\/v1beta1/i)).toBeTruthy();
        expect(react_2.screen.getByText(/metadata:/i)).toBeTruthy();
        expect(react_2.screen.getByText(/name:/i)).toBeTruthy();
        expect(react_2.screen.getByText(/azure-sample-repo0oooo00ooo/i)).toBeTruthy();
        expect(react_2.screen.getByText(/spec/i)).toBeTruthy();
        expect(react_2.screen.getByText(/connectionConfig:/i)).toBeTruthy();
        expect(react_2.screen.getByText(/url:/i)).toBeTruthy();
        expect(react_2.screen.getByText(/https:\/\/raw.githubusercontent.com\/Azure-Samples\/helm-charts\/master\/docs/i)).toBeTruthy();
    }));
    it('can click copy code button', () => __awaiter(void 0, void 0, void 0, function* () {
        // need explicit setup since RTL stubs clipboard if you do this
        const user = user_event_1.default.setup();
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: CODE_MESSAGE }));
        expect(react_2.screen.getByRole('button', { name: 'Copy code' })).toBeTruthy();
        yield user.click(react_2.screen.getByRole('button', { name: 'Copy code' }));
        const clipboardText = yield navigator.clipboard.readText();
        expect(clipboardText.trim()).toEqual(CODE.trim());
    }));
    it('should handle codeBlockProps correctly by spreading it onto the CodeMessage', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: CODE_MESSAGE, codeBlockProps: { 'aria-label': 'test' } }));
        expect(react_2.screen.getByRole('button', { name: 'test' })).toBeTruthy();
    });
    it('should be able to add custom actions to CodeMessage', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: CODE_MESSAGE, codeBlockProps: {
                customActions: ((0, jsx_runtime_1.jsx)(react_core_1.CodeBlockAction, { children: (0, jsx_runtime_1.jsx)(react_core_1.Button, { children: "New custom action" }) }))
            } }));
        expect(react_2.screen.getByRole('button', { name: /New custom action/i })).toBeTruthy();
    });
    it('should handle hasRoundAvatar correctly when it is true', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: "Hi", hasRoundAvatar: true }));
        expect(react_2.screen.getByRole('img')).toBeTruthy();
        expect(react_2.screen.getByRole('img')).toHaveClass('pf-chatbot__message-avatar');
        expect(react_2.screen.getByRole('img')).toHaveClass('pf-chatbot__message-avatar--round');
    });
    it('should handle hasRoundAvatar correctly when it is false', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: "Hi", hasRoundAvatar: false }));
        expect(react_2.screen.getByRole('img')).toBeTruthy();
        expect(react_2.screen.getByRole('img')).toHaveClass('pf-chatbot__message-avatar');
        expect(react_2.screen.getByRole('img')).not.toHaveClass('pf-chatbot__message-avatar--round');
    });
    it('should handle avatarProps correctly by spreading it onto the Message Avatar', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: "Hi", avatarProps: { className: 'test' } }));
        expect(react_2.screen.getByRole('img')).toBeTruthy();
        expect(react_2.screen.getByRole('img')).toHaveClass('test');
    });
    it('should handle avatarProps and hasRoundAvatar correctly', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: "Hi", avatarProps: { className: 'test' }, hasRoundAvatar: false }));
        expect(react_2.screen.getByRole('img')).toBeTruthy();
        expect(react_2.screen.getByRole('img')).toHaveClass('test');
        expect(react_2.screen.getByRole('img')).toHaveClass('pf-chatbot__message-avatar');
    });
    it('should handle QuickStart tile correctly', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: "Hi", quickStarts: {
                quickStart: monitor_sampleapp_quickstart_1.monitorSampleAppQuickStart,
                onSelectQuickStart: (id) => alert(id)
            } }));
        expect(react_2.screen.getByRole('button', { name: 'Monitoring your sample application' })).toBeTruthy();
        expect(react_2.screen.getByRole('heading', { name: '1 Prerequisite' })).toBeTruthy();
        expect(react_2.screen.getByRole('button', { name: 'Show prerequisites' })).toBeTruthy();
        expect(react_2.screen.getByRole('button', { name: 'Start' })).toBeTruthy();
    });
    it('should handle click on QuickStart tile correctly', () => __awaiter(void 0, void 0, void 0, function* () {
        const spy = jest.fn();
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: "Hi", quickStarts: {
                quickStart: monitor_sampleapp_quickstart_1.monitorSampleAppQuickStart,
                onSelectQuickStart: (id) => spy(id)
            } }));
        yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Monitoring your sample application' }));
        expect(spy).toHaveBeenCalledTimes(1);
        expect(spy).toHaveBeenCalledWith(monitor_sampleapp_quickstart_1.monitorSampleAppQuickStart.metadata.name);
    }));
    it('should handle QuickStart tile with image correctly', () => __awaiter(void 0, void 0, void 0, function* () {
        const spy = jest.fn();
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: "Hi", quickStarts: {
                quickStart: monitor_sampleapp_quickstart_with_image_1.monitorSampleAppQuickStartWithImage,
                onSelectQuickStart: (id) => spy(id)
            } }));
        expect(react_2.screen.getAllByRole('img')[1]).toHaveAttribute('src', 'test.png');
    }));
    it('should handle tool response correctly', () => __awaiter(void 0, void 0, void 0, function* () {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: "Hi", toolResponse: {
                toggleContent: 'Tool response: Name',
                subheading: 'Thought for 3 seconds',
                body: 'Lorem ipsum dolor sit amet',
                cardTitle: 'Card title',
                cardBody: 'Card body'
            } }));
        expect(react_2.screen.getByRole('button', { name: /Tool response: Name/i })).toBeTruthy();
        expect(react_2.screen.getByText('Thought for 3 seconds')).toBeTruthy();
        expect(react_2.screen.getByText('Lorem ipsum dolor sit amet')).toBeTruthy();
        expect(react_2.screen.getByText('Card title')).toBeTruthy();
        expect(react_2.screen.getByText('Card body')).toBeTruthy();
    }));
    it('should handle block quote correctly', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: BLOCK_QUOTES }));
        expect(react_2.screen.getByText(/Blockquotes can also be nested.../)).toBeTruthy();
        expect(react_2.screen.getByText('...by using additional greater-than signs (>) right next to each other...')).toBeTruthy();
        expect(react_2.screen.getByText(/...or with spaces between each sign./)).toBeTruthy();
    });
    it('should handle heading correctly', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: HEADING }));
        expect(react_2.screen.getByRole('heading', { name: /h1 Heading/i })).toBeTruthy();
        expect(react_2.screen.getByRole('heading', { name: /h2 Heading/i })).toBeTruthy();
        expect(react_2.screen.getByRole('heading', { name: /h3 Heading/i })).toBeTruthy();
        expect(react_2.screen.getByRole('heading', { name: /h4 Heading/i })).toBeTruthy();
        expect(react_2.screen.getByRole('heading', { name: /h5 Heading/i })).toBeTruthy();
        expect(react_2.screen.getByRole('heading', { name: /h6 Heading/i })).toBeTruthy();
    });
    it('should render table correctly', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: TABLE }));
        expect(react_2.screen.getByRole('row', { name: /Column 1 Column 2/i })).toBeTruthy();
        expect(react_2.screen.getByRole('row', { name: /Cell 1 Cell 2/i })).toBeTruthy();
        expect(react_2.screen.getByRole('row', { name: /Cell 3 Cell 4/i })).toBeTruthy();
        expect(react_2.screen.getByRole('columnheader', { name: /Column 1/i })).toBeTruthy();
        expect(react_2.screen.getByRole('columnheader', { name: /Column 2/i })).toBeTruthy();
        expect(react_2.screen.getByRole('cell', { name: /Cell 1/i })).toBeTruthy();
        expect(react_2.screen.getByRole('cell', { name: /Cell 2/i })).toBeTruthy();
        expect(react_2.screen.getByRole('cell', { name: /Cell 3/i })).toBeTruthy();
        expect(react_2.screen.getByRole('cell', { name: /Cell 4/i })).toBeTruthy();
    });
    it('should render table data labels correctly for mobile breakpoint', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: TABLE }));
        expect(react_2.screen.getByRole('row', { name: /Cell 1 Cell 2/i })).toHaveAttribute('extraHeaders', 'Column 1,Column 2');
        expect(react_2.screen.getByRole('row', { name: /Cell 3 Cell 4/i })).toHaveAttribute('extraHeaders', 'Column 1,Column 2');
        expect(react_2.screen.getByRole('cell', { name: /Cell 1/i })).toHaveAttribute('data-label', 'Column 1');
        expect(react_2.screen.getByRole('cell', { name: /Cell 2/i })).toHaveAttribute('data-label', 'Column 2');
        expect(react_2.screen.getByRole('cell', { name: /Cell 3/i })).toHaveAttribute('data-label', 'Column 1');
        expect(react_2.screen.getByRole('cell', { name: /Cell 4/i })).toHaveAttribute('data-label', 'Column 2');
    });
    it('should render table data labels correctly for mobile breakpoint for one column table', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: ONE_COLUMN_TABLE }));
        expect(react_2.screen.getByRole('row', { name: /Cell 1/i })).toHaveAttribute('extraHeaders', 'Column 1');
        expect(react_2.screen.getByRole('row', { name: /Cell 2/i })).toHaveAttribute('extraHeaders', 'Column 1');
        expect(react_2.screen.getByRole('cell', { name: /Cell 1/i })).toHaveAttribute('data-label', 'Column 1');
        expect(react_2.screen.getByRole('cell', { name: /Cell 2/i })).toHaveAttribute('data-label', 'Column 1');
    });
    it('should render table data labels correctly for mobile breakpoint for one cell table', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: ONE_CELL_TABLE }));
        expect(react_2.screen.getByRole('row', { name: /Cell 1/i })).toHaveAttribute('extraHeaders', 'Column 1');
        expect(react_2.screen.getByRole('cell', { name: /Cell 1/i })).toHaveAttribute('data-label', 'Column 1');
    });
    it('should render table data labels correctly for mobile breakpoint for headerless', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: HEADERLESS_TABLE }));
        expect(react_2.screen.getByRole('row', { name: /Cell 1/i })).toHaveAttribute('extraHeaders', '');
        expect(react_2.screen.getByRole('cell', { name: /Cell 1/i })).not.toHaveAttribute('data-label');
    });
    it('should render table data labels correctly for mobile breakpoint for childless', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: CHILDLESS_TABLE }));
        expect(react_2.screen.getByRole('cell')).not.toHaveAttribute('extraHeaders', 'Column 1');
    });
    it('should render table data labels correctly for mobile breakpoint for empty', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: EMPTY_TABLE }));
        expect(react_2.screen.getByRole('cell')).not.toHaveAttribute('extraHeaders', '');
    });
    it('should render custom table aria label correctly', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: TABLE, tableProps: { 'aria-label': 'Test' } }));
        expect(react_2.screen.getByRole('grid', { name: /Test/i })).toBeTruthy();
    });
    it('should render footnote correctly', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: FOOTNOTE }));
        expect(react_2.screen.getByText(/This is some text with a footnote/i)).toBeTruthy();
        expect(react_2.screen.getByText(/and here's a longer one./i)).toBeTruthy();
        expect(react_2.screen.getByText(/You can also reference the same footnote multiple times./i)).toBeTruthy();
        expect(react_2.screen.getByRole('heading', { name: /Footnotes/i })).toBeTruthy();
        expect(react_2.screen.getByText(/This is the full footnote text. You can click the arrow to go back up./i)).toBeTruthy();
        expect(react_2.screen.getByText(/Here's one with multiple paragraphs and/i)).toBeTruthy();
        expect(react_2.screen.getByText(/formatting/i)).toBeTruthy();
        expect(react_2.screen.getByText(/Indent paragraphs to include them in the footnote./i)).toBeTruthy();
        expect(react_2.screen.getByText(/Add as many paragraphs as you like. You can include/i)).toBeTruthy();
        expect(react_2.screen.getByText(/italic text/i)).toBeTruthy();
        expect(react_2.screen.getByText(/bold text/i)).toBeTruthy();
        expect(react_2.screen.getByText(/, and even/i)).toBeTruthy();
        expect(react_2.screen.getByText(/code/i)).toBeTruthy();
        expect(react_2.screen.getByText(/You can even include blockquotes in footnotes!/i)).toBeTruthy();
        expect(react_2.screen.getAllByRole('link', { name: '1' })).toHaveLength(2);
        expect(react_2.screen.getAllByRole('link', { name: '2' })).toBeTruthy();
        expect(react_2.screen.getByRole('link', { name: 'Back to reference 1' })).toBeTruthy();
        expect(react_2.screen.getByRole('link', { name: 'Back to reference 1-2' })).toBeTruthy();
        expect(react_2.screen.getByRole('link', { name: /Back to reference 2/i })).toBeTruthy();
    });
    it('should render beforeMainContent with main content', () => {
        const mainContent = 'Main message content';
        const beforeMainContentText = 'Before main content';
        const beforeMainContent = (0, jsx_runtime_1.jsx)("div", { children: beforeMainContentText });
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: mainContent, extraContent: { beforeMainContent } }));
        expect(react_2.screen.getByText(beforeMainContentText)).toBeTruthy();
        expect(react_2.screen.getByText(mainContent)).toBeTruthy();
    });
    it('should render afterMainContent with main content', () => {
        const mainContent = 'Main message content';
        const afterMainContentText = 'After main content';
        const afterMainContent = (0, jsx_runtime_1.jsx)("div", { children: afterMainContentText });
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: mainContent, extraContent: { afterMainContent } }));
        expect(react_2.screen.getByText(afterMainContentText)).toBeTruthy();
        expect(react_2.screen.getByText(mainContent)).toBeTruthy();
    });
    it('should render endContent with main content', () => {
        const mainContent = 'Main message content';
        const endMainContentText = 'End content';
        const endContent = (0, jsx_runtime_1.jsx)("div", { children: endMainContentText });
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: mainContent, extraContent: { endContent } }));
        expect(react_2.screen.getByText(endMainContentText)).toBeTruthy();
        expect(react_2.screen.getByText(mainContent)).toBeTruthy();
    });
    it('should render all parts of extraContent with main content', () => {
        const beforeMainContent = (0, jsx_runtime_1.jsx)("div", { children: "Before main content" });
        const afterMainContent = (0, jsx_runtime_1.jsx)("div", { children: "After main content" });
        const endContent = (0, jsx_runtime_1.jsx)("div", { children: "End content" });
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: "Main message content", extraContent: { beforeMainContent, afterMainContent, endContent } }));
        expect(react_2.screen.getByText('Before main content')).toBeTruthy();
        expect(react_2.screen.getByText('Main message content')).toBeTruthy();
        expect(react_2.screen.getByText('After main content')).toBeTruthy();
        expect(react_2.screen.getByText('End content')).toBeTruthy();
    });
    it('should not render extraContent when not provided', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: "Main message content" }));
        // Ensure no extraContent is rendered
        expect(react_2.screen.getByText('Main message content')).toBeTruthy();
        expect(react_2.screen.queryByText('Before main content')).toBeFalsy();
        expect(react_2.screen.queryByText('After main content')).toBeFalsy();
        expect(react_2.screen.queryByText('end message content')).toBeFalsy();
    });
    it('should handle undefined or null values in extraContent gracefully', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: "Main message content", extraContent: { beforeMainContent: null, afterMainContent: undefined, endContent: null } }));
        // Ensure that no extraContent is rendered if they are null or undefined
        expect(react_2.screen.getByText('Main message content')).toBeTruthy();
        expect(react_2.screen.queryByText('Before main content')).toBeFalsy();
        expect(react_2.screen.queryByText('After main content')).toBeFalsy();
        expect(react_2.screen.queryByText('end message content')).toBeFalsy();
    });
    it('should render JSX in extraContent correctly', () => {
        const beforeMainContent = ((0, jsx_runtime_1.jsx)("div", { "data-testid": "before-main-content", children: (0, jsx_runtime_1.jsx)("strong", { children: "Bold before content" }) }));
        const afterMainContent = ((0, jsx_runtime_1.jsx)("div", { "data-testid": "after-main-content", children: (0, jsx_runtime_1.jsx)("strong", { children: "Bold after content" }) }));
        const endContent = ((0, jsx_runtime_1.jsx)("div", { "data-testid": "end-main-content", children: (0, jsx_runtime_1.jsx)("strong", { children: "Bold end content" }) }));
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: "Main message content", extraContent: { beforeMainContent, afterMainContent, endContent } }));
        // Check that the JSX is correctly rendered
        expect(react_2.screen.getByTestId('before-main-content')).toContainHTML('<strong>Bold before content</strong>');
        expect(react_2.screen.getByTestId('after-main-content')).toContainHTML('<strong>Bold after content</strong>');
        expect(react_2.screen.getByTestId('end-main-content')).toContainHTML('<strong>Bold end content</strong>');
    });
    it('should handle image correctly for user', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: IMAGE }));
        expect(react_2.screen.queryByRole('img', { name: /Multi-colored wavy lines on a black background/i })).toBeFalsy();
    });
    it('should handle image correctly for bot', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "bot", name: "Bot", content: IMAGE }));
        expect(react_2.screen.getByRole('img', { name: /Multi-colored wavy lines on a black background/i })).toBeTruthy();
    });
    it('inline image parent should have class pf-chatbot__message-and-actions', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "bot", name: "Bot", content: INLINE_IMAGE }));
        expect(react_2.screen.getByRole('img', { name: /Multi-colored wavy lines on a black background/i })).toBeTruthy();
        expect(react_2.screen.getByRole('img', { name: /Multi-colored wavy lines on a black background/i }).parentElement).toHaveClass('pf-chatbot__message-and-actions');
    });
    it('should handle external links correctly', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: `[PatternFly](https://www.patternfly.org/)` }));
        // we are mocking rehype libraries, so we can't test target _blank addition on links directly with RTL
        expect(rehype_external_links_1.default).toHaveBeenCalledTimes(1);
    });
    it('should handle external links correctly', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: `[PatternFly](https://www.patternfly.org/)`, openLinkInNewTab: false }));
        // we are mocking rehype libraries, so we can't test target _blank addition on links directly with RTL
        expect(rehype_external_links_1.default).not.toHaveBeenCalled();
    });
    it('should handle extra link props correctly', () => __awaiter(void 0, void 0, void 0, function* () {
        const spy = jest.fn();
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: `[PatternFly](https://www.patternfly.org/)`, linkProps: { onClick: spy } }));
        yield user_event_1.default.click(react_2.screen.getByRole('link', { name: /PatternFly/i }));
        expect(spy).toHaveBeenCalledTimes(1);
    }));
    it('should handle error correctly', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", error: ERROR }));
        expect(react_2.screen.getByRole('heading', { name: /Could not load chat/i })).toBeTruthy();
        expect(react_2.screen.getByRole('link', { name: /Start a new chat/i })).toBeTruthy();
        expect(react_2.screen.getByRole('link', { name: /Contact support/i })).toBeTruthy();
        expect(react_2.screen.getByText('Wait a few minutes and check your network settings. If the issue persists:')).toBeTruthy();
    });
    it('should handle error correctly when loading', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", error: ERROR, isLoading: true }));
        expect(react_2.screen.queryByRole('heading', { name: /Could not load chat/i })).toBeFalsy();
        expect(react_2.screen.getByText('Loading message')).toBeTruthy();
    });
    it('should handle error correctly when these is content', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", error: ERROR, content: "Test" }));
        expect(react_2.screen.getByRole('heading', { name: /Could not load chat/i })).toBeTruthy();
        expect(react_2.screen.queryByText('Test')).toBeFalsy();
    });
    it('should handle isEditable when there is message content', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", isEditable: true, content: "Test" }));
        expect(react_2.screen.getByRole('textbox')).toBeTruthy();
        expect(react_2.screen.getByRole('textbox')).toHaveValue('Test');
        expect(react_2.screen.getByRole('button', { name: /Update/i })).toBeTruthy();
        expect(react_2.screen.getByRole('button', { name: /Cancel/i })).toBeTruthy();
    });
    it('should handle isEditable when there is no message content', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", isEditable: true }));
        expect(react_2.screen.getByRole('textbox')).toBeTruthy();
        expect(react_2.screen.getByRole('textbox')).toHaveValue('');
        expect(react_2.screen.getByRole('textbox')).toHaveAttribute('placeholder', 'Edit prompt message...');
        expect(react_2.screen.getByRole('button', { name: /Update/i })).toBeTruthy();
        expect(react_2.screen.getByRole('button', { name: /Cancel/i })).toBeTruthy();
    });
    it('should be able to change edit placeholder', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", isEditable: true, editPlaceholder: "I am a placeholder" }));
        expect(react_2.screen.getByRole('textbox')).toBeTruthy();
        expect(react_2.screen.getByRole('textbox')).toHaveValue('');
        expect(react_2.screen.getByRole('textbox')).toHaveAttribute('placeholder', 'I am a placeholder');
    });
    it('should be able to change updateWord', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", isEditable: true, updateWord: "Submit" }));
        expect(react_2.screen.getByRole('button', { name: /Submit/i })).toBeTruthy();
    });
    it('should be able to change cancelWord', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", isEditable: true, cancelWord: "Don't submit" }));
        expect(react_2.screen.getByRole('button', { name: /Don't submit/i })).toBeTruthy();
    });
    it('should be able to add onEditUpdate', () => __awaiter(void 0, void 0, void 0, function* () {
        const spy = jest.fn();
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", isEditable: true, onEditUpdate: spy }));
        yield user_event_1.default.click(react_2.screen.getByRole('button', { name: /Update/i }));
        expect(spy).toHaveBeenCalledTimes(1);
    }));
    it('should be able to add onEditCancel', () => __awaiter(void 0, void 0, void 0, function* () {
        const spy = jest.fn();
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", isEditable: true, onEditCancel: spy }));
        yield user_event_1.default.click(react_2.screen.getByRole('button', { name: /Cancel/i }));
        expect(spy).toHaveBeenCalledTimes(1);
    }));
    it('should be able to add  editFormProps', () => {
        const { container } = (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", isEditable: true, editFormProps: { className: 'test' } }));
        const form = container.querySelector('form');
        expect(form).toHaveClass('test');
    });
    it('should be able to disable markdown parsing', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: CODE_MESSAGE, isMarkdownDisabled: true }));
        // this is looking for markdown syntax that is ordinarily stripped
        expect(react_2.screen.getByText(/~~~yaml/i)).toBeTruthy();
    });
    it('should be able to pass props to react-markdown, such as disabling tags', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: CODE_MESSAGE, reactMarkdownProps: { disallowedElements: ['code'] } }));
        expect(react_2.screen.getByText('Here is some YAML code:')).toBeTruthy();
        // code block isn't rendering
        expect(react_2.screen.queryByRole('button', { name: 'Copy code' })).toBeFalsy();
    });
    it('should disable images and additional tags for user messages', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: `${IMAGE} ${CODE_MESSAGE}`, reactMarkdownProps: { disallowedElements: ['code'] } }));
        expect(react_2.screen.getByText('Here is some YAML code:')).toBeTruthy();
        // code block isn't rendering
        expect(react_2.screen.queryByRole('button', { name: 'Copy code' })).toBeFalsy();
        expect(react_2.screen.queryByRole('img', { name: /Multi-colored wavy lines on a black background/i })).toBeFalsy();
    });
    it('can override image tag removal default for user messages', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: IMAGE, hasNoImagesInUserMessages: false }));
        expect(react_2.screen.getByRole('img', { name: /Multi-colored wavy lines on a black background/i })).toBeTruthy();
    });
    it('should render deep thinking section correctly', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: "", deepThinking: DEEP_THINKING }));
        expect(react_2.screen.getByRole('button', { name: /Show thinking/i })).toBeTruthy();
        expect(react_2.screen.getByText('Thought for 3 seconds')).toBeTruthy();
        expect(react_2.screen.getByText("Here's why I said this.")).toBeTruthy();
    });
    it('should handle isPrimary correctly for inline code when it is true', () => {
        const { container } = (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: INLINE_CODE, isPrimary: true }));
        expect(container.querySelector('.pf-m-primary')).toBeTruthy();
    });
    it('should handle isPrimary correctly for inline code when it is false', () => {
        const { container } = (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: INLINE_CODE }));
        expect(container.querySelector('.pf-m-primary')).toBeFalsy();
    });
    it('should handle isPrimary correctly for table when it is true', () => {
        const { container } = (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: TABLE, isPrimary: true }));
        expect(container.querySelector('.pf-m-primary')).toBeTruthy();
    });
    it('should handle isPrimary correctly for table when it is false', () => {
        const { container } = (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: TABLE }));
        expect(container.querySelector('.pf-m-primary')).toBeFalsy();
    });
    it('should handle isPrimary correctly for loading when it is true', () => {
        const { container } = (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: "", isPrimary: true, isLoading: true }));
        expect(container.querySelector('.pf-m-primary')).toBeTruthy();
    });
    it('should handle isPrimary correctly for loading when it is false', () => {
        const { container } = (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: "", isLoading: true }));
        expect(container.querySelector('.pf-m-primary')).toBeFalsy();
    });
    it('should handle isPrimary correctly for attachments when it is true', () => {
        const { container } = (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: "", isPrimary: true, attachments: [{ name: 'testAttachment' }] }));
        expect(container.querySelector('.pf-m-outline')).toBeTruthy();
    });
    it('should handle isPrimary correctly for attachments when it is false', () => {
        const { container } = (0, react_2.render)((0, jsx_runtime_1.jsx)(Message_1.default, { avatar: "./img", role: "user", name: "User", content: "", attachments: [{ name: 'testAttachment' }] }));
        expect(container.querySelector('.pf-m-outline')).toBeFalsy();
    });
});
