Amire80 has uploaded a new change for review.
https://gerrit.wikimedia.org/r/107357
Change subject: WIP: Fix several test steps
......................................................................
WIP: Fix several test steps
Very WIP, don't commit
Change-Id: Iaebf221aa636bfdadb45f500d240aedaa04ef5e4
---
M modules/header/ext.cx.header.js
M tests/browser/features/special_content_translation.feature
M tests/browser/features/step_definitions/special_content_translation_steps.rb
M tests/browser/features/support/pages/content_translation_page.rb
4 files changed, 49 insertions(+), 33 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation
refs/changes/57/107357/1
diff --git a/modules/header/ext.cx.header.js b/modules/header/ext.cx.header.js
index 6f6797e..29c799b 100644
--- a/modules/header/ext.cx.header.js
+++ b/modules/header/ext.cx.header.js
@@ -36,6 +36,7 @@
.addClass( 'cx-header__user-details' )
.append(
$( '<a>' )
+ .addClass(
'cx-header__user-details__user-name' )
.attr( 'href', mw.util.getUrl(
'User:' + mw.user.getName() ) )
.text ( mw.user.getName() )
)
diff --git a/tests/browser/features/special_content_translation.feature
b/tests/browser/features/special_content_translation.feature
index e814ea8..d164bb6 100644
--- a/tests/browser/features/special_content_translation.feature
+++ b/tests/browser/features/special_content_translation.feature
@@ -22,23 +22,23 @@
When I am on the content translation page in a wiki in English,
translating the page "Bratislava" to Danish
Then I see a source column with the text "Bratislava is the capital of
Slovakia and the country's largest city."
And the source column text is not editable
- And the language code of the source column is "en"
- And the direction of the source column is "ltr"
+ #And the language code of the source column is "en"
+ #And the direction of the source column is "ltr"
And I see the title "Bratislava" at the top of the source column
- And I see a language label saying "English" below the source column's
title
- And I see a "view page" link that points to the page "Bratislava" on the
same wiki
- And I see a translation column with an empty editing area
- And the language code of the translation column is "da"
- And the direction of the translation column is "ltr"
- And I see an input box pre-filled with the text "Bratislava" above the
editing area in the second column
- And I see a language label saying "dansk" below the translation column's
title
- And I see a translation information column
+ #And I see a language label saying "English" below the source column's
title
+ #And I see a "view page" link that points to the page "Bratislava" on
the same wiki
+ #And I see a translation column with an empty editing area # placeholder
+ #And the language code of the translation column is "da"
+ #And the direction of the translation column is "ltr"
+ #And I see an input box pre-filled with the text "Bratislava" above the
editing area in the second column
+ #And I see a language label saying "dansk" below the translation
column's title
+ And I see a translation aids column
And I see a "Publish Translation" button
- And the "Publish Translation" button is disabled
+ #And the "Publish Translation" button is disabled
+ And I see the username at the top of the page
And I see a translation progress bar
And the translation progress bar is in 0% state
And the text near the translation progress bar says "0% translated"
- And I see the username at the top of the page
Scenario: Writing some translation text enables the "Publish Translation"
button
Given I am logged in
diff --git
a/tests/browser/features/step_definitions/special_content_translation_steps.rb
b/tests/browser/features/step_definitions/special_content_translation_steps.rb
index dea4249..e48da1a 100644
---
a/tests/browser/features/step_definitions/special_content_translation_steps.rb
+++
b/tests/browser/features/step_definitions/special_content_translation_steps.rb
@@ -1,9 +1,14 @@
Given(/^I am on the content translation page in a wiki in (.+?), translating
the page "(.+?)" to (.+)$/) do |source_language, page_name, target_language|
- visit(ContentTranslationPage, :using_params => {:extra =>
"title=#{page_name}&lang=#{target_language}"})
+ language_code = {
+ "Danish" => "da",
+ "English" => "en",
+ "Hebrew" => "he",
+ }
+ visit(ContentTranslationPage, :using_params => {:extra =>
"page=#{page_name}&lang=#{language_code[target_language]}"})
end
When(/^I empty the editing area in the translation column$/) do
- pending
+ on(ContentTranslationPage).empty_translation_editor
end
When(/^I press the "Publish Translation" button$/) do
@@ -39,7 +44,7 @@
end
Then(/^I see an input box pre\-filled with the text "(.*?)" above the editing
area in the second column$/) do |text|
- on(ContentTranslationPage).title("translation").should == text
+ on(ContentTranslationPage).title("translation").text.should == text
end
Then(/^I see a source column with the text "(.*?)"$/) do |text|
@@ -47,15 +52,15 @@
end
Then(/^I see a translation column with an empty editing area$/) do
- on(ContentTranslationPage).translation_editor.should == ""
+ on(ContentTranslationPage).translation_editor.text.should == ""
end
-Then(/^I see a translation information column$/) do
- on(ContentTranslationPage).column("information").should be_visible
+Then(/^I see a translation aids column$/) do
+ on(ContentTranslationPage).column("aids").should be_visible
end
Then(/^I see a translation progress bar$/) do
- on(ContentTranslationPage).progress_bar_element.should be_visible
+ on(ContentTranslationPage).progress_bar_container_element.should
be_visible
end
Then(/^I see the message "You must be logged in to translate in this
page\."$/) do
@@ -66,8 +71,8 @@
on(ContentTranslationPage).title("source").text.should ==
source_page_title
end
-Then(/^I see the username at the top of the page$/) do |username|
- on(ContentTranslationPage).user_name.should == ENV["MEDIAWIKI_USER"]
+Then(/^I see the username at the top of the page$/) do
+ on(ContentTranslationPage).user_name.text.should ==
ENV["MEDIAWIKI_USER"]
end
Then(/^the content of the page is "(.*?)"$/) do |page_content|
@@ -91,11 +96,11 @@
end
Then(/^the "Publish Translation" button is disabled$/) do
-
on(ContentTranslationPage).publish_translation_element.attribute("disabled").should
!= nil
+ on(ContentTranslationPage).publish_translation_element.should
be_disabled
end
Then(/^the "Publish Translation" button is enabled$/) do
-
on(ContentTranslationPage).publish_translation_element.attribute("disabled").should
== nil
+ on(ContentTranslationPage).publish_translation_element.should be_enabled
end
Then(/^the source column text is not editable$/) do
@@ -103,11 +108,11 @@
end
Then(/^the text near the translation progress bar says "(.*?)"$/) do |text|
- on(ContentTranslationPage).progress_bar_text.text.should == text
+ on(ContentTranslationPage).progress_bar_text.should == text
end
Then(/^the translation progress bar is in (\d+)% state$/) do |percentage|
- on(ContentTranslationPage).progress_bar_element.status.should ==
percentage
+ on(ContentTranslationPage).progress_bar_element.style("width").should
match(/^#{percentage}/)
end
Then(/^the "view page" link points to the page "(.*?)" on the same wiki$/) do
|source_page|
diff --git a/tests/browser/features/support/pages/content_translation_page.rb
b/tests/browser/features/support/pages/content_translation_page.rb
index 630e863..f728405 100644
--- a/tests/browser/features/support/pages/content_translation_page.rb
+++ b/tests/browser/features/support/pages/content_translation_page.rb
@@ -3,15 +3,29 @@
include URL
page_url URL.url("Special:ContentTranslation?<%=params[:extra]%>")
+ a(:user_name, class: "cx-header__user-details__user-name")
a(:view_page, class: "view-page")
button(:publish_translation, class: "cx-header__publish")
- div(:progress_bar, class: "cx-progressbar")
-
div(:content, class: "content")
+ div(:progress_bar_container, class: "cx-progressbar")
- a(:user_name, class: "user-name")
+ span(:progress_bar, class: "cx-progressbar__bar")
+ span(:progress_bar_text, class: "cx-progressbar__text")
+
+ # Sets the text of an element.
+ # Selenium doesn't give us an easy generic way to do this,
+ # so we use JavaScript.
+ # The element is selected by a jQuery selector.
+ def set_element_text(selector, text)
+ p selector
+ @browser.execute_script("$( '#{selector}' ).text( '#{text}' )")
+ end
+
+ def empty_translation_editor
+ set_element_text(".cx-column--translation .cx-column__content",
"")
+ end
def column(column_type)
@browser.div(class: "cx-column--#{column_type}")
@@ -21,16 +35,12 @@
column(column_type).span(class: "language-label")
end
- def progress_bar_text
- @browser.div(class: "progressbar").span(class: "status-text")
- end
-
def content(column_type)
column(column_type).div(class: "cx-column__content")
end
def title(column_type)
- column(column_type).div(class: "cx-column__title")
+ column(column_type).h2(class: "cx-column__title")
end
def translation_editor
--
To view, visit https://gerrit.wikimedia.org/r/107357
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaebf221aa636bfdadb45f500d240aedaa04ef5e4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Amire80 <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits