From 49e490d20949ecf62f8a504ef5b8b34f0ea63645 Mon Sep 17 00:00:00 2001 From: Angelia Dela Cruz Date: Wed, 12 Feb 2025 14:28:31 +0800 Subject: [PATCH] MDL-84424 tool_lp: admin can create learning plans from template --- .../lp/tests/behat/link_unlink_lp.feature | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 admin/tool/lp/tests/behat/link_unlink_lp.feature diff --git a/admin/tool/lp/tests/behat/link_unlink_lp.feature b/admin/tool/lp/tests/behat/link_unlink_lp.feature new file mode 100644 index 00000000000..80ef97ced9d --- /dev/null +++ b/admin/tool/lp/tests/behat/link_unlink_lp.feature @@ -0,0 +1,78 @@ +@tool @tool_lp @tool_lp_plan +Feature: Admin can create learning plans from template + In order to link and unlink a learning plan from a student + As an admin + I need to be able to create a learning plan from template + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Student | One | student1@email.com | + # Create competency frameworks. + And the following "core_competency > frameworks" exist: + | shortname | idnumber | + | CF1 | CF1 | + | CF2 | CF2 | + # Add competency to each competency frameworks. + And the following "core_competency > competencies" exist: + | shortname | competencyframework | idnumber | + | CF1 Competency 1 | CF1 | CF1C1 | + | CF2 Competency 1 | CF2 | CF2C1 | + # Create a learning plan template. + And the following "core_competency > templates" exist: + | shortname | description | + | LPT1 | LPT 1 description | + And I log in as "admin" + + @javascript + Scenario: Admin can assign competencies from different frameworks to a learning plan + Given I navigate to "Competencies > Learning plan templates" in site administration + And I click on "LPT1" "link" + # Add a competency in learning plan template. + When I press "Add competencies to learning plan template" + And I select "CF1 Competency 1" of the competency tree + And I click on "Add" "button" in the "Competency picker" "dialogue" + And I press "Add competencies to learning plan template" + # Add another competency from a different framework in the learning plan template. + And I set the field with xpath "//select[@data-action='chooseframework']" to "CF2 CF2" + And I select "CF2 Competency 1" of the competency tree + And I click on "Add" "button" in the "Competency picker" "dialogue" + # Confirm that both competencies from different frameworks are successfully added to learning plan template. + Then "LPT1" "text" should exist + And "Learning plan template competencies" "text" should exist + And "CF1 Competency 1" "text" should exist + And "CF2 Competency 1" "text" should exist + + @javascript + Scenario: Admin can link and unlink learning plans created from template + Given I navigate to "Competencies > Learning plan templates" in site administration + And I click on "LPT1" "link" + # Add a competency in learning plan template. + And I press "Add competencies to learning plan template" + And I select "CF1 Competency 1" of the competency tree + And I click on "Add" "button" in the "Competency picker" "dialogue" + And I navigate to "Competencies > Learning plan templates" in site administration + # Initially, the number of learning plans is 0. + And the following should exist in the "generaltable" table: + | Name | Learning plans | + | LPT1 | 0 | + And I click on ".template-userplans" "css_element" in the "LPT1" "table_row" + # Create a learning plan for selected student using template. + When I set the field "Select users" to "student1" + And I press "Create learning plans" + # Confirm that selected student is now in the list of learning plans. + Then "A learning plan was created" "text" should exist + And the following should exist in the "generaltable" table: + | Name | Email address | + | LPT1 | student1@email.com | + And I click on "LPT1" "link" in the "LPT1" "table_row" + # Template title and Unlink from learning plan template link exists. + And "Learning plan template" "text" should exist + And "Unlink from learning plan template" "link" should exist + # Unlink the template. + And I click on "Unlink from learning plan template" "link" + And I press "Unlink from learning plan template" + # Learning plan stil exists but Template name and Unlink from learning plan template link no longer exist. + And "LPT1" "text" should exist + And "Learning plan template" "text" should not exist + And "Unlink from learning plan template" "link" should not exist