Issue RCE tray's links query in the correct context

closes LS-1612
flag=rce_enhancements

When switching to links, force the context into the containing course
or group context.

test plan:
  - open Links > Course Links
  - expand Assignments
  - close the tray
  - open Documents > User Documents
  - Change Files to Links
  > expect the assignments section to be filled with the assignments
    and have no newwork error

The change to UnreadCounts.js is to fix a syntax error lint has started
erroring on.

Change-Id: Ib5b6f379fee38243ef997f20bc8bf3ec1ed0300f
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/252834
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: Ed Schiebel <eschiebel@instructure.com>
This commit is contained in:
Ed Schiebel 2020-11-14 11:23:30 -05:00
parent 345869ae85
commit 3ce50a1deb
6 changed files with 81 additions and 26 deletions

View File

@ -114,7 +114,7 @@ export default function UnreadCounts(props) {
unreadCount
})
sessionStorage.setItem(storageKeyFor(dataUrl), savedState)
} catch {
} catch (_ex) {
// error in setting storage, no biggie, ignore
}

View File

@ -288,9 +288,12 @@ export default function CanvasContentTray(props) {
contextId = props.containingContext.contextId
break
case 'course_files':
case 'links':
contextType = props.contextType
contextId = props.containingContext.contextId
break
case 'links':
contextType = props.containingContext.contextType
contextId = props.containingContext.contextId
}
onChangeContext({contextType, contextId})
}

View File

@ -36,7 +36,7 @@ describe('RCE Plugins > CanvasContentTray', () => {
props = {
bridge: new Bridge(),
editor,
containingContext: {type: 'course', contextId: '1201', userId: '17'},
containingContext: {contextType: 'course', contextId: '1201', userId: '17'},
contextId: '1201',
contextType: 'course',
source: fakeSource,

View File

@ -35,8 +35,8 @@ export default function(props, state) {
store.subscribe(() => {
try {
const accordionIndex = store.getState().ui.selectedAccordionIndex
if (accordionIndex !== window.sessionStorage.canvas_rce_links_accordion_index) {
window.sessionStorage.canvas_rce_links_accordion_index = accordionIndex
if (accordionIndex !== window.sessionStorage.getItem('canvas_rce_links_accordion_index')) {
window.sessionStorage.setItem('canvas_rce_links_accordion_index', accordionIndex)
}
} catch (err) {
// If there is an error accessing session storage, just ignore it.

View File

@ -126,7 +126,7 @@ module RCENextPage
end
def assignment_due_date_exists?(due_date)
modified_due_date = due_date.strftime("%B %-d, %Y")
modified_due_date = due_date.strftime('%B %-d, %Y')
element_exists?("//*[contains(text(),'#{modified_due_date}')]", true)
end
@ -284,7 +284,7 @@ module RCENextPage
end
def rce_page_body_ifr_style
element_value_for_attr(f('iframe.tox-edit-area__iframe'), "style")
element_value_for_attr(f('iframe.tox-edit-area__iframe'), 'style')
end
def course_item_link(title)
@ -312,7 +312,9 @@ module RCENextPage
end
def indent_toggle_button
possibly_hidden_toolbar_button('[role="button"][aria-label="Increase indent"] .tox-split-button__chevron')
possibly_hidden_toolbar_button(
'[role="button"][aria-label="Increase indent"] .tox-split-button__chevron'
)
end
def indent_button
@ -549,6 +551,23 @@ module RCENextPage
menu_option_by_name('Upload Document')
end
def content_tray_close_button
fj('[data-testid="CanvasContentTray"] button:contains("Close")')
end
def content_tray_content_type
f('input[role="combobox"]', fj(':contains("Content Type")'))
end
def change_content_tray_content_type(which)
content_type = content_tray_content_type
content_type.click
options_id = content_type.attribute('aria-owns')
options = f("##{options_id}")
option = fj(":contains(#{which})", options)
option.click
end
# ---------------------- Actions ----------------------
def click_pages_accordion
@ -838,6 +857,11 @@ module RCENextPage
embed_submit_button.click
end
def click_content_tray_close_button
content_tray_close_button.click
wait_for_animations
end
def switch_to_html_view
fj('button:contains("Switch to raw html editor")').click
end

View File

@ -203,7 +203,7 @@ describe 'RCE next tests', ignore_js_errors: true do
end
end
it "deletes the <a> when its text is deleted" do
it 'deletes the <a> when its text is deleted' do
@course.wiki_pages.create!(
title: 'title',
body: "<p id='para'><a id='lnk' href='http://example.com'>delete me</a></p>"
@ -213,16 +213,16 @@ describe 'RCE next tests', ignore_js_errors: true do
f("##{rce_page_body_ifr_id}").click
f("##{rce_page_body_ifr_id}").send_keys(
[:shift, :arrow_left],
[:shift, :arrow_left],
[:shift, :arrow_left],
[:shift, :arrow_left],
[:shift, :arrow_left],
[:shift, :arrow_left],
[:shift, :arrow_left],
[:shift, :arrow_left],
[:shift, :arrow_left],
[:shift, :arrow_left]
%i[shift arrow_left],
%i[shift arrow_left],
%i[shift arrow_left],
%i[shift arrow_left],
%i[shift arrow_left],
%i[shift arrow_left],
%i[shift arrow_left],
%i[shift arrow_left],
%i[shift arrow_left],
%i[shift arrow_left]
)
f("##{rce_page_body_ifr_id}").send_keys(:enter)
@ -232,7 +232,7 @@ describe 'RCE next tests', ignore_js_errors: true do
end
it "doesn't delete existing link when new image is added from course files directly after it" do
title = "newtext.txt"
title = 'newtext.txt'
@course.wiki_pages.create!(
title: 'title',
body: "<p id='para'><a id='lnk' href='http://example.com'>do I stay?</a></p>"
@ -244,7 +244,7 @@ describe 'RCE next tests', ignore_js_errors: true do
wait_for_tiny(edit_wiki_css)
in_frame rce_page_body_ifr_id do
f('#lnk').send_keys([:end, :return])
f('#lnk').send_keys(%i[end return])
end
click_document_toolbar_menu_button
@ -534,7 +534,8 @@ describe 'RCE next tests', ignore_js_errors: true do
it 'should display assignment due date in links accordion' do
title = 'Assignment-Title'
due_at = 3.days.from_now
@assignment = @course.assignments.create!(name: title, workflow_state: 'published', due_at: due_at)
@assignment =
@course.assignments.create!(name: title, workflow_state: 'published', due_at: due_at)
visit_new_announcement_page(@course)
click_links_toolbar_menu_button
@ -718,9 +719,9 @@ describe 'RCE next tests', ignore_js_errors: true do
expect(tray_container_exists?).to eq true
driver.action.send_keys(:escape).perform # Press esc key
driver.action.send_keys(:escape).perform
expect(tray_container_exists?).to eq false
expect(tray_container_exists?).to eq false # Press esc key
end
it 'should close the course images tray when pressing esc', ignore_js_errors: true do
@ -730,9 +731,9 @@ describe 'RCE next tests', ignore_js_errors: true do
click_course_images
expect(tray_container_exists?).to eq true
driver.action.send_keys(:escape).perform # Press esc key
driver.action.send_keys(:escape).perform
expect(tray_container_exists?).to eq false
expect(tray_container_exists?).to eq false # Press esc key
end
it 'should open upload image modal when clicking upload option' do
@ -1123,5 +1124,32 @@ describe 'RCE next tests', ignore_js_errors: true do
f('body').send_keys :escape
end
end
describe 'the content tray' do
after(:each) { driver.local_storage.clear }
it 'should show course links after user files' do
title = 'Assignment-Title'
@assignment = @course.assignments.create!(name: title)
rce_wysiwyg_state_setup(@course)
driver.session_storage['canvas_rce_links_accordion_index'] = 'assignments'
click_links_toolbar_menu_button
click_course_links
wait_for_ajaximations
expect(fj("li:contains('#{title}')")).to be_displayed
click_content_tray_close_button
wait_for_animations
click_document_toolbar_menu_button
click_user_documents
wait_for_ajaximations
change_content_tray_content_type('Links')
wait_for_ajaximations
expect(fj("li:contains('#{title}')")).to be_displayed
end
end
end
end