MDL-83696 core_tag: Added behat for book chapter and glossary entry tags

This commit is contained in:
Angelia Dela Cruz 2024-11-19 19:26:42 +08:00
parent aa55f38820
commit 2e49bf766a
2 changed files with 115 additions and 11 deletions

View File

@ -1,4 +1,4 @@
@mod @mod_book @core_tag @javascript
@mod @mod_book @core_tag
Feature: Edited book chapters handle tags correctly
In order to get book chapters properly labelled
As a user
@ -6,9 +6,10 @@ Feature: Edited book chapters handle tags correctly
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
| student2 | Student | 2 | student2@example.com |
And the following "courses" exist:
| fullname | shortname | format |
| Course 1 | C1 | topics |
@ -21,7 +22,11 @@ Feature: Edited book chapters handle tags correctly
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| tags | System | 1 | my-index | side-pre |
@javascript
Scenario: Book chapter edition of custom tags works as expected
Given I am on the "Test book" "book activity" page logged in as teacher1
And I set the following fields to these values:
@ -63,3 +68,51 @@ Feature: Edited book chapters handle tags correctly
And I should see "OT1" in the ".form-autocomplete-selection" "css_element"
And I should see "OT3" in the ".form-autocomplete-selection" "css_element"
And I should not see "OT2" in the ".form-autocomplete-selection" "css_element"
@javascript
Scenario: Deleting book chapter tags
# Add a book chapter with tags.
Given the following "mod_book > chapters" exist:
| book | title | content | tags |
| book1 | Dummy first chapter | Dream is the start of a journey | Example, Chapter, Cool |
And I am on the "Test book" "book activity" page logged in as teacher1
And I turn editing mode on
When I follow "Edit chapter \"1. Dummy first chapter\""
# Delete one of the book chapter tags.
And I click on "[data-value='Example']" "css_element"
And I press "Save changes"
# Confirm that the deleted tag no longer exists in the book chapter.
Then I should not see "Example" in the ".book-tags" "css_element"
And I should see "Chapter" in the ".book-tags" "css_element"
And I should see "Cool" in the ".book-tags" "css_element"
Scenario: Duplicating book chapter tags
# Add a book chapter with tags.
Given the following "mod_book > chapters" exist:
| book | title | content | tags |
| book1 | Dummy first chapter | Dream is the start of a journey | Example, Chapter, Cool |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
# Duplicate the book activity.
When I duplicate "Test book" activity
# Confirm that the book activity duplicate contains all the tags from the original activity.
Then I should see "Test book (copy)"
And I am on the "Test book (copy)" "book activity" page
And I should see "Example" in the ".book-tags" "css_element"
And I should see "Chapter" in the ".book-tags" "css_element"
And I should see "Cool" in the ".book-tags" "css_element"
Scenario Outline: Only enrolled users can see book chapters by tags
# Add a book chapter with tags.
Given the following "mod_book > chapters" exist:
| book | title | content | tags |
| book1 | Dummy first chapter | Dream is the start of a journey | Example, Chapter, Cool |
When I log in as "<user>"
And I click on "Chapter" "link" in the "Tags" "block"
Then I <chaptervisibility> see "Dummy first chapter"
Examples:
| user | chaptervisibility |
| teacher1 | should |
| student1 | should |
| student2 | should not |

View File

@ -1,4 +1,4 @@
@mod @mod_glossary @core_tag @javascript
@mod @mod_glossary @core_tag
Feature: Edited glossary entries handle tags correctly
In order to get glossary entries properly labelled
As a user
@ -6,22 +6,28 @@ Feature: Edited glossary entries handle tags correctly
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
| student2 | Student | 2 | student2@example.com |
And the following "courses" exist:
| fullname | shortname | format |
| Course 1 | C1 | topics |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
And the following "activity" exists:
| course | C1 |
| activity | glossary |
| name | Test glossary |
| intro | A glossary about dreams! |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| tags | System | 1 | my-index | side-pre |
@javascript
Scenario: Glossary entry edition of custom tags works as expected
Given I am on the "Test glossary" "glossary activity" page logged in as teacher1
And I press "Add entry"
@ -39,6 +45,7 @@ Feature: Edited glossary entries handle tags correctly
Then I should see "Entry" in the ".form-autocomplete-selection" "css_element"
Then I should see "Cool" in the ".form-autocomplete-selection" "css_element"
@javascript
Scenario: Glossary entry edition of standard tags works as expected
Given the following "tags" exist:
| name | isstandard |
@ -65,3 +72,47 @@ Feature: Edited glossary entries handle tags correctly
And I should see "OT1" in the ".form-autocomplete-selection" "css_element"
And I should see "OT3" in the ".form-autocomplete-selection" "css_element"
And I should not see "OT2" in the ".form-autocomplete-selection" "css_element"
@javascript
Scenario: Student delete glossary entry tags
# Add glossary entry with tags as an enrolled student.
Given the following "mod_glossary > entries" exist:
| glossary | concept | definition | tags | user |
| Test glossary | Entry 1 | Entry 1 definition | OT1, OT2, OT3 | student1 |
And I am on the "Test glossary" "glossary activity" page logged in as student1
When I click on "Edit entry: Entry 1" "link"
And I expand all fieldsets
# Delete a glossary entry tag.
And I click on "[data-value='OT1']" "css_element"
And I press "Save changes"
# Confirm that only the selected glossary entry tag is deleted.
Then I should not see "OT1" in the ".glossary-tags" "css_element"
And I should see "OT2" in the ".glossary-tags" "css_element"
And I should see "OT3" in the ".glossary-tags" "css_element"
Scenario Outline: Student glossary entry tags can be viewed depending on approval
# Add glossary entry with tags as an enrolled student.
Given the following "mod_glossary > entries" exist:
| glossary | concept | definition | tags | user | approved |
| Test glossary | Entry 1 | Entry 1 definition | OT1, OT2, OT3 | student1 | <approved> |
When I log in as "student2"
And I click on "OT1" "link" in the "Tags" "block"
Then I <entryvisibility> see "Entry 1"
Examples:
| approved | entryvisibility |
| 0 | should not |
| 1 | should |
@javascript
Scenario: Hidden glossary activity is not visible in tag index
Given the following "mod_glossary > entries" exist:
| glossary | concept | definition | tags | user |
| Test glossary | Entry 1 | Entry 1 definition | OT1, OT2, OT3 | student1 |
And I am on the "Course 1" course page logged in as teacher1
And I turn editing mode on
And I open "Test glossary" actions menu
And I click on "Hide" "link" in the "Test glossary" activity
When I log in as "student2"
And I click on "OT1" "link" in the "Tags" "block"
Then I should not see "Entry 1"