}); | }); | ||||
it('should display system announcement', async () => { | it('should display system announcement', async () => { | ||||
(getValues as jest.Mock) | |||||
jest | |||||
.mocked(getValues) | |||||
.mockResolvedValueOnce([ | .mockResolvedValueOnce([ | ||||
{ | { | ||||
key: 'sonar.announcement.displayMessage', | key: 'sonar.announcement.displayMessage', |
it('should call metric', async () => { | it('should call metric', async () => { | ||||
const metrics = { coverage: mockMetric() }; | const metrics = { coverage: mockMetric() }; | ||||
(getAllMetrics as jest.Mock).mockResolvedValueOnce(Object.values(metrics)); | |||||
jest.mocked(getAllMetrics).mockResolvedValueOnce(Object.values(metrics)); | |||||
const wrapper = shallowRender(); | const wrapper = shallowRender(); | ||||
expect(getAllMetrics).toHaveBeenCalled(); | expect(getAllMetrics).toHaveBeenCalled(); |
}); | }); | ||||
it("should not suggest creating a Project token if the user doesn't have at least one scannable Projects", () => { | it("should not suggest creating a Project token if the user doesn't have at least one scannable Projects", () => { | ||||
(getScannableProjects as jest.Mock).mockResolvedValueOnce({ | |||||
jest.mocked(getScannableProjects).mockResolvedValueOnce({ | |||||
projects: [], | projects: [], | ||||
}); | }); | ||||
renderAccountApp( | renderAccountApp( | ||||
}); | }); | ||||
it('should preselect the user token type if the user has no scan rights', async () => { | it('should preselect the user token type if the user has no scan rights', async () => { | ||||
(getScannableProjects as jest.Mock).mockResolvedValueOnce({ | |||||
jest.mocked(getScannableProjects).mockResolvedValueOnce({ | |||||
projects: [], | projects: [], | ||||
}); | }); | ||||
renderAccountApp(mockLoggedInUser(), securityPagePath); | renderAccountApp(mockLoggedInUser(), securityPagePath); | ||||
}); | }); | ||||
it('should preselect the only project the user has access to if they select project token', async () => { | it('should preselect the only project the user has access to if they select project token', async () => { | ||||
(getScannableProjects as jest.Mock).mockResolvedValueOnce({ | |||||
jest.mocked(getScannableProjects).mockResolvedValueOnce({ | |||||
projects: [ | projects: [ | ||||
{ | { | ||||
key: 'project-key-1', | key: 'project-key-1', |
branchLike={branchLike} | branchLike={branchLike} | ||||
branchLikes={branchLikes} | branchLikes={branchLikes} | ||||
component={component} | component={component} | ||||
hasAnalyses={isPending || isInProgress} | |||||
hasAnalyses={isPending ?? isInProgress} | |||||
projectBinding={projectBinding} | projectBinding={projectBinding} | ||||
/> | /> | ||||
)} | )} |
} | } | ||||
function metricKeyExists(key: string, metrics: Dict<Metric>) { | function metricKeyExists(key: string, metrics: Dict<Metric>) { | ||||
return metrics && metrics[key] !== undefined; | |||||
return metrics[key] !== undefined; | |||||
} | } | ||||
function getNoDiffMetric(metric: Metric, metrics: Dict<Metric>) { | function getNoDiffMetric(metric: Metric, metrics: Dict<Metric>) { |
</td> | </td> | ||||
<td className="thin nowrap text-middle"> | <td className="thin nowrap text-middle"> | ||||
<UserGroups | <UserGroups | ||||
groups={user.groups || []} | |||||
groups={user.groups ?? []} | |||||
manageProvider={manageProvider} | manageProvider={manageProvider} | ||||
onUpdateUsers={onUpdateUsers} | onUpdateUsers={onUpdateUsers} | ||||
user={user} | user={user} |
return ( | return ( | ||||
<div className="big-spacer-right"> | <div className="big-spacer-right"> | ||||
<ButtonToggle | <ButtonToggle | ||||
value={managed === undefined ? 'all' : managed} | |||||
value={managed ?? 'all'} | |||||
disabled={loading} | disabled={loading} | ||||
options={[ | options={[ | ||||
{ label: translate('all'), value: 'all' }, | { label: translate('all'), value: 'all' }, |
const query = new URLSearchParams(this.props.location.search); | const query = new URLSearchParams(this.props.location.search); | ||||
if (query.has('why')) { | if (query.has('why')) { | ||||
this.setState({ | this.setState({ | ||||
selectedTab: tabs.find((tab) => tab.key === TabKeys.WhyIsThisAnIssue) || tabs[0], | |||||
selectedTab: tabs.find((tab) => tab.key === TabKeys.WhyIsThisAnIssue) ?? tabs[0], | |||||
}); | }); | ||||
} | } | ||||
} | } |