diff options
author | guillaume-peoch-sonarsource <guillaume.peoch@sonarsource.com> | 2023-03-09 10:10:18 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-03-22 20:04:07 +0000 |
commit | c96fc17ae41f274d56cd329af1373a94352d74bf (patch) | |
tree | 709b273f35559b424a5d18230d9725e638df8dc8 /server/sonar-web/src/main/js/api/mocks | |
parent | 2879fc6789ada0ebfe449f47572a89ba7a83e9ed (diff) | |
download | sonarqube-c96fc17ae41f274d56cd329af1373a94352d74bf.tar.gz sonarqube-c96fc17ae41f274d56cd329af1373a94352d74bf.zip |
SONAR-18689 Add Filters for all, local and managed users on user list
Diffstat (limited to 'server/sonar-web/src/main/js/api/mocks')
-rw-r--r-- | server/sonar-web/src/main/js/api/mocks/UsersServiceMock.ts | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/server/sonar-web/src/main/js/api/mocks/UsersServiceMock.ts b/server/sonar-web/src/main/js/api/mocks/UsersServiceMock.ts index f575559c69a..0c8c719732c 100644 --- a/server/sonar-web/src/main/js/api/mocks/UsersServiceMock.ts +++ b/server/sonar-web/src/main/js/api/mocks/UsersServiceMock.ts @@ -19,7 +19,7 @@ */ import { cloneDeep } from 'lodash'; -import { mockClusterSysInfo, mockIdentityProvider } from '../../helpers/testMocks'; +import { mockClusterSysInfo, mockIdentityProvider, mockUser } from '../../helpers/testMocks'; import { IdentityProvider, Paging, SysInfoCluster } from '../../types/types'; import { User } from '../../types/users'; import { getSystemInfo } from '../system'; @@ -27,26 +27,44 @@ import { getIdentityProviders, searchUsers } from '../users'; export default class UsersServiceMock { isManaged = true; + users = [ + mockUser({ + managed: true, + login: 'bob.marley', + name: 'Bob Marley', + }), + mockUser({ + managed: false, + login: 'alice.merveille', + name: 'Alice Merveille', + }), + ]; constructor() { jest.mocked(getSystemInfo).mockImplementation(this.handleGetSystemInfo); jest.mocked(getIdentityProviders).mockImplementation(this.handleGetIdentityProviders); - jest.mocked(searchUsers).mockImplementation(this.handleSearchUsers); + jest.mocked(searchUsers).mockImplementation((p) => this.handleSearchUsers(p)); } setIsManaged(managed: boolean) { this.isManaged = managed; } - handleSearchUsers = (): Promise<{ paging: Paging; users: User[] }> => { - return this.reply({ - paging: { - pageIndex: 1, - pageSize: 100, - total: 0, - }, - users: [], - }); + handleSearchUsers = (data: any): Promise<{ paging: Paging; users: User[] }> => { + const paging = { + pageIndex: 1, + pageSize: 100, + total: 0, + }; + + if (this.isManaged) { + if (data.managed === undefined) { + return this.reply({ paging, users: this.users }); + } + const users = this.users.filter((user) => user.managed === data.managed); + return this.reply({ paging, users }); + } + return this.reply({ paging, users: this.users }); }; handleGetIdentityProviders = (): Promise<{ identityProviders: IdentityProvider[] }> => { |