mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-27 03:26:21 +08:00
This removes the topic author from the count of the "me too" button when `Enable solved shared issues` is enabled. This is based on some feedback in https://meta.discourse.org/t/solved-improvements-allowing-members-to-indicate-theyre-experiencing-a-reported-issue/402498 Now when the topic is created the counter starts at 0. Before: <img width="400" alt="image" src="https://github.com/user-attachments/assets/cefb5a84-beb6-4637-95b7-b05d9989b98b" /> <img width="400" alt="image" src="https://github.com/user-attachments/assets/a0154f0b-a66a-436a-aa1a-30ca1956dada" /> After: <img width="400" alt="image" src="https://github.com/user-attachments/assets/9b633da3-f7a9-4541-8813-d2721af5efef" /> <img width="400" alt="image" src="https://github.com/user-attachments/assets/24274b52-0a23-4157-b8e2-6b793ec78324" />
113 lines
3.3 KiB
Ruby
Vendored
113 lines
3.3 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
describe "Solved | Shared issue button" do
|
|
fab!(:author, :user)
|
|
fab!(:member, :user)
|
|
fab!(:support_category) do
|
|
Fabricate(:category).tap do |c|
|
|
c.upsert_custom_fields(DiscourseSolved::ENABLE_ACCEPTED_ANSWERS_CUSTOM_FIELD => "true")
|
|
end
|
|
end
|
|
fab!(:topic) do
|
|
Fabricate(
|
|
:post,
|
|
user: author,
|
|
topic: Fabricate(:topic, category: support_category, user: author),
|
|
).topic
|
|
end
|
|
fab!(:op) { topic.first_post }
|
|
|
|
let(:topic_page) { PageObjects::Pages::Topic.new }
|
|
let(:shared_issue_button) { PageObjects::Components::PostSharedIssueButton.new(op) }
|
|
|
|
before do
|
|
SiteSetting.solved_enabled = true
|
|
SiteSetting.enable_solved_shared_issues = true
|
|
DiscourseSolved::AcceptedAnswerCache.reset_accepted_answer_cache
|
|
end
|
|
|
|
it "lets a member toggle the shared issue on and off" do
|
|
sign_in(member)
|
|
topic_page.visit_topic(topic)
|
|
|
|
expect(shared_issue_button).to have_shared_issue_button
|
|
expect(shared_issue_button).to have_count(0)
|
|
|
|
shared_issue_button.click
|
|
expect(shared_issue_button).to have_count(1)
|
|
expect(shared_issue_button).to have_active
|
|
|
|
expect(TopicUser.get(topic, member).notification_level).to eq(
|
|
TopicUser.notification_levels[:tracking],
|
|
)
|
|
|
|
shared_issue_button.click
|
|
expect(shared_issue_button).to have_count(0)
|
|
expect(shared_issue_button).to have_no_css(".has-shared-issue")
|
|
end
|
|
|
|
it "hides the button once the topic is solved" do
|
|
answer_post = Fabricate(:post, topic:)
|
|
Fabricate(:solved_topic, topic:, answer_post:, accepter: author)
|
|
|
|
sign_in(member)
|
|
topic_page.visit_topic(topic)
|
|
|
|
expect(shared_issue_button).to have_no_shared_issue_button
|
|
end
|
|
|
|
it "re-shows the button after a solution is accepted then unaccepted" do
|
|
answer_post = Fabricate(:post, topic:)
|
|
|
|
sign_in(author)
|
|
topic_page.visit_topic(topic)
|
|
|
|
expect(shared_issue_button).to have_shared_issue_button
|
|
|
|
within("#post_#{answer_post.post_number}") do
|
|
find(".post-action-menu__solved-unaccepted").click
|
|
end
|
|
expect(page).to have_css(".accepted-answer")
|
|
expect(shared_issue_button).to have_no_shared_issue_button
|
|
|
|
within("#post_#{answer_post.post_number}") { find(".post-action-menu__solved-accepted").click }
|
|
expect(page).to have_no_css(".accepted-answer")
|
|
expect(shared_issue_button).to have_shared_issue_button
|
|
end
|
|
|
|
it "hides the button when the upcoming change is disabled" do
|
|
SiteSetting.enable_solved_shared_issues = false
|
|
|
|
sign_in(member)
|
|
topic_page.visit_topic(topic)
|
|
|
|
expect(shared_issue_button).to have_no_shared_issue_button
|
|
end
|
|
|
|
it "prompts anonymous visitors to log in" do
|
|
topic_page.visit_topic(topic)
|
|
|
|
expect(shared_issue_button).to have_shared_issue_button
|
|
shared_issue_button.click
|
|
|
|
expect(page).to have_current_path(%r{/login})
|
|
end
|
|
|
|
it "hides the button on topics outside a support category" do
|
|
other_topic = Fabricate(:post, user: author).topic
|
|
|
|
sign_in(member)
|
|
topic_page.visit_topic(other_topic)
|
|
|
|
expect(shared_issue_button).to have_no_shared_issue_button
|
|
end
|
|
|
|
it "shows the button as read-only for the topic author" do
|
|
sign_in(author)
|
|
topic_page.visit_topic(topic)
|
|
|
|
expect(shared_issue_button).to have_shared_issue_button
|
|
expect(shared_issue_button).to have_read_only
|
|
expect(shared_issue_button).to have_count(0)
|
|
end
|
|
end
|