[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/mod/forum/tests/behat/ -> posts_ordering_blog.feature (source)

   1  @mod @mod_forum
   2  Feature: Blog posts are always displayed in reverse chronological order
   3    In order to use forum as a blog
   4    As a user
   5    I need to see most recent blog posts first
   6  
   7    Background:
   8      Given the following "users" exist:
   9        | username  | firstname | lastname  | email                 |
  10        | teacher1  | Teacher   | 1         | teacher1@example.com  |
  11        | student1  | Student   | 1         | student1@example.com  |
  12      And the following "courses" exist:
  13        | fullname  | shortname | category  |
  14        | Course 1  | C1        | 0         |
  15      And the following "course enrolments" exist:
  16        | user      | course    | role            |
  17        | teacher1  | C1        | editingteacher  |
  18        | student1  | C1        | student         |
  19      And I log in as "teacher1"
  20      And I follow "Course 1"
  21      And I turn editing mode on
  22      And I add a "Forum" to section "1" and I fill the form with:
  23        | Forum name  | Course blog forum                               |
  24        | Description | Single discussion forum description             |
  25        | Forum type  | Standard forum displayed in a blog-like format  |
  26      And I log out
  27  
  28    #
  29    # We need javascript/wait to prevent creation of the posts in the same second. The threads
  30    # would then ignore each other in the prev/next navigation as the Forum is unable to compute
  31    # the correct order.
  32    #
  33    @javascript
  34    Scenario: Replying to a blog post or editing it does not affect its display order
  35      Given I log in as "student1"
  36      And I follow "Course 1"
  37      And I follow "Course blog forum"
  38      #
  39      # Add three posts into the blog.
  40      #
  41      When I add a new topic to "Course blog forum" forum with:
  42        | Subject | Blog post 1             |
  43        | Message | This is the first post  |
  44      And I add a new topic to "Course blog forum" forum with:
  45        | Subject | Blog post 2             |
  46        | Message | This is the second post |
  47      And I add a new topic to "Course blog forum" forum with:
  48        | Subject | Blog post 3             |
  49        | Message | This is the third post  |
  50      #
  51      # Edit one of the blog posts.
  52      #
  53      And I click on "Edit" "link" in the "//div[@aria-label='Blog post 2 by Student 1']" "xpath_element"
  54      And I set the following fields to these values:
  55        | Subject | Edited blog post 2      |
  56      And I press "Save changes"
  57      And I wait to be redirected
  58      And I log out
  59      #
  60      # Reply to another blog post.
  61      #
  62      And I log in as "teacher1"
  63      And I follow "Course 1"
  64      And I follow "Course blog forum"
  65      And I click on "Discuss this topic" "link" in the "//div[@aria-label='Blog post 1 by Student 1']" "xpath_element"
  66      And I click on "Reply" "link" in the "//div[@aria-label='Blog post 1 by Student 1']" "xpath_element"
  67      And I set the following fields to these values:
  68        | Message | Reply to the first post |
  69      And I press "Post to forum"
  70      And I wait to be redirected
  71      And I am on site homepage
  72      And I follow "Course 1"
  73      And I follow "Course blog forum"
  74      #
  75      # Make sure the order of the blog posts is still reverse chronological.
  76      #
  77      Then I should see "This is the third post" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' forumpost ')][position()=1]" "xpath_element"
  78      And I should see "This is the second post" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' forumpost ')][position()=2]" "xpath_element"
  79      And I should see "This is the first post" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' forumpost ')][position()=3]" "xpath_element"
  80      #
  81      # Make sure the next/prev navigation uses the same order of the posts.
  82      #
  83      And I click on "Discuss this topic" "link" in the "//div[@aria-label='Edited blog post 2 by Student 1']" "xpath_element"
  84      And "//a[@aria-label='Next discussion: Blog post 3']" "xpath_element" should exist
  85      And "//a[@aria-label='Previous discussion: Blog post 1']" "xpath_element" should exist


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1