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 { ...@@ -118,6 +118,7 @@ export default {
markdownPreviewLoading: false, markdownPreviewLoading: false,
previewMarkdown: false, previewMarkdown: false,
suggestions: this.note.suggestions || [], suggestions: this.note.suggestions || [],
debouncedFetchMarkdownLoading: false,
}; };
}, },
computed: { computed: {
...@@ -203,8 +204,10 @@ export default { ...@@ -203,8 +204,10 @@ export default {
const justRemovedAll = hadAll && !hasAll; const justRemovedAll = hadAll && !hasAll;
if (justAddedAll) { if (justAddedAll) {
this.debouncedFetchMarkdownLoading = false;
this.debouncedFetchMarkdown(); this.debouncedFetchMarkdown();
} else if (justRemovedAll) { } else if (justRemovedAll) {
this.debouncedFetchMarkdownLoading = true;
this.referencedUsers = []; this.referencedUsers = [];
} }
}, },
...@@ -284,7 +287,12 @@ export default { ...@@ -284,7 +287,12 @@ export default {
}, },
debouncedFetchMarkdown: debounce(function debouncedFetchMarkdown() { debouncedFetchMarkdown: debounce(function debouncedFetchMarkdown() {
return this.fetchMarkdown(); return this.fetchMarkdown().then(() => {
if (this.debouncedFetchMarkdownLoading) {
this.referencedUsers = [];
this.debouncedFetchMarkdownLoading = false;
}
});
}, 400), }, 400),
renderMarkdown(data = {}) { renderMarkdown(data = {}) {
......
...@@ -268,6 +268,24 @@ describe('Markdown field component', () => { ...@@ -268,6 +268,24 @@ describe('Markdown field component', () => {
'You are about to add 11 people to the discussion. They will all receive a notification.', '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