Commit 1a503d0d authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch 'psi-all-better' into 'master'

Fix erroneous all warning from race condition

See merge request gitlab-org/gitlab!81224
parents 1ab9b7c0 3e4134e6
......@@ -118,6 +118,7 @@ export default {
markdownPreviewLoading: false,
previewMarkdown: false,
suggestions: this.note.suggestions || [],
debouncedFetchMarkdownLoading: false,
};
},
computed: {
......@@ -203,8 +204,10 @@ export default {
const justRemovedAll = hadAll && !hasAll;
if (justAddedAll) {
this.debouncedFetchMarkdownLoading = false;
this.debouncedFetchMarkdown();
} else if (justRemovedAll) {
this.debouncedFetchMarkdownLoading = true;
this.referencedUsers = [];
}
},
......@@ -284,7 +287,12 @@ export default {
},
debouncedFetchMarkdown: debounce(function debouncedFetchMarkdown() {
return this.fetchMarkdown();
return this.fetchMarkdown().then(() => {
if (this.debouncedFetchMarkdownLoading) {
this.referencedUsers = [];
this.debouncedFetchMarkdownLoading = false;
}
});
}, 400),
renderMarkdown(data = {}) {
......
......@@ -268,6 +268,24 @@ describe('Markdown field component', () => {
'You are about to add 11 people to the discussion. They will all receive a notification.',
);
});
it('removes warning when all mention is removed while endpoint is loading', async () => {
axiosMock.onPost(markdownPreviewPath).reply(200, { references: { users } });
jest.spyOn(axios, 'post');
subject.setProps({ textareaValue: 'hello @all' });
await nextTick();
subject.setProps({ textareaValue: 'hello @allan' });
await axios.waitFor(markdownPreviewPath);
expect(axios.post).toHaveBeenCalled();
expect(subject.text()).not.toContain(
'You are about to add 11 people to the discussion. They will all receive a notification.',
);
});
});
});
});
......
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