2023-08-08 17:19:56 -04:00
|
|
|
#frozen_string_literal: true
|
|
|
|
|
|
|
|
RSpec.describe DiscourseAi::AiBot::Commands::ReadCommand do
|
|
|
|
fab!(:bot_user) { User.find(DiscourseAi::AiBot::EntryPoint::GPT3_5_TURBO_ID) }
|
|
|
|
|
|
|
|
describe "#process" do
|
|
|
|
it "can read a topic" do
|
|
|
|
post1 = Fabricate(:post, raw: "hello there")
|
|
|
|
Fabricate(:post, raw: "mister sam", topic: post1.topic)
|
|
|
|
|
2023-08-14 02:30:12 -04:00
|
|
|
read = described_class.new(bot_user: bot_user, args: nil, post: post1)
|
2023-08-08 17:19:56 -04:00
|
|
|
|
|
|
|
results = read.process(topic_id: post1.topic_id)
|
|
|
|
|
|
|
|
expect(results[:topic_id]).to eq(post1.topic_id)
|
|
|
|
expect(results[:content]).to include("hello")
|
|
|
|
expect(results[:content]).to include("sam")
|
2023-08-09 02:01:48 -04:00
|
|
|
expect(read.description_args).to eq(title: post1.topic.title, url: post1.topic.relative_url)
|
2023-08-08 17:19:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|