mediawiki-skins-MinervaNeue/tests/browser/features/step_definitions/talk_steps.rb
jdlrobson 7fd843cd89 Fix talk overlay workflow
The talk overlay must subscribe to the creation of new topics
so that the list of topics in the talk overlay contains the
newly created topic. It does this by subscribing to the
talk-discussion-added event and forcing a route refresh when that
has completed.

Additional changes to browser tests:
1) QA: CSS selector changed for talk overlay
Since I42fd7b08c4b9d92dee549d06de8a0012ea037d28 the '.add' class
was removed from the talk button. This makes the browser test fail
but is a false positive.

2) One of the browser tests was using the same selector to mean
two different elements - the add discussion button in the talk overlay
is now clearly distinguish from the "add discussion" button that is blue
and appears at the bottom of talk pages

Change-Id: I935b3c5f37baf242c06585ae0e2f13d059b9c324
2019-02-25 14:14:53 -08:00

55 lines
1.8 KiB
Ruby

When(/^I click the talk button$/) do
on(ArticlePage) do |page|
page.wait_until_rl_module_ready('skins.minerva.talk')
page.talk_element.when_present.click
end
end
When(/^no topic is present$/) do
expect(on(ArticlePage).talk_overlay_content_header_element.when_present.text).to match 'There are no conversations about this page.'
end
When(/^I add a topic called "(.+)"$/) do |topic|
step 'I click the add discussion button'
on(ArticlePage) do |page|
page.talk_overlay_summary = topic
page.talk_overlay_wikitext_editor = 'Topic body is a really long text.'
page.wait_until { page.talk_overlay_save_button_element.enabled? }
page.talk_overlay_save_button
end
end
When(/^I see the talk overlay$/) do
on(ArticlePage).overlay_element.when_visible
end
When(/^I click the add discussion button$/) do
on(ArticlePage).talkadd_element.when_present.click
end
Then(/^I should see the topic called "(.+)" in the list of topics$/) do |topic|
# Timeout is high as the previous action hits the API which may take some time
expect(on(ArticlePage).talk_overlay_first_topic_title_element.when_present(20).text).to match topic
end
Then(/^I should see the talk overlay$/) do
on(ArticlePage) do |page|
page.wait_until_rl_module_ready('mobile.talk.overlays')
expect(on(ArticlePage).overlay_heading_element.when_present.text).to match 'Talk'
end
end
Then(/^there should be no talk button$/) do
expect(on(ArticlePage).talk_element).not_to be_visible
end
Then(/^there should be an add discussion button$/) do
# give overlay time to fully load
expect(on(ArticlePage).talkadd_element.when_present(10)).to be_visible
end
Then(/^there should be a save discussion button$/) do
# give overlay time to fully load
expect(on(ArticlePage).talktopic_save_element.when_present(10)).to be_visible
end