jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/354298 )

Change subject: Display newly added talk topic
......................................................................


Display newly added talk topic

Expose PageGateway cache to the module rather than keeping it
private to the instance. The reason is that the various types of
talk overlays, e.g. TalkOverlay, TalkSectionAddOverlay, etc. create
their own instances of PageGateway and a change in one of them didn’t
reflect in the other instances of PageGateway.

Bug: T151041
Change-Id: I026b4a5a7c7fdc13e6115466180cf82d57eed524
---
M resources/mobile.startup/PageGateway.js
M tests/browser/features/step_definitions/talk_steps.rb
M tests/browser/features/support/pages/article_page.rb
M tests/browser/features/talk.feature
M tests/qunit/mobile.startup/test_PageGateway.js
5 files changed, 42 insertions(+), 6 deletions(-)

Approvals:
  jenkins-bot: Verified
  Jdlrobson: Looks good to me, approved



diff --git a/resources/mobile.startup/PageGateway.js 
b/resources/mobile.startup/PageGateway.js
index 5df091e..c588ec6 100644
--- a/resources/mobile.startup/PageGateway.js
+++ b/resources/mobile.startup/PageGateway.js
@@ -1,5 +1,6 @@
 ( function ( M, $ ) {
-       var sectionTemplate = mw.template.get( 'mobile.startup', 
'Section.hogan' );
+       var sectionTemplate = mw.template.get( 'mobile.startup', 
'Section.hogan' ),
+               cache = {};
 
        /**
         * Add child to listOfSections if the level of child is the same as the 
last
@@ -88,7 +89,6 @@
         */
        function PageGateway( api ) {
                this.api = api;
-               this.cache = {};
        }
 
        PageGateway.prototype = {
@@ -111,8 +111,8 @@
                                        edit: [ '*' ]
                                };
 
-                       if ( !this.cache[title] ) {
-                               page = this.cache[title] = $.Deferred();
+                       if ( !cache[title] ) {
+                               page = cache[title] = $.Deferred();
                                this.api.get( {
                                        action: 'mobileview',
                                        page: title,
@@ -179,7 +179,7 @@
                                } ).fail( $.proxy( page, 'reject' ) );
                        }
 
-                       return this.cache[title];
+                       return cache[title];
                },
 
                /**
@@ -189,7 +189,7 @@
                 * @param {string} title the title of the page who's cache you 
want to invalidate
                 */
                invalidatePage: function ( title ) {
-                       delete this.cache[title];
+                       delete cache[title];
                },
 
                /**
diff --git a/tests/browser/features/step_definitions/talk_steps.rb 
b/tests/browser/features/step_definitions/talk_steps.rb
index 9604327..9c38192 100644
--- a/tests/browser/features/step_definitions/talk_steps.rb
+++ b/tests/browser/features/step_definitions/talk_steps.rb
@@ -5,10 +5,28 @@
   end
 end
 
+When(/^no topic is present$/) do
+  
expect(on(ArticlePage).talk_overlay_content_header_element.when_present.text).to
 match 'There are no conversations about this page.'
+end
+
+When(/^I add a topic called "(.+)"$/) do |topic|
+  step 'I click the add discussion button'
+  on(ArticlePage) do |page|
+    page.talk_overlay_summary = topic
+    page.talk_overlay_wikitext_editor = 'Topic body is a really long text.'
+    page.wait_until { page.talk_overlay_save_button_element.enabled? }
+    page.talk_overlay_save_button
+  end
+end
+
 When(/^I click the add discussion button$/) do
   on(ArticlePage).talkadd_element.when_present.click
 end
 
+Then(/^I should see the topic called "(.+)" in the list of topics$/) do |topic|
+  
expect(on(ArticlePage).talk_overlay_first_topic_title_element.when_present.text).to
 match topic
+end
+
 Then(/^I should see the talk overlay$/) do
   on(ArticlePage) do |page|
     page.wait_until_rl_module_ready('mobile.talk.overlays')
diff --git a/tests/browser/features/support/pages/article_page.rb 
b/tests/browser/features/support/pages/article_page.rb
index 7d63c48..68f58f0 100644
--- a/tests/browser/features/support/pages/article_page.rb
+++ b/tests/browser/features/support/pages/article_page.rb
@@ -189,4 +189,9 @@
 
   # talk overlay
   a(:talkadd, css: '.add.continue')
+  p(:talk_overlay_content_header, css: '.talk-overlay .content-header')
+  li(:talk_overlay_first_topic_title, css: '.talk-overlay .topic-title-list 
li:first-child')
+  text_field(:talk_overlay_summary, css: '.talk-overlay .summary')
+  text_area(:talk_overlay_wikitext_editor, css: '.talk-overlay 
.wikitext-editor')
+  button(:talk_overlay_save_button, css: '.talk-overlay .confirm-save')
 end
diff --git a/tests/browser/features/talk.feature 
b/tests/browser/features/talk.feature
index d81cd81..07f0315 100644
--- a/tests/browser/features/talk.feature
+++ b/tests/browser/features/talk.feature
@@ -34,6 +34,16 @@
     When I click the talk button
     Then there should be an add discussion button
 
+  @integration
+  Scenario: A newly created topic appears in the list of topics immediately
+    Given the page "Talk:Selenium talk test" exists
+      And I am logged in as a user with a > 5 edit count
+      And the page "Selenium talk test" exists
+    When I click the talk button
+         And no topic is present
+         And I add a topic called "New topic"
+    Then I should see the topic called "New topic" in the list of topics
+
   Scenario: Add discussion on talk page not possible as logged out user
     Given the page "Talk:Selenium talk test" exists
       And the page "Selenium talk test" exists
diff --git a/tests/qunit/mobile.startup/test_PageGateway.js 
b/tests/qunit/mobile.startup/test_PageGateway.js
index a32df9a..436b2db 100644
--- a/tests/qunit/mobile.startup/test_PageGateway.js
+++ b/tests/qunit/mobile.startup/test_PageGateway.js
@@ -61,6 +61,7 @@
                this.sandbox.stub( this.api, 'get' )
                        .returns( $.Deferred().resolve( response ) );
 
+               pageGateway.invalidatePage( 'Test' );
                pageGateway.getPage( 'Test' ).done( function ( resp ) {
                        assert.deepEqual( resp, {
                                historyUrl: mw.util.getUrl( 'Test', {
@@ -173,6 +174,7 @@
                        }
                } ) );
 
+               pageGateway.invalidatePage( 'Test' );
                pageGateway.getPage( 'Test' ).done( function ( resp ) {
                        assert.deepEqual( resp, {
                                historyUrl: mw.util.getUrl( 'Test', {
@@ -478,6 +480,7 @@
                        }
                } ) );
 
+               pageGateway.invalidatePage( 'Test' );
                pageGateway.getPage( 'Test' ).done( function ( resp ) {
                        assert.deepEqual( resp.protection, expected );
                } );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I026b4a5a7c7fdc13e6115466180cf82d57eed524
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Bmansurov <bmansu...@wikimedia.org>
Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to