From 1de1fc58f3e4ceaf84271b49a468dbc4d418a787 Mon Sep 17 00:00:00 2001 From: Mihail Geshoski Date: Tue, 5 May 2020 16:13:00 +0800 Subject: [PATCH 1/3] MDL-68576 filepicker: Fix inability to select files in table view --- repository/filepicker.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/repository/filepicker.js b/repository/filepicker.js index e65a20268f4..240147fda00 100644 --- a/repository/filepicker.js +++ b/repository/filepicker.js @@ -390,9 +390,11 @@ YUI.add('moodle-core_filepicker', function(Y) { div.appendChild(checkboxLabel); div.appendChild(checkbox); - + // Define the selector for the click event handler. + var clickEventSelector = 'tr'; // Enable the selectable checkboxes if (options.disablecheckboxes != undefined && !options.disablecheckboxes) { + clickEventSelector = 'tr td:not(:first-child)'; cols.unshift({ key: "", label: div.getContent(), @@ -411,7 +413,7 @@ YUI.add('moodle-core_filepicker', function(Y) { } Y.bind(callback, this)(e, record.getAttrs()); } - }, 'tr td:not(:first-child)', options.callbackcontext, scope.tableview); + }, clickEventSelector, options.callbackcontext, scope.tableview); if (options.rightclickcallback) { scope.tableview.delegate('contextmenu', function (e, tableview) { From cba4a1d9b377f1c7dd5efc61a6f8cbde1120ca10 Mon Sep 17 00:00:00 2001 From: Mihail Geshoski Date: Fri, 8 May 2020 16:33:57 +0800 Subject: [PATCH 2/3] MDL-68576 filepicker: Cover in behat file selection from filepicker The added behat tests would cover the issue in MDL-68576. They test whether the behaviour of a click action on a file using different views in the filepicker is consistent. --- repository/tests/behat/select_file.feature | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 repository/tests/behat/select_file.feature diff --git a/repository/tests/behat/select_file.feature b/repository/tests/behat/select_file.feature new file mode 100644 index 00000000000..e7cd4eb238e --- /dev/null +++ b/repository/tests/behat/select_file.feature @@ -0,0 +1,73 @@ +@core @core_filepicker @_file_upload +Feature: Select file feature + In order to add a file to a filearea + As a user + I need to be able to select the file using the file picker + + Background: + Given the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + + @javascript + Scenario: Select a file from the "Recent files" repository using "icons" view + Given I log in as "admin" + And I am on "Course 1" course homepage with editing mode on + And I add a "Folder" to section "1" + And I set the following fields to these values: + | Name | Test folder | + | Description | Test folder description | + And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager + And I click on "Save and display" "button" + And I follow "Dashboard" in the user menu + And I follow "Manage private files" + And I click on "//label[contains(., 'Files')]/ancestor::div[contains(concat(' ', @class, ' '), ' fitem ')]//*[contains(@title, 'Add...')]" "xpath_element" + And I click on "Recent files" "link" in the ".fp-repo-area" "css_element" + And I click on "Display folder with file icons" "link" in the ".file-picker" "css_element" + And I click on "//a[contains(concat(' ', normalize-space(@class), ' '), ' fp-file ')][normalize-space(.)='empty.txt']" "xpath_element" + And I should see "Select empty.txt" + When I click on "Select this file" "button" + Then I should see "1" elements in "Files" filemanager + And I should see "empty.txt" in the ".fp-content .fp-file" "css_element" + + @javascript + Scenario: Select a file from the "Recent files" repository using "list" view + Given I log in as "admin" + And I am on "Course 1" course homepage with editing mode on + And I add a "Folder" to section "1" + And I set the following fields to these values: + | Name | Test folder | + | Description | Test folder description | + And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager + And I click on "Save and display" "button" + And I follow "Dashboard" in the user menu + And I follow "Manage private files" + And I click on "//label[contains(., 'Files')]/ancestor::div[contains(concat(' ', @class, ' '), ' fitem ')]//*[contains(@title, 'Add...')]" "xpath_element" + And I click on "Recent files" "link" in the ".fp-repo-area" "css_element" + And I click on "Display folder with file details" "link" in the ".file-picker" "css_element" + And I click on "//div[contains(concat(' ', normalize-space(@class), ' '), ' file-picker ')]/descendant::span[normalize-space(.)='empty.txt']/ancestor::a" "xpath_element" + And I should see "Select empty.txt" + When I click on "Select this file" "button" + Then I should see "1" elements in "Files" filemanager + And I should see "empty.txt" in the ".fp-content .fp-file" "css_element" + + @javascript + Scenario: Select a file from the "Recent files" repository using "tree" view + Given I log in as "admin" + And I am on "Course 1" course homepage with editing mode on + And I add a "Folder" to section "1" + And I set the following fields to these values: + | Name | Test folder | + | Description | Test folder description | + And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager + And I click on "Save and display" "button" + And I follow "Dashboard" in the user menu + And I follow "Manage private files" + And I click on "//label[contains(., 'Files')]/ancestor::div[contains(concat(' ', @class, ' '), ' fitem ')]//*[contains(@title, 'Add...')]" "xpath_element" + And I click on "Recent files" "link" in the ".fp-repo-area" "css_element" + And I click on "Display folder as file tree" "link" in the ".file-picker" "css_element" + And I click on "//div[contains(concat(' ', normalize-space(@class), ' '), ' file-picker ')]/descendant::span[normalize-space(.)='empty.txt']/ancestor::a" "xpath_element" + And I should see "Select empty.txt" + When I click on "Select this file" "button" + Then I should see "1" elements in "Files" filemanager + And I should see "empty.txt" in the ".fp-content .fp-file" "css_element" From 90feebe486b35a800153bd750e6a7b3a8b17f6be Mon Sep 17 00:00:00 2001 From: Mihail Geshoski Date: Fri, 8 May 2020 16:58:43 +0800 Subject: [PATCH 3/3] MDL-68576 filepicker: Cover in behat file edition in filemanager The added behat tests would also confirm whether the behaviour of a click action on a file using different views in the filemanager is consistent. --- repository/tests/behat/edit_file.feature | 55 ++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 repository/tests/behat/edit_file.feature diff --git a/repository/tests/behat/edit_file.feature b/repository/tests/behat/edit_file.feature new file mode 100644 index 00000000000..d58204df408 --- /dev/null +++ b/repository/tests/behat/edit_file.feature @@ -0,0 +1,55 @@ +@core @core_filepicker @_file_upload +Feature: Edit file feature + In order to edit a file + As a user + I need to be able to select the file in filemanager and modify the file information + + Background: + Given the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + + @javascript + Scenario: Select file from "Files" filemanager using "icons" view and edit the name + Given I log in as "admin" + And I follow "Manage private files" + And I click on "Display folder with file icons" "link" in the ".filemanager" "css_element" + And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager + And I should see "empty.txt" in the ".fp-content .fp-file" "css_element" + And I click on "//div[contains(concat(' ', normalize-space(@class), ' '), ' fp-file ')]/descendant::a[normalize-space(.)='empty.txt']" "xpath_element" + And I should see "Edit empty.txt" + And I set the following fields to these values: + | Name | empty_edited.txt | + When I click on "Update" "button" + Then I should see "empty_edited.txt" in the ".fp-content .fp-file" "css_element" + And I should not see "empty.txt" in the ".fp-content .fp-file" "css_element" + + @javascript + Scenario: Select file from "Files" filemanager using "list" view and edit the name + Given I log in as "admin" + And I follow "Manage private files" + And I click on "Display folder with file details" "link" in the ".filemanager" "css_element" + And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager + And I should see "empty.txt" in the ".fp-content .fp-filename" "css_element" + And I click on "//span[contains(concat(' ', normalize-space(@class), ' '), ' fp-filename-icon ')]/descendant::a[normalize-space(.)='empty.txt']" "xpath_element" + And I should see "Edit empty.txt" + And I set the following fields to these values: + | Name | empty_edited.txt | + When I click on "Update" "button" + Then I should see "empty_edited.txt" in the ".fp-content .fp-filename" "css_element" + And I should not see "empty.txt" in the ".fp-content .fp-filename" "css_element" + + @javascript + Scenario: Select file from "Files" filemanager using "tree" view and edit the name + Given I log in as "admin" + And I follow "Manage private files" + And I click on "Display folder as file tree" "link" in the ".filemanager" "css_element" + And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager + And I should see "empty.txt" in the ".fp-content .fp-hascontextmenu .fp-filename" "css_element" + And I click on "//span[contains(concat(' ', normalize-space(@class), ' '), ' fp-filename-icon ')]/descendant::a[normalize-space(.)='empty.txt']" "xpath_element" + And I should see "Edit empty.txt" + And I set the following fields to these values: + | Name | empty_edited.txt | + When I click on "Update" "button" + Then I should see "empty_edited.txt" in the ".fp-content .fp-hascontextmenu .fp-filename" "css_element" + And I should not see "empty.txt" in the ".fp-content .fp-hascontextmenu .fp-filename" "css_element"