From 0c0b4b69c988ec812a42bbecb536939f94e6e68d Mon Sep 17 00:00:00 2001 From: Angelia Dela Cruz Date: Mon, 1 Dec 2025 10:45:40 +0800 Subject: [PATCH] MDL-87070 mod_glossary: Behat to confirm glossary autolinking works --- .../tests/behat/glossary_autolink.feature | 162 +++++++++++++++++- 1 file changed, 154 insertions(+), 8 deletions(-) diff --git a/public/mod/glossary/tests/behat/glossary_autolink.feature b/public/mod/glossary/tests/behat/glossary_autolink.feature index 4d1d3f02439..a14dbdcddd0 100644 --- a/public/mod/glossary/tests/behat/glossary_autolink.feature +++ b/public/mod/glossary/tests/behat/glossary_autolink.feature @@ -1,7 +1,7 @@ @mod @mod_glossary -Feature: Glossary can set autolinked entries in text and media areas - In order to display the glossary entries for concepts in texts - As a teacher +Feature: Glossary entries are displayed properly when autolinked + In order to display linked glossary entries for concepts + As an admin I can set the glossary activity to autolink the entries Background: @@ -18,21 +18,167 @@ Feature: Glossary can set autolinked entries in text and media areas | teacher1 | C1 | editingteacher | | student1 | C1 | student | And the following "activities" exist: - | activity | name | intro | displayformat | course | idnumber | - | glossary | Test glossaryglossaireglossario | Test glossary description | encyclopedia | C1 | glossary1 | + | activity | name | intro | displayformat | course | idnumber | globalglossary | + | glossary | Test glossaryglossaireglossario | Test glossary description | encyclopedia | C1 | glossary1 | 0 | + | glossary | Autolinked Glossary | Autolinked glossary description | encyclopedia | Acceptance test site | glossary2 | 1 | And the following "mod_glossary > entries" exist: | glossary | concept | definition | usedynalink | | glossary1 | EnglishAnglaisinglés | Relating to England, its people, or the language spoken there.Relatif à l'Angleterre, à son peuple ou à la langue parlée là-bas.Relacionado con Inglaterra, su gente o el idioma hablado allí. | 1 | - | glossary1 | SpanishEspagnolCastellano | Relating to Spain, its people, or the language spoken there.Relatif à l'Espagne, à son peuple ou à la langue parlée là-bas.Relacionado con España, su gente o el idioma hablado allí. | 1 | + | glossary1 | SpanishEspagnolCastellano | Relating to Spain, its people, or the language spoken there.Relatif à l'Espagne, à son peuple ou à la langue parlée là-bas.Relacionado con España, su gente o el idioma hablado allí. | 1 | + | glossary2 | Linked entry | This is the linked entry definition | 1 | + | glossary2 | Normal entry | This is the normal entry definition | 0 | And the following "activities" exist: - | activity | name | intro | course | idnumber | - | label | Text and media area |

This is a text with the multilang syntax on the EnglishAnglaisInglés word that should be auto-linked.

This are plain text words that should also be auto-linked: English, Anglais, Inglés.

| C1 | label1 | + | activity | name | intro | course | idnumber | content | showdescription | + | label | Text and media area |

This is a text with the multilang syntax on the EnglishAnglaisInglés word that should be auto-linked.

This are plain text words that should also be auto-linked: English, Anglais, Inglés.

| C1 | label1 | | 0 | And the "glossary" filter is "on" And the following "language pack" exists: | language | fr | es | And the "multilang" filter is "on" And the "multilang" filter applies to "content and headings" + Scenario: Autolinked glossary entries are correctly linked in front page context + Given I log in as "admin" + When I am on site homepage + And I turn editing mode on + And I follow "Edit" + And I set the following fields to these values: + | Description | This is a Linked entry. This is a Normal entry | + And I press "Save changes" + # Confirm that the text "linked entry" is automatically linked when referenced. + Then "Linked entry" "link" should exist + # Confirm that the text "normal entry" is not linked when referenced. + And "Normal entry" "link" should not exist + And "Normal entry" "text" should exist + + Scenario: Autolinked glossary entries are correctly linked in course category + Given I log in as "admin" + And I navigate to "Courses > Manage courses and categories" in site administration + And I click on "edit" action for "Category 1" in management category listing + And I set the following fields to these values: + | Description | This is a Linked entry. This is a Normal entry | + And I press "Save changes" + When I click on "view" action for "Category 1" in management category listing + # Confirm that the text "linked entry" is automatically linked when referenced. + Then "Linked entry" "link" should exist + # Confirm that the text "normal entry" is not linked when referenced. + And "Normal entry" "link" should not exist + And "Normal entry" "text" should exist + + Scenario: Autolinked glossary entries are correctly linked in course summary + # Course summary is automatically generated so editing it is necessary. + Given I am on the "Course 1" "course editing" page logged in as "teacher1" + And I set the following fields to these values: + | Course summary | This is a Linked entry. This is the Normal entry | + And I press "Save and display" + When I am on site homepage + # Confirm that the text "linked entry" is automatically linked when referenced. + Then "Linked entry" "link" should exist + # Confirm that the text "normal entry" is not linked when referenced. + And "Normal entry" "link" should not exist + And "Normal entry" "text" should exist + + Scenario Outline: Autolinked glossary entries are correctly linked in text and media areas and url + Given the following "activities" exist: + | activity | name | intro | course | showdescription | + | | | This is a Linked entry. This is a Normal entry | C1 | 1 | + When I am on the "Course 1" course page logged in as teacher1 + # Confirm that the text "linked entry" is automatically linked when referenced. + Then "Linked entry" "link" should exist + # Confirm that the text "normal entry" is not linked when referenced. + And "Normal entry" "link" should not exist + And "Normal entry" "text" should exist + + Examples: + | activityname | activitytype | + | Text and media area | label | + | Url 1 | url | + + @javascript + Scenario: Autolinked glossary entries are correctly linked in text blocks + Given I am on the "Course 1" course page logged in as teacher1 + And I turn editing mode on + When I add the "Text" block to the default region with: + | Text block title | Text block | + | Content | This is a Linked entry. This is the Normal entry | + # Confirm that the text "linked entry" is automatically linked when referenced. + And "Linked entry" "link" should exist + # Confirm that the text "normal entry" is not linked when referenced. + And "Normal entry" "link" should not exist + And "Normal entry" "text" should exist + + Scenario Outline: Autolinked glossary entries are correctly linked in activities and resources + Given the following "activities" exist: + | activity | name | intro | course | content | + | | | This is a Linked entry. This is a Normal entry | C1 | | + When I am on the "" " activity" page logged in as teacher1 + # Confirm that the text "linked entry" is automatically linked when referenced. + Then "Linked entry" "link" should exist + # Confirm that the text "normal entry" is not linked when referenced. + And "Normal entry" "link" should not exist + And "Normal entry" "text" should exist + + Examples: + | activityname | activitytype | pagecontent | + | Page 1 | page | This is a Linked entry. This is a Normal entry | + | Assign 1 | assign | | + | Folder 1 | folder | | + | Quiz 1 | quiz | | + | Workshop 1 | workshop | | + | Choice 1 | choice | | + + Scenario: Autolinked glossary entries are correctly linked in database + Given the following "activities" exist: + | activity | name | intro | course | idnumber | + | data | Database 1 | This is a Linked entry. This is a Normal entry | C1 | data1 | + And the following "mod_data > fields" exist: + | database | type | name | description | + | data1 | text | Test field name | Test field description | + And the following "mod_data > entries" exist: + | database | user | Test field name | + | data1 | student1 | Student entry | + When I am on the "Database 1" "data activity" page logged in as teacher1 + # Confirm that the text "linked entry" is automatically linked when referenced in list view. + Then "Linked entry" "link" should exist + # Confirm that the text "normal entry" is not linked when referenced in list view. + And "Normal entry" "link" should not exist + And "Normal entry" "text" should exist + And I select "Single view" from the "jump" singleselect + # Confirm that the text "linked entry" is automatically linked when referenced in single view. + And "Linked entry" "link" should exist + # Confirm that the text "normal entry" is not linked when referenced in single view. + And "Normal entry" "link" should not exist + And "Normal entry" "text" should exist + + Scenario: Autolinked glossary entries are correctly linked in wiki page + Given the following "activities" exist: + | activity | course | name | wikimode | + | wiki | C1 | Wiki 1 | collaborative | + When I am on the "Wiki 1" "wiki activity" page logged in as teacher1 + And I press "Create page" + And I set the following fields to these values: + | HTML format | This is a Linked entry. This is a Normal entry. | + And I press "Save" + # Confirm that the text "linked entry" is automatically linked when referenced. + Then "Linked entry" "link" should exist + # Confirm that the text "normal entry" is not linked when referenced. + And "Normal entry" "link" should not exist + And "Normal entry" "text" should exist + + Scenario: Autolinked glossary entries are correctly linked in forum posts + Given the following "activities" exist: + | activity | course | name | idnumber | + | forum | C1 | Forum 1 | forum1 | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | teacher1 | forum1 | Discussion 1 | This is a Linked entry. This is a Normal entry. | + And I am on the "Course 1" course page logged in as teacher1 + When I navigate to post "Discussion 1" in "Forum 1" forum + # Confirm that the text "linked entry" is automatically linked when referenced. + Then "Linked entry" "link" should exist + # Confirm that the text "normal entry" is not linked when referenced. + And "Normal entry" "link" should not exist + And "Normal entry" "text" should exist + @javascript Scenario: Glossary entries show up in text and media areas in the correct user interface/language combination When I am on the "Course 1" course page logged in as teacher1