Skip to content

Commit f1ade44

Browse files
author
Nguyen Son
committed
style: format chatbot widget test
1 parent e78c244 commit f1ade44

1 file changed

Lines changed: 30 additions & 13 deletions

File tree

frontend/src/test/components/ChatbotWidget.test.tsx

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,18 @@ describe("ChatbotWidget", () => {
140140
expect(await screen.findByText("Chào bạn!")).toBeInTheDocument();
141141
expect(screen.getByText("Đăng nhập để bắt đầu chat")).toBeInTheDocument();
142142
expect(screen.getByTestId("chat-header-subtitle")).toHaveTextContent(
143-
"Gợi ý sách, đơn hàng và ưu đãi ngay trong cửa hàng."
143+
"Gợi ý sách, đơn hàng và ưu đãi ngay trong cửa hàng.",
144+
);
145+
expect(screen.getByTestId("chatbot-status-badge")).toHaveTextContent(
146+
"Grok sẵn sàng · grok-3",
144147
);
145-
expect(screen.getByTestId("chatbot-status-badge")).toHaveTextContent("Grok sẵn sàng · grok-3");
146148
expectNoMojibake();
147149

148150
fireEvent.click(screen.getByTestId("chatbot-login-cta"));
149151

150-
expect(pushMock).toHaveBeenCalledWith("/login?redirect=%2Fproducts%3Fsource%3Dhome");
152+
expect(pushMock).toHaveBeenCalledWith(
153+
"/login?redirect=%2Fproducts%3Fsource%3Dhome",
154+
);
151155
});
152156

153157
it("renders English guest copy and action labels when locale changes", async () => {
@@ -169,9 +173,11 @@ describe("ChatbotWidget", () => {
169173
expect(screen.getByText("View promotions")).toBeInTheDocument();
170174
expect(screen.getByText("Browse categories")).toBeInTheDocument();
171175
expect(screen.getByTestId("chat-header-subtitle")).toHaveTextContent(
172-
"Book suggestions, orders, and deals right inside the store."
176+
"Book suggestions, orders, and deals right inside the store.",
177+
);
178+
expect(screen.getByTestId("chatbot-status-badge")).toHaveTextContent(
179+
"Grok ready · grok-3",
173180
);
174-
expect(screen.getByTestId("chatbot-status-badge")).toHaveTextContent("Grok ready · grok-3");
175181
expectNoMojibake();
176182
});
177183

@@ -188,13 +194,17 @@ describe("ChatbotWidget", () => {
188194
render(<ChatbotWidget />);
189195
fireEvent.click(screen.getByTestId("chatbot-launcher"));
190196

191-
expect(await screen.findByText("Chatbot is ready to help")).toBeInTheDocument();
192-
expect(screen.getByTestId("chatbot-status-badge")).toHaveTextContent("Grok ready · grok-3");
197+
expect(
198+
await screen.findByText("Chatbot is ready to help"),
199+
).toBeInTheDocument();
200+
expect(screen.getByTestId("chatbot-status-badge")).toHaveTextContent(
201+
"Grok ready · grok-3",
202+
);
193203
expect(screen.getByTestId("chat-input-placeholder")).toHaveTextContent(
194-
"Ask about books, orders, or promotions..."
204+
"Ask about books, orders, or promotions...",
195205
);
196206
expect(screen.getByTestId("chat-input-helper")).toHaveTextContent(
197-
"Press Enter to send, Shift + Enter for a new line"
207+
"Press Enter to send, Shift + Enter for a new line",
198208
);
199209
expect(screen.getByText("Find books about Python")).toBeInTheDocument();
200210
expectNoMojibake();
@@ -213,13 +223,20 @@ describe("ChatbotWidget", () => {
213223
render(<ChatbotWidget />);
214224
fireEvent.click(screen.getByTestId("chatbot-launcher"));
215225

216-
expect(await screen.findByText("Chatbot đang tạm tắt ở môi trường này")).toBeInTheDocument();
226+
expect(
227+
await screen.findByText("Chatbot đang tạm tắt ở môi trường này"),
228+
).toBeInTheDocument();
217229
await waitFor(() => {
218-
expect(screen.getByTestId("chat-input")).toHaveAttribute("data-disabled", "true");
230+
expect(screen.getByTestId("chat-input")).toHaveAttribute(
231+
"data-disabled",
232+
"true",
233+
);
219234
});
220-
expect(screen.getByTestId("chat-input-placeholder")).toHaveTextContent("Chatbot đang tạm tắt");
235+
expect(screen.getByTestId("chat-input-placeholder")).toHaveTextContent(
236+
"Chatbot đang tạm tắt",
237+
);
221238
expect(screen.getByTestId("chat-input-helper")).toHaveTextContent(
222-
"Chatbot đang tạm tắt. Bạn vẫn có thể duyệt sách và khuyến mãi trực tiếp."
239+
"Chatbot đang tạm tắt. Bạn vẫn có thể duyệt sách và khuyến mãi trực tiếp.",
223240
);
224241
expectNoMojibake();
225242
});

0 commit comments

Comments
 (0)