canvas-lms/spec/selenium/conversations_submissions_s...

93 lines
3.6 KiB
Ruby
Raw Normal View History

require File.expand_path(File.dirname(__FILE__) + '/helpers/conversations_common')
describe "conversations submissions" do
save attachments before message creation, fixes #7229 rather than proxy attachments through the conversations controller and cause a long-running db transaction, we now just send them to the right place (files controller, s3, whatever), and then create the message. we now store the attachment in a special folder on the user so that they can more easily be tracked in the future for quota management. because we now just store one instance of each attachment, sending a bulk private message w/ attachments should be a bit less painful. known regression: if a user deletes a conversation attachment from their files area, it deletes if for all recipients. this is essentially the same problem as tickets #6732 and #7481 where we don't let a "deleted" attachment to still be viewed via associations with other objects. test plan: 1. send an attachment on a new conversation and confirm that was sent correctly and can be viewed by recipients 2. send an attachment on an existing conversation and confirm that was sent correctly and can be viewed by recipients 3. send an attachment on a bulk private conversation and 1. confirm that was sent correctly and can be viewed by recipients 2. confirm that only one attachment was actually created, but each message in each conversation is linked to it 4. send multiple attachments and confirm that they were sent correctly and can be viewed by recipients 5. perform steps 1-4 for both local and s3 uploads Change-Id: I7cb21c635f98e47163ef81f0c4050346c64faa91 Reviewed-on: https://gerrit.instructure.com/9046 Reviewed-by: Jon Jensen <jon@instructure.com> Tested-by: Hudson <hudson@instructure.com>
2012-02-28 07:54:00 +08:00
it_should_behave_like "in-process server selenium tests"
before (:each) do
conversation_setup
end
it "should list submission comments in the conversation" do
@me = @user
@bob = student_in_course(:name => "bob", :active_all => true).user
submission1 = submission_model(:course => @course, :user => @bob)
submission2 = submission_model(:course => @course, :user => @bob)
submission1.add_comment(:comment => "hey bob", :author => @me)
submission1.add_comment(:comment => "wut up teacher", :author => @bob)
submission2.add_comment(:comment => "my name is bob", :author => @bob)
submission2.assignment.grade_student(@bob, {:grade => 0.9})
conversation(@bob)
get "/conversations"
elements = nil
keep_trying_until do
conversations refactor part 2, ajax loading, fixes #7062 refactored conversations pane, implemented ajaxy scrollable list widget, partially backbone.js'ed conversation items, re-did fragment hash fu, and made filter/scope changes update the page via ajax. from an end-user perspective, the noticeable changes are: 1. filters/scopes update the page via ajax 2. the conversations pane appears to load more quickly now (we set it to the full height from the outset, and things load in as you scroll) test plan: 1. general regression test of conversations, specifically focusing on: 1. actions that remove a conversation from the list, e.g. 1. deleting it 2. deleting all messages from it 3. marking it as read when in the unread filter 4. archiving/unarchiving (depending on the view) 2. actions that update a conversation in the list, e.g. 1. adding a message should update the preview and move it to the top 2. deleting the most recent message should move it down in the list 3. sending a new message to an existing conversation should update it (and possibly reposition it) 3. actions that should add a conversation to the list 1. starting a new conversation, provided that it should be visible under the current filter/scope 2. if the conversation should not be visible (e.g. start a new conversation under the archived scope), simply display the "Message Sent" notification but don't show the conversation 2. test ajax loading of filters and scopes. confirm that back button works 3. test scrollable list component 1. confirm the scrollable list is big enough for all items in the view 2. confirm that items load as you scroll 3. confirm that jumping to the very bottom loads those items in a timely manner (they should load before the skipped middle stuff does) Change-Id: Icb1e09f34c653b55c62de0c82ac0cfc172827520 Reviewed-on: https://gerrit.instructure.com/9612 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Zach Pendleton <zachp@instructure.com>
2012-03-27 07:51:29 +08:00
elements = get_conversations
elements.size == 1
end
elements.first.click
wait_for_ajaximations
subs = ff("#messages .submission")
subs.size.should == 2
subs[0].find_element(:css, '.score').text.should == '0.9 / 1.5'
subs[1].find_element(:css, '.score').text.should == 'no score'
coms = subs[0].find_elements(:css, '.comment')
coms.size.should == 1
coms.first.find_element(:css, '.audience').text.should == 'bob'
coms.first.find_element(:css, 'p').text.should == 'my name is bob'
coms = subs[1].find_elements(:css, '.comment')
coms.size.should == 2
coms.first.find_element(:css, '.audience').text.should == 'bob'
coms.first.find_element(:css, 'p').text.should == 'wut up teacher'
coms.last.find_element(:css, '.audience').text.should == 'nobody@example.com'
coms.last.find_element(:css, 'p').text.should == 'hey bob'
end
it "should interleave submissions with messages based on comment time" do
SubmissionComment.any_instance.stubs(:current_time_from_proper_timezone).returns(10.minutes.ago, 8.minutes.ago)
@me = @user
@bob = student_in_course(:name => "bob", :active_all => true).user
@conversation = conversation(@bob).conversation
@conversation.conversation_messages.first.update_attribute(:created_at, 9.minutes.ago)
submission1 = submission_model(:course => @course, :user => @bob)
submission1.add_comment(:comment => "hey bob", :author => @me)
# message comes first, then submission, due to creation times
msgs = get_messages
msgs.size.should == 2
msgs[0].should have_class('message')
msgs[1].should have_class('submission')
# now new submission comment bumps it up
submission1.add_comment(:comment => "hey teach", :author => @bob)
msgs = get_messages
msgs.size.should == 2
msgs[0].should have_class('submission')
msgs[1].should have_class('message')
# new message appears on top, submission now in the middle
@conversation.add_message(@bob, 'ohai there').update_attribute(:created_at, 7.minutes.ago)
msgs = get_messages
msgs.size.should == 3
msgs[0].should have_class('message')
msgs[1].should have_class('submission')
msgs[2].should have_class('message')
end
it "should allow deleting submission messages from the conversation" do
@me = @user
@bob = student_in_course(:name => "bob", :active_all => true).user
submission1 = submission_model(:course => @course, :user => @bob)
submission1.add_comment(:comment => "hey teach", :author => @bob)
@conversation = @me.conversations.first
@conversation.should be_present
msgs = get_messages
msgs.size.should == 1
msgs.first.click
delete_selected_messages
@conversation.reload
@conversation.last_message_at.should be_nil
end
end