Skip to content

Commit 1beb48e

Browse files
committed
implement type column values
1 parent 5e476a7 commit 1beb48e

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

src/components/AlertsTable.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ const getTitle = (alert: AlertConversation) => {
3737
return title;
3838
};
3939

40+
function TypeCellContent({ alert }: { alert: AlertConversation }) {
41+
const conversationType = alert.conversation.type;
42+
console.log({ conversationType });
43+
44+
if (conversationType === "chat") {
45+
return "Chat";
46+
}
47+
48+
return "Completion";
49+
}
50+
4051
export function AlertsTable() {
4152
const {
4253
isMaliciousFilterActive,
@@ -156,7 +167,9 @@ export function AlertsTable() {
156167
addSuffix: true,
157168
})}
158169
</Cell>
159-
<Cell className="truncate">{alert.trigger_type}</Cell>
170+
<Cell className="truncate">
171+
<TypeCellContent alert={alert} />
172+
</Cell>
160173
<Cell className="truncate">{getTitle(alert)}</Cell>
161174
</Row>
162175
))}

src/routes/__tests__/route-dashboard.test.tsx

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ describe("Dashboard", () => {
167167
"row",
168168
)[1] as HTMLElement;
169169

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

@@ -209,10 +209,10 @@ describe("Dashboard", () => {
209209

210210
expect(screen.getByTestId(/alerts-count/i)).toHaveTextContent("2");
211211
expect(
212-
screen.getByRole("row", {
213-
name: /codegate-secrets/i,
214-
}),
215-
).toBeVisible();
212+
screen.getAllByRole("row", {
213+
name: /chat/i,
214+
}).length,
215+
).toBeGreaterThanOrEqual(1);
216216

217217
userEvent.click(
218218
screen.getByRole("switch", {
@@ -244,15 +244,10 @@ describe("Dashboard", () => {
244244

245245
expect(screen.getByTestId(/alerts-count/i)).toHaveTextContent("2");
246246
expect(
247-
screen.getByRole("row", {
248-
name: /codegate-secrets/i,
249-
}),
250-
).toBeVisible();
251-
expect(
252-
screen.getByRole("row", {
253-
name: /codegate-context-retriever/i,
254-
}),
255-
).toBeVisible();
247+
screen.getAllByRole("row", {
248+
name: /chat/i,
249+
}).length,
250+
).toBeGreaterThanOrEqual(1);
256251

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

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

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

0 commit comments

Comments
 (0)