discussion reply tinymce keyboard shortcut icon renders correctly

fixes CNVS-18665

test plan:
- create a discussion, with a reply
- click on two different reply lines, so that two instances of tinymce
  open up
- each one should have their own keyboard shortcuts icon (the 'i' in
  a blue bubble)
- basic regression test of discussion replies

Change-Id: I855cea72caf56f250f2334da10bebd4c8a881bdf
Reviewed-on: https://gerrit.instructure.com/49250
Tested-by: Jenkins
Reviewed-by: Steven Burnett <sburnett@instructure.com>
QA-Review: Nathan Rogowski <nathan@instructure.com>
QA-Review: Adam Stone <astone@instructure.com>
Product-Review: Aaron Cannon <acannon@instructure.com>
This commit is contained in:
Simon Williams 2015-02-23 09:25:42 -07:00
parent 24150d7613
commit 5c44670db2
4 changed files with 58 additions and 5 deletions

View File

@ -40,7 +40,7 @@ define [
attachKeyboardShortcuts: =>
$('.toggle-wrapper').first().before((new KeyboardShortcuts()).render().$el)
@view.$('.toggle-wrapper').first().before((new KeyboardShortcuts()).render().$el)
##
# Shows or hides the TinyMCE editor for a reply

View File

@ -15,8 +15,7 @@ define [
# Model representing an entry in discussion topic
class Entry extends Backbone.Model
defaults:
defaults: ->
##
# Attributes persisted with the server
id: null

View File

@ -0,0 +1,54 @@
define [
'jquery'
'compiled/models/Entry'
'compiled/views/DiscussionTopic/EntryView'
'compiled/discussions/Reply'
'helpers/fakeENV'
], ($, Entry, EntryView, Reply, fakeENV) ->
module 'EntryView',
setup: ->
fakeENV.setup
DISCUSSION:
PERMISSIONS: { CAN_REPLY: true }
CURRENT_USER: {}
THREADED: true
teardown: ->
fakeENV.teardown()
$('#fixtures').empty()
test 'renders', ->
entry = new Entry(id: 1, message: 'hi')
$('#fixtures').append($('<div />').attr('id', 'e1'))
view = new EntryView
model: entry
el: '#e1'
view.render()
ok view
test 'two entries do not render keyboard shortcuts to the same place', ->
clock = sinon.useFakeTimers()
sinon.stub(Reply.prototype, 'edit')
$('#fixtures').append($('<div />').attr('id', 'e1'))
$('#fixtures').append($('<div />').attr('id', 'e2'))
entry1 = new Entry(id: 1, message: 'hi')
entry2 = new Entry(id: 2, message: 'reply')
view1 = new EntryView
model: entry1
el: '#e1'
view1.render()
view1.addReply()
view2 = new EntryView
model: entry2
el: '#e2'
view2.render()
view2.addReply()
clock.tick 1
equal view1.$('.tinymce-keyboard-shortcuts-toggle').length, 1
equal view2.$('.tinymce-keyboard-shortcuts-toggle').length, 1
clock.restore()