jenkins-bot has submitted this change and it was merged.

Change subject: H5: Hide reply and edit links in locked posts
......................................................................


H5: Hide reply and edit links in locked posts

Change-Id: I1e5f36c0a7f125e440110aff082410839ac2fd2e
---
M FlowActions.php
M handlebars/compiled/flow_block_topic_lock.handlebars.php
M handlebars/compiled/flow_block_topic_moderate_post.handlebars.php
M handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php
M handlebars/compiled/flow_post.handlebars.php
M handlebars/flow_post_meta_actions.handlebars
M handlebars/flow_topic_titlebar_lock.handlebars
M includes/FlowActions.php
M includes/RevisionActionPermissions.php
M modules/new/components/flow-board.js
M modules/new/styles/board/topic/post.less
M tests/browser/features/lock_unlock_topics.feature
M tests/browser/features/step_definitions/lock_unlock_topics_steps.rb
M tests/browser/features/support/pages/flow_page.rb
M tests/phpunit/PermissionsTest.php
M tests/qunit/new/components/test_flow-board.js
16 files changed, 135 insertions(+), 50 deletions(-)

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



diff --git a/FlowActions.php b/FlowActions.php
index dde01a8..9608774 100644
--- a/FlowActions.php
+++ b/FlowActions.php
@@ -186,6 +186,9 @@
                                        return $post->isCreator( 
$permissions->getUser() ) ? '' : 'flow-edit-post';
                                }
                ),
+               'root-permissions' => array(
+                       PostRevision::MODERATED_NONE => '',
+               ),
                'button-method' => 'GET',
                'links' => array( 'post-history', 'topic', 'post', 'diff-post', 
'post-revision' ),
                'actions' => array( 'reply', 'thank', 'edit-post', 
'restore-post', 'hide-post', 'delete-post', 'suppress-post' ),
@@ -214,6 +217,13 @@
                        // of the post to perform the action against. The value 
is a string or array
                        // of user rights that can allow this action.
                        PostRevision::MODERATED_NONE => array( 'flow-hide', 
'flow-delete', 'flow-suppress' ),
+               ),
+               'root-permissions' => array(
+                       // Can only hide within an unmoderated or hidden topic. 
This doesn't check for a specific
+                       // permissions because thats already done above in 
'permissions', this just ensures the
+                       // topic is in an appropriate state.
+                       PostRevision::MODERATED_NONE => '',
+                       PostRevision::MODERATED_HIDDEN => '',
                ),
                'button-method' => 'POST',
                'links' => array( 'topic', 'post', 'post-history', 
'post-revision' ),
@@ -518,6 +528,9 @@
                'permissions' => array(
                        PostRevision::MODERATED_NONE => '',
                ),
+               'root-permissions' => array(
+                       PostRevision::MODERATED_NONE => '',
+               ),
                'button-method' => 'GET',
                'links' => array( 'topic-history', 'topic', 'post', 
'post-revision', 'watch-topic', 'unwatch-topic' ),
                'actions' => array( 'reply', 'thank', 'edit-post', 'hide-post', 
'delete-post', 'suppress-post', 'edit-topic-summary', 'lock-topic', 
'restore-topic' ),
diff --git a/handlebars/compiled/flow_block_topic_lock.handlebars.php 
b/handlebars/compiled/flow_block_topic_lock.handlebars.php
index 7e1ac22..3f3ea91 100644
--- a/handlebars/compiled/flow_block_topic_lock.handlebars.php
+++ b/handlebars/compiled/flow_block_topic_lock.handlebars.php
@@ -52,7 +52,7 @@
                                        data-role="submit"
                                        class="mw-ui-button mw-ui-constructive"
                                        
data-flow-interactive-handler="apiRequest"
-                                       data-flow-api-target="< 
.flow-topic-titlebar"
+                                       data-flow-api-target="< .flow-topic"
                                        data-flow-api-handler="lockTopic">
                                                '.((LCRun3::ifvar($cx, 
((is_array($in) && isset($in['isModerated'])) ? $in['isModerated'] : null))) ? '
                                                        '.LCRun3::ch($cx, 
'l10n', Array(Array('flow-topic-action-unlock-topic'),Array()), 'encq').'
diff --git a/handlebars/compiled/flow_block_topic_moderate_post.handlebars.php 
b/handlebars/compiled/flow_block_topic_moderate_post.handlebars.php
index 02afa96..e6be916 100644
--- a/handlebars/compiled/flow_block_topic_moderate_post.handlebars.php
+++ b/handlebars/compiled/flow_block_topic_moderate_post.handlebars.php
@@ -197,7 +197,6 @@
                           
data-flow-interactive-handler="activateReplyPost">'.htmlentities(((is_array($in['actions']['reply'])
 && isset($in['actions']['reply']['title'])) ? $in['actions']['reply']['title'] 
: null), ENT_QUOTES, 'UTF-8').'</a>
                ' : '').'
                '.((LCRun3::ifvar($cx, ((is_array($in['actions']) && 
isset($in['actions']['edit'])) ? $in['actions']['edit'] : null))) ? '
-                       &#8226;
                        <a 
href="'.htmlentities(((is_array($in['actions']['edit']) && 
isset($in['actions']['edit']['url'])) ? $in['actions']['edit']['url'] : null), 
ENT_QUOTES, 'UTF-8').'"
                           
title="'.htmlentities(((is_array($in['actions']['edit']) && 
isset($in['actions']['edit']['title'])) ? $in['actions']['edit']['title'] : 
null), ENT_QUOTES, 'UTF-8').'"
                           data-flow-api-handler="activateEditPost"
@@ -208,7 +207,6 @@
                        </a>
                ' : '').'
                '.((LCRun3::ifvar($cx, ((is_array($in['actions']) && 
isset($in['actions']['thank'])) ? $in['actions']['thank'] : null))) ? '
-                       &#8226;
                        '.'
                        <a class="mw-ui-anchor mw-ui-constructive mw-ui-quiet 
mw-thanks-flow-thank-link"
                           
href="'.htmlentities(((is_array($in['actions']['thank']) && 
isset($in['actions']['thank']['url'])) ? $in['actions']['thank']['url'] : 
null), ENT_QUOTES, 'UTF-8').'"
@@ -392,7 +390,6 @@
                           
data-flow-interactive-handler="activateReplyPost">'.htmlentities(((is_array($in['actions']['reply'])
 && isset($in['actions']['reply']['title'])) ? $in['actions']['reply']['title'] 
: null), ENT_QUOTES, 'UTF-8').'</a>
                ' : '').'
                '.((LCRun3::ifvar($cx, ((is_array($in['actions']) && 
isset($in['actions']['edit'])) ? $in['actions']['edit'] : null))) ? '
-                       &#8226;
                        <a 
href="'.htmlentities(((is_array($in['actions']['edit']) && 
isset($in['actions']['edit']['url'])) ? $in['actions']['edit']['url'] : null), 
ENT_QUOTES, 'UTF-8').'"
                           
title="'.htmlentities(((is_array($in['actions']['edit']) && 
isset($in['actions']['edit']['title'])) ? $in['actions']['edit']['title'] : 
null), ENT_QUOTES, 'UTF-8').'"
                           data-flow-api-handler="activateEditPost"
@@ -403,7 +400,6 @@
                        </a>
                ' : '').'
                '.((LCRun3::ifvar($cx, ((is_array($in['actions']) && 
isset($in['actions']['thank'])) ? $in['actions']['thank'] : null))) ? '
-                       &#8226;
                        '.'
                        <a class="mw-ui-anchor mw-ui-constructive mw-ui-quiet 
mw-thanks-flow-thank-link"
                           
href="'.htmlentities(((is_array($in['actions']['thank']) && 
isset($in['actions']['thank']['url'])) ? $in['actions']['thank']['url'] : 
null), ENT_QUOTES, 'UTF-8').'"
diff --git a/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php 
b/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php
index 2023d0f..0c6f7a6 100644
--- a/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php
+++ b/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php
@@ -197,7 +197,6 @@
                           
data-flow-interactive-handler="activateReplyPost">'.htmlentities(((is_array($in['actions']['reply'])
 && isset($in['actions']['reply']['title'])) ? $in['actions']['reply']['title'] 
: null), ENT_QUOTES, 'UTF-8').'</a>
                ' : '').'
                '.((LCRun3::ifvar($cx, ((is_array($in['actions']) && 
isset($in['actions']['edit'])) ? $in['actions']['edit'] : null))) ? '
-                       &#8226;
                        <a 
href="'.htmlentities(((is_array($in['actions']['edit']) && 
isset($in['actions']['edit']['url'])) ? $in['actions']['edit']['url'] : null), 
ENT_QUOTES, 'UTF-8').'"
                           
title="'.htmlentities(((is_array($in['actions']['edit']) && 
isset($in['actions']['edit']['title'])) ? $in['actions']['edit']['title'] : 
null), ENT_QUOTES, 'UTF-8').'"
                           data-flow-api-handler="activateEditPost"
@@ -208,7 +207,6 @@
                        </a>
                ' : '').'
                '.((LCRun3::ifvar($cx, ((is_array($in['actions']) && 
isset($in['actions']['thank'])) ? $in['actions']['thank'] : null))) ? '
-                       &#8226;
                        '.'
                        <a class="mw-ui-anchor mw-ui-constructive mw-ui-quiet 
mw-thanks-flow-thank-link"
                           
href="'.htmlentities(((is_array($in['actions']['thank']) && 
isset($in['actions']['thank']['url'])) ? $in['actions']['thank']['url'] : 
null), ENT_QUOTES, 'UTF-8').'"
@@ -392,7 +390,6 @@
                           
data-flow-interactive-handler="activateReplyPost">'.htmlentities(((is_array($in['actions']['reply'])
 && isset($in['actions']['reply']['title'])) ? $in['actions']['reply']['title'] 
: null), ENT_QUOTES, 'UTF-8').'</a>
                ' : '').'
                '.((LCRun3::ifvar($cx, ((is_array($in['actions']) && 
isset($in['actions']['edit'])) ? $in['actions']['edit'] : null))) ? '
-                       &#8226;
                        <a 
href="'.htmlentities(((is_array($in['actions']['edit']) && 
isset($in['actions']['edit']['url'])) ? $in['actions']['edit']['url'] : null), 
ENT_QUOTES, 'UTF-8').'"
                           
title="'.htmlentities(((is_array($in['actions']['edit']) && 
isset($in['actions']['edit']['title'])) ? $in['actions']['edit']['title'] : 
null), ENT_QUOTES, 'UTF-8').'"
                           data-flow-api-handler="activateEditPost"
@@ -403,7 +400,6 @@
                        </a>
                ' : '').'
                '.((LCRun3::ifvar($cx, ((is_array($in['actions']) && 
isset($in['actions']['thank'])) ? $in['actions']['thank'] : null))) ? '
-                       &#8226;
                        '.'
                        <a class="mw-ui-anchor mw-ui-constructive mw-ui-quiet 
mw-thanks-flow-thank-link"
                           
href="'.htmlentities(((is_array($in['actions']['thank']) && 
isset($in['actions']['thank']['url'])) ? $in['actions']['thank']['url'] : 
null), ENT_QUOTES, 'UTF-8').'"
diff --git a/handlebars/compiled/flow_post.handlebars.php 
b/handlebars/compiled/flow_post.handlebars.php
index c4d7a77..8f8214f 100644
--- a/handlebars/compiled/flow_post.handlebars.php
+++ b/handlebars/compiled/flow_post.handlebars.php
@@ -164,7 +164,6 @@
                           
data-flow-interactive-handler="activateReplyPost">'.htmlentities(((is_array($in['actions']['reply'])
 && isset($in['actions']['reply']['title'])) ? $in['actions']['reply']['title'] 
: null), ENT_QUOTES, 'UTF-8').'</a>
                ' : '').'
                '.((LCRun3::ifvar($cx, ((is_array($in['actions']) && 
isset($in['actions']['edit'])) ? $in['actions']['edit'] : null))) ? '
-                       &#8226;
                        <a 
href="'.htmlentities(((is_array($in['actions']['edit']) && 
isset($in['actions']['edit']['url'])) ? $in['actions']['edit']['url'] : null), 
ENT_QUOTES, 'UTF-8').'"
                           
title="'.htmlentities(((is_array($in['actions']['edit']) && 
isset($in['actions']['edit']['title'])) ? $in['actions']['edit']['title'] : 
null), ENT_QUOTES, 'UTF-8').'"
                           data-flow-api-handler="activateEditPost"
@@ -175,7 +174,6 @@
                        </a>
                ' : '').'
                '.((LCRun3::ifvar($cx, ((is_array($in['actions']) && 
isset($in['actions']['thank'])) ? $in['actions']['thank'] : null))) ? '
-                       &#8226;
                        '.'
                        <a class="mw-ui-anchor mw-ui-constructive mw-ui-quiet 
mw-thanks-flow-thank-link"
                           
href="'.htmlentities(((is_array($in['actions']['thank']) && 
isset($in['actions']['thank']['url'])) ? $in['actions']['thank']['url'] : 
null), ENT_QUOTES, 'UTF-8').'"
@@ -359,7 +357,6 @@
                           
data-flow-interactive-handler="activateReplyPost">'.htmlentities(((is_array($in['actions']['reply'])
 && isset($in['actions']['reply']['title'])) ? $in['actions']['reply']['title'] 
: null), ENT_QUOTES, 'UTF-8').'</a>
                ' : '').'
                '.((LCRun3::ifvar($cx, ((is_array($in['actions']) && 
isset($in['actions']['edit'])) ? $in['actions']['edit'] : null))) ? '
-                       &#8226;
                        <a 
href="'.htmlentities(((is_array($in['actions']['edit']) && 
isset($in['actions']['edit']['url'])) ? $in['actions']['edit']['url'] : null), 
ENT_QUOTES, 'UTF-8').'"
                           
title="'.htmlentities(((is_array($in['actions']['edit']) && 
isset($in['actions']['edit']['title'])) ? $in['actions']['edit']['title'] : 
null), ENT_QUOTES, 'UTF-8').'"
                           data-flow-api-handler="activateEditPost"
@@ -370,7 +367,6 @@
                        </a>
                ' : '').'
                '.((LCRun3::ifvar($cx, ((is_array($in['actions']) && 
isset($in['actions']['thank'])) ? $in['actions']['thank'] : null))) ? '
-                       &#8226;
                        '.'
                        <a class="mw-ui-anchor mw-ui-constructive mw-ui-quiet 
mw-thanks-flow-thank-link"
                           
href="'.htmlentities(((is_array($in['actions']['thank']) && 
isset($in['actions']['thank']['url'])) ? $in['actions']['thank']['url'] : 
null), ENT_QUOTES, 'UTF-8').'"
diff --git a/handlebars/flow_post_meta_actions.handlebars 
b/handlebars/flow_post_meta_actions.handlebars
index c4cc626..89a67a2 100644
--- a/handlebars/flow_post_meta_actions.handlebars
+++ b/handlebars/flow_post_meta_actions.handlebars
@@ -9,7 +9,6 @@
                        </a>
                {{/if}}
                {{#if actions.edit}}
-                       &#8226;
                        <a href="{{actions.edit.url}}"
                           title="{{actions.edit.title}}"
                           data-flow-api-handler="activateEditPost"
@@ -20,7 +19,6 @@
                        </a>
                {{/if}}
                {{#if actions.thank}}
-                       &#8226;
                        {{!--
                                progressive enhancement happens in the Thank 
extension
                                based on the mw-thanks-flow-thank-link class
diff --git a/handlebars/flow_topic_titlebar_lock.handlebars 
b/handlebars/flow_topic_titlebar_lock.handlebars
index 6c604ad..818d864 100644
--- a/handlebars/flow_topic_titlebar_lock.handlebars
+++ b/handlebars/flow_topic_titlebar_lock.handlebars
@@ -35,7 +35,7 @@
                                        data-role="submit"
                                        class="mw-ui-button mw-ui-constructive"
                                        
data-flow-interactive-handler="apiRequest"
-                                       data-flow-api-target="< 
.flow-topic-titlebar"
+                                       data-flow-api-target="< .flow-topic"
                                        data-flow-api-handler="lockTopic">
                                                {{#if isModerated}}
                                                        {{l10n 
"flow-topic-action-unlock-topic"}}
diff --git a/includes/FlowActions.php b/includes/FlowActions.php
index 59a2d35..2e9cc7a 100644
--- a/includes/FlowActions.php
+++ b/includes/FlowActions.php
@@ -8,7 +8,7 @@
        /**
         * @var MultiDimArray
         */
-       protected $actions = array();
+       protected $actions;
 
        /**
         * @param array $actions
@@ -30,6 +30,23 @@
         * @param string[optional] $type
         * @param string[optional] $option Function can be overloaded in case 
the
         * desired value is nested deeper
+        * @return bool True when the requested parameter exists and is not null
+        */
+       public function hasValue( $action, $type = null /* [, $option = null [, 
...]] */ ) {
+               $arguments = func_get_args();
+               try {
+                       return isset( $this->actions[$arguments] );
+               } catch ( \OutOfBoundsException $e ) {
+                       // NOTE: doesn't currently support BC aliases, seems 
reasonable for now
+                       return false;
+               }
+       }
+
+       /**
+        * @param string $action
+        * @param string[optional] $type
+        * @param string[optional] $option Function can be overloaded in case 
the
+        * desired value is nested deeper
         * @return mixed|null Requested value or null if missing
         */
        public function getValue( $action, $type = null /* [, $option = null [, 
...]] */ ) {
diff --git a/includes/RevisionActionPermissions.php 
b/includes/RevisionActionPermissions.php
index 484fd45..599751a 100644
--- a/includes/RevisionActionPermissions.php
+++ b/includes/RevisionActionPermissions.php
@@ -5,6 +5,7 @@
 use Flow\Collection\CollectionCache;
 use Flow\Exception\InvalidDataException;
 use Flow\Model\AbstractRevision;
+use Flow\Model\PostRevision;
 use Closure;
 use User;
 
@@ -59,6 +60,10 @@
                $section = new \ProfileSection( __METHOD__ );
                $allowed = $this->isRevisionAllowed( $revision, $action );
 
+               if ( $allowed && $revision instanceof PostRevision ) {
+                       $allowed = $this->isRootAllowed( $revision, $action );
+               }
+
                // if there was no revision object, it's pointless to find last 
revision
                // if we already fail, no need in checking most recent revision 
status
                if ( $allowed && $revision !== null  ) {
@@ -105,6 +110,40 @@
        }
 
        /**
+        * Check if a user is allowed to perform a certain action, against the 
latest
+        * root(topic) post related to the provided revision.  This is required 
for
+        * things like preventing replys to locked topics.
+        *
+        * @param PostRevision $revision
+        * @param string $action
+        * @return bool
+        */
+       protected function isRootAllowed( PostRevision $revision, $action ) {
+               // If the revision is a root then this does not apply.
+               if ( $revision->isTopicTitle() ) {
+                       return true;
+               }
+               // If the `root-permissions` key is not set then it is allowed
+               if ( !$this->actions->hasValue( $action, 'root-permissions' ) ) 
{
+                       return true;
+               }
+
+               $root = $revision->getRootPost();
+               $permission = $this->getPermission( $root, $action, 
'root-permissions' );
+
+               // If `root-permissions` is defined but not for the current 
state
+               // then action is denied
+               if ( $permission === null ) {
+                       return false;
+               }
+
+               return call_user_func_array(
+                       array( $this->user, 'isAllowedAny' ),
+                       (array) $permission
+               );
+       }
+
+       /**
         * Check if a user is allowed to perform a certain action, only against 
1
         * specific revision (whereas the default isAllowed() will check if the
         * given $action is allowed for both given and the most current 
revision)
@@ -143,13 +182,13 @@
         * @param string $action
         * @return Closure|string
         */
-       public function getPermission( AbstractRevision $revision = null, 
$action ) {
+       public function getPermission( AbstractRevision $revision = null, 
$action, $type = 'permissions' ) {
                // $revision may be null if the revision has yet to be created
                $moderationState = AbstractRevision::MODERATED_NONE;
                if ( $revision !== null ) {
                        $moderationState = $revision->getModerationState();
                }
-               $permission = $this->actions->getValue( $action, 'permissions', 
$moderationState );
+               $permission = $this->actions->getValue( $action, $type, 
$moderationState );
 
                // Some permissions may be more complex to be defined as simple 
array
                // values, in which case they're a Closure (which will accept
diff --git a/modules/new/components/flow-board.js 
b/modules/new/components/flow-board.js
index 16f815a..6dbfd59 100644
--- a/modules/new/components/flow-board.js
+++ b/modules/new/components/flow-board.js
@@ -605,12 +605,11 @@
                 * @param {jqXHR} jqxhr
                 */
                FlowBoardComponent.UI.events.apiHandlers.lockTopic = function ( 
info, data ) {
-                       var revision, topicId, revisionId, $topicTitleBar,
+                       var $replacement,
                                $target = info.$target,
-                               $topic = $target.parents( '.flow-topic' ),
-                               self = this,
-                               flowBoard = 
FlowBoardComponent.prototype.getInstanceByElement( $( this ) ),
-                               flowId = $( self ).closest( 
'.flow-topic-titlebar' ).parent().data( 'flow-id' );
+                               $this = $( this ),
+                               flowBoard = 
FlowBoardComponent.prototype.getInstanceByElement( $this ),
+                               flowId = $this.closest( '.flow-topic' ).data( 
'flow-id' );
 
                        if ( info.status !== 'done' ) {
                                // Error will be displayed by default & edit 
conflict handled, nothing else to wrap up
@@ -636,28 +635,14 @@
                                // Flow topic title, in Topic:<topicId> format 
(2600 is topic namespace id)
                                page: mw.Title.newFromText( flowId, 2600 
).getPrefixedDb()
                        } ).done( function( result ) {
-                               // FIXME: Why doesn't the API return this?
-                               result = result.flow['view-topic'].result.topic;
-                               topicId = result.roots[0];
-                               revisionId = result.posts[topicId];
-                               revision = result.revisions[revisionId];
+                               // Update view of the full topic
+                               $replacement = $( 
flowBoard.TemplateEngine.processTemplateGetFragment(
+                                       'flow_topiclist_loop',
+                                       result.flow['view-topic'].result.topic
+                               ) ).children();
 
-                               if ( revision.isModerated ) {
-                                       $topic.addClass( 'flow-topic-moderated' 
).
-                                               addClass( 
'flow-topic-moderatestate-lock' );
-                               } else {
-                                       $topic.removeClass( 
'flow-topic-moderated flow-topic-moderatestate-lock' );
-                               }
-
-                               // Update view of the title bar
-                               $topicTitleBar = $(
-                                       
flowBoard.TemplateEngine.processTemplateGetFragment(
-                                               'flow_topic_titlebar',
-                                               revision
-                                       )
-                               ).children();
-                               $target.replaceWith( $topicTitleBar );
-                               FlowBoardComponent.UI.makeContentInteractive( 
$topicTitleBar );
+                               $target.replaceWith( $replacement );
+                               FlowBoardComponent.UI.makeContentInteractive( 
$replacement );
                        } ).fail( function( code, result ) {
                                /*
                                 * At this point, the lock/unlock actually 
worked, but failed
diff --git a/modules/new/styles/board/topic/post.less 
b/modules/new/styles/board/topic/post.less
index f01073b..7501204 100644
--- a/modules/new/styles/board/topic/post.less
+++ b/modules/new/styles/board/topic/post.less
@@ -139,6 +139,20 @@
 .flow-post-meta-actions {
        float: left;
        text-transform: capitalize;
+       a {
+               &::after {
+                       content: "\2022";
+                       padding: 0 8px;
+                       text-decoration: none;
+                       display: inline-block;
+                       color: @colorGrayDark;
+               }
+               &:last-child {
+                       &::after {
+                               content: "";
+                       }
+               }
+       }
 }
 
 // MEDIA QUERIES
diff --git a/tests/browser/features/lock_unlock_topics.feature 
b/tests/browser/features/lock_unlock_topics.feature
index 59835ba..ce02c62 100644
--- a/tests/browser/features/lock_unlock_topics.feature
+++ b/tests/browser/features/lock_unlock_topics.feature
@@ -4,6 +4,15 @@
   Background:
       Given I am logged in
 
+  @wip
+  Scenario: Locked topics have no reply links
+    Given I am on Flow page
+        And I have created a Flow topic
+        And the top post has been locked
+    When I expand the top post
+    Then the original message for the top post has no reply link
+        And the original message for the top post has no edit link
+
   @internet_explorer_10
   Scenario: Locking a topic and then changing your mind
     Given I am on Flow page
diff --git 
a/tests/browser/features/step_definitions/lock_unlock_topics_steps.rb 
b/tests/browser/features/step_definitions/lock_unlock_topics_steps.rb
index ebd0d2d..4acf422 100644
--- a/tests/browser/features/step_definitions/lock_unlock_topics_steps.rb
+++ b/tests/browser/features/step_definitions/lock_unlock_topics_steps.rb
@@ -54,3 +54,11 @@
   on(FlowPage).topic_lock_form_element.when_not_present
 end
 
+Then(/^the original message for the top post has no reply link$/) do
+  on(FlowPage).flow_first_topic_original_post_reply_element.should_not exist
+end
+
+Then(/the original message for the top post has no edit link$/) do
+  on(FlowPage).flow_first_topic_original_post_edit_element.should_not exist
+end
+
diff --git a/tests/browser/features/support/pages/flow_page.rb 
b/tests/browser/features/support/pages/flow_page.rb
index 22dd90d..38ae974 100644
--- a/tests/browser/features/support/pages/flow_page.rb
+++ b/tests/browser/features/support/pages/flow_page.rb
@@ -49,6 +49,13 @@
   div(:flow_first_topic_summary) do |page|
     page.flow_first_topic_element.div_element(css: ".flow-topic-summary")
   end
+  div(:flow_first_topic_original_post, css: ".flow-post", index: 0)
+  a(:flow_first_topic_original_post_edit) do |page|
+    page.flow_first_topic_original_post_element.link_element(text: "Edit")
+  end
+  a(:flow_first_topic_original_post_reply) do |page|
+    page.flow_first_topic_original_post_element.link_element(text: "Reply")
+  end
 
   ### Hover over username behaviour
   span(:usertools, css: '.mw-usertoollinks')
diff --git a/tests/phpunit/PermissionsTest.php 
b/tests/phpunit/PermissionsTest.php
index da81848..dda7792 100644
--- a/tests/phpunit/PermissionsTest.php
+++ b/tests/phpunit/PermissionsTest.php
@@ -318,6 +318,10 @@
                                'tree_orig_user_id' => 
$this->unconfirmedUser()->getId(),
                                'tree_parent_id' => 
$this->topic()->getPostId()->getBinary()
                        ), array(), 1 );
+                       $this->post->setRootPost( $this->generateObject( array(
+                               'tree_orig_user_id' => 
$this->unconfirmedUser()->getId(),
+                               'tree_parent_id' => 
$this->topic()->getPostId()->getBinary()
+                       ), array(), 1 ) );
                }
 
                return $this->post;
diff --git a/tests/qunit/new/components/test_flow-board.js 
b/tests/qunit/new/components/test_flow-board.js
index e944a37..8f2bb86 100644
--- a/tests/qunit/new/components/test_flow-board.js
+++ b/tests/qunit/new/components/test_flow-board.js
@@ -64,7 +64,8 @@
                                                                                
        format: 'html',
                                                                                
        content: 'Hi'
                                                                                
},
-                                                                               
isModerated: true
+                                                                               
isModerated: true,
+                                                                               
moderateState: 'lock'
                                                                        }
                                                                }
                                                        }
@@ -77,27 +78,29 @@
        }
 } );
 
-QUnit.test( 'FlowBoardComponent.UI.events.apiHandlers.preview', 2, function( 
assert ) {
+QUnit.test( 'FlowBoardComponent.UI.events.apiHandlers.lockTopic - perform 
unlock', 2, function( assert ) {
        var
                $topic = $( '<div class="flow-topic" 
data-flow-id="s18cjkj1bs3rkt13">' ).
                        addClass( 'flow-topic-moderatestate-lock 
flow-topic-moderated' ).
                        appendTo( this.$el ),
                $titleBar = $( '<div class="flow-topic-titlebar">' ).appendTo( 
$topic ),
-               info = { status: 'done', $target: $titleBar };
+               info = { status: 'done', $target: $topic };
 
        this.UI.events.apiHandlers.lockTopic.call( $titleBar, info );
+       $topic = this.$el.children( '.flow-topic' );
        assert.strictEqual( $topic.hasClass( 'flow-topic-moderated' ), false, 
'No longer has the moderated state.' );
        assert.strictEqual( $topic.hasClass( 'flow-topic-moderatestate-lock' ), 
false, 'No longer has the moderated lock state.' );
 } );
 
-QUnit.test( 'FlowBoardComponent.UI.events.apiHandlers.preview', 2, function( 
assert ) {
+QUnit.test( 'FlowBoardComponent.UI.events.apiHandlers.lockTopic - perform 
lock', 2, function( assert ) {
        var
                $topic = $( '<div class="flow-topic" 
data-flow-id="t18cjkj1bs3rkt13">' ).
                        appendTo( this.$el ),
                $titleBar = $( '<div class="flow-topic-titlebar">' ).appendTo( 
$topic ),
-               info = { status: 'done', $target: $titleBar };
+               info = { status: 'done', $target: $topic };
 
        this.UI.events.apiHandlers.lockTopic.call( $titleBar, info );
+       $topic = this.$el.children( '.flow-topic' );
        assert.strictEqual( $topic.hasClass( 'flow-topic-moderated' ), true, 
'Has the moderated state.' );
        assert.strictEqual( $topic.hasClass( 'flow-topic-moderatestate-lock' ), 
true, 'Has the moderated lock state.' );
 } );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1e5f36c0a7f125e440110aff082410839ac2fd2e
Gerrit-PatchSet: 10
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: SG <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to