Skip to content

Commit 272c5f1

Browse files
style(ui): format chat-qa-panel.test.tsx
Prettier formatting was missed on this file since it was written after the workspace-wide format pass, tripping ui:lint on CI.
1 parent 124358f commit 272c5f1

1 file changed

Lines changed: 85 additions & 14 deletions

File tree

apps/loopover-ui/src/components/site/app-panels/chat-qa-panel.test.tsx

Lines changed: 85 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ const ELIGIBLE = [
1414
];
1515

1616
async function askQuestion(question = "Why is this blocked?") {
17-
fireEvent.change(screen.getByPlaceholderText(/why is this pr blocked/i), { target: { value: question } });
17+
fireEvent.change(screen.getByPlaceholderText(/why is this pr blocked/i), {
18+
target: { value: question },
19+
});
1820
fireEvent.click(screen.getByRole("button", { name: /ask/i }));
1921
}
2022

@@ -25,7 +27,9 @@ describe("ChatQaPanel (#6489)", () => {
2527

2628
it("renders nothing at all when no PR in view has chatQa enabled (not a disabled-looking version of the panel)", () => {
2729
const { container } = render(
28-
<ChatQaPanel reviewability={[{ pr: "acme/widgets#2", title: "Fix flaky test", chatQaEnabled: false }]} />,
30+
<ChatQaPanel
31+
reviewability={[{ pr: "acme/widgets#2", title: "Fix flaky test", chatQaEnabled: false }]}
32+
/>,
2933
);
3034
expect(container.firstChild).toBeNull();
3135
expect(apiFetch).not.toHaveBeenCalled();
@@ -43,29 +47,56 @@ describe("ChatQaPanel (#6489)", () => {
4347
});
4448

4549
it("posts the question to the selected PR's chat-qa route and renders an 'ok' answer", async () => {
46-
apiFetch.mockResolvedValue({ ok: true, data: { status: "ok", model: "test-model", estimatedNeurons: 12, text: "This PR is blocked on a failing check." } });
50+
apiFetch.mockResolvedValue({
51+
ok: true,
52+
data: {
53+
status: "ok",
54+
model: "test-model",
55+
estimatedNeurons: 12,
56+
text: "This PR is blocked on a failing check.",
57+
},
58+
});
4759
render(<ChatQaPanel reviewability={ELIGIBLE} />);
4860
await askQuestion("Why is this blocked?");
4961

50-
await waitFor(() => expect(screen.getByText("This PR is blocked on a failing check.")).toBeTruthy());
62+
await waitFor(() =>
63+
expect(screen.getByText("This PR is blocked on a failing check.")).toBeTruthy(),
64+
);
5165
expect(screen.getByText("answered")).toBeTruthy();
5266
expect(screen.getByText("test-model")).toBeTruthy();
5367
expect(apiFetch).toHaveBeenCalledWith(
5468
"https://api.test/v1/repos/acme/widgets/pulls/1/chat-qa",
55-
expect.objectContaining({ method: "POST", label: "Chat Q&A", body: JSON.stringify({ question: "Why is this blocked?" }) }),
69+
expect.objectContaining({
70+
method: "POST",
71+
label: "Chat Q&A",
72+
body: JSON.stringify({ question: "Why is this blocked?" }),
73+
}),
5674
);
5775
});
5876

5977
it("renders the 'disabled' status distinctly", async () => {
60-
apiFetch.mockResolvedValue({ ok: true, data: { status: "disabled", reason: "Chat Q&A is not enabled on this instance (settings.advisoryAiRouting.chatQa is off)." } });
78+
apiFetch.mockResolvedValue({
79+
ok: true,
80+
data: {
81+
status: "disabled",
82+
reason:
83+
"Chat Q&A is not enabled on this instance (settings.advisoryAiRouting.chatQa is off).",
84+
},
85+
});
6186
render(<ChatQaPanel reviewability={ELIGIBLE} />);
6287
await askQuestion();
6388
await waitFor(() => expect(screen.getByText("Not enabled")).toBeTruthy());
6489
expect(screen.getByText(/settings\.advisoryAiRouting\.chatQa is off/)).toBeTruthy();
6590
});
6691

6792
it("renders the 'unavailable' status distinctly", async () => {
68-
apiFetch.mockResolvedValue({ ok: true, data: { status: "unavailable", reason: "Local advisory inference (env.AI_ADVISORY) is not configured." } });
93+
apiFetch.mockResolvedValue({
94+
ok: true,
95+
data: {
96+
status: "unavailable",
97+
reason: "Local advisory inference (env.AI_ADVISORY) is not configured.",
98+
},
99+
});
69100
render(<ChatQaPanel reviewability={ELIGIBLE} />);
70101
await askQuestion();
71102
await waitFor(() => expect(screen.getByText("Unavailable")).toBeTruthy());
@@ -75,7 +106,12 @@ describe("ChatQaPanel (#6489)", () => {
75106
it("renders the 'declined' status with its fallback command suggestion", async () => {
76107
apiFetch.mockResolvedValue({
77108
ok: true,
78-
data: { status: "declined", reason: "No cached deterministic facts are available.", suggestion: "Run `@loopover preflight` or `@loopover blockers` for the deterministic readiness facts." },
109+
data: {
110+
status: "declined",
111+
reason: "No cached deterministic facts are available.",
112+
suggestion:
113+
"Run `@loopover preflight` or `@loopover blockers` for the deterministic readiness facts.",
114+
},
79115
});
80116
render(<ChatQaPanel reviewability={ELIGIBLE} />);
81117
await askQuestion();
@@ -84,30 +120,61 @@ describe("ChatQaPanel (#6489)", () => {
84120
});
85121

86122
it("renders the 'quota_exceeded' status with the remaining budget", async () => {
87-
apiFetch.mockResolvedValue({ ok: true, data: { status: "quota_exceeded", model: "test-model", estimatedNeurons: 900, remainingBudget: 0 } });
123+
apiFetch.mockResolvedValue({
124+
ok: true,
125+
data: {
126+
status: "quota_exceeded",
127+
model: "test-model",
128+
estimatedNeurons: 900,
129+
remainingBudget: 0,
130+
},
131+
});
88132
render(<ChatQaPanel reviewability={ELIGIBLE} />);
89133
await askQuestion();
90134
await waitFor(() => expect(screen.getByText("Daily AI budget reached")).toBeTruthy());
91135
expect(screen.getByText(/Remaining budget: 0 neurons/)).toBeTruthy();
92136
});
93137

94138
it("renders the 'unsafe' status distinctly", async () => {
95-
apiFetch.mockResolvedValue({ ok: true, data: { status: "unsafe", model: "test-model", estimatedNeurons: 20, reason: "chat answer failed public sanitizer" } });
139+
apiFetch.mockResolvedValue({
140+
ok: true,
141+
data: {
142+
status: "unsafe",
143+
model: "test-model",
144+
estimatedNeurons: 20,
145+
reason: "chat answer failed public sanitizer",
146+
},
147+
});
96148
render(<ChatQaPanel reviewability={ELIGIBLE} />);
97149
await askQuestion();
98150
await waitFor(() => expect(screen.getByText("Answer withheld")).toBeTruthy());
99151
});
100152

101153
it("renders the 'error' status distinctly", async () => {
102-
apiFetch.mockResolvedValue({ ok: true, data: { status: "error", model: "test-model", estimatedNeurons: 0, reason: "empty_chat_answer" } });
154+
apiFetch.mockResolvedValue({
155+
ok: true,
156+
data: {
157+
status: "error",
158+
model: "test-model",
159+
estimatedNeurons: 0,
160+
reason: "empty_chat_answer",
161+
},
162+
});
103163
render(<ChatQaPanel reviewability={ELIGIBLE} />);
104164
await askQuestion();
105165
await waitFor(() => expect(screen.getByText("Answer failed")).toBeTruthy());
106166
expect(screen.getByText(/empty_chat_answer/)).toBeTruthy();
107167
});
108168

109169
it("renders the route-local 'rate_limited' status distinctly", async () => {
110-
apiFetch.mockResolvedValue({ ok: true, data: { status: "rate_limited", reason: "The chat command has reached its rate limit (2 within 24h), shared with the @loopover chat PR-comment command." } });
170+
apiFetch.mockResolvedValue({
171+
ok: true,
172+
data: {
173+
status: "rate_limited",
174+
reason:
175+
"The chat command has reached its rate limit (2 within 24h), shared with the @loopover chat PR-comment command.",
176+
},
177+
});
111178
render(<ChatQaPanel reviewability={ELIGIBLE} />);
112179
await askQuestion();
113180
await waitFor(() => expect(screen.getByText("Rate limited")).toBeTruthy());
@@ -124,7 +191,11 @@ describe("ChatQaPanel (#6489)", () => {
124191
it("disables the Ask button until a question is entered", () => {
125192
render(<ChatQaPanel reviewability={ELIGIBLE} />);
126193
expect((screen.getByRole("button", { name: /ask/i }) as HTMLButtonElement).disabled).toBe(true);
127-
fireEvent.change(screen.getByPlaceholderText(/why is this pr blocked/i), { target: { value: "Why?" } });
128-
expect((screen.getByRole("button", { name: /ask/i }) as HTMLButtonElement).disabled).toBe(false);
194+
fireEvent.change(screen.getByPlaceholderText(/why is this pr blocked/i), {
195+
target: { value: "Why?" },
196+
});
197+
expect((screen.getByRole("button", { name: /ask/i }) as HTMLButtonElement).disabled).toBe(
198+
false,
199+
);
129200
});
130201
});

0 commit comments

Comments
 (0)