Thiemo Mättig (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/344116 )

Change subject: Basic browser test setup
......................................................................

Basic browser test setup

Change-Id: I8480d2d23a0d8abb5faef4825d6b24ca141a611b
---
A tests/browser/Gemfile.lock
A tests/browser/environments.yml
A tests/browser/features/non_existing_lexeme.feature
A tests/browser/features/step_definitions/non_existing_lexeme_steps.rb
A tests/browser/features/support/env.rb
A tests/browser/features/support/pages/non_existing_lexeme_page.rb
6 files changed, 256 insertions(+), 0 deletions(-)


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

diff --git a/tests/browser/Gemfile.lock b/tests/browser/Gemfile.lock
new file mode 100644
index 0000000..9fdee44
--- /dev/null
+++ b/tests/browser/Gemfile.lock
@@ -0,0 +1,131 @@
+GEM
+  remote: https://rubygems.org/
+  specs:
+    activesupport (4.2.4)
+      i18n (~> 0.7)
+      json (~> 1.7, >= 1.7.7)
+      minitest (~> 5.1)
+      thread_safe (~> 0.3, >= 0.3.4)
+      tzinfo (~> 1.1)
+    ast (2.1.0)
+    astrolabe (1.3.1)
+      parser (~> 2.2)
+    builder (3.2.2)
+    childprocess (0.5.7)
+      ffi (~> 1.0, >= 1.0.11)
+    cucumber (1.3.20)
+      builder (>= 2.1.2)
+      diff-lcs (>= 1.1.3)
+      gherkin (~> 2.12)
+      multi_json (>= 1.7.5, < 2.0)
+      multi_test (>= 0.1.2)
+    data_magic (0.21)
+      faker (>= 1.1.2)
+      yml_reader (>= 0.4)
+    diff-lcs (1.2.5)
+    domain_name (0.5.25)
+      unf (>= 0.0.5, < 1.0.0)
+    faker (1.5.0)
+      i18n (~> 0.5)
+    faraday (0.9.2)
+      multipart-post (>= 1.2, < 3)
+    faraday-cookie_jar (0.0.6)
+      faraday (>= 0.7.4)
+      http-cookie (~> 1.0.0)
+    ffi (1.9.10)
+    ffi (1.9.10-x86-mingw32)
+    gherkin (2.12.2)
+      multi_json (~> 1.3)
+    gherkin (2.12.2-x86-mingw32)
+      multi_json (~> 1.3)
+    headless (2.2.0)
+    http-cookie (1.0.2)
+      domain_name (~> 0.5)
+    i18n (0.7.0)
+    json (1.8.3)
+    mediawiki_api (0.5.0)
+      faraday (~> 0.9, >= 0.9.0)
+      faraday-cookie_jar (~> 0.0, >= 0.0.6)
+    mediawiki_api-wikidata (0.2)
+      mediawiki_api (~> 0.5.0)
+    mediawiki_selenium (1.6.2)
+      cucumber (~> 1.3, >= 1.3.20)
+      headless (~> 2.0, >= 2.1.0)
+      json (~> 1.8, >= 1.8.1)
+      mediawiki_api (~> 0.5, >= 0.5.0)
+      page-object (~> 1.0)
+      rest-client (~> 1.6, >= 1.6.7)
+      rspec-core (~> 2.14, >= 2.14.4)
+      rspec-expectations (~> 2.14, >= 2.14.4)
+      syntax (~> 1.2, >= 1.2.0)
+      thor (~> 0.19, >= 0.19.1)
+    mime-types (2.6.2)
+    minitest (5.8.2)
+    multi_json (1.11.2)
+    multi_test (0.1.2)
+    multipart-post (2.0.0)
+    netrc (0.11.0)
+    page-object (1.1.0)
+      page_navigation (>= 0.9)
+      selenium-webdriver (>= 2.44.0)
+      watir-webdriver (>= 0.6.11)
+    page_navigation (0.9)
+      data_magic (>= 0.14)
+    parallel (1.6.1)
+    parallel_tests (1.9.0)
+      parallel
+    parser (2.2.3.0)
+      ast (>= 1.1, < 3.0)
+    powerpack (0.1.1)
+    rainbow (2.0.0)
+    require_all (1.3.3)
+    rest-client (1.8.0)
+      http-cookie (>= 1.0.2, < 2.0)
+      mime-types (>= 1.16, < 3.0)
+      netrc (~> 0.7)
+    rest-client (1.8.0-x86-mingw32)
+      ffi (~> 1.9)
+      http-cookie (>= 1.0.2, < 2.0)
+      mime-types (>= 1.16, < 3.0)
+      netrc (~> 0.7)
+    rspec-core (2.99.2)
+    rspec-expectations (2.99.2)
+      diff-lcs (>= 1.1.3, < 2.0)
+    rubocop (0.34.2)
+      astrolabe (~> 1.3)
+      parser (>= 2.2.2.5, < 3.0)
+      powerpack (~> 0.1)
+      rainbow (>= 1.99.1, < 3.0)
+      ruby-progressbar (~> 1.4)
+    ruby-progressbar (1.7.5)
+    rubyzip (1.1.7)
+    selenium-webdriver (2.48.1)
+      childprocess (~> 0.5)
+      multi_json (~> 1.0)
+      rubyzip (~> 1.0)
+      websocket (~> 1.0)
+    syntax (1.2.0)
+    thor (0.19.1)
+    thread_safe (0.3.5)
+    tzinfo (1.2.2)
+      thread_safe (~> 0.1)
+    unf (0.1.4)
+      unf_ext
+    unf_ext (0.0.7.1)
+    unf_ext (0.0.7.1-x86-mingw32)
+    watir-webdriver (0.9.1)
+      selenium-webdriver (>= 2.46.2)
+    websocket (1.2.2)
+    yml_reader (0.5)
+
+PLATFORMS
+  ruby
+  x86-mingw32
+
+DEPENDENCIES
+  activesupport
+  mediawiki_api-wikidata (~> 0.2.0)
+  mediawiki_selenium (~> 1.6.2)
+  parallel_tests
+  require_all
+  rubocop
diff --git a/tests/browser/environments.yml b/tests/browser/environments.yml
new file mode 100644
index 0000000..7010b2c
--- /dev/null
+++ b/tests/browser/environments.yml
@@ -0,0 +1,66 @@
+# Customize this configuration as necessary to provide defaults for various
+# test environments.
+#
+# The set of defaults to use is determined by the MEDIAWIKI_ENVIRONMENT
+# environment variable.
+#
+#   export MEDIAWIKI_ENVIRONMENT=mw-vagrant-host
+#   bundle exec cucumber
+#
+# Additional variables set by the environment will override the corresponding
+# defaults defined here.
+#
+#   export MEDIAWIKI_ENVIRONMENT=mw-vagrant-host
+#   export MEDIAWIKI_USER=Selenium_user2
+#   bundle exec cucumber
+#
+mw-vagrant-host: &default
+  language_code: en
+  browser: firefox
+  mediawiki_url: http://127.0.0.1:8080/wiki/
+  mediawiki_user: Selenium_user
+  mediawiki_password: vagrant
+
+mw-vagrant-guest:
+  language_code: en
+  browser: firefox
+  mediawiki_url: http://127.0.0.1/wiki/
+  mediawiki_user: Selenium_user
+  mediawiki_password: vagrant
+
+beta:
+  language_code: en
+  browser: firefox
+  mediawiki_url: https://wikidata.beta.wmflabs.org/wiki/
+  mediawiki_user: Selenium_user
+  user_factory: true
+  # mediawiki_password: SET THIS IN THE ENVIRONMENT!
+
+test:
+  language_code: en
+  browser: firefox
+  mediawiki_url: https://test.wikidata.org/wiki/
+  mediawiki_user: Selenium_user
+  user_factory: true
+  # mediawiki_password: SET THIS IN THE ENVIRONMENT!
+
+integration:
+  item_namespace: 'Item:'
+  language_code: en
+  browser: firefox
+  user_factory: true
+  # mediawiki_url: JENKINS WILL SET THIS
+
+# Use this with "export MEDIAWIKI_ENVIRONMENT=custom" before running "bundle 
exec cucumber".
+custom:
+  # language_code: en
+  browser: chrome
+  mediawiki_url: http://localhost/wiki/
+  # A sensible default for the "mediawiki_url_api" is derived from the 
"mediawiki_url".
+  # mediawiki_url_api: http://localhost/w/api.php
+  mediawiki_user: …
+  mediawiki_password: …
+  user_factory: true
+  # lexeme_namespace: 'Lexeme:'
+
+default: *default
diff --git a/tests/browser/features/non_existing_lexeme.feature 
b/tests/browser/features/non_existing_lexeme.feature
new file mode 100644
index 0000000..c77cd2a
--- /dev/null
+++ b/tests/browser/features/non_existing_lexeme.feature
@@ -0,0 +1,6 @@
+@chrome @firefox @internet_explorer_10 @internet_explorer_11 @local_config 
@test.wikidata.org @wikidata.beta.wmflabs.org
+Feature: Non existing Lexeme
+
+Scenario: Non-existing Lexeme
+  Given I am on a page of a non existing Lexeme
+  Then check if the page says the entity does not exist
diff --git 
a/tests/browser/features/step_definitions/non_existing_lexeme_steps.rb 
b/tests/browser/features/step_definitions/non_existing_lexeme_steps.rb
new file mode 100644
index 0000000..9b64ec9
--- /dev/null
+++ b/tests/browser/features/step_definitions/non_existing_lexeme_steps.rb
@@ -0,0 +1,13 @@
+# -*- encoding : utf-8 -*-
+
+Given(/^I am on a page of a non existing Lexeme$/) do
+  visit_page(NonExistingLexemePage)
+end
+
+Then(/^check if the page says the entity does not exist$/) do
+  on_page(NonExistingLexemePage) do |page|
+    # expect(page.first_heading?).to be true
+    # expect(page.first_heading_element.text).to be == ENV['LEXEME_NAMESPACE'] 
+ 'Linvalid'
+    # TODO: Use no_article_text
+  end
+end
diff --git a/tests/browser/features/support/env.rb 
b/tests/browser/features/support/env.rb
new file mode 100644
index 0000000..d89bd74
--- /dev/null
+++ b/tests/browser/features/support/env.rb
@@ -0,0 +1,31 @@
+# -*- encoding : utf-8 -*-
+
+require 'mediawiki_selenium/cucumber'
+require 'mediawiki_selenium/pages'
+require 'mediawiki_selenium/step_definitions'
+require 'mediawiki_selenium'
+require 'mediawiki_api/wikidata'
+require 'net/http'
+require 'active_support/all'
+require 'require_all'
+
+lenv = MediawikiSelenium::Environment.load_default
+ENV['WIKIDATA_REPO_URL'] = lenv.lookup(:mediawiki_url)
+ENV['WIKIDATA_REPO_API'] = lenv.lookup(:mediawiki_url_api, default: lambda do
+  lenv.lookup(:mediawiki_url)
+      .gsub(%r{wiki/$}, 'w/api.php')
+      .gsub(%r{index.php/?$}, 'api.php')
+end)
+ENV['LEXEME_NAMESPACE'] = lenv.lookup(:item_namespace, default: -> { 'Lexeme:' 
})
+ENV['LANGUAGE_CODE'] = lenv.lookup(:language_code, default: -> { 'en' })
+
+require_all File.dirname(__FILE__) + '/modules'
+require_all File.dirname(__FILE__) + '/pages'
+require_all File.dirname(__FILE__) + '/utils'
+
+PageObject.default_element_wait = 10 # increased to avoid fails on saucelabs
+
+# TODO: find out if this is still needed? is there a real fix wait on it 
happening instead of sleeping? move this into one of the gems if this is 
needed, as other can benefit
+unless (env_no = ENV['TEST_ENV_NUMBER'].to_i).zero?
+  sleep env_no * 4 # sleep time to give webdriver time to setup
+end
diff --git a/tests/browser/features/support/pages/non_existing_lexeme_page.rb 
b/tests/browser/features/support/pages/non_existing_lexeme_page.rb
new file mode 100644
index 0000000..5c2295b
--- /dev/null
+++ b/tests/browser/features/support/pages/non_existing_lexeme_page.rb
@@ -0,0 +1,9 @@
+# -*- encoding : utf-8 -*-
+
+class NonExistingLexemePage
+  include PageObject
+  page_url ENV['WIKIDATA_REPO_URL'] + ENV['LEXEME_NAMESPACE'] + 'Linvalid'
+
+  h1(:first_heading, class: 'firstHeading')
+  div(:no_article_text, class: 'noarticletext')
+end

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8480d2d23a0d8abb5faef4825d6b24ca141a611b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseLexeme
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to