From 9932fee563c32536fd1f8a55799ea8ac9d33e183 Mon Sep 17 00:00:00 2001 From: Baha Date: Wed, 2 Dec 2015 17:58:40 +0500 Subject: [PATCH 1/5] Add browser tests for ReadMore Change-Id: Ia1f628b4f2e1af7d33dc6779a139c2800be82964 --- tests/browser/LocalSettings.php | 7 ++ tests/browser/README.mediawiki | 56 ++++++++++++ tests/browser/environments.yml | 50 +++++++++++ tests/browser/features/read_more.feature | 30 +++++++ tests/browser/features/support/env.rb | 4 + tests/browser/features/support/hooks.rb | 6 ++ .../features/support/pages/article_page.rb | 11 +++ .../features/support/pages/login_page.rb | 15 ++++ .../features/support/pages/main_page.rb | 5 ++ .../support/pages/special_preferences_page.rb | 14 +++ .../features/support/permissions.sqlite | Bin 0 -> 65536 bytes .../support/step_definitions/common_steps.rb | 83 ++++++++++++++++++ .../samples/related_articles_1.wikitext | 5 ++ .../samples/related_articles_2.wikitext | 3 + .../samples/related_articles_3.wikitext | 3 + .../samples/related_articles_4.wikitext | 3 + 16 files changed, 295 insertions(+) create mode 100644 tests/browser/LocalSettings.php create mode 100644 tests/browser/README.mediawiki create mode 100644 tests/browser/environments.yml create mode 100644 tests/browser/features/read_more.feature create mode 100644 tests/browser/features/support/env.rb create mode 100644 tests/browser/features/support/hooks.rb create mode 100644 tests/browser/features/support/pages/article_page.rb create mode 100644 tests/browser/features/support/pages/login_page.rb create mode 100644 tests/browser/features/support/pages/main_page.rb create mode 100644 tests/browser/features/support/pages/special_preferences_page.rb create mode 100644 tests/browser/features/support/permissions.sqlite create mode 100644 tests/browser/features/support/step_definitions/common_steps.rb create mode 100644 tests/browser/samples/related_articles_1.wikitext create mode 100644 tests/browser/samples/related_articles_2.wikitext create mode 100644 tests/browser/samples/related_articles_3.wikitext create mode 100644 tests/browser/samples/related_articles_4.wikitext diff --git a/tests/browser/LocalSettings.php b/tests/browser/LocalSettings.php new file mode 100644 index 00000000..9a2d8bc7 --- /dev/null +++ b/tests/browser/LocalSettings.php @@ -0,0 +1,7 @@ + # Linux/Unix/Mac + set MEDIAWIKI_USER= # Windows + + export MEDIAWIKI_PASSWORD= # Linux/Unix/Mac + set MEDIAWIKI_PASSWORD= # Windows + +In addition to this create another user which will be reserved for new uploads +"Selenium_newuser". The password for this user should be the same as +MEDIAWIKI_PASSWORD + +Tests that use the "Given I create a random page using the API" step need to set +the MEDIAWIKI_API_URL environment variable, e.g. +export MEDIAWIKI_API_URL=http://en.wikipedia.beta.wmflabs.org/w/api.php + +Run the tests from the RelatedArticles directory with: + + make cucumber + +If you want to run a single set of tests, go to the tests/browser directory and +call 'bundle exec cucumber' with the path to the test file. For example, to run +only the watchlist tests: + + bundle exec cucumber features/read_more_desktop.feature + +XML report (for Jenkins) is created at tests/browser/reports/junit. + +Jenkins is hosted at https://wmf.ci.cloudbees.com/ and it drives +browsers at http://saucelabs.com/ + +For more information about running Selenium tests please see +https://github.com/wikimedia/mediawiki-selenium diff --git a/tests/browser/environments.yml b/tests/browser/environments.yml new file mode 100644 index 00000000..cb14ed5a --- /dev/null +++ b/tests/browser/environments.yml @@ -0,0 +1,50 @@ +# 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 + mediawiki_url: http://127.0.0.1:8080/wiki/ + user_factory: true + +barry: + browser: phantomjs + user_factory: false + # mediawiki_url: Will be set manually + +mw-vagrant-guest: + mediawiki_url: http://127.0.0.1/wiki/ + user_factory: true + +beta: + mediawiki_url: http://en.m.wikipedia.beta.wmflabs.org/wiki/ + mediawiki_user: Selenium_user + # mediawiki_password: SET THIS IN THE ENVIRONMENT! + +staging: + mediawiki_url: http://reading-web-staging.wmflabs.org/wiki/ + mediawiki_user: Selenium_user + # mediawiki_password: SET THIS IN THE ENVIRONMENT! + +test2: + mediawiki_url: http://test2.wikipedia.org/wiki/ + mediawiki_user: Selenium_user + # mediawiki_password: SET THIS IN THE ENVIRONMENT! + +integration: + browser: chrome + user_factory: true + # mediawiki_url: JENKINS WILL SET THIS + +default: *default diff --git a/tests/browser/features/read_more.feature b/tests/browser/features/read_more.feature new file mode 100644 index 00000000..d9cf5e52 --- /dev/null +++ b/tests/browser/features/read_more.feature @@ -0,0 +1,30 @@ +@staging @integration +Feature: ReadMore + Background: + Given RelatedArticles test pages are installed + + Scenario: ReadMore is not present in minerva stable + Given I am using the mobile site + And I am on the "Related Articles 1" page + And page has fully loaded without ReadMore code + Then I must not see ReadMore + + Scenario: ReadMore is present in minerva beta + Given I am using the mobile site + And I am in mobile beta mode + And I am on the "Related Articles 1" page + And page has fully loaded with ReadMore code + Then I must see ReadMore + And ReadMore must have three cards + + Scenario: ReadMore is not present when disabled as a BetaFeature + Given I am on the "Related Articles 1" page + And page has fully loaded without ReadMore code + Then I must not see ReadMore + + Scenario: ReadMore is present when enabled as a BetaFeature + Given I am logged into the website + And ReadMore is enabled as a beta feature + And I am on the "Related Articles 1" page + And page has fully loaded with ReadMore code + Then I must see ReadMore diff --git a/tests/browser/features/support/env.rb b/tests/browser/features/support/env.rb new file mode 100644 index 00000000..5eff4ce5 --- /dev/null +++ b/tests/browser/features/support/env.rb @@ -0,0 +1,4 @@ +require 'mediawiki_selenium' + +require 'mediawiki_selenium/support' +require 'mediawiki_selenium/step_definitions' diff --git a/tests/browser/features/support/hooks.rb b/tests/browser/features/support/hooks.rb new file mode 100644 index 00000000..56f159bc --- /dev/null +++ b/tests/browser/features/support/hooks.rb @@ -0,0 +1,6 @@ +# Needed for cucumber --dry-run -f stepdefs +require_relative 'env' + +Before('@skip') do |scenario| + scenario.skip_invoke! +end diff --git a/tests/browser/features/support/pages/article_page.rb b/tests/browser/features/support/pages/article_page.rb new file mode 100644 index 00000000..d1d547cf --- /dev/null +++ b/tests/browser/features/support/pages/article_page.rb @@ -0,0 +1,11 @@ +# Standard article page +class ArticlePage + include PageObject + + page_url '<%= URI.encode(params[:article_name]) %>'\ + '<%= URI.encode(params[:query_string]) if params[:query_string] %>'\ + '<%= params[:hash] %>' + + aside(:read_more, css: '.ra-read-more') + li(:read_more_cards, css: '.ext-cards-card') +end diff --git a/tests/browser/features/support/pages/login_page.rb b/tests/browser/features/support/pages/login_page.rb new file mode 100644 index 00000000..de791ccf --- /dev/null +++ b/tests/browser/features/support/pages/login_page.rb @@ -0,0 +1,15 @@ +class LoginPage + include PageObject + page_url 'Special:Userlogin' + + text_field(:username, name: 'wpName') + text_field(:password, name: 'wpPassword') + + def login_with(username, password) + # deal with autocomplete + self.username_element.when_present.clear + self.username = username + self.password = password + login + end +end diff --git a/tests/browser/features/support/pages/main_page.rb b/tests/browser/features/support/pages/main_page.rb new file mode 100644 index 00000000..66685bd0 --- /dev/null +++ b/tests/browser/features/support/pages/main_page.rb @@ -0,0 +1,5 @@ +class MainPage + include PageObject + + page_url 'Main_Page' +end diff --git a/tests/browser/features/support/pages/special_preferences_page.rb b/tests/browser/features/support/pages/special_preferences_page.rb new file mode 100644 index 00000000..0bf0c971 --- /dev/null +++ b/tests/browser/features/support/pages/special_preferences_page.rb @@ -0,0 +1,14 @@ +class SpecialPreferencesPage + include PageObject + page_url 'Special:Preferences' + + a(:beta_features_tab, css: '#preftab-betafeatures') + text_field(:read_more_checkbox, css: '#mw-input-wpread-more') + button(:submit_button, css: '#prefcontrol') + + def enable_read_more + self.beta_features_tab_element.when_present.click + read_more_checkbox_element.when_present.click if read_more_checkbox_element.attribute('checked').nil? + submit_button_element.when_present.click + end +end diff --git a/tests/browser/features/support/permissions.sqlite b/tests/browser/features/support/permissions.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..06d20318dfbb6e6e5edad230761bf2296953e051 GIT binary patch literal 65536 zcmeI*J#W)M9LMoL zm%s)S2#Fo>4w!fcEKKaoNF5NDIx&G(rL5>{CCb_U{e5>IU*@}YbH-1lRf&_(O|3KH zsW1$2#j=DDp8gi}w{sY}(c3xEzpeA0uJg5;o+y4D>TiXc=Y;-nAbdpr;jGx@S7pqj|jl$%tGhTA6()h%TW965vdXzd z%B_-fyEL3WuF9-cl}YF;<;PK{WLQ3``iU&HBJHPiF8SfFOK!C~op&?rtLbPWiEBzG zjvlLw(oXGAzkV+R^$Vi;rTL-RXihbEE`45lyOb`CHGVWcHC{I2#>K|A`nUSW`iuI5 z`Yj#hKmY**5I_I{1Q0*~0R#|0009ILKmY**5I_I{1Q0*~0R#|0009ILKmY**5I_I{ z1Q0*~0R#|0009ILKmY**5I_I{1Q0*~0R#|0009ILKmY**5I_I{1Q0*~0R#|0009IL zKmY**5I_I{1Q0*~0R#|0009ILKmY**5I_I{1Q0*~0R#|0009ILKmY**5I_I{1Q0*~ zfi(mM223%y*X+|r5PNRW+QEE5#)tNqqL^K-BzDce?^k8nckMV?(06r#IFsE?rAkk) z3fOy0aWe~eaTvytT8V@!&zP5~YuCa`;LfY|1BZ5-Vk*nasOxEKL=WxCNA_DZ8`;U7 zrZ_cZ8k_q1+;X|quimxY4}z7ESKL79;krp$OuW&8G4XmNzH@TN1}l`?t~lOrim}5+ zi>%#;SB~<2BAMzfWBKf6Q(Vj@ zR;$(Qg*aXaWYLY>;Bo4E%GN8Z8zg(9M=yOpyD6_zD%fb<WNYS literal 0 HcmV?d00001 diff --git a/tests/browser/features/support/step_definitions/common_steps.rb b/tests/browser/features/support/step_definitions/common_steps.rb new file mode 100644 index 00000000..3d639af1 --- /dev/null +++ b/tests/browser/features/support/step_definitions/common_steps.rb @@ -0,0 +1,83 @@ +Given(/^RelatedArticles test pages are installed$/) do + api.create_page 'Related Articles 1', + File.read('samples/related_articles_1.wikitext') + + api.create_page 'Related Articles 2', + File.read('samples/related_articles_2.wikitext') + + api.create_page 'Related Articles 3', + File.read('samples/related_articles_3.wikitext') + + api.create_page 'Related Articles 4', + File.read('samples/related_articles_4.wikitext') +end + +Given(/^I am using the mobile site$/) do + visit(MainPage) do |page| + page_uri = URI.parse(page.page_url_value) + + domain = page_uri.host == 'localhost' ? nil : page_uri.host + browser.cookies.add 'mf_useformat', 'true', domain: domain + + page.refresh + end +end + +Given /^I am in mobile beta mode$/ do + visit(MainPage) do |page| + page_uri = URI.parse(page.page_url_value) + + # A domain is explicitly given to avoid a bug in earlier versions of Chrome + domain = page_uri.host == 'localhost' ? nil : page_uri.host + browser.cookies.add 'mf_useformat', 'true', domain: domain + browser.cookies.add 'optin', 'beta', domain: domain + + page.refresh + end +end + +Given(/^I am logged into the website$/) do + visit(LoginPage).login_with(user, password) +end + +Given(/^I am on the "(.*?)" page/) do |arg1| + visit(ArticlePage, using_params: { article_name: arg1 }) +end + +Then(/^page has fully loaded with ReadMore code$/) do + on(ArticlePage) do |page| + page.wait_until do + # Wait for async JS to hijack standard link + script = 'return mw && mw.loader && '\ + 'mw.loader.getState("ext.relatedArticles.readMore") === "ready";' + page.execute_script(script) + end + end +end + +Then(/^page has fully loaded without ReadMore code$/) do + on(ArticlePage) do |page| + page.wait_until do + # Wait for async JS to hijack standard link + script = 'return mw && mw.loader && '\ + 'mw.loader.getState("ext.relatedArticles.readMore") === "registered";' + page.execute_script(script) + end + end +end + +Then(/^ReadMore is enabled as a beta feature$/) do + visit(SpecialPreferencesPage).enable_read_more() +end + +Then(/^I must see ReadMore$/) do + expect(on(ArticlePage).read_more_element.when_present).to be_visible +end + +Then(/^I must not see ReadMore$/) do + expect(on(ArticlePage).read_more_element).to_not be_visible +end + +Then(/^ReadMore must have three cards$/) do + expect(browser.execute_script("return $('.ext-cards-card').length")).to eq(3) +end diff --git a/tests/browser/samples/related_articles_1.wikitext b/tests/browser/samples/related_articles_1.wikitext new file mode 100644 index 00000000..7071bda7 --- /dev/null +++ b/tests/browser/samples/related_articles_1.wikitext @@ -0,0 +1,5 @@ +RelatedArticles page 1 + +{{#related:related_articles_2}} +{{#related:related_articles_3}} +{{#related:related_articles_4}} diff --git a/tests/browser/samples/related_articles_2.wikitext b/tests/browser/samples/related_articles_2.wikitext new file mode 100644 index 00000000..63cbd033 --- /dev/null +++ b/tests/browser/samples/related_articles_2.wikitext @@ -0,0 +1,3 @@ +RelatedArticles page 2 + +{{#related:related_articles_1}} diff --git a/tests/browser/samples/related_articles_3.wikitext b/tests/browser/samples/related_articles_3.wikitext new file mode 100644 index 00000000..62d5de5d --- /dev/null +++ b/tests/browser/samples/related_articles_3.wikitext @@ -0,0 +1,3 @@ +RelatedArticles page 3 + +{{#related:related_articles_4}} diff --git a/tests/browser/samples/related_articles_4.wikitext b/tests/browser/samples/related_articles_4.wikitext new file mode 100644 index 00000000..7dbea90c --- /dev/null +++ b/tests/browser/samples/related_articles_4.wikitext @@ -0,0 +1,3 @@ +RelatedArticles page 4 + +{{#related:related_articles_1}} From 8a73239abf324cebdbe484734a6b47fe6e7155cd Mon Sep 17 00:00:00 2001 From: Paladox Date: Mon, 7 Dec 2015 18:19:16 +0000 Subject: [PATCH 2/5] Update packages Update grunt-jscs to 2.4.0 Update grunt-jsonlint to 1.0.6 Change-Id: I34b1f23469a35e64345ee42a183dd74679e50b81 --- .jshintrc | 4 +++- package.json | 4 ++-- resources/ext.relatedArticles.readMore.bootstrap/index.js | 4 ++-- .../RelatedPagesGateway.js | 4 ++-- resources/ext.relatedArticles.readMore/eventLogging.js | 2 +- resources/ext.relatedArticles.readMore/index.js | 4 ++-- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.jshintrc b/.jshintrc index 682e2b15..e4d3480f 100644 --- a/.jshintrc +++ b/.jshintrc @@ -3,6 +3,7 @@ "bitwise": true, "eqeqeq": true, "es3": true, + "freeze": true, "latedef": true, "noarg": true, "nonew": true, @@ -11,10 +12,11 @@ // Environment "browser": true, + "jquery": true, "globals": { "mw": false, - "jQuery": false, + "mediaWiki": false, "OO": false, "QUnit": false } diff --git a/package.json b/package.json index 3c970e67..43d3027d 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "grunt-cli": "0.1.13", "grunt-contrib-jshint": "0.11.3", "grunt-banana-checker": "0.4.0", - "grunt-jscs": "2.1.0", - "grunt-jsonlint": "1.0.4" + "grunt-jscs": "2.4.0", + "grunt-jsonlint": "1.0.6" } } diff --git a/resources/ext.relatedArticles.readMore.bootstrap/index.js b/resources/ext.relatedArticles.readMore.bootstrap/index.js index 3cd056e3..b404fffa 100644 --- a/resources/ext.relatedArticles.readMore.bootstrap/index.js +++ b/resources/ext.relatedArticles.readMore.bootstrap/index.js @@ -1,4 +1,4 @@ -( function ( $ ) { +( function ( $, mw ) { var config = mw.config.get( [ 'skin', 'wgNamespaceNumber', 'wgMFMode', 'wgIsMainPage' ] ), relatedPages = new mw.relatedPages.RelatedPagesGateway( @@ -29,4 +29,4 @@ } ); } -}( jQuery ) ); +}( jQuery, mediaWiki ) ); diff --git a/resources/ext.relatedArticles.readMore.gateway/RelatedPagesGateway.js b/resources/ext.relatedArticles.readMore.gateway/RelatedPagesGateway.js index a99dea5d..7e9d19c3 100644 --- a/resources/ext.relatedArticles.readMore.gateway/RelatedPagesGateway.js +++ b/resources/ext.relatedArticles.readMore.gateway/RelatedPagesGateway.js @@ -1,4 +1,4 @@ -( function ( $ ) { +( function ( $, mw ) { // FIXME: Move into separate file as this module becomes larger. mw.relatedPages = {}; @@ -92,4 +92,4 @@ } mw.relatedPages.RelatedPagesGateway = RelatedPagesGateway; -}( jQuery ) ); +}( jQuery, mediaWiki ) ); diff --git a/resources/ext.relatedArticles.readMore/eventLogging.js b/resources/ext.relatedArticles.readMore/eventLogging.js index 58f4b11c..33a4c8e7 100644 --- a/resources/ext.relatedArticles.readMore/eventLogging.js +++ b/resources/ext.relatedArticles.readMore/eventLogging.js @@ -77,4 +77,4 @@ } ); } ); -} )( jQuery ); +}( jQuery, mediaWiki ) ); diff --git a/resources/ext.relatedArticles.readMore/index.js b/resources/ext.relatedArticles.readMore/index.js index 9d181cb5..bc83d6e2 100644 --- a/resources/ext.relatedArticles.readMore/index.js +++ b/resources/ext.relatedArticles.readMore/index.js @@ -1,4 +1,4 @@ -( function ( $ ) { +( function ( $, mw ) { // Make sure 'ext.cards' is loaded. It may not be because of the race // condition in the bootstrap file. mw.loader.using( 'ext.cards' ).done( function () { @@ -55,4 +55,4 @@ } ); } ); -}( jQuery ) ); +}( jQuery, mediaWiki ) ); From 9623c1cc4263f439081d057a79c1d27ebab198fb Mon Sep 17 00:00:00 2001 From: Sumit Asthana Date: Sat, 5 Dec 2015 23:14:15 +0530 Subject: [PATCH 3/5] RelatedArticles load after half window scroll Only triggers RelatedArticles module load and query after user has scrolled through half the document height. Bug: T116838 Change-Id: If290988fb7cc187cad37dd4a8a2c4f38abed9bb9 --- extension.json | 3 +- .../index.js | 42 +++++++++++++------ 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/extension.json b/extension.json index f1f11684..9917e582 100644 --- a/extension.json +++ b/extension.json @@ -88,7 +88,8 @@ ], "dependencies": [ "mediawiki.api", - "ext.relatedArticles.readMore.gateway" + "ext.relatedArticles.readMore.gateway", + "jquery.throttle-debounce" ], "targets": [ "mobile", diff --git a/resources/ext.relatedArticles.readMore.bootstrap/index.js b/resources/ext.relatedArticles.readMore.bootstrap/index.js index 3cd056e3..bf0af833 100644 --- a/resources/ext.relatedArticles.readMore.bootstrap/index.js +++ b/resources/ext.relatedArticles.readMore.bootstrap/index.js @@ -8,25 +8,43 @@ mw.config.get( 'wgRelatedArticlesUseCirrusSearch' ), mw.config.get( 'wgRelatedArticlesOnlyUseCirrusSearch' ) ), - LIMIT = 3; + LIMIT = 3, + debouncedLoad = $.debounce( 100, function () { + loadRelatedArticles(); + } ), + $window = $( window ), + /** + * Threshold value to load related articles - after about half scroll + */ + scrollThreshold = ( $( document ).height() / 2 ) - $window.height(); + function loadRelatedArticles() { + if ( $window.scrollTop() > scrollThreshold ) { + $.when( + // Note we load dependencies here rather than ResourceLoader + // to avoid PHP exceptions when Cards not installed + // which should never happen given the if statement. + mw.loader.using( [ 'ext.cards', 'ext.relatedArticles.readMore' ] ), + relatedPages.getForCurrentPage( LIMIT ) + ).done( function ( _, pages ) { + if ( pages.length ) { + mw.track( 'ext.relatedArticles.init', pages ); + } + } ); + // detach handler to stop subsequent loads on scroll + $window.off( 'scroll', debouncedLoad ); + } + } if ( config.wgNamespaceNumber === 0 && !config.wgIsMainPage && // any skin except minerva stable ( config.skin !== 'minerva' || config.wgMFMode === 'beta' ) ) { - $.when( - // Note we load dependencies here rather than ResourceLoader - // to avoid PHP exceptions when Cards not installed - // which should never happen given the if statement. - mw.loader.using( [ 'ext.cards', 'ext.relatedArticles.readMore' ] ), - relatedPages.getForCurrentPage( LIMIT ) - ).done( function ( _, pages ) { - if ( pages.length ) { - mw.track( 'ext.relatedArticles.init', pages ); - } - } ); + // try related articles load on scroll + $window.on( 'scroll', debouncedLoad ); + // try an initial load, in case of no scroll + loadRelatedArticles(); } }( jQuery ) ); From ed338bbed5d07167bd638ad322c5bccb3f1ac43b Mon Sep 17 00:00:00 2001 From: jdlrobson Date: Wed, 9 Dec 2015 15:11:00 -0800 Subject: [PATCH 4/5] Disable RelatedArticles when editor enabled We only want to show it in view mode. When a reader hits edit, wgAction is view so we add a CSS rule to hide the widget when that transition occurs. This means related widget does not show up post edit (you'll need to refresh but this seems like an acceptable workaround until we can understand this issue some more) Bug: T120443 Bug: T120735 Change-Id: If1356906d5f55167c9d1abbed88f433f36b7f390 --- resources/ext.relatedArticles.readMore.bootstrap/index.js | 2 ++ resources/ext.relatedArticles.readMore/readMore.less | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/resources/ext.relatedArticles.readMore.bootstrap/index.js b/resources/ext.relatedArticles.readMore.bootstrap/index.js index 4a769a22..edaa3423 100644 --- a/resources/ext.relatedArticles.readMore.bootstrap/index.js +++ b/resources/ext.relatedArticles.readMore.bootstrap/index.js @@ -38,6 +38,8 @@ if ( config.wgNamespaceNumber === 0 && !config.wgIsMainPage && + // T120735 + mw.config.get( 'wgAction' ) === 'view' && // any skin except minerva stable ( config.skin !== 'minerva' || config.wgMFMode === 'beta' ) ) { diff --git a/resources/ext.relatedArticles.readMore/readMore.less b/resources/ext.relatedArticles.readMore/readMore.less index 001f4c77..d4dcde13 100644 --- a/resources/ext.relatedArticles.readMore/readMore.less +++ b/resources/ext.relatedArticles.readMore/readMore.less @@ -1,5 +1,12 @@ @import "mediawiki.ui/variables"; +// Hide RelatedArticles when VE is activated (https://phabricator.wikimedia.org/T120443) +.ve-activated { + .ra-read-more { + display: none; + } +} + .ra-read-more { margin-top: 35px; margin-bottom: 70px; From a3d9b22a66018dcc9fd4444ac4f52e88862e22db Mon Sep 17 00:00:00 2001 From: Baha Date: Mon, 14 Dec 2015 15:34:17 +0500 Subject: [PATCH 5/5] Fix loading related articles on small screens Related articles are loaded when the user scrolls past half the document height, which used to be calculated on page load. This height, however, changes after all sections are collapsed on small screens, thus never loading the related articles for the page. Calculating the document height just before showing related articles allows us to correctly decide whether it's time to load the needed modules. Bug: T121263 Change-Id: I1266894ab763cfb571b14f067086445fb6be1887 --- resources/ext.relatedArticles.readMore.bootstrap/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/resources/ext.relatedArticles.readMore.bootstrap/index.js b/resources/ext.relatedArticles.readMore.bootstrap/index.js index edaa3423..208bb76d 100644 --- a/resources/ext.relatedArticles.readMore.bootstrap/index.js +++ b/resources/ext.relatedArticles.readMore.bootstrap/index.js @@ -12,13 +12,14 @@ debouncedLoad = $.debounce( 100, function () { loadRelatedArticles(); } ), - $window = $( window ), + $window = $( window ); + + function loadRelatedArticles() { /** * Threshold value to load related articles - after about half scroll */ - scrollThreshold = ( $( document ).height() / 2 ) - $window.height(); + var scrollThreshold = ( $( document ).height() / 2 ) - $window.height(); - function loadRelatedArticles() { if ( $window.scrollTop() > scrollThreshold ) { $.when( // Note we load dependencies here rather than ResourceLoader