aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/components/issue/popups
diff options
context:
space:
mode:
authorMathieu Suen <mathieu.suen@sonarsource.com>2020-10-19 10:57:04 +0200
committersonartech <sonartech@sonarsource.com>2020-10-20 20:08:04 +0000
commit257acb97b7ec7b5867dfb7c77f0aa4364f73f2f7 (patch)
tree757deb0ece1a9553be970c8f194983bfebf8976a /server/sonar-web/src/main/js/components/issue/popups
parentb9bd4b1a071ade7f83e522f35d53dac9ca74c374 (diff)
downloadsonarqube-257acb97b7ec7b5867dfb7c77f0aa4364f73f2f7.tar.gz
sonarqube-257acb97b7ec7b5867dfb7c77f0aa4364f73f2f7.zip
SONAR-13936 Fix issues sidebar search where in some case we trigger wrong API call.
Diffstat (limited to 'server/sonar-web/src/main/js/components/issue/popups')
-rw-r--r--server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.tsx16
-rw-r--r--server/sonar-web/src/main/js/components/issue/popups/__tests__/SetAssigneePopup-test.tsx24
2 files changed, 1 insertions, 39 deletions
diff --git a/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.tsx b/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.tsx
index 9e35814702a..759c43169fd 100644
--- a/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.tsx
+++ b/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.tsx
@@ -22,9 +22,7 @@ import * as React from 'react';
import { DropdownOverlay } from 'sonar-ui-common/components/controls/Dropdown';
import SearchBox from 'sonar-ui-common/components/controls/SearchBox';
import { translate } from 'sonar-ui-common/helpers/l10n';
-import { searchMembers } from '../../../api/organizations';
import { searchUsers } from '../../../api/users';
-import { isSonarCloud } from '../../../helpers/system';
import { isLoggedIn, isUserActive } from '../../../helpers/users';
import SelectList from '../../common/SelectList';
import SelectListItem from '../../common/SelectListItem';
@@ -63,14 +61,6 @@ export class SetAssigneePopup extends React.PureComponent<Props, State> {
};
}
- searchMembers = (query: string) => {
- searchMembers({
- organization: this.props.issue.projectOrganization,
- q: query,
- ps: LIST_SIZE
- }).then(this.handleSearchResult, () => {});
- };
-
searchUsers = (query: string) => {
searchUsers({ q: query, ps: LIST_SIZE }).then(this.handleSearchResult, () => {});
};
@@ -92,11 +82,7 @@ export class SetAssigneePopup extends React.PureComponent<Props, State> {
});
} else {
this.setState({ query });
- if (isSonarCloud()) {
- this.searchMembers(query);
- } else {
- this.searchUsers(query);
- }
+ this.searchUsers(query);
}
};
diff --git a/server/sonar-web/src/main/js/components/issue/popups/__tests__/SetAssigneePopup-test.tsx b/server/sonar-web/src/main/js/components/issue/popups/__tests__/SetAssigneePopup-test.tsx
index 9f53b7631b5..58cde836f8e 100644
--- a/server/sonar-web/src/main/js/components/issue/popups/__tests__/SetAssigneePopup-test.tsx
+++ b/server/sonar-web/src/main/js/components/issue/popups/__tests__/SetAssigneePopup-test.tsx
@@ -20,25 +20,10 @@
import { shallow } from 'enzyme';
import * as React from 'react';
import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
-import { searchMembers } from '../../../../api/organizations';
import { searchUsers } from '../../../../api/users';
-import { isSonarCloud } from '../../../../helpers/system';
import { mockLoggedInUser, mockUser } from '../../../../helpers/testMocks';
import { SetAssigneePopup } from '../SetAssigneePopup';
-jest.mock('../../../../helpers/system', () => ({
- isSonarCloud: jest.fn().mockReturnValue(false)
-}));
-
-jest.mock('../../../../api/organizations', () => {
- const { mockUser } = jest.requireActual('../../../../helpers/testMocks');
- return {
- searchMembers: jest.fn().mockResolvedValue({
- users: [mockUser(), mockUser({ active: false, login: 'foo', name: undefined })]
- })
- };
-});
-
jest.mock('../../../../api/users', () => {
const { mockUser } = jest.requireActual('../../../../helpers/testMocks');
return { searchUsers: jest.fn().mockResolvedValue({ users: [mockUser()] }) };
@@ -60,15 +45,6 @@ it('should allow to search for a user on SQ', async () => {
expect(wrapper.state('users')).toEqual([mockUser()]);
});
-it('should allow to search for a user on SC', async () => {
- (isSonarCloud as jest.Mock).mockReturnValueOnce(true);
- const wrapper = shallowRender();
- wrapper.find('SearchBox').prop<Function>('onChange')('o');
- await waitAndUpdate(wrapper);
- expect(searchMembers).toBeCalledWith({ organization: 'foo', q: 'o', ps: 10 });
- expect(wrapper.state('users')).toEqual([mockUser()]);
-});
-
function shallowRender(props: Partial<SetAssigneePopup['props']> = {}) {
return shallow(
<SetAssigneePopup