MDL-64820 forum: add classes to first post to fix behat

This commit is contained in:
Ryan Wyllie 2019-03-20 14:42:14 +08:00
parent 96a49734ac
commit 57ad9a0ce7
2 changed files with 11 additions and 1 deletions

View file

@ -194,6 +194,7 @@ class renderer {
unset($exportedpost->author); unset($exportedpost->author);
} }
$exportedpost->firstpost = false;
$exportedpost->readonly = $readonly; $exportedpost->readonly = $readonly;
$exportedpost->hasreplies = false; $exportedpost->hasreplies = false;
$exportedpost->replies = []; $exportedpost->replies = [];
@ -228,6 +229,11 @@ class renderer {
$exportedposts = [$exportedfirstpost]; $exportedposts = [$exportedfirstpost];
} }
if (!empty($exportedposts)) {
// Need to identify the first post so that we can use it in behat tests.
$exportedposts[0]->firstpost = true;
}
return $exportedposts; return $exportedposts;
} }
); );

View file

@ -31,7 +31,11 @@
}} }}
<article id="p{{id}}" class="relativelink mb-2" tabindex="-1" data-post-id="{{id}}"> <article id="p{{id}}" class="relativelink mb-2" tabindex="-1" data-post-id="{{id}}">
<div class="d-flex border p-2 mb-2 forumpost {{#unread}}unread{{/unread}}"> <!-- The firstpost and starter classes below aren't used for anything other than to identify the first post in behat -->
<div
class="d-flex border p-2 mb-2 forumpost {{#unread}}unread{{/unread}} {{#firstpost}}firstpost starter{{/firstpost}}"
aria-label='{{#str}} postbyuser, mod_forum, {"post": "{{subject}}", "user": "{{author.fullname}}"} {{/str}}'
>
{{#isfirstunread}}<a id="unread"></a>{{/isfirstunread}} {{#isfirstunread}}<a id="unread"></a>{{/isfirstunread}}
<div style="width: 45px;"> <div style="width: 45px;">
{{^isdeleted}} {{^isdeleted}}