Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit b394275

Browse files
committed
try spec with formkit helper
1 parent ce0e7a0 commit b394275

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

spec/system/embeddings/ai_embedding_definition_spec.rb

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
RSpec.describe "Managing Embeddings configurations", type: :system, js: true do
44
fab!(:admin)
55
let(:page_header) { PageObjects::Components::DPageHeader.new }
6+
let(:form) { PageObjects::Components::FormKit.new("form") }
67

78
before { sign_in(admin) }
89

@@ -16,8 +17,8 @@
1617

1718
find("[data-preset-id='text-embedding-3-small'] button").click()
1819

19-
find(".form-kit__control-password").fill_in(with: api_key)
20-
find(".ai-embedding-editor__save").click()
20+
form.field("api_key").fill_in(api_key)
21+
form.submit
2122

2223
expect(page).to have_current_path("/admin/plugins/discourse-ai/ai-embeddings")
2324

@@ -45,29 +46,27 @@
4546

4647
find("[data-preset-id='manual'] button").click()
4748

48-
find("#control-display_name input").fill_in(with: "text-embedding-3-small")
49-
50-
find("#control-provider select").select(EmbeddingDefinition::OPEN_AI)
51-
52-
find("#control-url input").fill_in(with: "https://api.openai.com/v1/embeddings")
53-
find("#control-api_key input").fill_in(with: api_key)
54-
55-
find("#control-tokenizer_class select").select("OpenAiTokenizer")
49+
# Use the FormKit helper to fill in the form fields
50+
form.field("display_name").fill_in("text-embedding-3-small")
51+
form.field("provider").select(EmbeddingDefinition::OPEN_AI)
52+
form.field("url").fill_in("https://api.openai.com/v1/embeddings")
53+
form.field("api_key").fill_in(api_key)
54+
form.field("tokenizer_class").select("DiscourseAi::Tokenizer::OpenAiTokenizer")
5655

5756
embed_prefix = "On creation:"
5857
search_prefix = "On search:"
59-
find("#control-embed_prompt textarea").fill_in(with: embed_prefix)
60-
find("#control-search_prompt textarea").fill_in(with: search_prefix)
61-
find("#control-dimensions input").fill_in(with: 1536)
62-
find("#control-max_sequence_length input").fill_in(with: 8191)
58+
form.field("embed_prompt").fill_in(embed_prefix)
59+
form.field("search_prompt").fill_in(search_prefix)
60+
form.field("dimensions").fill_in(1536)
61+
form.field("max_sequence_length").fill_in(8191)
62+
form.field("pg_function").select("<=>")
6363

64-
find("#control-pg_function select").select("Cosine distance")
65-
66-
find(".ai-embedding-editor__save").click()
64+
form.submit
6765

6866
expect(page).to have_current_path("/admin/plugins/discourse-ai/ai-embeddings")
6967

7068
embedding_def = EmbeddingDefinition.order(:id).last
69+
7170
expect(embedding_def.api_key).to eq(api_key)
7271

7372
preset = EmbeddingDefinition.presets.find { |p| p[:preset_id] == "text-embedding-3-small" }

0 commit comments

Comments
 (0)