Skip to content

Commit

Permalink
implement type column values
Browse files Browse the repository at this point in the history
  • Loading branch information
kantord committed Jan 24, 2025
1 parent 04860b3 commit 5e92cbe
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
15 changes: 14 additions & 1 deletion src/components/AlertsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ const getTitle = (alert: AlertConversation) => {
return title;
};

function TypeCellContent({ alert }: { alert: AlertConversation }) {
const conversationType = alert.conversation.type;
console.log({ conversationType });

if (conversationType === "chat") {
return "Chat";
}

return "Completion";
}

export function AlertsTable() {
const {
isMaliciousFilterActive,
Expand Down Expand Up @@ -151,7 +162,9 @@ export function AlertsTable() {
addSuffix: true,
})}
</Cell>
<Cell className="truncate">{alert.trigger_type}</Cell>
<Cell className="truncate">
<TypeCellContent alert={alert} />
</Cell>
<Cell className="truncate">{getTitle(alert)}</Cell>
</Row>
))}
Expand Down
25 changes: 10 additions & 15 deletions src/routes/__tests__/route-dashboard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ describe("Dashboard", () => {
"row",
)[1] as HTMLElement;

expect(within(firstRow).getByText(/codegate-secrets/i)).toBeVisible();
expect(within(firstRow).getByText(/chat/i)).toBeVisible();
expect(within(firstRow).getByText(/[0-9]+.*ago/i)).toBeVisible();
});

Expand Down Expand Up @@ -209,10 +209,10 @@ describe("Dashboard", () => {

expect(screen.getByTestId(/alerts-count/i)).toHaveTextContent("2");
expect(
screen.getByRole("row", {
name: /codegate-secrets/i,
}),
).toBeVisible();
screen.getAllByRole("row", {
name: /chat/i,
}).length,
).toBeGreaterThanOrEqual(1);

userEvent.click(
screen.getByRole("switch", {
Expand Down Expand Up @@ -244,15 +244,10 @@ describe("Dashboard", () => {

expect(screen.getByTestId(/alerts-count/i)).toHaveTextContent("2");
expect(
screen.getByRole("row", {
name: /codegate-secrets/i,
}),
).toBeVisible();
expect(
screen.getByRole("row", {
name: /codegate-context-retriever/i,
}),
).toBeVisible();
screen.getAllByRole("row", {
name: /chat/i,
}).length,
).toBeGreaterThanOrEqual(1);

await userEvent.type(screen.getByRole("searchbox"), "codegate-secrets");

Expand All @@ -262,7 +257,7 @@ describe("Dashboard", () => {
const row = within(screen.getByTestId("alerts-table")).getAllByRole(
"row",
)[1] as HTMLElement;
expect(within(row).getByText(/codegate-secrets/i)).toBeVisible();
expect(within(row).getByText(/chat/i)).toBeVisible();
});

it("should sort alerts by date desc", async () => {
Expand Down

0 comments on commit 5e92cbe

Please sign in to comment.