discourse/spec/system/admin_embeddable_hosts_spec.rb
Rafael dos Santos Silva 6c2d77ef66
FEATURE: Add full app mode toggle to embedding admin page (#39052)
## Summary
- Adds a toggle to the top of the embedding hosts page
(`/admin/customize/embedding`) to enable/disable the `embed_full_app`
site setting directly from the UI
- When enabled, the configuration snippet automatically includes
`fullApp: true` and `embedHeight: '800px'` parameters
- Un-hides the `embed_full_app` site setting so it also appears in the
embedding settings tab

<img width="1885" height="2033" alt="image"
src="https://github.com/user-attachments/assets/bc541036-61f7-4ff4-b038-81f93e4a174c"
/>
<img width="1146" height="746" alt="image"
src="https://github.com/user-attachments/assets/3e8dfb86-00b8-439f-be2b-9cb550005229"
/>
<img width="1145" height="783" alt="image"
src="https://github.com/user-attachments/assets/54f110d2-17bb-4398-8481-0732a2c96269"
/>

---------

Co-authored-by: Keegan George <kgeorge13@gmail.com>
2026-04-01 15:02:51 -03:00

100 lines
3.6 KiB
Ruby

# frozen_string_literal: true
RSpec.describe "Admin EmbeddableHost Management" do
fab!(:admin)
fab!(:author, :admin)
fab!(:author_2, :admin)
fab!(:category)
fab!(:category_2, :category)
fab!(:tag)
fab!(:tag_2, :tag)
before { sign_in(admin) }
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
it "allows admin to add, edit and delete embeddable hosts" do
admin_embedding_page.visit
expect(page).not_to have_css(".admin-embedding-index__code")
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
expect(page).to have_content("awesome-discourse-site.local")
expect(page).to have_content("/blog/.*")
expect(page).to have_content("#{tag.name}")
expect(page).to have_content("#{category.name}")
expect(page).to have_content("#{author.username}")
expect(page).to have_css(".admin-embedding-index__code")
admin_embedding_page.click_edit_host
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
expect(page).to have_content("updated-example.com")
expect(page).to have_content("/updated-blog/.*")
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 toggle full app mode and updates the snippet" do
Fabricate(:embeddable_host)
admin_embedding_page.visit
admin_embedding_page.expand_snippet
expect(admin_embedding_page).to have_full_app_mode_disabled
expect(admin_embedding_page).to have_no_snippet_containing("fullApp")
admin_embedding_page.click_full_app_mode_toggle
expect(admin_embedding_page).to have_full_app_mode_enabled
expect(admin_embedding_page).to have_snippet_containing("fullApp")
expect(admin_embedding_page).to have_snippet_containing("embedHeight")
expect(SiteSetting.embed_full_app).to eq(true)
admin_embedding_page.click_full_app_mode_toggle
expect(admin_embedding_page).to have_full_app_mode_disabled
expect(admin_embedding_page).to have_no_snippet_containing("fullApp")
expect(SiteSetting.embed_full_app).to eq(false)
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_tab("posts-and-topics")
admin_embedding_posts_and_topics_page.fill_in_embed_by_username(author)
admin_embedding_posts_and_topics_page.click_save
admin_embedding_page.click_tab("hosts")
expect(page).to have_content("#{author.username}")
end
end