mirror of
https://github.com/discourse/discourse.git
synced 2026-03-04 01:15:08 +08:00
Commit 9e99066b07 changed TagChooser to pass tag objects instead of tag
name strings, but the webhook model sends these objects directly to the
backend, where `permit(tag_names: [])` silently stripped the non-scalar
values, so no tags were saved.
We'll still be taking in `tag_names` on the API, with a deprecation
note. The frontend should start sending `tag_ids` which is the new way
forward.
<img width="351" height="156" alt="Screenshot 2026-02-20 at 4 10 58 PM"
src="https://github.com/user-attachments/assets/9afb6fbe-d676-43d4-a0ff-29cbc1bcd377"
/>
meta:
https://meta.discourse.org/t/webhook-not-accepting-private-tags/396521
92 lines
2.5 KiB
Ruby
92 lines
2.5 KiB
Ruby
#frozen_string_literal: true
|
|
|
|
describe "Admin Webhooks Page", type: :system do
|
|
fab!(:admin)
|
|
fab!(:tag)
|
|
|
|
let(:webhooks_page) { PageObjects::Pages::AdminWebhooks.new }
|
|
let(:dialog) { PageObjects::Components::Dialog.new }
|
|
|
|
before do
|
|
SiteSetting.tagging_enabled = true
|
|
Fabricate(:web_hook, payload_url: "https://www.example.com/1")
|
|
|
|
sign_in(admin)
|
|
end
|
|
|
|
it "shows a list of webhooks" do
|
|
webhooks_page.visit_page
|
|
|
|
expect(webhooks_page).to have_webhook_listed("https://www.example.com/1")
|
|
end
|
|
|
|
it "can add a new webhook" do
|
|
webhooks_page.visit_page
|
|
webhooks_page.add_webhook(payload_url: "https://www.example.com/2")
|
|
|
|
expect(webhooks_page).to have_webhook_details("https://www.example.com/2")
|
|
|
|
webhooks_page.click_back
|
|
|
|
expect(webhooks_page).to have_webhook_listed("https://www.example.com/2")
|
|
end
|
|
|
|
it "can edit existing webhooks" do
|
|
webhooks_page.visit_page
|
|
webhooks_page.click_edit("https://www.example.com/1")
|
|
webhooks_page.edit_payload_url("https://www.example.com/3")
|
|
|
|
expect(webhooks_page).to have_webhook_listed("https://www.example.com/3")
|
|
end
|
|
|
|
it "can add a webhook with a tag filter" do
|
|
tag_chooser = PageObjects::Components::SelectKit.new(".tag-chooser")
|
|
|
|
webhooks_page.visit_page
|
|
webhooks_page.click_add
|
|
|
|
expect(tag_chooser).to be_visible
|
|
|
|
tag_chooser.expand
|
|
tag_chooser.search(tag.name)
|
|
tag_chooser.select_row_by_name(tag.name)
|
|
|
|
webhooks_page.fill_payload_url("https://www.example.com/4")
|
|
webhooks_page.click_save
|
|
|
|
expect(webhooks_page).to have_webhook_details("https://www.example.com/4")
|
|
|
|
webhook = WebHook.find_by(payload_url: "https://www.example.com/4")
|
|
expect(webhook.tags).to contain_exactly(tag)
|
|
end
|
|
|
|
it "persists tag filters when re-editing a webhook" do
|
|
tag_chooser = PageObjects::Components::SelectKit.new(".tag-chooser")
|
|
|
|
webhooks_page.visit_page
|
|
webhooks_page.click_add
|
|
|
|
tag_chooser.expand
|
|
tag_chooser.search(tag.name)
|
|
tag_chooser.select_row_by_name(tag.name)
|
|
|
|
webhooks_page.fill_payload_url("https://www.example.com/5")
|
|
webhooks_page.click_save
|
|
|
|
expect(webhooks_page).to have_webhook_details("https://www.example.com/5")
|
|
|
|
webhooks_page.click_back
|
|
webhooks_page.click_edit("https://www.example.com/5")
|
|
|
|
expect(tag_chooser).to have_selected_name(tag.name)
|
|
end
|
|
|
|
it "can delete webhooks" do
|
|
webhooks_page.visit_page
|
|
webhooks_page.click_delete("https://www.example.com/1")
|
|
|
|
dialog.click_danger
|
|
|
|
expect(webhooks_page).to have_no_webhook_listed("https://www.example.com/1")
|
|
end
|
|
end
|