2024-04-03 23:20:43 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-10-24 20:15:32 +08:00
|
|
|
describe "DiscourseAutomation | smoke test", type: :system do
|
2024-04-03 23:20:43 +08:00
|
|
|
fab!(:admin)
|
|
|
|
fab!(:group) { Fabricate(:group, name: "test") }
|
|
|
|
fab!(:badge) { Fabricate(:badge, name: "badge") }
|
|
|
|
|
|
|
|
before do
|
|
|
|
SiteSetting.discourse_automation_enabled = true
|
|
|
|
sign_in(admin)
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when default_value fields are set" do
|
|
|
|
before do
|
|
|
|
DiscourseAutomation::Scriptable.add("test") do
|
|
|
|
triggerables %i[post_created_edited]
|
|
|
|
field :test, component: :text, default_value: "test-default-value"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
after { DiscourseAutomation::Scriptable.remove("test") }
|
|
|
|
|
|
|
|
it "populate correctly" do
|
|
|
|
visit("/admin/plugins/discourse-automation")
|
2024-10-24 02:04:17 +08:00
|
|
|
find(".admin-section-landing__header-filter").set("test")
|
|
|
|
find(".admin-section-landing-item__content", match: :first).click
|
2024-04-03 23:20:43 +08:00
|
|
|
fill_in("automation-name", with: "aaaaa")
|
|
|
|
select_kit = PageObjects::Components::SelectKit.new(".triggerables")
|
|
|
|
select_kit.expand
|
|
|
|
select_kit.select_row_by_value("post_created_edited")
|
|
|
|
|
|
|
|
expect(find(".field input[name=test]").value).to eq("test-default-value")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "works" do
|
|
|
|
visit("/admin/plugins/discourse-automation")
|
|
|
|
|
2024-10-24 02:04:17 +08:00
|
|
|
find(".admin-section-landing__header-filter").set("user group membership through badge")
|
|
|
|
find(".admin-section-landing-item__content", match: :first).click
|
2024-04-03 23:20:43 +08:00
|
|
|
fill_in("automation-name", with: "aaaaa")
|
|
|
|
select_kit = PageObjects::Components::SelectKit.new(".triggerables")
|
|
|
|
select_kit.expand
|
|
|
|
select_kit.select_row_by_value("user_first_logged_in")
|
|
|
|
select_kit = PageObjects::Components::SelectKit.new(".fields-section .combo-box")
|
|
|
|
select_kit.expand
|
|
|
|
select_kit.select_row_by_name("badge")
|
|
|
|
select_kit = PageObjects::Components::SelectKit.new(".group-chooser")
|
|
|
|
select_kit.expand
|
|
|
|
select_kit.select_row_by_name("test")
|
|
|
|
find(".automation-enabled input").click
|
|
|
|
find(".update-automation").click
|
|
|
|
|
2024-10-24 02:04:17 +08:00
|
|
|
expect(page).to have_css('[role="button"]', text: "aaaaa")
|
2024-04-03 23:20:43 +08:00
|
|
|
end
|
|
|
|
end
|