2012-06-05 00:12:30 +08:00
|
|
|
require File.expand_path(File.dirname(__FILE__) + '/helpers/conversations_common')
|
2012-02-02 02:43:27 +08:00
|
|
|
|
|
|
|
describe "conversations submissions" do
|
2012-02-28 07:54:00 +08:00
|
|
|
it_should_behave_like "in-process server selenium tests"
|
2013-03-30 06:20:42 +08:00
|
|
|
|
|
|
|
before (:each) do
|
|
|
|
conversation_setup
|
|
|
|
end
|
2012-02-02 02:43:27 +08:00
|
|
|
|
|
|
|
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
|
2012-07-17 08:21:11 +08:00
|
|
|
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
|
2012-02-02 02:43:27 +08:00
|
|
|
elements.size == 1
|
2012-07-17 08:21:11 +08:00
|
|
|
end
|
2012-02-02 02:43:27 +08:00
|
|
|
elements.first.click
|
|
|
|
wait_for_ajaximations
|
2012-09-07 05:39:13 +08:00
|
|
|
subs = ff("#messages .submission")
|
2012-02-02 02:43:27 +08:00
|
|
|
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
|
2012-02-01 09:31:23 +08:00
|
|
|
delete_selected_messages
|
2012-02-02 02:43:27 +08:00
|
|
|
@conversation.reload
|
|
|
|
@conversation.last_message_at.should be_nil
|
|
|
|
end
|
|
|
|
end
|