discourse/spec/system/page_objects/components/composer_onebox_toolbar.rb
Renato Atilio af0f428164
FEATURE: Add onebox toolbar and show preview for rich editor (#39054)
Adds a floating toolbar for oneboxes with copy link, remove preview, and
visit actions. Supports both block and inline oneboxes.

Adds a "Show preview" button to the link toolbar so users can re-onebox
a URL after removing its preview. Uses a `forceOneboxUrl` meta attribute
to bypass the selection proximity check in the onebox plugin.

Also extracts `oneboxTypeAtPos` helper to share onebox type detection
between the onebox plugin and link toolbar.

<img width="494" alt="image"
src="https://github.com/user-attachments/assets/2a8c6983-9049-4d67-a346-7755d65654a2"
/>

<img width="494" alt="image"
src="https://github.com/user-attachments/assets/2f9bb1e0-8f5e-444d-b7d7-d8cc22f58469"
/>

<img width="494" alt="image"
src="https://github.com/user-attachments/assets/c80d6611-81f0-4860-a538-6cb0cd98ac48"
/>
2026-04-14 11:05:11 -03:00

39 lines
930 B
Ruby

# frozen_string_literal: true
module PageObjects
module Components
class ComposerOneboxToolbar < PageObjects::Components::Base
TOOLBAR_SELECTOR = "[data-identifier='composer-onebox-toolbar']"
def has_toolbar?
page.has_css?(TOOLBAR_SELECTOR)
end
def has_no_toolbar?
page.has_no_css?(TOOLBAR_SELECTOR)
end
def has_copy_button?
page.has_css?("button.composer-onebox-toolbar__copy")
end
def has_remove_preview_button?
page.has_css?("button.composer-onebox-toolbar__remove-preview")
end
def has_visit_link?
page.has_css?("a.composer-onebox-toolbar__visit")
end
def click_remove_preview
page.find("button.composer-onebox-toolbar__remove-preview").click
self
end
def click_copy
page.find("button.composer-onebox-toolbar__copy").click
self
end
end
end
end