Jakob has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/349234 )
Change subject: Add browser tests for the "add form" story.
......................................................................
Add browser tests for the "add form" story.
This browser test only tests the UI part of the story without checking
that the new form gets persisted.
Bug: T162338
Change-Id: I9527ddd13933c7acb43f4ac6a1dc7ac43d6cd8e3
---
M tests/browser/features/forms.feature
M tests/browser/features/step_definitions/forms_steps.rb
M tests/browser/features/support/pages/lexeme_page.rb
3 files changed, 38 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseLexeme
refs/changes/34/349234/1
diff --git a/tests/browser/features/forms.feature
b/tests/browser/features/forms.feature
index b5e864b..aa0e49e 100644
--- a/tests/browser/features/forms.feature
+++ b/tests/browser/features/forms.feature
@@ -11,4 +11,12 @@
Then Forms header should be there
And Forms container should be there
And for each Form there is a representation and an ID
- And each representation is enclosed in tag having lang attribute with
"some language" as a value
\ No newline at end of file
+ And each representation is enclosed in tag having lang attribute with
"some language" as a value
+
+ @integration
+ Scenario: Add Form
+ When I am on a Lexeme page
+ And I click the Forms list add button
+ And I enter "whatever" as the form representation
+ And I save the new Form
+ Then "whatever" should be displayed as a representation in the list of
Forms
diff --git a/tests/browser/features/step_definitions/forms_steps.rb
b/tests/browser/features/step_definitions/forms_steps.rb
index fb3757d..e9e68b2 100644
--- a/tests/browser/features/step_definitions/forms_steps.rb
+++ b/tests/browser/features/step_definitions/forms_steps.rb
@@ -15,4 +15,26 @@
Then(/^each representation is enclosed in tag having lang attribute with
"(.+)" as a value$/) do |value|
#todo: this only checks if there is at least one lang attribute
on(LexemePage).form_representation_element.attribute('lang').should == value
-end
\ No newline at end of file
+end
+
+When(/^I click the Forms list add button$/) do
+ on(LexemePage).add_lexeme_form_element.when_visible.click
+end
+
+When(/^I enter "(.+)" as the form representation$/) do |representation|
+ on(LexemePage) do |page|
+ page.lexeme_form_input_field_element.when_visible.clear
+ page.lexeme_form_input_field = representation
+ end
+end
+
+When(/^I save the new Form$/) do
+ on(LexemePage).lexeme_form_save_element.when_visible.click
+end
+
+Then(/^"(.+)" should be displayed as a representation in the list of Forms$/)
do |representation|
+ has_lexeme_form = on(LexemePage).lexeme_form_representation_text_elements
+ .any? { |element| element.text == representation }
+
+ expect(has_lexeme_form).to be true
+end
diff --git a/tests/browser/features/support/pages/lexeme_page.rb
b/tests/browser/features/support/pages/lexeme_page.rb
index 41d9439..845cf7f 100644
--- a/tests/browser/features/support/pages/lexeme_page.rb
+++ b/tests/browser/features/support/pages/lexeme_page.rb
@@ -9,6 +9,12 @@
span(:senses_header, id: 'senses')
div(:senses_container, class: 'wikibase-lexeme-senses')
+ # Lexeme Form
+ a(:add_lexeme_form, css: '.wikibase-lexeme-forms-section >
.wikibase-addtoolbar-container a')
+ textarea(:lexeme_form_input_field, css:
'.wikibase-lexemeformview:last-of-type .wikibase-lexeme-form-text > textarea')
+ spans(:lexeme_form_representation_text, css:
'.wikibase-lexeme-form-representation .wikibase-lexeme-form-text')
+ a(:lexeme_form_save, css: '.wikibase-lexemeformview:last-of-type
.wikibase-toolbar-button-save > a')
+
def create_lexeme(lexeme_data)
wb_api = MediawikiApi::Wikidata::WikidataClient.new URL.repo_api
resp = wb_api.create_entity(lexeme_data, "lexeme")
--
To view, visit https://gerrit.wikimedia.org/r/349234
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9527ddd13933c7acb43f4ac6a1dc7ac43d6cd8e3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseLexeme
Gerrit-Branch: master
Gerrit-Owner: Jakob <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits