0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-07 13:19:19 +08:00
discourse/spec/system/page_objects/modals/base.rb
chapoi ada0aa0d4e
UX: modal modifier class BEM rename + new modifier (#40369)
- Renames .d-modal modifiers from single-dash (-large, -max) to --large,
--max across SCSS, <DModal>, and all callers (core +
discourse-local-dates plugin) to match Discourse's BEM convention.
- Moves per-modal overrides out of modal.scss into the dedicated
modal-overrides.scss file
- Add new `has-search` modifier, for use in modals with a inline
filter/search element to avoid jumping height
- Move all core `.modal selectors` to `.d-modal`

This commit should not change anything visually (if all goes well).
2026-05-28 17:36:48 +02:00

82 lines
1.7 KiB
Ruby
Vendored

# frozen_string_literal: true
module PageObjects
module Modals
class Base
include Capybara::DSL
include RSpec::Matchers
BODY_SELECTOR = ""
MODAL_SELECTOR = ""
def initialize(body_selector: MODAL_SELECTOR, modal_selector: MODAL_SELECTOR)
# This can be used as an alternative to making a whole new
# modal PageObject when there isn't a lot of specific custom stuff
# in that modal's UI -- in many cases just having the modal scoping
# is enough.
@body_selector = body_selector
@modal_selector = modal_selector
end
def full_body_selector
".d-modal__body#{@body_selector}"
end
def full_modal_selector
".d-modal#{@modal_selector}"
end
def footer_selector
"#{full_modal_selector} .d-modal__footer"
end
def header
find(".d-modal__header")
end
def body
find(full_body_selector)
end
def footer
find(footer_selector)
end
def has_footer?
has_css?(footer_selector)
end
def has_no_footer?
has_no_css?(footer_selector)
end
def close
find("#{full_modal_selector} .modal-close").click
end
def cancel
find("#{full_modal_selector} .d-modal-cancel").click
end
def click_outside
find("#{full_modal_selector}").click(x: 0, y: 0)
end
def click_primary_button
footer.find(".btn-primary").click
end
def has_content?(content)
body.has_content?(content)
end
def open?
has_css?(full_modal_selector)
end
def closed?
has_no_css?(full_modal_selector)
end
end
end
end