Skip to content

Commit

Permalink
Update Behat tests for Moodle 4.4 part 3 (MDL-80923)
Browse files Browse the repository at this point in the history
  • Loading branch information
james-cnz committed Apr 14, 2024
1 parent 830346c commit b48e737
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 101 deletions.
24 changes: 7 additions & 17 deletions tests/behat/activity_navigation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,24 @@ Feature: Activity navigation in Multitopic format
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I edit the section "1" and I fill the form with:
| Custom | 1 |
| New value for Section name | Section A |
| Level | 0 |
And I edit the section "2" and I fill the form with:
| Custom | 1 |
| New value for Section name | Section B |
| Level | 1 |
And I edit the section "3" and I fill the form with:
| Custom | 1 |
| New value for Section name | Section C |
| Level | 2 |
And I edit the section "4" and I fill the form with:
| Custom | 1 |
| New value for Section name | Section D |
| Level | 0 |
And I edit the section "5" and I fill the form with:
| Custom | 1 |
| New value for Section name | Section E |
| Level | 2 |
And I click on "Hide" "link" in the "Page 1" activity
And I click on "Make available" "link" in the "Page 1" activity
And I click on "General" "link" in the ".course-content .nav" "css_element"

Scenario: Enter and exit activity
Given I click on "Section A" "link" in the ".course-content .nav" "css_element"
And I click on "Section B" "link" in the ".course-content .nav ~ .nav" "css_element"
Then I should see "Section B" in the "#section-2" "css_element"
And I should see "Section C" in the "#section-3" "css_element"
Given I click on "Section 1" "link" in the ".course-content .nav" "css_element"
And I click on "Section 2" "link" in the ".course-content .nav ~ .nav" "css_element"
Then I should see "Section 2" in the "#section-2" "css_element"
And I should see "Section 3" in the "#section-3" "css_element"
And I should see "Assignment 1" in the "#section-3" "css_element"
And I follow "Assignment 1"
And I should see "Back to course" in the ".course-content-header" "css_element"
Expand All @@ -61,9 +51,9 @@ Feature: Activity navigation in Multitopic format
And I should see "Assignment 1" in the "#section-3" "css_element"

Scenario: Back to course links not shown for stealth activities
Given I click on "Section D" "link" in the ".course-content .nav" "css_element"
Then I should see "Section D" in the "#section-4" "css_element"
And I should see "Section E" in the "#section-5" "css_element"
Given I click on "Section 4" "link" in the ".course-content .nav" "css_element"
Then I should see "Section 4" in the "#section-4" "css_element"
And I should see "Section 5" in the "#section-5" "css_element"
And I should see "Page 1" in the "#section-5" "css_element"
And I follow "Page 1"
And I should not see "Back to course" in the ".course-content-header" "css_element"
Expand Down
37 changes: 14 additions & 23 deletions tests/behat/edit_delete_sections.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,33 @@ Feature: Sections can be edited and deleted in Multitopic format
And the following "activities" exist:
| activity | name | intro | course | idnumber | section |
| assign | Test assignment name | Test assignment description | C1 | assign1 | 0 |
| book | Test book name | Test book description | C1 | book1 | 1 |
| chat | Test chat name | Test chat description | C1 | chat1 | 4 |
| book | Test book name | | C1 | book1 | 1 |
| lesson | Test lesson name | Test lesson description | C1 | chat1 | 4 |
| choice | Test choice name | Test choice description | C1 | choice1 | 5 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on

Scenario: View the default name of the general section in Multitopic format
Given I am on "Course 1" course homepage with editing mode on
When I edit the section "0"
Then the field "Custom" matches value "0"
And the field "New value for Section name" matches value "General"
Then I should see "General"

Scenario: Edit the default name of the general section in Multitopic format
Given I should see "General" in the "General" "section"
When I edit the section "0" and I fill the form with:
| Custom | 1 |
| New value for Section name | This is the general section |
Then I should see "This is the general section" in the "This is the general section" "section"
# Edit the default name of the general section removed, because the field type changed.

Scenario: View the default name of the second section in Multitopic format
Given I am on "Course 1" course homepage with editing mode on
When I edit the section "2"
Then the field "Custom" matches value "0"
And the field "New value for Section name" matches value "Section 2"
Then I should see "Section 2"

# Edit section summary removed, because the field name changed.

Scenario: Edit section default name in Multitopic format
When I edit the section "2" and I fill the form with:
| Custom | 1 |
| New value for Section name | This is the second topic |
Then I should see "This is the second topic" in the "This is the second topic" "section"
And I should not see "Section 2" in the "region-main" "region"
# Edit section default name removed, because the field type changed.

@javascript
Scenario: Inline edit section name in Multitopic format
Given I am on "Course 1" course homepage with editing mode on
When I set the field "Edit section name" in the "Section 1" "section" to "Midterm evaluation"
Then I should not see "Section 1" in the "region-main" "region"
And "New name for section" "field" should not exist
Expand All @@ -60,24 +50,25 @@ Feature: Sections can be edited and deleted in Multitopic format
And I should see "Midterm evaluation" in the "Midterm evaluation" "section"

Scenario: Deleting the last section in Multitopic format
Given I should see "Section 5" in the "Section 5" "section"
Given I am on "Course 1" course homepage with editing mode on
When I delete section "5"
Then I should see "Are you absolutely sure you want to completely delete \"Section 5\" and all the activities it contains?"
And I press "Delete"
And I should not see "Section 5"
And I should see "Section 4"

Scenario: Deleting the middle section in Multitopic format
Given I should see "Section 5" in the "Section 5" "section"
Given I am on "Course 1" course homepage with editing mode on
When I delete section "4"
And I press "Delete"
Then I should not see "Section 5"
And I should not see "Test chat name"
And I should see "Test choice name" in the "Section 4" "section"
And I should see "Section 4"
And I should not see "Test lesson name"
And I should see "Test choice name" in the "Section 4" "section"

@javascript
Scenario: Adding sections at the end of a Multitopic format
Given I am on "Course 1" course homepage with editing mode on
When I follow "Add topic"
Then I should see "Section 6" in the "Section 6" "section"
And I should see "Test choice name" in the "Section 5" "section"
68 changes: 34 additions & 34 deletions tests/behat/move_sections.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,83 +8,83 @@ Feature: Sections can be moved in Multitopic format
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | format | coursedisplay | numsections |
| Course 1 | C1 | multitopic | 0 | 5 |
And the following "course" exists:
| fullname | Course 1 |
| shortname | C1 |
| format | multitopic |
| coursedisplay | 0 |
| numsections | 5 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following "activities" exist:
| activity | name | course | idnumber | section |
| forum | Test forum name A | C1 | forum1 | 1 |
| forum | Test forum name B | C1 | forum2 | 2 |
| forum | Test forum name C | C1 | forum3 | 3 |
| forum | Test forum name D | C1 | forum4 | 4 |
| forum | Test forum name E | C1 | forum5 | 5 |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I edit the section "1" and I fill the form with:
| Custom | 1 |
| New value for Section name | Section A |
| Level | 0 |
And I edit the section "2" and I fill the form with:
| Custom | 1 |
| New value for Section name | Section B |
| Level | 1 |
And I edit the section "3" and I fill the form with:
| Custom | 1 |
| New value for Section name | Section C |
| Level | 2 |
And I edit the section "4" and I fill the form with:
| Custom | 1 |
| New value for Section name | Section D |
| Level | 0 |
And I edit the section "5" and I fill the form with:
| Custom | 1 |
| New value for Section name | Section E |
| Level | 2 |
And I click on "General" "link" in the ".course-content .nav" "css_element"

Scenario: Move first-level page forward and back
Given I click on "Section A" "link" in the ".course-content .nav" "css_element"
Then I should see "Section A" in the "#section-1" "css_element"
Given I click on "Section 1" "link" in the ".course-content .nav" "css_element"
Then I should see "Test forum name A" in the "#section-1" "css_element"
And I should see "Move page right" in the "#section-1" "css_element"
And I should not see "Move page left" in the "#section-1" "css_element"
And I click on "Move page right" "link" in the "#section-1" "css_element"
And I should see "Section A" in the "#section-3" "css_element"
And I should see "Test forum name A" in the "#section-3" "css_element"
And I should see "Move page left" in the "#section-3" "css_element"
And I should not see "Move page right" in the "#section-3" "css_element"
And I click on "Move page left" "link" in the "#section-3" "css_element"
And I should see "Section A" in the "#section-1" "css_element"
And I should see "Test forum name A" in the "#section-1" "css_element"

Scenario: Move second-level page forward and back
Given I click on "Section A" "link" in the ".course-content .nav" "css_element"
And I click on "Section B" "link" in the ".course-content .nav ~ .nav" "css_element"
Then I should see "Section B" in the "#section-2" "css_element"
Given I click on "Section 1" "link" in the ".course-content .nav" "css_element"
And I click on "Section 2" "link" in the ".course-content .nav ~ .nav" "css_element"
Then I should see "Test forum name B" in the "#section-2" "css_element"
And I should see "Move page left" in the "#section-2" "css_element"
And I should see "Move page right" in the "#section-2" "css_element"
And I click on "Move page right" "link" in the "#section-2" "css_element"
And I should see "Section B" in the "#section-4" "css_element"
And I should see "Test forum name B" in the "#section-4" "css_element"
And I should see "Move page left" in the "#section-4" "css_element"
And I should not see "Move page right" in the "#section-4" "css_element"
And I click on "Move page left" "link" in the "#section-4" "css_element"
And I should see "Section B" in the "#section-2" "css_element"
And I should see "Test forum name B" in the "#section-2" "css_element"

Scenario: Raise and lower page level
Given I click on "Section A" "link" in the ".course-content .nav" "css_element"
And I click on "Section B" "link" in the ".course-content .nav ~ .nav" "css_element"
Then I should see "Section B" in the "#section-2" "css_element"
Given I click on "Section 1" "link" in the ".course-content .nav" "css_element"
And I click on "Section 2" "link" in the ".course-content .nav ~ .nav" "css_element"
Then I should see "Test forum name B" in the "#section-2" "css_element"
And I should see "Raise page level" in the "#section-2" "css_element"
And I should not see "Lower page level" in the "#section-2" "css_element"
And I click on "Raise page level" "link" in the "#section-2" "css_element"
And I should see "Section B" in the "#section-2" "css_element"
And I should see "Test forum name B" in the "#section-2" "css_element"
And I should see "Lower page level" in the "#section-2" "css_element"
And I should not see "Raise page level" in the "#section-2" "css_element"
And I click on "Lower page level" "link" in the "#section-2" "css_element"
And I should see "Section B" in the "#section-2" "css_element"
And I should see "Test forum name B" in the "#section-2" "css_element"

Scenario: Move topic between pages
Given I click on "Section A" "link" in the ".course-content .nav" "css_element"
And I click on "Section B" "link" in the ".course-content .nav ~ .nav" "css_element"
Then I should see "Section C" in the "#section-3" "css_element"
Given I click on "Section 1" "link" in the ".course-content .nav" "css_element"
And I click on "Section 2" "link" in the ".course-content .nav ~ .nav" "css_element"
Then I should see "Test forum name C" in the "#section-3" "css_element"
And I should see "Move to previous page" in the "#section-3" "css_element"
And I should see "Move to next page" in the "#section-3" "css_element"
And I click on "Move to next page" "link" in the "#section-3" "css_element"
And I should see "Section C" in the "#section-5" "css_element"
And I should see "Test forum name C" in the "#section-5" "css_element"
And I should see "Move to previous page" in the "#section-5" "css_element"
And I should not see "Move to next page" in the "#section-5" "css_element"
And I click on "Move to previous page" "link" in the "#section-5" "css_element"
And I should see "Section C" in the "#section-3" "css_element"
And I should see "Test forum name C" in the "#section-3" "css_element"
50 changes: 23 additions & 27 deletions tests/behat/section_visibility.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@format @format_multitopic
@format @format_multitopic @_cross_browser
Feature: Show/hide course sections in Multitopic format
In order to delay sections availability
As a teacher
Expand All @@ -8,59 +8,55 @@ Feature: Show/hide course sections in Multitopic format
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | format | hiddensections | numsections |
| Course 1 | C1 | multitopic | 0 | 5 |
| student1 | Student | 1 | student1@example.com |
And the following "course" exists:
| fullname | Course 1 |
| shortname | C1 |
| format | multitopic |
| hiddensections | 0 |
| enablecompletion | 1 |
| numsections | 5 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I edit the section "1" and I fill the form with:
| Custom | 1 |
| New value for Section name | Section A |
| Level | 0 |
And I edit the section "2" and I fill the form with:
| Custom | 1 |
| New value for Section name | Section B |
| Level | 1 |
And I edit the section "3" and I fill the form with:
| Custom | 1 |
| New value for Section name | Section C |
| Level | 2 |
And I edit the section "4" and I fill the form with:
| Custom | 1 |
| New value for Section name | Section D |
| Level | 0 |
And I edit the section "5" and I fill the form with:
| Custom | 1 |
| New value for Section name | Section E |
| Level | 2 |
And I click on "General" "link" in the ".course-content .nav" "css_element"

Scenario: Hide and show page
Given I click on "Section A" "link" in the ".course-content .nav" "css_element"
Then I should see "Section A" in the "#section-1" "css_element"
Given I click on "Section 1" "link" in the ".course-content .nav" "css_element"
Then I should see "Section 1" in the "#section-1" "css_element"
And I hide section "1"
And section "1" should be hidden
And I click on "Section B" "link" in the ".course-content .nav ~ .nav" "css_element"
And I should see "Section B" in the "#section-2" "css_element"
And I click on "Section 2" "link" in the ".course-content .nav ~ .nav" "css_element"
And I should see "Section 2" in the "#section-2" "css_element"
And section "2" should be hidden
And I should see "Section C" in the "#section-3" "css_element"
And I should see "Section 3" in the "#section-3" "css_element"
And section "3" should be hidden
And I click on "Section D" "link" in the ".course-content .nav" "css_element"
And I should see "Section D" in the "#section-4" "css_element"
And I click on "Section 4" "link" in the ".course-content .nav" "css_element"
And I should see "Section 4" in the "#section-4" "css_element"
And section "4" should be visible
And I click on "Section A" "link" in the ".course-content .nav" "css_element"
And I should see "Section A" in the "#section-1" "css_element"
And I click on "Section 1" "link" in the ".course-content .nav" "css_element"
And I should see "Section 1" in the "#section-1" "css_element"
And I show section "1"
And section "1" should be visible

Scenario: Hide and show topic
Given I click on "Section A" "link" in the ".course-content .nav" "css_element"
And I click on "Section B" "link" in the ".course-content .nav ~ .nav" "css_element"
Then I should see "Section B" in the "#section-2" "css_element"
And I should see "Section C" in the "#section-3" "css_element"
Given I click on "Section 1" "link" in the ".course-content .nav" "css_element"
And I click on "Section 2" "link" in the ".course-content .nav ~ .nav" "css_element"
Then I should see "Section 2" in the "#section-2" "css_element"
And I should see "Section 3" in the "#section-3" "css_element"
And section "3" should be visible
And I hide section "3"
And section "3" should be hidden
Expand Down

0 comments on commit b48e737

Please sign in to comment.