Commit 8d268273 authored by Simon Knox's avatar Simon Knox

Add proper null check for task item rendering

If description is empty, this.$el was still non-null, but
it was just an HTML comment as a string. So the call to
querySelectorAll failed
parent 9fb2bece
......@@ -95,7 +95,7 @@ export default {
this.renderGFM();
this.updateTaskStatusText();
if (this.workItemsEnabled && this.$el) {
if (this.workItemsEnabled) {
this.renderTaskActions();
}
},
......@@ -157,7 +157,12 @@ export default {
}
},
renderTaskActions() {
if (!this.$el?.querySelectorAll) {
return;
}
const taskListFields = this.$el.querySelectorAll('.task-list-item');
taskListFields.forEach((item, index) => {
const button = document.createElement('button');
button.classList.add(
......
......@@ -209,6 +209,27 @@ describe('Description component', () => {
});
describe('with work items feature flag is enabled', () => {
describe('empty description', () => {
beforeEach(async () => {
createComponent({
props: {
descriptionHtml: '',
},
provide: {
glFeatures: {
workItems: true,
},
},
});
await nextTick();
});
it('renders without error', () => {
expect(findTaskActionButtons()).toHaveLength(0);
});
});
describe('description with checkboxes', () => {
beforeEach(async () => {
createComponent({
props: {
......@@ -262,4 +283,5 @@ describe('Description component', () => {
expect(wrapper.text()).toContain(newTitle);
});
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment