From d9d8a1ad365171e513287bce5956e821e01f2cd5 Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Mon, 20 Feb 2023 19:15:49 +0800 Subject: [PATCH 1/2] MDL-77271 behat: test to verify used licence cannot be deleted --- .../tests/behat/delete_license.feature | 23 +++++++++++++++++++ .../tests/behat/license_manager.feature | 15 ++++++++++++ 2 files changed, 38 insertions(+) diff --git a/admin/tool/licensemanager/tests/behat/delete_license.feature b/admin/tool/licensemanager/tests/behat/delete_license.feature index 8648d55242d..cdba0bff1b6 100644 --- a/admin/tool/licensemanager/tests/behat/delete_license.feature +++ b/admin/tool/licensemanager/tests/behat/delete_license.feature @@ -24,3 +24,26 @@ Feature: Delete custom licenses And I navigate to "Licence > Licence manager" in site administration Then I should see "Licence not specified" in the "unknown" "table_row" And I should not see "Delete" in the "unknown" "table_row" + + @javascript @_file_upload + Scenario: I cannot delete a custom license in use + Given I log in as "admin" + And I navigate to "Licence > Licence manager" in site administration + And I click on "Create licence" "link" + And I set the following fields to these values: + | shortname | Test licence | + | fullname | Test licence | + | source | https://opensource.org/licenses/MIT | + | Licence version | ##1 March 2019## | + And I press "Save changes" + And I follow "Private files" in the user menu + And I upload "lib/editor/atto/tests/fixtures/moodle-logo.png" file to "Files" filemanager + And I click on "moodle-logo.png" "link" + And I set the field "Choose licence" to "Test licence" + And I press "Update" + And I press "Save changes" + And I am on site homepage + And I navigate to "Licence > Licence manager" in site administration + And I click on "Delete" "icon" in the "Test licence" "table_row" + When I click on "Save changes" "button" in the "Delete licence" "dialogue" + Then I should see "Cannot delete a licence which is currently assigned to one or more files" diff --git a/admin/tool/licensemanager/tests/behat/license_manager.feature b/admin/tool/licensemanager/tests/behat/license_manager.feature index 0ff21b929d1..a420c7152d2 100644 --- a/admin/tool/licensemanager/tests/behat/license_manager.feature +++ b/admin/tool/licensemanager/tests/behat/license_manager.feature @@ -33,3 +33,18 @@ Feature: Licence manager And "This is the site default licence" "icon" should exist in the "cc" "table_row" And "Enable licence" "icon" should not exist in the "cc" "table_row" And "This is the site default licence" "icon" should not exist in the "public" "table_row" + + @javascript @_file_upload + Scenario: User default licence preference is remembered + Given I log in as "admin" + And I navigate to "Licence > Licence settings" in site administration + And I set the following fields to these values: + | Default site licence | cc | + | Remember user licence preference | 0 | + And I press "Save changes" + And I follow "Private files" in the user menu + And I follow "Add..." + And I follow "Upload a file" + #And the field "licence" matches value "cc" + #And the field with xpath "//select[@name='licence']" matches value "cc" + #Then the "data-initial-value" attribute of "[name='licence']" "css_element" should contain "cc" From 26cf7b3fa977194bfd03349c7b01862f6d1b563c Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Tue, 21 Feb 2023 12:19:40 +0800 Subject: [PATCH 2/2] MDL-77271 behat: verify user licence preference is remembered --- .../tests/behat/license_manager.feature | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/admin/tool/licensemanager/tests/behat/license_manager.feature b/admin/tool/licensemanager/tests/behat/license_manager.feature index a420c7152d2..5ab86353b30 100644 --- a/admin/tool/licensemanager/tests/behat/license_manager.feature +++ b/admin/tool/licensemanager/tests/behat/license_manager.feature @@ -35,16 +35,24 @@ Feature: Licence manager And "This is the site default licence" "icon" should not exist in the "public" "table_row" @javascript @_file_upload - Scenario: User default licence preference is remembered - Given I log in as "admin" - And I navigate to "Licence > Licence settings" in site administration - And I set the following fields to these values: - | Default site licence | cc | - | Remember user licence preference | 0 | - And I press "Save changes" + Scenario Outline: User licence preference is remembered depending of setting value + Given the following config values are set as admin: + | sitedefaultlicense | cc | + | rememberuserlicensepref | | + And I log in as "admin" And I follow "Private files" in the user menu And I follow "Add..." And I follow "Upload a file" - #And the field "licence" matches value "cc" - #And the field with xpath "//select[@name='licence']" matches value "cc" - #Then the "data-initial-value" attribute of "[name='licence']" "css_element" should contain "cc" + And the field with xpath "//select[@name='license']" matches value "Creative Commons" + And I click on "Close" "button" in the "File picker" "dialogue" + When I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager as: + | Save as | empty_copy.txt | + | license | Public domain | + And I press "Save changes" + And I follow "Add..." + Then the field with xpath "//select[@name='license']" matches value "" + + Examples: + | rememberuserlicensepref | expectedlicence | + | 0 | Creative Commons | + | 1 | Public domain |