|
284 | 284 | .and have_content('"id": "call_dqGpbb39drQDafLsjDLtnbGD"') |
285 | 285 | end |
286 | 286 |
|
287 | | - it "doesn't render the tabs component when there is no analysis" do |
| 287 | + it "doesn't render the tabs component when there are no topics or auto-eval aggregate data" do |
288 | 288 | question = create(:question, :with_answer) |
289 | 289 | get admin_show_question_path(question) |
290 | 290 |
|
|
353 | 353 | .to have_selector("#details-tab", text: question.message) |
354 | 354 | end |
355 | 355 |
|
356 | | - it "renders the topics in the analysis tab" do |
| 356 | + it "renders the topics in the topics tab" do |
357 | 357 | get admin_show_question_path(question) |
358 | 358 |
|
359 | 359 | expect(response.body) |
360 | 360 | .to have_selector("#analysis-tab", text: topics.primary_topic.capitalize) |
361 | 361 | .and have_selector("#analysis-tab", text: topics.secondary_topic.capitalize) |
362 | 362 | end |
363 | 363 | end |
| 364 | + |
| 365 | + context "when answer relevancy aggregate data is present" do |
| 366 | + let(:run) do |
| 367 | + create( |
| 368 | + :answer_relevancy_run, |
| 369 | + score: 0.85, |
| 370 | + reason: "The answer is relevant to the question.", |
| 371 | + llm_responses: { |
| 372 | + "statements" => { "statements" => ["The answer is relevant."] }, |
| 373 | + "verdicts" => { "verdicts" => [{ "verdict" => "yes" }] }, |
| 374 | + }, |
| 375 | + metrics: { |
| 376 | + "statements" => { duration: 1.55556 }, |
| 377 | + "verdicts" => { duration: 1.44445 }, |
| 378 | + }, |
| 379 | + ) |
| 380 | + end |
| 381 | + let!(:aggregate) do |
| 382 | + create( |
| 383 | + :answer_relevancy_aggregate, |
| 384 | + runs: [run], |
| 385 | + ) |
| 386 | + end |
| 387 | + let(:question) { aggregate.answer.question } |
| 388 | + |
| 389 | + it "renders the answer relevancy aggregate and run details" do |
| 390 | + get admin_show_question_path(question) |
| 391 | + |
| 392 | + expect(response.body.squish) |
| 393 | + .to have_content("Answer relevancy") |
| 394 | + .and have_content("Run 1 score") |
| 395 | + .and have_content("0.85") |
| 396 | + .and have_content("Run 1 reason") |
| 397 | + .and have_content("The answer is relevant to the question.") |
| 398 | + end |
| 399 | + |
| 400 | + it "renders the runs llm responses" do |
| 401 | + get admin_show_question_path(question) |
| 402 | + |
| 403 | + expect(response.body.squish) |
| 404 | + .to have_content('{ "statements": [ "The answer is relevant." ] }') |
| 405 | + .and have_content('{ "verdicts": [ { "verdict": "yes" } ] }') |
| 406 | + end |
| 407 | + |
| 408 | + it "renders the runs metrics" do |
| 409 | + get admin_show_question_path(question) |
| 410 | + |
| 411 | + expect(response.body.squish) |
| 412 | + .to have_content("Statements") |
| 413 | + .and have_content(/duration.*1\.55556/) |
| 414 | + .and have_content("Verdicts") |
| 415 | + .and have_content(/duration.*1\.44445/) |
| 416 | + end |
| 417 | + end |
364 | 418 | end |
365 | 419 |
|
366 | 420 | def expect_unprocessable_content_with_date_errors |
|
0 commit comments