Add safe nav to display_name

fixes VICE-2952
flag=none

Test Plan:
 - import an announcement
 > should load without error

Change-Id: I5fc2b4612eabd352b4785359ce9563fe0b6bf608
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/294464
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jason Gillett <jason.gillett@instructure.com>
Product-Review: Jason Gillett <jason.gillett@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
This commit is contained in:
Drake Harper 2022-06-21 20:09:03 -06:00
parent 1f6df9c743
commit 5313b7a7fa
2 changed files with 8 additions and 3 deletions

View File

@ -50,6 +50,11 @@ test('renders the CourseItemRow component', () => {
ok(tree.exists())
})
test("renders the CourseItemRow component when author doesn't exist", () => {
const tree = mount(<CourseItemRow {...props} author={null} />)
ok(tree.exists())
})
test('renders children inside content column', () => {
const tree = mount(
<CourseItemRow

View File

@ -237,9 +237,9 @@ export default class CourseItemRow extends Component {
<div className="ic-item-row__author-col">
<Avatar
size="small"
alt={this.props.author.display_name || I18n.t('Unknown')}
name={this.props.author.display_name || I18n.t('Unknown')}
src={this.props.author.avatar_image_url}
alt={this.props.author?.display_name || I18n.t('Unknown')}
name={this.props.author?.display_name || I18n.t('Unknown')}
src={this.props.author?.avatar_image_url}
data-fs-exclude
/>
</div>