show_hide_chapters.feature 3.44 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
@mod @mod_book
Feature: Book activity chapter visibility management
  In order to properly manage chapters in a book activity
  As a teacher
  I need to be able to show or hide chapters.

  Background:
    Given the following "courses" exist:
      | fullname | shortname | category | groupmode |
      | Course 1 | C1 | 0 | 1 |
    And the following "users" exist:
      | username | firstname | lastname | email |
13
      | teacher1 | Teacher | 1 | teacher1@example.com |
14
      | student1 | Student | 2 | student1@example.com |
15
16
17
    And the following "course enrolments" exist:
      | user | course | role |
      | teacher1 | C1 | editingteacher |
18
      | student1 | C1 | student        |
19
20
21
22
23
    And the following "activity" exists:
      | course   | C1                  |
      | activity | book                |
      | name     | Test book           |
    And I am on the "Test book" "book activity" page logged in as teacher1
24
25
26
27
    And I set the following fields to these values:
      | Chapter title | First chapter |
      | Content | First chapter |
    And I press "Save changes"
28
    And I turn editing mode on
29
    And I click on "Add new chapter after \"First chapter\"" "link"
30
31
32
33
    And I set the following fields to these values:
      | Chapter title | Second chapter |
      | Content | Second chapter |
    And I press "Save changes"
34
    And I click on "Add new chapter after \"Second chapter\"" "link"
35
36
37
38
39
    And I set the following fields to these values:
      | Chapter title | Sub chapter |
      | subchapter | 1 |
      | Content | Sub chapter |
    And I press "Save changes"
40
    And I click on "Add new chapter after \"Sub chapter\"" "link"
41
42
43
44
45
    And I set the following fields to these values:
      | Chapter title | Third chapter |
      | subchapter | 0 |
      | Content | Third chapter |
    And I press "Save changes"
46
    And I click on "Add new chapter after \"Third chapter\"" "link"
47
48
49
50
51
52
53
    And I set the following fields to these values:
      | Chapter title | Fourth chapter |
      | Content | Fourth chapter |
    And I press "Save changes"

  @javascript
  Scenario: Show/hide chapters and subchapters
54
55
    When I follow "Hide chapter \"2. Second chapter\""
    And I follow "Hide chapter \"2. Third chapter\""
56
    And I am on the "Test book" "book activity" page
57
    And I turn editing mode off
58
59
    Then the "class" attribute of "a[title='Second chapter']" "css_element" should contain "dimmed_text"
    And the "class" attribute of "a[title='Third chapter']" "css_element" should contain "dimmed_text"
60
    And I turn editing mode on
61
62
63
64
65
66
67
68
69
70
    And I follow "Next"
    And I should see "Second chapter" in the ".book_content" "css_element"
    And I should not see "Exit book"
    And I follow "Next"
    And I should see "Sub chapter" in the ".book_content" "css_element"
    And I follow "Next"
    And I should see "Third chapter" in the ".book_content" "css_element"
    And I follow "Next"
    And I should see "Fourth chapter" in the ".book_content" "css_element"
    And I follow "Exit book"
71
    And I log out
72
    And I am on the "Test book" "book activity" page logged in as student1
73
74
    And I should not see "Second chapter" in the "Table of contents" "block"
    And I should not see "Third chapter" in the "Table of contents" "block"
75
76
77
    And I follow "Next"
    And I should see "Fourth chapter" in the ".book_content" "css_element"
    And I follow "Exit book"
78
    And I am on the "Test book" "book activity" page
79
    And I should see "First chapter" in the ".book_content" "css_element"