-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconversation_with_claude_structured_answer_spec.rb
More file actions
82 lines (64 loc) · 2.24 KB
/
conversation_with_claude_structured_answer_spec.rb
File metadata and controls
82 lines (64 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
RSpec.describe "Conversation with Claude with a structured answer", :aws_credentials_stubbed, :chunked_content_index do
scenario do
given_i_am_using_the_claude_structured_answer_strategy
when_i_visit_the_conversation_page
and_i_enter_a_question
then_i_see_the_answer_is_pending
when_the_first_answer_is_generated
and_i_click_on_the_check_answer_button
then_i_see_my_question_on_the_page
and_i_can_see_the_first_answer
when_i_enter_a_second_question
then_i_see_the_answer_is_pending
when_the_second_answer_is_generated
and_i_click_on_the_check_answer_button
then_i_see_my_second_question_on_the_page
and_i_can_see_the_second_answer
end
def when_i_visit_the_conversation_page
visit show_conversation_path
end
def and_i_enter_a_question
@first_question = "How much tax should I be paying?"
fill_in "Message", with: @first_question
click_on "Send"
end
def then_i_see_the_answer_is_pending
expect(page).to have_content("GOV.UK Chat is generating an answer")
end
def when_the_first_answer_is_generated
@first_answer = "You can use a simple service on GOV.UK"
stubs_for_mock_answer(@first_question,
@first_answer,
sources_used: %w[link_1])
execute_queued_sidekiq_jobs
end
def and_i_click_on_the_check_answer_button
click_on "Check if an answer has been generated"
end
def then_i_see_my_question_on_the_page
expect(page).to have_content(@first_question)
end
def and_i_can_see_the_first_answer
expect(page).to have_content(@first_answer)
end
def when_i_enter_a_second_question
@second_question = "Are you sure?"
fill_in "Message", with: @second_question
click_on "Send"
end
def when_the_second_answer_is_generated
@second_answer = "Even more tax."
stubs_for_mock_answer(@second_question,
@second_answer,
sources_used: %w[link_1],
create_content_chunk: false)
execute_queued_sidekiq_jobs
end
def then_i_see_my_second_question_on_the_page
expect(page).to have_content(@second_question)
end
def and_i_can_see_the_second_answer
expect(page).to have_content(@second_answer)
end
end