Skip to content

[inter-v2-06] Web Q&A UI: mock vs real provider (#413) - #433

Open
CodingMinh wants to merge 1 commit into
masterfrom
inter-v2/06-qa-e2e-mock
Open

[inter-v2-06] Web Q&A UI: mock vs real provider (#413)#433
CodingMinh wants to merge 1 commit into
masterfrom
inter-v2/06-qa-e2e-mock

Conversation

@CodingMinh

Copy link
Copy Markdown
Collaborator

Tóm tắt thay đổi

  • Tạo bài test E2E Playwright mới tại web/e2e/inter-v2-qa-mock.spec.ts cho luồng Q&A ở chế độ mock (happy path).
  • Xác minh hành vi UI khi đặt câu hỏi: câu trả lời được stream hiển thị chính xác (grounded answer), khối nguồn trích dẫn (citations/source) xuất hiện với tên tài liệu (Roadmap.xlsx).
  • Tuân thủ nguyên tắc kiểm thử: sử dụng web-first assertions / expect polling, tuyệt đối không dùng sleep() / waitForTimeout(), không test React internal state.
  • Ghi chú và giải thích chi tiết trong source code về sự khác biệt giữa Mock Handler vs API thật cùng các biến môi trường cần thiết (MARKHAND_CHAT_* / FILECONV_LLM_*) để chạy Q&A trên stack thực tế.

Khác biệt Mock vs Real Provider

  1. Mock Handler (web/src/mocks/handlers/qa.ts):
    • Hoạt động ở tầng browser fetch mock (VITE_MARKHAND_MOCK=1).
    • Tạo toàn bộ luồng SSE pre-serialized và trả về một lần (rawBody text/event-stream), đảm bảo deterministic và tránh sleep-race khi chạy test.
  2. Real Backend API (crates/server/src/services/qa/ask_stream.rs):
    • Kết nối với pipeline semantic search (PostgreSQL + Qdrant) và stream token thời gian thực từ LLM provider (OpenRouter).
    • Yêu cầu các biến môi trường cấu hình LLM: FILECONV_LLM_API_KEY, FILECONV_LLM_MODEL, FILECONV_LLM_BASE_URL (hoặc MARKHAND_CHAT_*) và tài liệu đã được index hoàn tất.

Acceptance Criteria

  • ≥1 E2E test Q&A pass (mock)
  • Giải thích mock handler vs API thật
  • Assert UI behavior (answer visible, citation/source)
  • Note env cần cho real Q&A (MARKHAND_CHAT_* / FILECONV_LLM_*)
  • Không hardcode sleep, không test React internal state

Closes #413

@CodingMinh
CodingMinh requested a review from anhnth24 as a code owner September 1, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[inter-v2-06] Web Q&A UI: mock vs real provider

1 participant