discourse-ai/spec/requests/admin/rag_document_fragments_controller_spec.rb
Roman Rizzi f5cf1019fb
FEATURE: configurable embeddings (#1049)
* Use AR model for embeddings features

* endpoints

* Embeddings CRUD UI

* Add presets. Hide a couple more settings

* system specs

* Seed embedding definition from old settings

* Generate search bit index on the fly. cleanup orphaned data

* support for seeded models

* Fix run test for new embedding

* fix selected model not set correctly
2025-01-21 12:23:19 -03:00

38 lines
1.0 KiB
Ruby

# frozen_string_literal: true
RSpec.describe DiscourseAi::Admin::RagDocumentFragmentsController do
fab!(:admin)
fab!(:ai_persona)
fab!(:vector_def) { Fabricate(:embedding_definition) }
before do
sign_in(admin)
SiteSetting.ai_embeddings_selected_model = vector_def.id
SiteSetting.ai_embeddings_enabled = true
end
describe "GET #indexing_status_check" do
it "works for AiPersona" do
get "/admin/plugins/discourse-ai/rag-document-fragments/files/status.json?target_type=AiPersona&target_id=#{ai_persona.id}"
expect(response.parsed_body).to eq({})
expect(response.status).to eq(200)
end
end
describe "POST #upload_file" do
it "works" do
post "/admin/plugins/discourse-ai/rag-document-fragments/files/upload.json",
params: {
file: Rack::Test::UploadedFile.new(file_from_fixtures("spec.txt", "md")),
}
expect(response.status).to eq(200)
upload = Upload.last
expect(upload.original_filename).to end_with("spec.txt")
end
end
end