Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 74 additions & 82 deletions spec/system/ai_bot/share_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,122 +43,114 @@
page.execute_script("window.navigator.clipboard.writeText('')")
end

glimmer_post_menu_states = %w[enabled disabled]
it "can share a conversation with a persona user" do
clip_text = nil

glimmer_post_menu_states.each do |state|
context "with the glimmer post menu #{state}" do
before { SiteSetting.glimmer_post_menu_mode = state }
persona = Fabricate(:ai_persona, name: "Tester")
persona.create_user!

it "can share a conversation with a persona user" do
clip_text = nil
Fabricate(:post, topic: pm, user: admin, raw: "How do I do stuff?")
Fabricate(:post, topic: pm, user: persona.user, raw: "No idea")

persona = Fabricate(:ai_persona, name: "Tester")
persona.create_user!
visit(pm.url)

Fabricate(:post, topic: pm, user: admin, raw: "How do I do stuff?")
Fabricate(:post, topic: pm, user: persona.user, raw: "No idea")
find("#post_2 .post-action-menu__share-ai").click

visit(pm.url)

find("#post_2 .post-action-menu__share-ai").click

try_until_success do
clip_text = cdp.read_clipboard
expect(clip_text).not_to eq("")
end
try_until_success do
clip_text = cdp.read_clipboard
expect(clip_text).not_to eq("")
end

conversation = (<<~TEXT).strip
<details class='ai-quote'>
<summary>
<span>This is my special PM</span>
<span title='Conversation with AI'>AI</span>
</summary>
conversation = (<<~TEXT).strip
<details class='ai-quote'>
<summary>
<span>This is my special PM</span>
<span title='Conversation with AI'>AI</span>
</summary>

**ai_sharer:**
**ai_sharer:**

How do I do stuff?
How do I do stuff?

**Tester_bot:**
**Tester_bot:**

No idea
</details>
TEXT
No idea
</details>
TEXT

expect(conversation).to eq(clip_text)
end
expect(conversation).to eq(clip_text)
end

it "can share a conversation" do
clip_text = nil
it "can share a conversation" do
clip_text = nil

pm
pm_posts
pm
pm_posts

visit(pm.url)
visit(pm.url)

find("#post_2 .post-action-menu__share-ai").click
find("#post_2 .post-action-menu__share-ai").click

try_until_success do
clip_text = cdp.read_clipboard
expect(clip_text).not_to eq("")
end
try_until_success do
clip_text = cdp.read_clipboard
expect(clip_text).not_to eq("")
end

conversation = (<<~TEXT).strip
<details class='ai-quote'>
<summary>
<span>This is my special PM</span>
<span title='Conversation with AI'>AI</span>
</summary>
conversation = (<<~TEXT).strip
<details class='ai-quote'>
<summary>
<span>This is my special PM</span>
<span title='Conversation with AI'>AI</span>
</summary>

**ai_sharer:**
**ai_sharer:**

test test test user reply 1
test test test user reply 1

**gpt-4:**
**gpt-4:**

test test test bot reply 1
</details>
TEXT
test test test bot reply 1
</details>
TEXT

expect(conversation).to eq(clip_text)
expect(conversation).to eq(clip_text)

page.execute_script("window.navigator.clipboard.writeText('')")
page.execute_script("window.navigator.clipboard.writeText('')")

find("#post_6 .post-action-menu__share-ai").click
find(".ai-share-modal__slider input").set("2")
find(".ai-share-modal button.btn-primary").click
find("#post_6 .post-action-menu__share-ai").click
find(".ai-share-modal__slider input").set("2")
find(".ai-share-modal button.btn-primary").click

try_until_success do
clip_text = cdp.read_clipboard
expect(clip_text).not_to eq("")
end
try_until_success do
clip_text = cdp.read_clipboard
expect(clip_text).not_to eq("")
end

conversation = (<<~TEXT).strip
<details class='ai-quote'>
<summary>
<span>This is my special PM</span>
<span title='Conversation with AI'>AI</span>
</summary>
conversation = (<<~TEXT).strip
<details class='ai-quote'>
<summary>
<span>This is my special PM</span>
<span title='Conversation with AI'>AI</span>
</summary>

**ai_sharer:**
**ai_sharer:**

test test test user reply 2
test test test user reply 2

**gpt-4:**
**gpt-4:**

test test test bot reply 2
test test test bot reply 2

**ai_sharer:**
**ai_sharer:**

test test test user reply 3
test test test user reply 3

**gpt-4:**
**gpt-4:**

test test test bot reply 3
</details>
TEXT
test test test bot reply 3
</details>
TEXT

expect(conversation).to eq(clip_text)
end
end
expect(conversation).to eq(clip_text)
end
end