|
| 1 | +import { screen } from "@testing-library/react"; |
| 2 | +import type { Line } from "#/components/Logs/LogLine"; |
| 3 | +import { renderComponent } from "#/testHelpers/renderHelpers"; |
| 4 | +import { AgentLogLine } from "./AgentLogLine"; |
| 5 | + |
| 6 | +const line: Line = { |
| 7 | +id: 1, |
| 8 | +level: "info", |
| 9 | +output: 'safe <span data-testid="agent-log-xss">xss</span>', |
| 10 | +sourceId: "source-id", |
| 11 | +time: "2024-03-14T11:31:04.090715Z", |
| 12 | +}; |
| 13 | + |
| 14 | +describe("AgentLogLine", () => { |
| 15 | +it("renders log HTML as escaped text", () => { |
| 16 | +renderComponent(<AgentLogLine line={line} sourceIcon={null} style={{}} />); |
| 17 | + |
| 18 | +expect(screen.queryByTestId("agent-log-xss")).not.toBeInTheDocument(); |
| 19 | +expect( |
| 20 | +screen.getByText(/safe <span data-testid="agent-log-xss">xss<\/span>/), |
| 21 | +).toBeInTheDocument(); |
| 22 | +}); |
| 23 | +}); |