2017-04-30 01:21:34 +08:00
|
|
|
#
|
|
|
|
# Copyright (C) 2015 - present Instructure, Inc.
|
|
|
|
#
|
|
|
|
# This file is part of Canvas.
|
|
|
|
#
|
|
|
|
# Canvas is free software: you can redistribute it and/or modify it under
|
|
|
|
# the terms of the GNU Affero General Public License as published by the Free
|
|
|
|
# Software Foundation, version 3 of the License.
|
|
|
|
#
|
|
|
|
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
|
|
# details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License along
|
|
|
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2015-07-22 05:25:39 +08:00
|
|
|
require File.expand_path(File.dirname(__FILE__) + '/common')
|
|
|
|
require File.expand_path(File.dirname(__FILE__) + '/helpers/files_common')
|
|
|
|
|
|
|
|
describe "better_file_browsing" do
|
2015-08-08 06:24:05 +08:00
|
|
|
include_context "in-process server selenium tests"
|
2015-11-14 02:58:49 +08:00
|
|
|
include FilesCommon
|
|
|
|
|
2015-07-22 05:25:39 +08:00
|
|
|
context "as a student" do
|
2016-12-21 08:09:11 +08:00
|
|
|
before :once do
|
|
|
|
@student = course_with_student(active_all: true).user
|
|
|
|
end
|
|
|
|
|
|
|
|
before :each do
|
2015-07-22 05:25:39 +08:00
|
|
|
user_session(@student)
|
|
|
|
end
|
|
|
|
|
|
|
|
def verify_hidden_item_not_searchable_as_student(search_text)
|
2016-12-21 08:09:11 +08:00
|
|
|
f("input[type='search']").send_keys "#{search_text}", :return
|
|
|
|
expect(f("body")).not_to contain_css(".ef-item-row")
|
2015-07-22 05:25:39 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
context "in course with files" do
|
2016-12-21 08:09:11 +08:00
|
|
|
before :once do
|
2015-07-22 05:25:39 +08:00
|
|
|
txt_files = ["a_file.txt", "b_file.txt", "c_file.txt"]
|
2016-12-21 08:09:11 +08:00
|
|
|
@files = txt_files.map do |text_file|
|
2015-07-22 05:25:39 +08:00
|
|
|
add_file(fixture_file_upload("files/#{text_file}", 'text/plain'), @course, text_file)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-03-21 04:04:22 +08:00
|
|
|
it "should search for a file", priority: "1", test_id: 220355 do
|
2016-12-21 08:09:11 +08:00
|
|
|
get "/courses/#{@course.id}/files"
|
|
|
|
f("input[type='search']").send_keys "b_fi", :return
|
|
|
|
expect(all_files_folders).to have_size 1
|
2015-07-22 05:25:39 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should not return unpublished files in search results", priority: "1", test_id: 238870 do
|
2016-12-21 08:09:11 +08:00
|
|
|
@files[0].update_attribute(:locked, true)
|
2015-07-22 05:25:39 +08:00
|
|
|
get "/courses/#{@course.id}/files"
|
|
|
|
verify_hidden_item_not_searchable_as_student("a_fi")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should not return hidden files in search results", priority: "1", test_id: 238871 do
|
2016-12-21 08:09:11 +08:00
|
|
|
@files[0].update_attribute(:hidden, true)
|
2015-07-22 05:25:39 +08:00
|
|
|
get "/courses/#{@course.id}/files"
|
|
|
|
verify_hidden_item_not_searchable_as_student("a_fi")
|
|
|
|
end
|
2015-08-29 07:45:25 +08:00
|
|
|
|
|
|
|
it "should not see upload file, add folder buttons and cloud icon", priority: "1", test_id: 327118 do
|
2016-12-21 08:09:11 +08:00
|
|
|
get "/courses/#{@course.id}/files"
|
2016-05-01 06:23:03 +08:00
|
|
|
content = f("#content")
|
|
|
|
expect(content).not_to contain_css('.btn-upload')
|
|
|
|
expect(content).not_to contain_css('.btn-add-folder')
|
|
|
|
expect(content).not_to contain_css('.btn-link.published-status')
|
2015-08-29 07:45:25 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should only see Download option on cog icon", priority: "1", test_id: 133105 do
|
2017-11-13 08:37:07 +08:00
|
|
|
skip_if_safari(:alert)
|
2016-12-21 08:09:11 +08:00
|
|
|
get "/courses/#{@course.id}/files"
|
2016-05-01 06:23:03 +08:00
|
|
|
content = f("#content")
|
2016-12-21 08:09:11 +08:00
|
|
|
f('.al-trigger-gray').click
|
2015-08-29 07:45:25 +08:00
|
|
|
expect(fln("Download")).to be_displayed
|
2016-05-01 06:23:03 +08:00
|
|
|
expect(content).not_to contain_link("Rename")
|
|
|
|
expect(content).not_to contain_link("Move")
|
|
|
|
expect(content).not_to contain_link("Delete")
|
2015-08-29 07:45:25 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should only see View and Download options on toolbar menu", priority: "1", test_id: 133109 do
|
2016-12-21 08:09:11 +08:00
|
|
|
get "/courses/#{@course.id}/files"
|
2016-05-01 06:23:03 +08:00
|
|
|
content = f("#content")
|
2016-12-21 08:09:11 +08:00
|
|
|
f('.ef-item-row').click
|
2015-08-29 07:45:25 +08:00
|
|
|
expect(f('.btn-download')).to be_displayed
|
|
|
|
expect(f('.btn-view')).to be_displayed
|
2016-05-01 06:23:03 +08:00
|
|
|
expect(content).not_to contain_css('.btn-move')
|
|
|
|
expect(content).not_to contain_css('.btn-restrict')
|
|
|
|
expect(content).not_to contain_css('.btn-delete')
|
2015-08-29 07:45:25 +08:00
|
|
|
end
|
2015-11-16 18:02:15 +08:00
|
|
|
|
|
|
|
it "should see calendar icon on restricted files within a given timeframe", priority: "1", test_id: 133108 do
|
2020-01-09 07:39:02 +08:00
|
|
|
@files[0].update unlock_at: Time.zone.now - 1.week,
|
2016-12-21 08:09:11 +08:00
|
|
|
lock_at: Time.zone.now + 1.week
|
2015-11-16 18:02:15 +08:00
|
|
|
get "/courses/#{@course.id}/files"
|
|
|
|
expect(f('.icon-calendar-day')).to be_displayed
|
|
|
|
f('.icon-calendar-day').click
|
|
|
|
wait_for_ajaximations
|
2016-12-21 08:09:11 +08:00
|
|
|
expect(f("body")).not_to contain_css("[name=permissions]")
|
2015-11-16 18:02:15 +08:00
|
|
|
end
|
2015-07-22 05:25:39 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
context "in course with folders" do
|
2016-12-21 08:09:11 +08:00
|
|
|
before :once do
|
|
|
|
@folder = folder_model(name: "restricted_folder", context: @course)
|
|
|
|
@file = add_file(fixture_file_upload('files/example.pdf', 'application/pdf'),
|
|
|
|
@course, "example.pdf", @folder)
|
2015-07-22 05:25:39 +08:00
|
|
|
end
|
|
|
|
|
2016-12-21 08:09:11 +08:00
|
|
|
it "should not return files from hidden folders in search results", priority: "1", test_id: 171774 do
|
|
|
|
@folder.update_attribute :hidden, true
|
|
|
|
get "/courses/#{@course.id}/files"
|
2015-07-22 05:25:39 +08:00
|
|
|
verify_hidden_item_not_searchable_as_student("example")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should not return files from unpublished folders in search results", priority: "1", test_id: 171774 do
|
2016-12-21 08:09:11 +08:00
|
|
|
@folder.update_attribute :locked, true
|
|
|
|
get "/courses/#{@course.id}/files"
|
2015-07-22 05:25:39 +08:00
|
|
|
verify_hidden_item_not_searchable_as_student("example")
|
|
|
|
end
|
2015-11-03 23:39:12 +08:00
|
|
|
|
|
|
|
it "should let student access files in restricted folder hidden by link", priority: "1", test_id: 134750 do
|
2016-12-21 08:09:11 +08:00
|
|
|
@folder.update_attribute :hidden, true
|
|
|
|
|
|
|
|
get "/courses/#{@course.id}/files/folder/restricted_folder?preview=#{@file.id}"
|
|
|
|
refresh_page # the header seriously doesn't show up until you refres ¯\_(ツ)_/¯
|
2015-11-03 23:39:12 +08:00
|
|
|
expect(f('.ef-file-preview-header')).to be_present
|
|
|
|
end
|
2015-07-22 05:25:39 +08:00
|
|
|
end
|
|
|
|
end
|
2016-05-01 06:23:03 +08:00
|
|
|
end
|