Commit fb996876 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch '214594-add-avatar-popover' into 'master'

Fix avatar popover not appearing for delayed data

See merge request gitlab-org/gitlab!36254
parents 27b66c4c 6f82b862
...@@ -9,6 +9,7 @@ import SolutionCard from 'ee/vue_shared/security_reports/components/solution_car ...@@ -9,6 +9,7 @@ import SolutionCard from 'ee/vue_shared/security_reports/components/solution_car
import MergeRequestNote from 'ee/vue_shared/security_reports/components/merge_request_note.vue'; import MergeRequestNote from 'ee/vue_shared/security_reports/components/merge_request_note.vue';
import HistoryEntry from './history_entry.vue'; import HistoryEntry from './history_entry.vue';
import VulnerabilitiesEventBus from './vulnerabilities_event_bus'; import VulnerabilitiesEventBus from './vulnerabilities_event_bus';
import initUserPopovers from '~/user_popovers';
export default { export default {
name: 'VulnerabilityFooter', name: 'VulnerabilityFooter',
...@@ -70,6 +71,12 @@ export default { ...@@ -70,6 +71,12 @@ export default {
VulnerabilitiesEventBus.$on('VULNERABILITY_STATE_CHANGE', this.fetchDiscussions); VulnerabilitiesEventBus.$on('VULNERABILITY_STATE_CHANGE', this.fetchDiscussions);
}, },
updated() {
this.$nextTick(() => {
initUserPopovers(this.$el.querySelectorAll('.js-user-link'));
});
},
beforeDestroy() { beforeDestroy() {
if (this.poll) this.poll.stop(); if (this.poll) this.poll.stop();
}, },
......
---
title: Fix avatar popover not appearing for delayed data
merge_request: 36254
author:
type: fixed
...@@ -8,9 +8,11 @@ import MergeRequestNote from 'ee/vue_shared/security_reports/components/merge_re ...@@ -8,9 +8,11 @@ import MergeRequestNote from 'ee/vue_shared/security_reports/components/merge_re
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import createFlash from '~/flash'; import createFlash from '~/flash';
import initUserPopovers from '~/user_popovers';
const mockAxios = new MockAdapter(axios); const mockAxios = new MockAdapter(axios);
jest.mock('~/flash'); jest.mock('~/flash');
jest.mock('~/user_popovers');
describe('Vulnerability Footer', () => { describe('Vulnerability Footer', () => {
let wrapper; let wrapper;
...@@ -130,6 +132,18 @@ describe('Vulnerability Footer', () => { ...@@ -130,6 +132,18 @@ describe('Vulnerability Footer', () => {
}); });
}); });
it('calls initUserPopovers when a new history item is retrieved', () => {
const historyItems = [{ id: 1, note: 'some note' }];
mockAxios.onGet(discussionUrl).replyOnce(200, historyItems, { date: Date.now() });
expect(initUserPopovers).not.toHaveBeenCalled();
createWrapper();
return axios.waitForAll().then(() => {
expect(initUserPopovers).toHaveBeenCalled();
});
});
it('shows an error the history list could not be retrieved', () => { it('shows an error the history list could not be retrieved', () => {
mockAxios.onGet(discussionUrl).replyOnce(500); mockAxios.onGet(discussionUrl).replyOnce(500);
createWrapper(); createWrapper();
...@@ -194,6 +208,16 @@ describe('Vulnerability Footer', () => { ...@@ -194,6 +208,16 @@ describe('Vulnerability Footer', () => {
}); });
}); });
it('calls initUserPopovers when a new note is retrieved', () => {
expect(initUserPopovers).not.toHaveBeenCalled();
const note = { id: 300, note: 'new note on a new discussion', discussion_id: 3 };
createNotesRequest(note);
return axios.waitForAll().then(() => {
expect(initUserPopovers).toHaveBeenCalled();
});
});
it('shows an error if the notes poll fails', () => { it('shows an error if the notes poll fails', () => {
mockAxios.onGet(minimumProps.notesUrl).replyOnce(500); mockAxios.onGet(minimumProps.notesUrl).replyOnce(500);
......
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