mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-02 05:06:51 +08:00
This change seeks to improve the reliability of our system tests by resolving the lack of consistency in the state of the client side application between steps in a system test. This is achieved by patching various action methods in `Capybara::Playwright::Node` and `Capybara::Playwright::Browser` so that the methods execute an async JavaScript function on the client side that waits for the client side application to reach a settled state. A settled state is currently defined as: 1. No inflight ajax requests. (_messageBus and presence requests are excluded_) 2. 2 event cycles of the Javascript event loop has happened for for all "click", "input", "mousedown", "keydown", "focusin", "focusout", "touchstart", "change", "resize", "scroll" DOM events that fired. For debugging purposes, a `--debug-client-settled` CLI flag has been added to `bin/rspec`. When used, detailed debugging information will be printed to the browser's console as well as to `stdout` of the `bin/rspec` process. This change was inspired by https://evilmartians.com/chronicles/flaky-tests-be-gone-long-lasting-relief-chronic-ci-retry-irritation and the https://github.com/makandra/capybara-lockstep rubygem.
63 lines
1.6 KiB
Ruby
63 lines
1.6 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module PageObjects
|
|
module Pages
|
|
class AdminEmailTemplates < PageObjects::Pages::AdminBase
|
|
def visit
|
|
page.visit("/admin/email/templates")
|
|
self
|
|
end
|
|
|
|
def visit_template(template_id)
|
|
page.visit("/admin/email/templates/#{template_id}")
|
|
self
|
|
end
|
|
|
|
def has_template?(template_name)
|
|
has_css?("td", text: template_name)
|
|
end
|
|
|
|
def click_template(template_name)
|
|
find("td", text: template_name).click
|
|
self
|
|
end
|
|
|
|
def edit_subject(text)
|
|
find("input.email-template__subject").fill_in(with: text)
|
|
self
|
|
end
|
|
|
|
def has_subject_value?(value)
|
|
expect(find("input.email-template__subject").value).to eq(value)
|
|
end
|
|
|
|
def edit_body(text)
|
|
find(".d-editor-input").fill_in(with: text)
|
|
self
|
|
end
|
|
|
|
def has_preview_content?(text)
|
|
has_css?(".d-editor-preview", text: text)
|
|
end
|
|
|
|
def save_changes
|
|
find(".save-changes").click
|
|
self
|
|
end
|
|
|
|
def has_multiple_subjects_link?(href)
|
|
link = find(".email-template__has-multiple-subjects")
|
|
expect(link[:href]).to eq(href)
|
|
expect(link.text).to eq(
|
|
I18n.t("admin_js.admin.customize.email_templates.multiple_subjects"),
|
|
)
|
|
end
|
|
|
|
def has_multiple_bodies_link?(href)
|
|
link = find(".email-template__has-multiple-bodies")
|
|
expect(link[:href]).to eq(href)
|
|
expect(link.text).to eq(I18n.t("admin_js.admin.customize.email_templates.multiple_bodies"))
|
|
end
|
|
end
|
|
end
|
|
end
|