Aleksey Bekh-Ivanov (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/378730 )

Change subject: [WIP] Browser tests for Form ID counter when revert/undo
......................................................................

[WIP] Browser tests for Form ID counter when revert/undo

Change-Id: I45f1c9c4a0ff9a1b8637e90bf0b78da3f6a0a27f
---
M tests/browser/features/forms.feature
M tests/browser/features/step_definitions/forms_steps.rb
A tests/browser/features/support/pages/entity_history_page.rb
M tests/browser/features/support/pages/lexeme_page.rb
A tests/browser/features/support/pages/undo_page.rb
5 files changed, 72 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseLexeme 
refs/changes/30/378730/1

diff --git a/tests/browser/features/forms.feature 
b/tests/browser/features/forms.feature
index 537fe03..d151fd2 100644
--- a/tests/browser/features/forms.feature
+++ b/tests/browser/features/forms.feature
@@ -81,3 +81,21 @@
   Scenario: I can see each Form's statements
     Given I have a Lexeme with a Form
     Then for each Form there is a statement list
+
+  @integration
+  Scenario: FormId counter is not decremented when change is undone
+    Given I am on a Lexeme page
+     Then I add a Form
+     Then I go to the history page
+      And I undo the latest change
+     When I add a Form
+     Then the new Form has the ID greater than the previous one
+
+  @integration
+  Scenario: FormId counter is not decremented when old revision is restored
+    Given I am on a Lexeme page
+      And I add a Form
+     Then I go to the history page
+      And I restore the previous revision
+     When I add a Form
+     Then the new Form has the ID greater than the previous one
diff --git a/tests/browser/features/step_definitions/forms_steps.rb 
b/tests/browser/features/step_definitions/forms_steps.rb
index 7bbe413..2c237c6 100644
--- a/tests/browser/features/step_definitions/forms_steps.rb
+++ b/tests/browser/features/step_definitions/forms_steps.rb
@@ -148,3 +148,38 @@
 Then(/^the first Form should no longer have the removed grammatical feature$/) 
do
   
expect(@form_I_am_currently_editing.grammatical_feature?(@grammatical_feature_to_delete)).to
 be false
 end
+
+Then(/^I add a Form$/) do
+  step 'I click the Forms list add button'
+  step 'I enter "some representation" as the "en" form representation'
+  step 'I save the Form'
+end
+
+Then(/^I go to the history page$/) do
+  @last_form_id_before_undo = on(LexemePage).forms[-1].id_element.text
+  on(LexemePage).history_link_element.when_visible.click
+end
+
+
+Then(/^I undo the latest change$/) do
+  # pick latest revision and click "undo" link
+  on(EntityHistoryPage).revisions[0].undo_element.when_visible.click
+  # confirm "undo"
+  on(UndoPage).save_page.when_visible.click
+  # got back to the initial Lexeme page
+end
+
+Then(/^I restore the previous revision$/) do
+  # pick latest revision and click "undo" link
+  on(EntityHistoryPage).revisions[1].undo_element.when_visible.click
+  # confirm "undo"
+  on(UndoPage).save_page.when_visible.click
+  # got back to the initial Lexeme page
+end
+
+Then(/^the new Form has the ID greater than the previous one$/) do
+  last_form_id = on(LexemePage).forms[-1].id_element.text
+
+  expect(last_form_id).to > @last_form_id_before_undo
+end
+
diff --git a/tests/browser/features/support/pages/entity_history_page.rb 
b/tests/browser/features/support/pages/entity_history_page.rb
new file mode 100644
index 0000000..6c7f6d2
--- /dev/null
+++ b/tests/browser/features/support/pages/entity_history_page.rb
@@ -0,0 +1,12 @@
+class EntityRevision
+  include PageObject
+
+  a(:undo, css: '.mw-history-undo a')
+  a(:restore, text: 'restore') #This link doesn't have any css identifier
+end
+
+class EntityHistoryPage
+  include PageObject
+
+  page_sections(:revisions, EntityRevision, css: 'ul#pagehistory > li')
+end
\ No newline at end of file
diff --git a/tests/browser/features/support/pages/lexeme_page.rb 
b/tests/browser/features/support/pages/lexeme_page.rb
index e254a00..4da7f07 100644
--- a/tests/browser/features/support/pages/lexeme_page.rb
+++ b/tests/browser/features/support/pages/lexeme_page.rb
@@ -112,6 +112,8 @@
   include PageObject
   include EntityPage
 
+  element(:history_link, css: '#ca-history a')
+
   span(:forms_header, id: 'forms')
   div(:forms_container, class: 'wikibase-lexeme-forms')
   h3(:form_representation, class: 'wikibase-lexeme-form-representation')
diff --git a/tests/browser/features/support/pages/undo_page.rb 
b/tests/browser/features/support/pages/undo_page.rb
new file mode 100644
index 0000000..40a57bc
--- /dev/null
+++ b/tests/browser/features/support/pages/undo_page.rb
@@ -0,0 +1,5 @@
+class UndoPage
+  include PageObject
+
+  button(:save_page, css:'form#undo button')
+end
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/378730
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I45f1c9c4a0ff9a1b8637e90bf0b78da3f6a0a27f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseLexeme
Gerrit-Branch: master
Gerrit-Owner: Aleksey Bekh-Ivanov (WMDE) <aleksey.bekh-iva...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to