mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 16:18:32 +08:00
UX: admins embedding page follows admin ux guideline (#30122)
Conversion of /admin/customize/embedding page to follow admin UX guidelines.
This commit is contained in:

committed by
GitHub

parent
02113fc22a
commit
407fa69778
@ -3,59 +3,75 @@
|
||||
RSpec.describe "Admin EmbeddableHost Management", type: :system do
|
||||
fab!(:admin)
|
||||
fab!(:author) { Fabricate(:admin) }
|
||||
fab!(:author_2) { Fabricate(:admin) }
|
||||
fab!(:category)
|
||||
fab!(:category2) { Fabricate(:category) }
|
||||
fab!(:category_2) { Fabricate(:category) }
|
||||
fab!(:tag)
|
||||
fab!(:tag2) { Fabricate(:tag) }
|
||||
fab!(:tag_2) { Fabricate(:tag) }
|
||||
|
||||
before { sign_in(admin) }
|
||||
|
||||
it "allows admin to add and edit embeddable hosts" do
|
||||
visit "/admin/customize/embedding"
|
||||
let(:admin_embedding_page) { PageObjects::Pages::AdminEmbedding.new }
|
||||
let(:admin_embedding_host_form_page) { PageObjects::Pages::AdminEmbeddingHostForm.new }
|
||||
let(:admin_embedding_posts_and_topics_page) do
|
||||
PageObjects::Pages::AdminEmbeddingPostsAndTopics.new
|
||||
end
|
||||
|
||||
find("button.btn-icon-text", text: "Add Host").click
|
||||
within find("tr.ember-view") do
|
||||
find('input[placeholder="example.com"]').set("awesome-discourse-site.local")
|
||||
find('input[placeholder="/blog/.*"]').set("/blog/.*")
|
||||
it "allows admin to add, edit and delete embeddable hosts" do
|
||||
admin_embedding_page.visit
|
||||
|
||||
category_chooser = PageObjects::Components::SelectKit.new(".category-chooser")
|
||||
category_chooser.expand
|
||||
category_chooser.select_row_by_name(category.name)
|
||||
expect(page).not_to have_css(".admin-embedding-index__code")
|
||||
|
||||
tag_chooser = PageObjects::Components::SelectKit.new(".tag-chooser")
|
||||
tag_chooser.expand
|
||||
tag_chooser.select_row_by_name(tag.name)
|
||||
admin_embedding_page.click_add_host
|
||||
|
||||
admin_embedding_host_form_page.fill_in_allowed_hosts("awesome-discourse-site.local")
|
||||
admin_embedding_host_form_page.fill_in_path_allow_list("/blog/.*")
|
||||
admin_embedding_host_form_page.fill_in_category(category)
|
||||
admin_embedding_host_form_page.fill_in_tags(tag)
|
||||
admin_embedding_host_form_page.fill_in_post_author(author)
|
||||
admin_embedding_host_form_page.click_save
|
||||
|
||||
find(".user-chooser").click
|
||||
find(".select-kit-body .select-kit-filter input").fill_in with: author.username
|
||||
find(".select-kit-body", text: author.username).click
|
||||
end
|
||||
find("td.editing-controls .btn.btn-primary").click
|
||||
expect(page).to have_content("awesome-discourse-site.local")
|
||||
expect(page).to have_content("/blog/.*")
|
||||
expect(page).not_to have_content("#{tag.name},#{tag2.name}")
|
||||
expect(page).to have_content("#{tag.name}")
|
||||
expect(page).to have_content("#{category.name}")
|
||||
expect(page).to have_content("#{author.username}")
|
||||
|
||||
# Editing
|
||||
expect(page).to have_css(".admin-embedding-index__code")
|
||||
|
||||
find(".embeddable-hosts tr:first-child .controls svg.d-icon-pencil").find(:xpath, "..").click
|
||||
admin_embedding_page.click_edit_host
|
||||
|
||||
within find(".embeddable-hosts tr:first-child.ember-view") do
|
||||
find('input[placeholder="example.com"]').set("updated-example.com")
|
||||
find('input[placeholder="/blog/.*"]').set("/updated-blog/.*")
|
||||
admin_embedding_host_form_page.fill_in_allowed_hosts("updated-example.com")
|
||||
admin_embedding_host_form_page.fill_in_path_allow_list("/updated-blog/.*")
|
||||
admin_embedding_host_form_page.fill_in_category(category_2)
|
||||
admin_embedding_host_form_page.fill_in_tags(tag_2)
|
||||
admin_embedding_host_form_page.fill_in_post_author(author_2)
|
||||
admin_embedding_host_form_page.click_save
|
||||
|
||||
category_chooser = PageObjects::Components::SelectKit.new(".category-chooser")
|
||||
category_chooser.expand
|
||||
category_chooser.select_row_by_name(category2.name)
|
||||
|
||||
tag_chooser = PageObjects::Components::SelectKit.new(".tag-chooser")
|
||||
tag_chooser.expand
|
||||
tag_chooser.select_row_by_name(tag2.name)
|
||||
end
|
||||
|
||||
find("td.editing-controls .btn.btn-primary").click
|
||||
expect(page).to have_content("updated-example.com")
|
||||
expect(page).to have_content("/updated-blog/.*")
|
||||
expect(page).to have_content("#{tag.name},#{tag2.name}")
|
||||
expect(page).to have_content("#{tag.name}, #{tag_2.name}")
|
||||
expect(page).to have_content("#{category_2.name}")
|
||||
expect(page).to have_content("#{author_2.username}")
|
||||
|
||||
admin_embedding_page.click_delete
|
||||
admin_embedding_page.confirm_delete
|
||||
|
||||
expect(page).not_to have_css(".admin-embedding-index__code")
|
||||
end
|
||||
|
||||
it "allows admin to save posts and topics settings" do
|
||||
Fabricate(:embeddable_host)
|
||||
|
||||
admin_embedding_page.visit
|
||||
expect(page).not_to have_content("#{author.username}")
|
||||
|
||||
admin_embedding_page.click_posts_and_topics_tab
|
||||
|
||||
admin_embedding_posts_and_topics_page.fill_in_embed_by_username(author)
|
||||
admin_embedding_posts_and_topics_page.click_save
|
||||
|
||||
admin_embedding_page.click_hosts_tab
|
||||
expect(page).to have_content("#{author.username}")
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user