mirror of
https://ghfast.top/https://github.com/discourse/discourse-ai.git
synced 2026-07-17 11:46:28 +08:00
This improves the site setting search so it performs a somewhat
fuzzy match.
Previously it did not handle seperators such as "space" and a
term such as "min_post_length" would not find "min_first_post_length"
A more liberal search algorithm makes it easier to the AI to
navigate settings.
* Minor fix, {{and parameter.enum parameter.enum.length}} is non
obviously broken.
If parameter.enum is a tracked array it will return the object
cause embers and helper implementation.
This corrects an issue where enum keeps on selecting itself by
mistake.
71 lines
2.1 KiB
Ruby
71 lines
2.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require "rails_helper"
|
|
|
|
describe "AI Tool Management", type: :system do
|
|
fab!(:admin)
|
|
|
|
before do
|
|
SiteSetting.ai_embeddings_enabled = true
|
|
sign_in(admin)
|
|
end
|
|
|
|
it "allows admin to create a new AI tool from preset" do
|
|
visit "/admin/plugins/discourse-ai/ai-tools"
|
|
|
|
expect(page).to have_content("Tools")
|
|
|
|
find(".ai-tool-list-editor__new-button").click
|
|
|
|
select_kit = PageObjects::Components::SelectKit.new(".ai-tool-editor__presets")
|
|
select_kit.expand
|
|
select_kit.select_row_by_value("exchange_rate")
|
|
|
|
find(".ai-tool-editor__next").click
|
|
|
|
expect(page.first(".parameter-row__required-toggle").checked?).to eq(true)
|
|
expect(page.first(".parameter-row__enum-toggle").checked?).to eq(false)
|
|
|
|
find(".ai-tool-editor__test-button").click
|
|
|
|
expect(page).not_to have_button(".ai-tool-editor__delete")
|
|
|
|
modal = PageObjects::Modals::AiToolTest.new
|
|
modal.base_currency = "USD"
|
|
modal.target_currency = "EUR"
|
|
modal.amount = "100"
|
|
|
|
stub_request(:get, %r{https://open\.er-api\.com/v6/latest/USD}).to_return(
|
|
status: 200,
|
|
body: '{"rates": {"EUR": 0.85}}',
|
|
headers: {
|
|
"Content-Type" => "application/json",
|
|
},
|
|
)
|
|
modal.run_test
|
|
|
|
expect(modal).to have_content("exchange_rate")
|
|
expect(modal).to have_content("0.85")
|
|
|
|
modal.close
|
|
|
|
find(".ai-tool-editor__save").click
|
|
|
|
expect(page).to have_content("Tool saved")
|
|
|
|
last_tool = AiTool.order("id desc").limit(1).first
|
|
visit "/admin/plugins/discourse-ai/ai-tools/#{last_tool.id}"
|
|
|
|
expect(page.first(".parameter-row__required-toggle").checked?).to eq(true)
|
|
expect(page.first(".parameter-row__enum-toggle").checked?).to eq(false)
|
|
|
|
visit "/admin/plugins/discourse-ai/ai-personas/new"
|
|
|
|
tool_id = AiTool.order("id desc").limit(1).pluck(:id).first
|
|
tool_selector = PageObjects::Components::SelectKit.new(".ai-persona-editor__tools")
|
|
tool_selector.expand
|
|
|
|
tool_selector.select_row_by_value("custom-#{tool_id}")
|
|
expect(tool_selector).to have_selected_value("custom-#{tool_id}")
|
|
end
|
|
end
|