aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src')
-rw-r--r--server/sonar-web/src/main/js/app/components/App.tsx2
-rw-r--r--server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/app/components/extensions/legacy/__tests__/request-legacy-test.ts25
-rw-r--r--server/sonar-web/src/main/js/app/components/extensions/legacy/request-legacy.ts9
-rw-r--r--server/sonar-web/src/main/js/app/components/indexation/__tests__/PageUnavailableDueToIndexation-test.tsx14
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx6
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/__tests__/Menu-test.tsx1
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/__tests__/utils-test.ts2
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/__tests__/MetaTagsSelector-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/projectInformation/notifications/ProjectNotifications.tsx1
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/projectInformation/notifications/__tests__/ProjectNotifications-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/global/GlobalNavMenu.tsx3
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/settings/SettingsNav.tsx9
-rw-r--r--server/sonar-web/src/main/js/app/index.ts12
-rw-r--r--server/sonar-web/src/main/js/apps/application-console/__tests__/EditForm-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetails-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureContent-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/create/project/__tests__/AzureProjectCreate-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/create/project/__tests__/AzureProjectCreateRenderer-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketImportRepositoryForm-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketProjectAccordion-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketRepositories-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/create/project/__tests__/ManualProjectCreate-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/documentation/__tests__/pages-test.ts2
-rw-r--r--server/sonar-web/src/main/js/apps/documentation/components/__tests__/App-test.tsx4
-rw-r--r--server/sonar-web/src/main/js/apps/groups/components/App.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.tsx1
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/IssuesCounter.tsx1
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/PageActions.tsx4
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/PageActions-test.tsx.snap1
-rw-r--r--server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/CrossComponentSourceViewerWrapper-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/StandardFacet-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-test.tsx16
-rw-r--r--server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/PullRequestOverview-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/portfolio/components/__tests__/MetricBox-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/portfolio/components/__tests__/Report-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/portfolio/components/__tests__/Subscription-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAnalysesList-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAnalysis-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/BranchAnalysisListRenderer-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/projectQualityGate/ProjectQualityGateApp.tsx27
-rw-r--r--server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/ProjectQualityGateAppRenderer-test.tsx11
-rw-r--r--server/sonar-web/src/main/js/apps/projectQualityProfiles/components/__tests__/AddLanguageModal-test.tsx64
-rw-r--r--server/sonar-web/src/main/js/apps/projectQualityProfiles/components/__tests__/SetQualityProfileModal-test.tsx65
-rw-r--r--server/sonar-web/src/main/js/apps/projects/components/__tests__/AllProjects-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx99
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ChangelogContainer-test.tsx4
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsFormSelect-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/security-hotspots/components/__tests__/__snapshots__/HotspotOpenInIdeButton-test.tsx.snap8
-rw-r--r--server/sonar-web/src/main/js/apps/settings/components/__tests__/EmailForm-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/system/__tests__/utils-test.ts2
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx11
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerBase-test.tsx7
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineSCM-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/SCMPopup-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsHistory-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltips-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContentCoverage-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/components/activity-graph/__tests__/utils-test.ts2
-rw-r--r--server/sonar-web/src/main/js/components/common/BranchStatus.tsx10
-rw-r--r--server/sonar-web/src/main/js/components/common/__tests__/AnalysisWarningsModal-test.tsx39
-rw-r--r--server/sonar-web/src/main/js/components/common/__tests__/BranchStatus-test.tsx3
-rw-r--r--server/sonar-web/src/main/js/components/docs/DocCollapsibleBlock.tsx1
-rw-r--r--server/sonar-web/src/main/js/components/docs/__tests__/DocToc-test.tsx6
-rw-r--r--server/sonar-web/src/main/js/components/docs/__tests__/__snapshots__/DocCollapsibleBlock-test.tsx.snap2
-rw-r--r--server/sonar-web/src/main/js/components/measure/__tests__/Measure-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/components/RenderOptions.tsx1
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/RenderOptions-test.tsx.snap6
-rw-r--r--server/sonar-web/src/main/js/helpers/extensions.ts2
-rw-r--r--server/sonar-web/src/main/js/helpers/mocks/quality-gates.ts2
-rw-r--r--server/sonar-web/src/main/js/helpers/testMocks.ts2
-rw-r--r--server/sonar-web/src/main/js/store/__tests__/rootActions-test.tsx6
-rw-r--r--server/sonar-web/src/main/js/store/__tests__/rootReducers-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/store/__tests__/users-test.tsx2
74 files changed, 296 insertions, 264 deletions
diff --git a/server/sonar-web/src/main/js/app/components/App.tsx b/server/sonar-web/src/main/js/app/components/App.tsx
index 8204c871ecc..e32dc36aabe 100644
--- a/server/sonar-web/src/main/js/app/components/App.tsx
+++ b/server/sonar-web/src/main/js/app/components/App.tsx
@@ -61,7 +61,7 @@ class App extends React.PureComponent<Props> {
const outer = document.createElement('div');
outer.style.visibility = 'hidden';
outer.style.width = '100px';
- outer.style.msOverflowStyle = 'scrollbar';
+ outer.style.setProperty('msOverflowStyle', 'scrollbar');
document.body.appendChild(outer);
diff --git a/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx b/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx
index 476aa6c836a..6a0d13028d1 100644
--- a/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx
@@ -33,7 +33,7 @@ import { ComponentContainer } from '../ComponentContainer';
import PageUnavailableDueToIndexation from '../indexation/PageUnavailableDueToIndexation';
jest.mock('../../../api/branches', () => {
- const { mockMainBranch, mockPullRequest } = require.requireActual(
+ const { mockMainBranch, mockPullRequest } = jest.requireActual(
'../../../helpers/mocks/branch-like'
);
return {
diff --git a/server/sonar-web/src/main/js/app/components/extensions/legacy/__tests__/request-legacy-test.ts b/server/sonar-web/src/main/js/app/components/extensions/legacy/__tests__/request-legacy-test.ts
index 8fed4500317..e77a08d4466 100644
--- a/server/sonar-web/src/main/js/app/components/extensions/legacy/__tests__/request-legacy-test.ts
+++ b/server/sonar-web/src/main/js/app/components/extensions/legacy/__tests__/request-legacy-test.ts
@@ -20,13 +20,21 @@
import handleRequiredAuthentication from 'sonar-ui-common/helpers/handleRequiredAuthentication';
import request from '../request-legacy';
-const { checkStatus, parseError, requestTryAndRepeatUntil } = request;
+const { checkStatus, delay, parseError, requestTryAndRepeatUntil } = request;
jest.mock('sonar-ui-common/helpers/handleRequiredAuthentication', () => ({ default: jest.fn() }));
jest.mock('sonar-ui-common/helpers/cookies', () => ({
getCookie: jest.fn().mockReturnValue('qwerasdf')
}));
+beforeAll(() => {
+ jest.useFakeTimers();
+});
+
+afterAll(() => {
+ jest.useRealTimers();
+});
+
beforeEach(() => {
jest.clearAllMocks();
});
@@ -91,6 +99,7 @@ describe('requestTryAndRepeatUntil', () => {
for (let i = 1; i < 5; i++) {
jest.runAllTimers();
expect(apiCall).toBeCalledTimes(i);
+ // eslint-disable-next-line no-await-in-loop
await new Promise(setImmediate);
expect(stopRepeat).toBeCalledTimes(i);
}
@@ -115,6 +124,7 @@ describe('requestTryAndRepeatUntil', () => {
for (let i = 1; i < 5; i++) {
jest.runAllTimers();
expect(apiCall).toBeCalledTimes(i);
+ // eslint-disable-next-line no-await-in-loop
await new Promise(setImmediate);
}
apiCall.mockResolvedValue('Success');
@@ -141,6 +151,7 @@ describe('requestTryAndRepeatUntil', () => {
for (let i = 1; i < 3; i++) {
jest.runAllTimers();
expect(apiCall).toBeCalledTimes(i);
+ // eslint-disable-next-line no-await-in-loop
await new Promise(setImmediate);
}
apiCall.mockResolvedValue('Success');
@@ -156,6 +167,7 @@ describe('requestTryAndRepeatUntil', () => {
for (let i = 1; i < 3; i++) {
jest.advanceTimersByTime(500);
expect(apiCall).toBeCalledTimes(i);
+ // eslint-disable-next-line no-await-in-loop
await new Promise(setImmediate);
}
@@ -284,3 +296,14 @@ describe('request functions', () => {
});
});
});
+
+describe('delay', () => {
+ it('should work as expected', async () => {
+ const param = { some: 'response' };
+
+ const promise = delay(param);
+ jest.runAllTimers();
+
+ expect(await promise).toBe(param);
+ });
+});
diff --git a/server/sonar-web/src/main/js/app/components/extensions/legacy/request-legacy.ts b/server/sonar-web/src/main/js/app/components/extensions/legacy/request-legacy.ts
index f39f74fd801..1d3a51d8a27 100644
--- a/server/sonar-web/src/main/js/app/components/extensions/legacy/request-legacy.ts
+++ b/server/sonar-web/src/main/js/app/components/extensions/legacy/request-legacy.ts
@@ -87,7 +87,10 @@ const DEFAULT_HEADERS = {
class Request {
private data?: RequestData;
- constructor(private readonly url: string, private readonly options: { method?: string } = {}) {}
+ constructor(private readonly url: string, private readonly options: { method?: string } = {}) {
+ this.url = url;
+ this.options = options;
+ }
getSubmitData(customHeaders: any = {}): { url: string; options: RequestInit } {
let { url } = this;
@@ -257,7 +260,9 @@ function requestDelete(url: string, data?: RequestData): Promise<any> {
* Delay promise for testing purposes
*/
function delay(response: any): Promise<any> {
- return new Promise(resolve => setTimeout(() => resolve(response), 1200));
+ return new Promise(resolve => {
+ setTimeout(() => resolve(response), 1200);
+ });
}
function tryRequestAgain<T>(
diff --git a/server/sonar-web/src/main/js/app/components/indexation/__tests__/PageUnavailableDueToIndexation-test.tsx b/server/sonar-web/src/main/js/app/components/indexation/__tests__/PageUnavailableDueToIndexation-test.tsx
index 824d1870caa..1c89df96447 100644
--- a/server/sonar-web/src/main/js/app/components/indexation/__tests__/PageUnavailableDueToIndexation-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/indexation/__tests__/PageUnavailableDueToIndexation-test.tsx
@@ -29,8 +29,11 @@ it('should render correctly', () => {
it('should not refresh the page once the indexation is complete if there were failures', () => {
const reload = jest.fn();
- delete window.location;
- (window as any).location = { reload };
+
+ Object.defineProperty(window, 'location', {
+ writable: true,
+ value: { reload }
+ });
const wrapper = shallowRender();
@@ -46,8 +49,11 @@ it('should not refresh the page once the indexation is complete if there were fa
it('should refresh the page once the indexation is complete if there were NO failures', () => {
const reload = jest.fn();
- delete window.location;
- (window as any).location = { reload };
+
+ Object.defineProperty(window, 'location', {
+ writable: true,
+ value: { reload }
+ });
const wrapper = shallowRender();
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx b/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx
index 21968d737b7..d9b7212b918 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx
@@ -266,7 +266,8 @@ export class Menu extends React.PureComponent<Props> {
{({ onToggleClick, open }) => (
<a
aria-expanded={open}
- aria-haspopup="true"
+ aria-haspopup="menu"
+ role="button"
className={classNames('dropdown-toggle', { active: isSettingsActive || open })}
href="#"
id="component-navigation-admin"
@@ -558,7 +559,8 @@ export class Menu extends React.PureComponent<Props> {
{({ onToggleClick, open }) => (
<a
aria-expanded={open}
- aria-haspopup="true"
+ aria-haspopup="menu"
+ role="button"
className={classNames('dropdown-toggle', { active: open })}
href="#"
id="component-navigation-more"
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/Menu-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/Menu-test.tsx
index a0bbd65bbfb..0599e075ba2 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/Menu-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/Menu-test.tsx
@@ -17,7 +17,6 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
import { shallow } from 'enzyme';
import * as React from 'react';
import {
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/__tests__/utils-test.ts b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/__tests__/utils-test.ts
index c4b8d9dafba..c733bb8c7ad 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/__tests__/utils-test.ts
+++ b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/__tests__/utils-test.ts
@@ -21,7 +21,7 @@ import { Location } from 'sonar-ui-common/helpers/urls';
import { BadgeOptions, BadgeType, getBadgeSnippet, getBadgeUrl } from '../utils';
jest.mock('sonar-ui-common/helpers/urls', () => ({
- ...require.requireActual('sonar-ui-common/helpers/urls'),
+ ...jest.requireActual('sonar-ui-common/helpers/urls'),
getHostUrl: () => 'host',
getPathUrlAsString: (o: Location) =>
`host${o.pathname}?id=${o.query ? o.query.id : ''}&branch=${o.query ? o.query.branch : ''}`
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/__tests__/MetaTagsSelector-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/__tests__/MetaTagsSelector-test.tsx
index bbb7cfcd9ba..3aa6b718bab 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/__tests__/MetaTagsSelector-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/__tests__/MetaTagsSelector-test.tsx
@@ -28,7 +28,7 @@ jest.mock('../../../../../../../api/components', () => ({
}));
jest.mock('lodash', () => {
- const lodash = require.requireActual('lodash');
+ const lodash = jest.requireActual('lodash');
lodash.debounce = jest.fn(fn => fn);
return lodash;
});
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/notifications/ProjectNotifications.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/notifications/ProjectNotifications.tsx
index 456dc01a6ec..0092e1e9a79 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/notifications/ProjectNotifications.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/notifications/ProjectNotifications.tsx
@@ -28,7 +28,6 @@ import {
} from '../../../../../../components/hoc/withNotifications';
interface Props {
- className?: string;
component: T.Component;
}
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/notifications/__tests__/ProjectNotifications-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/notifications/__tests__/ProjectNotifications-test.tsx
index 85cabc9c232..2e33d89a858 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/notifications/__tests__/ProjectNotifications-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/notifications/__tests__/ProjectNotifications-test.tsx
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import { shallow } from 'enzyme';
import * as React from 'react';
import { mockComponent } from '../../../../../../../helpers/testMocks';
diff --git a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavMenu.tsx b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavMenu.tsx
index 4e790d74700..378363b4479 100644
--- a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavMenu.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavMenu.tsx
@@ -139,7 +139,8 @@ export default class GlobalNavMenu extends React.PureComponent<Props> {
{({ onToggleClick, open }) => (
<a
aria-expanded={open}
- aria-haspopup="true"
+ aria-haspopup="menu"
+ role="button"
className={classNames('dropdown-toggle', { active: open })}
href="#"
id="global-navigation-more"
diff --git a/server/sonar-web/src/main/js/app/components/nav/settings/SettingsNav.tsx b/server/sonar-web/src/main/js/app/components/nav/settings/SettingsNav.tsx
index aa705968af2..f3030b36a17 100644
--- a/server/sonar-web/src/main/js/app/components/nav/settings/SettingsNav.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/settings/SettingsNav.tsx
@@ -120,7 +120,8 @@ export default class SettingsNav extends React.PureComponent<Props> {
{({ onToggleClick, open }) => (
<a
aria-expanded={open}
- aria-haspopup="true"
+ aria-haspopup="menu"
+ role="button"
className={classNames('dropdown-toggle', {
active:
open ||
@@ -162,7 +163,8 @@ export default class SettingsNav extends React.PureComponent<Props> {
{({ onToggleClick, open }) => (
<a
aria-expanded={open}
- aria-haspopup="true"
+ aria-haspopup="menu"
+ role="button"
className={classNames('dropdown-toggle', { active: open || this.isProjectsActive() })}
href="#"
onClick={onToggleClick}>
@@ -205,7 +207,8 @@ export default class SettingsNav extends React.PureComponent<Props> {
{({ onToggleClick, open }) => (
<a
aria-expanded={open}
- aria-haspopup="true"
+ aria-haspopup="menu"
+ role="button"
className={classNames('dropdown-toggle', { active: open || this.isSecurityActive() })}
href="#"
onClick={onToggleClick}>
diff --git a/server/sonar-web/src/main/js/app/index.ts b/server/sonar-web/src/main/js/app/index.ts
index 258abd572d1..98dc2d01d5f 100644
--- a/server/sonar-web/src/main/js/app/index.ts
+++ b/server/sonar-web/src/main/js/app/index.ts
@@ -46,11 +46,15 @@ if (isMainApp()) {
} else {
// login, maintenance or setup pages
- const appStatePromise: Promise<T.AppState> = new Promise(resolve =>
+ const appStatePromise: Promise<T.AppState | undefined> = new Promise(resolve => {
loadAppState()
- .then(data => resolve(data))
- .catch(() => resolve(undefined))
- );
+ .then(data => {
+ resolve(data);
+ })
+ .catch(() => {
+ resolve(undefined);
+ });
+ });
Promise.all([loadL10nBundle(), appStatePromise, loadApp()]).then(
([l10nBundle, appState, startReactApp]) => {
diff --git a/server/sonar-web/src/main/js/apps/application-console/__tests__/EditForm-test.tsx b/server/sonar-web/src/main/js/apps/application-console/__tests__/EditForm-test.tsx
index 317d4c2d336..1e60305639d 100644
--- a/server/sonar-web/src/main/js/apps/application-console/__tests__/EditForm-test.tsx
+++ b/server/sonar-web/src/main/js/apps/application-console/__tests__/EditForm-test.tsx
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import { shallow } from 'enzyme';
import * as React from 'react';
import SimpleModal from 'sonar-ui-common/components/controls/SimpleModal';
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetails-test.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetails-test.tsx
index de8f9c1ca3b..c0dbe57b146 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetails-test.tsx
+++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetails-test.tsx
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import { shallow } from 'enzyme';
import * as React from 'react';
import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureContent-test.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureContent-test.tsx
index 1474bd9d110..9c11be6f3b1 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureContent-test.tsx
+++ b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureContent-test.tsx
@@ -25,7 +25,7 @@ import { mockComponentMeasure, mockRouter } from '../../../../helpers/testMocks'
import MeasureContent from '../MeasureContent';
jest.mock('../../../../api/components', () => {
- const { mockComponentMeasure } = require.requireActual('../../../../helpers/testMocks');
+ const { mockComponentMeasure } = jest.requireActual('../../../../helpers/testMocks');
return {
getComponentTree: jest.fn().mockResolvedValue({
paging: { pageIndex: 1, pageSize: 500, total: 2 },
diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/AzureProjectCreate-test.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/AzureProjectCreate-test.tsx
index 896ceea2733..f773c8f33f0 100644
--- a/server/sonar-web/src/main/js/apps/create/project/__tests__/AzureProjectCreate-test.tsx
+++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/AzureProjectCreate-test.tsx
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import { shallow } from 'enzyme';
import * as React from 'react';
import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/AzureProjectCreateRenderer-test.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/AzureProjectCreateRenderer-test.tsx
index d185784ed2d..a11317e3bbf 100644
--- a/server/sonar-web/src/main/js/apps/create/project/__tests__/AzureProjectCreateRenderer-test.tsx
+++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/AzureProjectCreateRenderer-test.tsx
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import { shallow } from 'enzyme';
import * as React from 'react';
import { mockAzureProject, mockAzureRepository } from '../../../../helpers/mocks/alm-integrations';
diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketImportRepositoryForm-test.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketImportRepositoryForm-test.tsx
index b103d0da5a5..702e6134058 100644
--- a/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketImportRepositoryForm-test.tsx
+++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketImportRepositoryForm-test.tsx
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import { shallow } from 'enzyme';
import * as React from 'react';
import SearchBox from 'sonar-ui-common/components/controls/SearchBox';
diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketProjectAccordion-test.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketProjectAccordion-test.tsx
index 99d2bb7e2da..671cfa4fdc0 100644
--- a/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketProjectAccordion-test.tsx
+++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketProjectAccordion-test.tsx
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import { shallow } from 'enzyme';
import * as React from 'react';
import Radio from 'sonar-ui-common/components/controls/Radio';
diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketRepositories-test.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketRepositories-test.tsx
index b6e44289991..87cdc788213 100644
--- a/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketRepositories-test.tsx
+++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketRepositories-test.tsx
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import { shallow } from 'enzyme';
import * as React from 'react';
import { click } from 'sonar-ui-common/helpers/testUtils';
diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/ManualProjectCreate-test.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/ManualProjectCreate-test.tsx
index cf7b86df900..10199afaa91 100644
--- a/server/sonar-web/src/main/js/apps/create/project/__tests__/ManualProjectCreate-test.tsx
+++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/ManualProjectCreate-test.tsx
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import { shallow } from 'enzyme';
import * as React from 'react';
import { SubmitButton } from 'sonar-ui-common/components/controls/buttons';
diff --git a/server/sonar-web/src/main/js/apps/documentation/__tests__/pages-test.ts b/server/sonar-web/src/main/js/apps/documentation/__tests__/pages-test.ts
index 0b99e9c18f8..7e61f661cc4 100644
--- a/server/sonar-web/src/main/js/apps/documentation/__tests__/pages-test.ts
+++ b/server/sonar-web/src/main/js/apps/documentation/__tests__/pages-test.ts
@@ -123,5 +123,5 @@ it('should not break the whole doc when one page cannot be parsed', () => {
function getPages(overrides: T.Dict<ParsedContent> = {}) {
// This allows the use of out-of-scope data inside jest.mock
// Usually, it is impossible as jest.mock'ed module is hoisted on the top of the file
- return require.requireActual('../pages').default(overrides);
+ return jest.requireActual('../pages').default(overrides);
}
diff --git a/server/sonar-web/src/main/js/apps/documentation/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/documentation/components/__tests__/App-test.tsx
index dbdd11f6770..4f96566d970 100644
--- a/server/sonar-web/src/main/js/apps/documentation/components/__tests__/App-test.tsx
+++ b/server/sonar-web/src/main/js/apps/documentation/components/__tests__/App-test.tsx
@@ -84,7 +84,7 @@ jest.mock('sonar-ui-common/helpers/pages', () => ({
}));
jest.mock('sonar-ui-common/helpers/request', () => {
- const { mockDocumentationMarkdown } = require.requireActual('../../../../helpers/testMocks');
+ const { mockDocumentationMarkdown } = jest.requireActual('../../../../helpers/testMocks');
return {
request: jest.fn(() => ({
submit: jest.fn().mockResolvedValue({
@@ -96,7 +96,7 @@ jest.mock('sonar-ui-common/helpers/request', () => {
});
jest.mock('../../pages', () => {
- const { mockDocumentationEntry } = require.requireActual('../../../../helpers/testMocks');
+ const { mockDocumentationEntry } = jest.requireActual('../../../../helpers/testMocks');
return {
default: jest
.fn()
diff --git a/server/sonar-web/src/main/js/apps/groups/components/App.tsx b/server/sonar-web/src/main/js/apps/groups/components/App.tsx
index 0419db39de8..fc779853d14 100644
--- a/server/sonar-web/src/main/js/apps/groups/components/App.tsx
+++ b/server/sonar-web/src/main/js/apps/groups/components/App.tsx
@@ -110,7 +110,8 @@ export default class App extends React.PureComponent<{}, State> {
// reload all pages in order
if (paging && paging.pageIndex > 1) {
for (let p = 1; p < paging.pageIndex; p++) {
- await this.fetchMoreGroups();
+ // eslint-disable-next-line no-await-in-loop
+ await this.fetchMoreGroups(); // This is a intentional promise chain
}
}
};
diff --git a/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.tsx b/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.tsx
index 776206a9ac1..cacfe24b828 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.tsx
@@ -25,7 +25,6 @@ import { getSelectedLocation } from '../utils';
interface Props {
component?: T.Component;
issue: T.Issue;
- link?: boolean;
selectedFlowIndex?: number;
selectedLocationIndex?: number;
}
diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssuesCounter.tsx b/server/sonar-web/src/main/js/apps/issues/components/IssuesCounter.tsx
index 8657dfd02d9..8526a566871 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/IssuesCounter.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/components/IssuesCounter.tsx
@@ -22,7 +22,6 @@ import { translate } from 'sonar-ui-common/helpers/l10n';
import PageCounter from '../../../components/common/PageCounter';
interface Props {
- className?: string;
current: number | undefined;
total: number;
}
diff --git a/server/sonar-web/src/main/js/apps/issues/components/PageActions.tsx b/server/sonar-web/src/main/js/apps/issues/components/PageActions.tsx
index f005e337474..e401c145624 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/PageActions.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/components/PageActions.tsx
@@ -61,9 +61,7 @@ export default class PageActions extends React.PureComponent<Props> {
<div className="issues-page-actions">
<ReloadButton onClick={this.props.onReload} />
- {paging != null && (
- <IssuesCounter className="spacer-left" current={selectedIndex} total={paging.total} />
- )}
+ {paging != null && <IssuesCounter current={selectedIndex} total={paging.total} />}
{effortTotal !== undefined && <TotalEffort effort={effortTotal} />}
</div>
diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/PageActions-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/PageActions-test.tsx.snap
index 446f460ac6d..09f7ccf406e 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/PageActions-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/PageActions-test.tsx.snap
@@ -43,7 +43,6 @@ exports[`should render 1`] = `
onClick={[MockFunction]}
/>
<IssuesCounter
- className="spacer-left"
current={5}
total={12345}
/>
diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/CrossComponentSourceViewerWrapper-test.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/CrossComponentSourceViewerWrapper-test.tsx
index 6099c40c521..088058f9735 100644
--- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/CrossComponentSourceViewerWrapper-test.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/CrossComponentSourceViewerWrapper-test.tsx
@@ -32,7 +32,7 @@ import {
import CrossComponentSourceViewerWrapper from '../CrossComponentSourceViewerWrapper';
jest.mock('../../../../api/issues', () => {
- const { mockSnippetsByComponent } = require.requireActual('../../../../helpers/testMocks');
+ const { mockSnippetsByComponent } = jest.requireActual('../../../../helpers/testMocks');
return {
getIssueFlowSnippets: jest.fn().mockResolvedValue({ 'main.js': mockSnippetsByComponent() })
};
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/StandardFacet-test.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/StandardFacet-test.tsx
index 2ef95ee86da..57205c07e31 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/StandardFacet-test.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/StandardFacet-test.tsx
@@ -25,7 +25,7 @@ import { Query } from '../../utils';
import StandardFacet from '../StandardFacet';
jest.mock('../../../../helpers/security-standard', () => ({
- ...require.requireActual('../../../../helpers/security-standard'),
+ ...jest.requireActual('../../../../helpers/security-standard'),
getStandards: jest.fn().mockResolvedValue({
owaspTop10: {
a1: {
diff --git a/server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-test.tsx b/server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-test.tsx
index 7899f1f37fa..db78cc4ec3b 100644
--- a/server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-test.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-test.tsx
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import { shallow } from 'enzyme';
import * as React from 'react';
import { isDiffMetric } from 'sonar-ui-common/helpers/measures';
@@ -45,7 +45,7 @@ jest.mock('sonar-ui-common/helpers/dates', () => ({
}));
jest.mock('../../../../api/measures', () => {
- const { mockMeasure, mockMetric } = require.requireActual('../../../../helpers/testMocks');
+ const { mockMeasure, mockMetric } = jest.requireActual('../../../../helpers/testMocks');
return {
getMeasuresWithPeriodAndMetrics: jest.fn((_, metricKeys: string[]) => {
const metrics: T.Metric[] = [];
@@ -83,10 +83,10 @@ jest.mock('../../../../api/measures', () => {
});
jest.mock('../../../../api/quality-gates', () => {
- const { mockQualityGateProjectStatus, mockQualityGateApplicationStatus } = require.requireActual(
+ const { mockQualityGateProjectStatus, mockQualityGateApplicationStatus } = jest.requireActual(
'../../../../helpers/mocks/quality-gates'
);
- const { MetricKey } = require.requireActual('../../../../types/metrics');
+ const { MetricKey } = jest.requireActual('../../../../types/metrics');
return {
getQualityGateProjectStatus: jest.fn().mockResolvedValue(
mockQualityGateProjectStatus({
@@ -124,7 +124,7 @@ jest.mock('../../../../api/quality-gates', () => {
});
jest.mock('../../../../api/time-machine', () => {
- const { MetricKey } = require.requireActual('../../../../types/metrics');
+ const { MetricKey } = jest.requireActual('../../../../types/metrics');
return {
getAllTimeMachineData: jest.fn().mockResolvedValue({
measures: [
@@ -143,7 +143,7 @@ jest.mock('../../../../api/time-machine', () => {
});
jest.mock('../../../../api/projectActivity', () => {
- const { mockAnalysis } = require.requireActual('../../../../helpers/testMocks');
+ const { mockAnalysis } = jest.requireActual('../../../../helpers/testMocks');
return {
getProjectActivity: jest.fn().mockResolvedValue({
analyses: [mockAnalysis(), mockAnalysis(), mockAnalysis(), mockAnalysis(), mockAnalysis()]
@@ -175,8 +175,8 @@ jest.mock('../../../../api/application', () => ({
}));
jest.mock('../../../../components/activity-graph/utils', () => {
- const { MetricKey } = require.requireActual('../../../../types/metrics');
- const { GraphType } = require.requireActual('../../../../types/project-activity');
+ const { MetricKey } = jest.requireActual('../../../../types/metrics');
+ const { GraphType } = jest.requireActual('../../../../types/project-activity');
return {
getActivityGraph: jest.fn(() => ({ graph: GraphType.coverage })),
saveActivityGraph: jest.fn(),
diff --git a/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/PullRequestOverview-test.tsx b/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/PullRequestOverview-test.tsx
index a90e9b7a4fc..3f79a7f6288 100644
--- a/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/PullRequestOverview-test.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/PullRequestOverview-test.tsx
@@ -28,7 +28,7 @@ import { PR_METRICS } from '../../utils';
import { PullRequestOverview } from '../PullRequestOverview';
jest.mock('../../../../api/measures', () => {
- const { mockMeasure, mockMetric } = require.requireActual('../../../../helpers/testMocks');
+ const { mockMeasure, mockMetric } = jest.requireActual('../../../../helpers/testMocks');
return {
getMeasuresWithMetrics: jest.fn().mockResolvedValue({
component: {
diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/MetricBox-test.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/MetricBox-test.tsx
index d66a165cfba..80307fead00 100644
--- a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/MetricBox-test.tsx
+++ b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/MetricBox-test.tsx
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import { shallow } from 'enzyme';
import * as React from 'react';
import MetricBox, { MetricBoxProps } from '../MetricBox';
diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/Report-test.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/Report-test.tsx
index 9c37d7fc6f6..26638a78f2c 100644
--- a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/Report-test.tsx
+++ b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/Report-test.tsx
@@ -19,7 +19,7 @@
*/
/* eslint-disable import/first */
jest.mock('../../../../api/report', () => {
- const report = require.requireActual('../../../../api/report');
+ const report = jest.requireActual('../../../../api/report');
report.getReportStatus = jest.fn(() => Promise.resolve({}));
return report;
});
diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/Subscription-test.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/Subscription-test.tsx
index 8a44930a8fb..045226a7e85 100644
--- a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/Subscription-test.tsx
+++ b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/Subscription-test.tsx
@@ -19,7 +19,7 @@
*/
/* eslint-disable import/first */
jest.mock('../../../../api/report', () => {
- const report = require.requireActual('../../../../api/report');
+ const report = jest.requireActual('../../../../api/report');
report.subscribe = jest.fn(() => Promise.resolve());
report.unsubscribe = jest.fn(() => Promise.resolve());
return report;
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAnalysesList-test.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAnalysesList-test.tsx
index efc6d80ff00..c458e7cc0b7 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAnalysesList-test.tsx
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAnalysesList-test.tsx
@@ -32,7 +32,7 @@ jest.mock('date-fns/start_of_day', () => (date: Date) => {
});
jest.mock('sonar-ui-common/helpers/dates', () => {
- const actual = require.requireActual('sonar-ui-common/helpers/dates');
+ const actual = jest.requireActual('sonar-ui-common/helpers/dates');
return { ...actual, toShortNotSoISOString: (date: string) => 'ISO.' + date };
});
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAnalysis-test.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAnalysis-test.tsx
index 4d84633519d..f88cebbbb25 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAnalysis-test.tsx
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAnalysis-test.tsx
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import { mount, shallow } from 'enzyme';
import * as React from 'react';
import { IntlProvider } from 'react-intl';
diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/BranchAnalysisListRenderer-test.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/BranchAnalysisListRenderer-test.tsx
index 5ff26cfbb98..45785c4f34e 100644
--- a/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/BranchAnalysisListRenderer-test.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/BranchAnalysisListRenderer-test.tsx
@@ -31,7 +31,7 @@ jest.mock('date-fns/start_of_day', () => (date: Date) => {
});
jest.mock('sonar-ui-common/helpers/dates', () => {
- const actual = require.requireActual('sonar-ui-common/helpers/dates');
+ const actual = jest.requireActual('sonar-ui-common/helpers/dates');
return { ...actual, toShortNotSoISOString: (date: string) => `ISO.${date}` };
});
diff --git a/server/sonar-web/src/main/js/apps/projectQualityGate/ProjectQualityGateApp.tsx b/server/sonar-web/src/main/js/apps/projectQualityGate/ProjectQualityGateApp.tsx
index 7ab4dcafc11..5aa28ff3d43 100644
--- a/server/sonar-web/src/main/js/apps/projectQualityGate/ProjectQualityGateApp.tsx
+++ b/server/sonar-web/src/main/js/apps/projectQualityGate/ProjectQualityGateApp.tsx
@@ -76,22 +76,21 @@ export default class ProjectQualityGateApp extends React.PureComponent<Props, St
if (!qualityGate.isDefault) {
return false;
- } else {
- // If this is the default Quality Gate, check if it was explicitly
- // selected, or if we're inheriting the system default.
- /* eslint-disable-next-line sonarjs/prefer-immediate-return */
- const selected = await searchProjects({
- gateName: qualityGate.name,
- query: component.key
+ }
+
+ // If this is the default Quality Gate, check if it was explicitly
+ // selected, or if we're inheriting the system default.
+ const selected = await searchProjects({
+ gateName: qualityGate.name,
+ query: component.key
+ })
+ .then(({ results }) => {
+ return Boolean(results.find(r => r.key === component.key)?.selected);
})
- .then(({ results }) => {
- return Boolean(results.find(r => r.key === component.key)?.selected);
- })
- .catch(() => false);
+ .catch(() => false);
- // If it's NOT selected, it means we're following the system default.
- return !selected;
- }
+ // If it's NOT selected, it means we're following the system default.
+ return !selected;
};
fetchQualityGates = async () => {
diff --git a/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/ProjectQualityGateAppRenderer-test.tsx b/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/ProjectQualityGateAppRenderer-test.tsx
index 5ae3cba3cbd..cc1b3a36896 100644
--- a/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/ProjectQualityGateAppRenderer-test.tsx
+++ b/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/ProjectQualityGateAppRenderer-test.tsx
@@ -52,13 +52,14 @@ it('should render correctly', () => {
});
it('should render select options correctly', () => {
- return new Promise(resolve => {
+ return new Promise<void>(resolve => {
const wrapper = shallowRender();
const render = wrapper.find(Select).props().optionRenderer;
- if (render) {
- expect(render({ value: '1', label: 'Gate 1' })).toMatchSnapshot('default');
- resolve();
- }
+
+ expect(render).toBeDefined();
+
+ expect(render!({ value: '1', label: 'Gate 1' })).toMatchSnapshot('default');
+ resolve();
});
});
diff --git a/server/sonar-web/src/main/js/apps/projectQualityProfiles/components/__tests__/AddLanguageModal-test.tsx b/server/sonar-web/src/main/js/apps/projectQualityProfiles/components/__tests__/AddLanguageModal-test.tsx
index cb40823fea7..60d5960ca89 100644
--- a/server/sonar-web/src/main/js/apps/projectQualityProfiles/components/__tests__/AddLanguageModal-test.tsx
+++ b/server/sonar-web/src/main/js/apps/projectQualityProfiles/components/__tests__/AddLanguageModal-test.tsx
@@ -29,39 +29,37 @@ it('should render correctly', () => {
});
it('should correctly handle changes', () => {
- return new Promise(resolve => {
- const onSubmit = jest.fn();
- const wrapper = shallowRender({ onSubmit });
-
- const langSelect = getLanguageSelect(wrapper);
- let profileSelect = getProfileSelect(wrapper);
-
- // Language select should only have 2; JS is not available. Profile Select
- // should have none, as no language is selected yet.
- expect(langSelect.props().options).toHaveLength(2);
- expect(profileSelect.props().options).toHaveLength(0);
-
- // Choose CSS.
- const langChange = langSelect.props().onChange;
- if (langChange) {
- langChange({ value: 'css' });
-
- // Should now show 2 available profiles.
- profileSelect = getProfileSelect(wrapper);
- expect(profileSelect.props().options).toHaveLength(2);
-
- // Choose 1 profile.
- const profileChange = profileSelect.props().onChange;
- if (profileChange) {
- profileChange({ value: 'css2' });
-
- submitSimpleModal(wrapper);
- expect(onSubmit).toHaveBeenLastCalledWith('css2');
-
- resolve();
- }
- }
- });
+ const onSubmit = jest.fn();
+ const wrapper = shallowRender({ onSubmit });
+
+ const langSelect = getLanguageSelect(wrapper);
+ let profileSelect = getProfileSelect(wrapper);
+
+ // Language select should only have 2; JS is not available. Profile Select
+ // should have none, as no language is selected yet.
+ expect(langSelect.props().options).toHaveLength(2);
+ expect(profileSelect.props().options).toHaveLength(0);
+
+ // Choose CSS.
+ const langChange = langSelect.props().onChange;
+
+ expect(langChange).toBeDefined();
+
+ langChange!({ value: 'css' });
+
+ // Should now show 2 available profiles.
+ profileSelect = getProfileSelect(wrapper);
+ expect(profileSelect.props().options).toHaveLength(2);
+
+ // Choose 1 profile.
+ const profileChange = profileSelect.props().onChange;
+
+ expect(profileChange).toBeDefined();
+
+ profileChange!({ value: 'css2' });
+
+ submitSimpleModal(wrapper);
+ expect(onSubmit).toHaveBeenLastCalledWith('css2');
});
function diveIntoSimpleModal(wrapper: ShallowWrapper) {
diff --git a/server/sonar-web/src/main/js/apps/projectQualityProfiles/components/__tests__/SetQualityProfileModal-test.tsx b/server/sonar-web/src/main/js/apps/projectQualityProfiles/components/__tests__/SetQualityProfileModal-test.tsx
index 3695fe932a0..6e3b4fe9145 100644
--- a/server/sonar-web/src/main/js/apps/projectQualityProfiles/components/__tests__/SetQualityProfileModal-test.tsx
+++ b/server/sonar-web/src/main/js/apps/projectQualityProfiles/components/__tests__/SetQualityProfileModal-test.tsx
@@ -32,48 +32,43 @@ it('should render correctly', () => {
});
it('should render select options correctly', () => {
- return new Promise(resolve => {
- const wrapper = shallowRender();
- const render = wrapper.find(Select).props().optionRenderer;
- if (render) {
- expect(render({ value: 'bar', label: 'Profile 1' })).toMatchSnapshot('default');
- resolve();
- }
- });
+ const wrapper = shallowRender();
+ const render = wrapper.find(Select).props().optionRenderer;
+
+ expect(render).toBeDefined();
+
+ expect(render!({ value: 'bar', label: 'Profile 1' })).toMatchSnapshot('default');
});
it('should correctly handle changes', () => {
- return new Promise(resolve => {
- const onSubmit = jest.fn();
- const wrapper = shallowRender({ onSubmit }, false);
+ const onSubmit = jest.fn();
+ const wrapper = shallowRender({ onSubmit }, false);
- diveIntoSimpleModal(wrapper)
- .find(Radio)
- .at(0)
- .props()
- .onCheck('');
- submitSimpleModal(wrapper);
- expect(onSubmit).toHaveBeenLastCalledWith(undefined, 'foo');
+ diveIntoSimpleModal(wrapper)
+ .find(Radio)
+ .at(0)
+ .props()
+ .onCheck('');
+ submitSimpleModal(wrapper);
+ expect(onSubmit).toHaveBeenLastCalledWith(undefined, 'foo');
+
+ diveIntoSimpleModal(wrapper)
+ .find(Radio)
+ .at(1)
+ .props()
+ .onCheck('');
+ submitSimpleModal(wrapper);
+ expect(onSubmit).toHaveBeenLastCalledWith('foo', 'foo');
- diveIntoSimpleModal(wrapper)
- .find(Radio)
- .at(1)
- .props()
- .onCheck('');
- submitSimpleModal(wrapper);
- expect(onSubmit).toHaveBeenLastCalledWith('foo', 'foo');
+ const change = diveIntoSimpleModal(wrapper)
+ .find(Select)
+ .props().onChange;
- const change = diveIntoSimpleModal(wrapper)
- .find(Select)
- .props().onChange;
- if (change) {
- change({ value: 'bar' });
- submitSimpleModal(wrapper);
- expect(onSubmit).toHaveBeenLastCalledWith('bar', 'foo');
+ expect(change).toBeDefined();
- resolve();
- }
- });
+ change!({ value: 'bar' });
+ submitSimpleModal(wrapper);
+ expect(onSubmit).toHaveBeenLastCalledWith('bar', 'foo');
});
function diveIntoSimpleModal(wrapper: ShallowWrapper) {
diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/AllProjects-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/AllProjects-test.tsx
index 59588af0b39..529ff1d70fc 100644
--- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/AllProjects-test.tsx
+++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/AllProjects-test.tsx
@@ -50,7 +50,7 @@ jest.mock('../PageSidebar', () => ({
}));
jest.mock('../../utils', () => {
- const utils = require.requireActual('../../utils');
+ const utils = jest.requireActual('../../utils');
utils.fetchProjects = jest.fn(() => Promise.resolve({ projects: [] }));
return utils;
});
diff --git a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx
index e5bdaaff22d..195587df404 100644
--- a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx
+++ b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx
@@ -50,20 +50,18 @@ interface Props {
type?: string;
}
-function renderFirstLine(props: Props) {
+function renderFirstLine(project: Props['project'], handleFavorite: Props['handleFavorite']) {
const {
- project: {
- analysisDate,
- tags,
- qualifier,
- isFavorite,
- key,
- name,
- measures,
- needIssueSync,
- visibility
- }
- } = props;
+ analysisDate,
+ tags,
+ qualifier,
+ isFavorite,
+ key,
+ name,
+ measures,
+ needIssueSync,
+ visibility
+ } = project;
return (
<div className="display-flex-center">
@@ -73,7 +71,7 @@ function renderFirstLine(props: Props) {
className="spacer-right"
component={key}
favorite={isFavorite}
- handleFavorite={props.handleFavorite}
+ handleFavorite={handleFavorite}
qualifier={qualifier}
/>
)}
@@ -134,10 +132,12 @@ function renderFirstLine(props: Props) {
);
}
-function renderSecondLine(props: Props, isNewCode: boolean) {
- const {
- project: { measures }
- } = props;
+function renderSecondLine(
+ currentUser: Props['currentUser'],
+ project: Props['project'],
+ isNewCode: boolean
+) {
+ const { measures } = project;
return (
<div
@@ -145,7 +145,7 @@ function renderSecondLine(props: Props, isNewCode: boolean) {
'project-card-leak': isNewCode
})}>
<div className="project-card-main big-padded-left big-padded-right big-padded-bottom">
- {renderMeasures(props, isNewCode)}
+ {renderMeasures(currentUser, project, isNewCode)}
</div>
<div className="project-card-meta display-flex-end big-padded-left big-padded-right big-padded-bottom">
{isNewCode
@@ -187,11 +187,12 @@ function renderSecondLine(props: Props, isNewCode: boolean) {
);
}
-function renderMeasures(props: Props, isNewCode: boolean) {
- const {
- currentUser,
- project: { measures, needIssueSync, analysisDate, leakPeriodDate, qualifier, key }
- } = props;
+function renderMeasures(
+ currentUser: Props['currentUser'],
+ project: Props['project'],
+ isNewCode: boolean
+) {
+ const { measures, needIssueSync, analysisDate, leakPeriodDate, qualifier, key } = project;
if (analysisDate && (!isNewCode || leakPeriodDate)) {
return (
@@ -202,44 +203,40 @@ function renderMeasures(props: Props, isNewCode: boolean) {
newCodeStartingDate={leakPeriodDate}
/>
);
- } else {
- return (
- <div className="spacer-top spacer-bottom">
- <span className="note">
- {isNewCode && analysisDate
- ? translate('projects.no_new_code_period', qualifier)
- : translate('projects.not_analyzed', qualifier)}
- </span>
- {qualifier !== ComponentQualifier.Application &&
- !analysisDate &&
- isLoggedIn(currentUser) &&
- !needIssueSync && (
- <Link className="button spacer-left" to={getProjectUrl(key)}>
- {translate('projects.configure_analysis')}
- </Link>
- )}
- </div>
- );
}
+
+ return (
+ <div className="spacer-top spacer-bottom">
+ <span className="note">
+ {isNewCode && analysisDate
+ ? translate('projects.no_new_code_period', qualifier)
+ : translate('projects.not_analyzed', qualifier)}
+ </span>
+ {qualifier !== ComponentQualifier.Application &&
+ !analysisDate &&
+ isLoggedIn(currentUser) &&
+ !needIssueSync && (
+ <Link className="button spacer-left" to={getProjectUrl(key)}>
+ {translate('projects.configure_analysis')}
+ </Link>
+ )}
+ </div>
+ );
}
export default function ProjectCard(props: Props) {
- const {
- height,
- type,
- project: { needIssueSync, key }
- } = props;
+ const { currentUser, height, type, project } = props;
const isNewCode = type === 'leak';
return (
<div
className={classNames('display-flex-column boxed-group it_project_card', {
- 'project-card-disabled': needIssueSync
+ 'project-card-disabled': project.needIssueSync
})}
- data-key={key}
+ data-key={project.key}
style={{ height }}>
- {renderFirstLine(props)}
- {renderSecondLine(props, isNewCode)}
+ {renderFirstLine(project, props.handleFavorite)}
+ {renderSecondLine(currentUser, project, isNewCode)}
</div>
);
}
diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ChangelogContainer-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ChangelogContainer-test.tsx
index ef0577c733e..3a5f0c36159 100644
--- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ChangelogContainer-test.tsx
+++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ChangelogContainer-test.tsx
@@ -27,9 +27,7 @@ import { ChangelogContainer } from '../ChangelogContainer';
beforeEach(() => jest.clearAllMocks());
jest.mock('../../../../api/quality-profiles', () => {
- const { mockQualityProfileChangelogEvent } = require.requireActual(
- '../../../../helpers/testMocks'
- );
+ const { mockQualityProfileChangelogEvent } = jest.requireActual('../../../../helpers/testMocks');
return {
getProfileChangelog: jest.fn().mockResolvedValue({
events: [
diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsFormSelect-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsFormSelect-test.tsx
index a34e5703e25..3097591015b 100644
--- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsFormSelect-test.tsx
+++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsFormSelect-test.tsx
@@ -22,7 +22,7 @@ import * as React from 'react';
import ProfilePermissionsFormSelect from '../ProfilePermissionsFormSelect';
jest.mock('lodash', () => {
- const lodash = require.requireActual('lodash');
+ const lodash = jest.requireActual('lodash');
lodash.debounce = (fn: Function) => (...args: any[]) => fn(...args);
return lodash;
});
diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/__tests__/__snapshots__/HotspotOpenInIdeButton-test.tsx.snap b/server/sonar-web/src/main/js/apps/security-hotspots/components/__tests__/__snapshots__/HotspotOpenInIdeButton-test.tsx.snap
index c8e8a39851d..7a96eec6c18 100644
--- a/server/sonar-web/src/main/js/apps/security-hotspots/components/__tests__/__snapshots__/HotspotOpenInIdeButton-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/__tests__/__snapshots__/HotspotOpenInIdeButton-test.tsx.snap
@@ -6,7 +6,7 @@ exports[`HotspotOpenInIdeButton should handle several IDE 1`] = `
open={false}
overlay={
<DropdownOverlay>
- <Unknown
+ <HotspotOpenInIdeOverlay
ides={Array []}
onIdeSelected={[Function]}
/>
@@ -31,7 +31,7 @@ exports[`HotspotOpenInIdeButton should handle several IDE: dropdown open 1`] = `
open={true}
overlay={
<DropdownOverlay>
- <Unknown
+ <HotspotOpenInIdeOverlay
ides={
Array [
Object {
@@ -69,7 +69,7 @@ exports[`HotspotOpenInIdeButton should render correctly 1`] = `
open={false}
overlay={
<DropdownOverlay>
- <Unknown
+ <HotspotOpenInIdeOverlay
ides={Array []}
onIdeSelected={[Function]}
/>
@@ -86,4 +86,4 @@ exports[`HotspotOpenInIdeButton should render correctly 1`] = `
/>
</Button>
</Toggler>
-`; \ No newline at end of file
+`;
diff --git a/server/sonar-web/src/main/js/apps/settings/components/__tests__/EmailForm-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/__tests__/EmailForm-test.tsx
index 14724260582..a0ae6b993d6 100644
--- a/server/sonar-web/src/main/js/apps/settings/components/__tests__/EmailForm-test.tsx
+++ b/server/sonar-web/src/main/js/apps/settings/components/__tests__/EmailForm-test.tsx
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import { shallow } from 'enzyme';
import * as React from 'react';
import { change, submit, waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
diff --git a/server/sonar-web/src/main/js/apps/system/__tests__/utils-test.ts b/server/sonar-web/src/main/js/apps/system/__tests__/utils-test.ts
index 5290647c0af..331497b902d 100644
--- a/server/sonar-web/src/main/js/apps/system/__tests__/utils-test.ts
+++ b/server/sonar-web/src/main/js/apps/system/__tests__/utils-test.ts
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import { mockClusterSysInfo, mockStandaloneSysInfo } from '../../../helpers/testMocks';
import { SystemUpgrade } from '../../../types/system';
import * as u from '../utils';
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx
index 918f8d2cec9..d300da764ec 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx
+++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx
@@ -223,9 +223,9 @@ export default class SourceViewerBase extends React.PureComponent<Props, State>
const firstLine = sources[0];
const lastList = sources[sources.length - 1];
return lineNumber < firstLine.line || lineNumber > lastList.line;
- } else {
- return true;
}
+
+ return true;
}
fetchComponent() {
@@ -383,10 +383,9 @@ export default class SourceViewerBase extends React.PureComponent<Props, State>
// request one additional line to define `hasSourcesAfter`
to++;
- return this.propsLoadSources(this.props.component, from, to, this.props.branchLike).then(
- sources => resolve(sources),
- onFailLoadSources
- );
+ this.propsLoadSources(this.props.component, from, to, this.props.branchLike).then(sources => {
+ resolve(sources);
+ }, onFailLoadSources);
});
};
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerBase-test.tsx b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerBase-test.tsx
index 316faf2c5ca..eea4cbd8247 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerBase-test.tsx
+++ b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerBase-test.tsx
@@ -146,6 +146,13 @@ it('should load sources after', async () => {
expect(wrapper.state().issues).toHaveLength(2);
});
+it('should handle no sources when checking ranges', () => {
+ const wrapper = shallowRender();
+
+ wrapper.setState({ sources: undefined });
+ expect(wrapper.instance().isLineOutsideOfRange(12)).toBe(true);
+});
+
function shallowRender(overrides: Partial<SourceViewerBase['props']> = {}) {
return shallow<SourceViewerBase>(
<SourceViewerBase branchLike={mockMainBranch()} component="my-component" {...overrides} />
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineSCM-test.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineSCM-test.tsx
index aa69190a747..a1493b031e6 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineSCM-test.tsx
+++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineSCM-test.tsx
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import { shallow } from 'enzyme';
import * as React from 'react';
import { LineSCM, LineSCMProps } from '../LineSCM';
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/SCMPopup-test.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/SCMPopup-test.tsx
index 9db75c86dc2..c8a5daff578 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/SCMPopup-test.tsx
+++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/SCMPopup-test.tsx
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import { shallow } from 'enzyme';
import * as React from 'react';
import { SCMPopup, SCMPopupProps } from '../SCMPopup';
diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsHistory-test.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsHistory-test.tsx
index be789d1176a..ad83117996c 100644
--- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsHistory-test.tsx
+++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsHistory-test.tsx
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import { shallow } from 'enzyme';
import * as React from 'react';
import { parseDate } from 'sonar-ui-common/helpers/dates';
diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltips-test.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltips-test.tsx
index 85cdb305288..98d8bf9d83c 100644
--- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltips-test.tsx
+++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltips-test.tsx
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import { shallow } from 'enzyme';
import * as React from 'react';
import { parseDate } from 'sonar-ui-common/helpers/dates';
diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContentCoverage-test.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContentCoverage-test.tsx
index 190ba4f0844..f088d70aadc 100644
--- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContentCoverage-test.tsx
+++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContentCoverage-test.tsx
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import { shallow } from 'enzyme';
import * as React from 'react';
import { parseDate } from 'sonar-ui-common/helpers/dates';
diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/utils-test.ts b/server/sonar-web/src/main/js/components/activity-graph/__tests__/utils-test.ts
index 83d28c9e19c..d9f53bc3ef8 100644
--- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/utils-test.ts
+++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/utils-test.ts
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import * as dates from 'sonar-ui-common/helpers/dates';
import { MetricKey } from '../../../types/metrics';
import { GraphType, Serie } from '../../../types/project-activity';
diff --git a/server/sonar-web/src/main/js/components/common/BranchStatus.tsx b/server/sonar-web/src/main/js/components/common/BranchStatus.tsx
index 5ebe12fe6ea..91d80dab3e3 100644
--- a/server/sonar-web/src/main/js/components/common/BranchStatus.tsx
+++ b/server/sonar-web/src/main/js/components/common/BranchStatus.tsx
@@ -23,13 +23,16 @@ import Level from 'sonar-ui-common/components/ui/Level';
import { getBranchStatusByBranchLike, Store } from '../../store/rootReducer';
import { BranchLike } from '../../types/branch-like';
-interface Props {
+interface ExposedProps {
branchLike: BranchLike;
component: string;
+}
+
+interface BranchStatusProps {
status?: string;
}
-export function BranchStatus({ status }: Props) {
+export function BranchStatus({ status }: BranchStatusProps) {
if (!status) {
return null;
}
@@ -37,7 +40,8 @@ export function BranchStatus({ status }: Props) {
return <Level level={status} small={true} />;
}
-const mapStateToProps = (state: Store, { branchLike, component }: Props) => {
+const mapStateToProps = (state: Store, props: ExposedProps) => {
+ const { branchLike, component } = props;
const { status } = getBranchStatusByBranchLike(state, component, branchLike);
return { status };
};
diff --git a/server/sonar-web/src/main/js/components/common/__tests__/AnalysisWarningsModal-test.tsx b/server/sonar-web/src/main/js/components/common/__tests__/AnalysisWarningsModal-test.tsx
index 9f34d4ed538..6514e28297a 100644
--- a/server/sonar-web/src/main/js/components/common/__tests__/AnalysisWarningsModal-test.tsx
+++ b/server/sonar-web/src/main/js/components/common/__tests__/AnalysisWarningsModal-test.tsx
@@ -59,29 +59,24 @@ it('should fetch task warnings if it has to', async () => {
expect(getTask).toBeCalledWith('abcd1234', ['warnings']);
});
-it('should correctly handle dismissing warnings', () => {
- return new Promise(resolve => {
- const onWarningDismiss = jest.fn();
- const wrapper = shallowRender({
- componentKey: 'foo',
- onWarningDismiss,
- warnings: [mockTaskWarning({ key: 'bar', dismissable: true })]
- });
-
- const click = wrapper.find('ButtonLink.link-base-color').props().onClick;
- if (click) {
- click(mockEvent());
-
- waitAndUpdate(wrapper).then(
- () => {
- expect(dismissAnalysisWarning).toBeCalledWith('foo', 'bar');
- expect(onWarningDismiss).toBeCalled();
- resolve();
- },
- () => {}
- );
- }
+it('should correctly handle dismissing warnings', async () => {
+ const onWarningDismiss = jest.fn();
+ const wrapper = shallowRender({
+ componentKey: 'foo',
+ onWarningDismiss,
+ warnings: [mockTaskWarning({ key: 'bar', dismissable: true })]
});
+
+ const click = wrapper.find('ButtonLink.link-base-color').props().onClick;
+
+ expect(click).toBeDefined();
+
+ click!(mockEvent());
+
+ await waitAndUpdate(wrapper);
+
+ expect(dismissAnalysisWarning).toBeCalledWith('foo', 'bar');
+ expect(onWarningDismiss).toBeCalled();
});
it('should correctly handle updates', async () => {
diff --git a/server/sonar-web/src/main/js/components/common/__tests__/BranchStatus-test.tsx b/server/sonar-web/src/main/js/components/common/__tests__/BranchStatus-test.tsx
index 2072a60faad..8f20cc14cfe 100644
--- a/server/sonar-web/src/main/js/components/common/__tests__/BranchStatus-test.tsx
+++ b/server/sonar-web/src/main/js/components/common/__tests__/BranchStatus-test.tsx
@@ -19,7 +19,6 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockBranch } from '../../../helpers/mocks/branch-like';
import { BranchStatus } from '../BranchStatus';
it('should render correctly', () => {
@@ -29,5 +28,5 @@ it('should render correctly', () => {
});
function shallowRender(status?: string) {
- return shallow(<BranchStatus branchLike={mockBranch()} component="foo" status={status} />);
+ return shallow(<BranchStatus status={status} />);
}
diff --git a/server/sonar-web/src/main/js/components/docs/DocCollapsibleBlock.tsx b/server/sonar-web/src/main/js/components/docs/DocCollapsibleBlock.tsx
index eda55b285b5..9af17ff06a6 100644
--- a/server/sonar-web/src/main/js/components/docs/DocCollapsibleBlock.tsx
+++ b/server/sonar-web/src/main/js/components/docs/DocCollapsibleBlock.tsx
@@ -38,6 +38,7 @@ export default class DocCollapsibleBlock extends React.PureComponent<{}, State>
<a
aria-expanded={this.state.open}
aria-haspopup={true}
+ role="button"
className="link-no-underline"
href="#"
onClick={this.handleClick}>
diff --git a/server/sonar-web/src/main/js/components/docs/__tests__/DocToc-test.tsx b/server/sonar-web/src/main/js/components/docs/__tests__/DocToc-test.tsx
index d2eb9298eef..e49cf8710df 100644
--- a/server/sonar-web/src/main/js/components/docs/__tests__/DocToc-test.tsx
+++ b/server/sonar-web/src/main/js/components/docs/__tests__/DocToc-test.tsx
@@ -45,17 +45,17 @@ Risus placerat, efficitur enim ut, pellentesque sem. Mauris non lorem auctor, co
`;
jest.mock('remark', () => {
- const remark = require.requireActual('remark');
+ const remark = jest.requireActual('remark');
return { default: remark };
});
jest.mock('remark-react', () => {
- const remarkReact = require.requireActual('remark-react');
+ const remarkReact = jest.requireActual('remark-react');
return { default: remarkReact };
});
jest.mock('lodash', () => {
- const lodash = require.requireActual('lodash');
+ const lodash = jest.requireActual('lodash');
lodash.debounce = (fn: any) => fn;
return lodash;
});
diff --git a/server/sonar-web/src/main/js/components/docs/__tests__/__snapshots__/DocCollapsibleBlock-test.tsx.snap b/server/sonar-web/src/main/js/components/docs/__tests__/__snapshots__/DocCollapsibleBlock-test.tsx.snap
index 11bc4d073e2..7d1afc88f86 100644
--- a/server/sonar-web/src/main/js/components/docs/__tests__/__snapshots__/DocCollapsibleBlock-test.tsx.snap
+++ b/server/sonar-web/src/main/js/components/docs/__tests__/__snapshots__/DocCollapsibleBlock-test.tsx.snap
@@ -12,6 +12,7 @@ exports[`should render a collapsible block 1`] = `
className="link-no-underline"
href="#"
onClick={[Function]}
+ role="button"
>
<OpenCloseIcon
className="text-middle little-spacer-right"
@@ -32,6 +33,7 @@ exports[`should render a collapsible block 2`] = `
className="link-no-underline"
href="#"
onClick={[Function]}
+ role="button"
>
<OpenCloseIcon
className="text-middle little-spacer-right"
diff --git a/server/sonar-web/src/main/js/components/measure/__tests__/Measure-test.tsx b/server/sonar-web/src/main/js/components/measure/__tests__/Measure-test.tsx
index 1d3dee4d9c4..77b3811bf09 100644
--- a/server/sonar-web/src/main/js/components/measure/__tests__/Measure-test.tsx
+++ b/server/sonar-web/src/main/js/components/measure/__tests__/Measure-test.tsx
@@ -22,7 +22,7 @@ import * as React from 'react';
import Measure from '../Measure';
jest.mock('../../../helpers/measures', () => {
- const measures = require.requireActual('../../../helpers/measures');
+ const measures = jest.requireActual('../../../helpers/measures');
measures.getRatingTooltip = jest.fn(() => 'tooltip');
return measures;
});
diff --git a/server/sonar-web/src/main/js/components/tutorials/components/RenderOptions.tsx b/server/sonar-web/src/main/js/components/tutorials/components/RenderOptions.tsx
index e6fee8deee3..84659248d5b 100644
--- a/server/sonar-web/src/main/js/components/tutorials/components/RenderOptions.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/components/RenderOptions.tsx
@@ -32,6 +32,7 @@ export interface RenderOptionsProps {
export default function RenderOptions({
checked,
+ name,
onCheck,
optionLabelKey,
options,
diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/RenderOptions-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/RenderOptions-test.tsx.snap
index 535f9f58721..cbfa048a20c 100644
--- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/RenderOptions-test.tsx.snap
+++ b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/RenderOptions-test.tsx.snap
@@ -6,7 +6,7 @@ exports[`should render correctly: default 1`] = `
>
<RadioToggle
disabled={false}
- name=""
+ name="bar"
onCheck={[MockFunction]}
options={
Array [
@@ -31,7 +31,7 @@ exports[`should render correctly: option checked 1`] = `
>
<RadioToggle
disabled={false}
- name=""
+ name="bar"
onCheck={[MockFunction]}
options={
Array [
@@ -61,7 +61,7 @@ exports[`should render correctly: with title 1`] = `
</h4>
<RadioToggle
disabled={false}
- name=""
+ name="bar"
onCheck={[MockFunction]}
options={
Array [
diff --git a/server/sonar-web/src/main/js/helpers/extensions.ts b/server/sonar-web/src/main/js/helpers/extensions.ts
index da828ea9105..9add8d45ae7 100644
--- a/server/sonar-web/src/main/js/helpers/extensions.ts
+++ b/server/sonar-web/src/main/js/helpers/extensions.ts
@@ -38,10 +38,10 @@ export async function getExtensionStart(key: string) {
}
if (!librariesExposed) {
+ librariesExposed = true;
// Async import allows to reduce initial vendor bundle size
const exposeLibraries = (await import('../app/components/extensions/exposeLibraries')).default;
exposeLibraries();
- librariesExposed = true;
}
await installScript(`/static/${key}.js`);
diff --git a/server/sonar-web/src/main/js/helpers/mocks/quality-gates.ts b/server/sonar-web/src/main/js/helpers/mocks/quality-gates.ts
index f126e02f564..546a32c7799 100644
--- a/server/sonar-web/src/main/js/helpers/mocks/quality-gates.ts
+++ b/server/sonar-web/src/main/js/helpers/mocks/quality-gates.ts
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import {
QualityGateApplicationStatus,
QualityGateProjectStatus,
diff --git a/server/sonar-web/src/main/js/helpers/testMocks.ts b/server/sonar-web/src/main/js/helpers/testMocks.ts
index 629785904a3..f23dedf2a7c 100644
--- a/server/sonar-web/src/main/js/helpers/testMocks.ts
+++ b/server/sonar-web/src/main/js/helpers/testMocks.ts
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import { Location } from 'history';
import { InjectedRouter } from 'react-router';
import { createStore, Store } from 'redux';
diff --git a/server/sonar-web/src/main/js/store/__tests__/rootActions-test.tsx b/server/sonar-web/src/main/js/store/__tests__/rootActions-test.tsx
index 0d71e8a9906..294bd5a08d8 100644
--- a/server/sonar-web/src/main/js/store/__tests__/rootActions-test.tsx
+++ b/server/sonar-web/src/main/js/store/__tests__/rootActions-test.tsx
@@ -23,14 +23,12 @@ import { registerBranchStatusAction } from '../branches';
import { fetchBranchStatus, registerBranchStatus } from '../rootActions';
jest.mock('../branches', () => ({
- ...require.requireActual('../branches'),
+ ...jest.requireActual('../branches'),
registerBranchStatusAction: jest.fn()
}));
jest.mock('../../api/quality-gates', () => {
- const { mockQualityGateProjectStatus } = require.requireActual(
- '../../helpers/mocks/quality-gates'
- );
+ const { mockQualityGateProjectStatus } = jest.requireActual('../../helpers/mocks/quality-gates');
return {
getQualityGateProjectStatus: jest.fn().mockResolvedValue(
mockQualityGateProjectStatus({
diff --git a/server/sonar-web/src/main/js/store/__tests__/rootReducers-test.tsx b/server/sonar-web/src/main/js/store/__tests__/rootReducers-test.tsx
index 92730bcf321..9829ef6c19d 100644
--- a/server/sonar-web/src/main/js/store/__tests__/rootReducers-test.tsx
+++ b/server/sonar-web/src/main/js/store/__tests__/rootReducers-test.tsx
@@ -23,7 +23,7 @@ import { getBranchStatusByBranchLike, Store } from '../rootReducer';
jest.mock('../branches', () => {
return {
- ...require.requireActual('../branches'),
+ ...jest.requireActual('../branches'),
getBranchStatusByBranchLike: jest.fn()
};
});
diff --git a/server/sonar-web/src/main/js/store/__tests__/users-test.tsx b/server/sonar-web/src/main/js/store/__tests__/users-test.tsx
index d8c5b32f9fe..cf2615fd0ab 100644
--- a/server/sonar-web/src/main/js/store/__tests__/users-test.tsx
+++ b/server/sonar-web/src/main/js/store/__tests__/users-test.tsx
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable sonarjs/no-duplicate-string */
+
import { mockCurrentUser, mockLoggedInUser, mockUser } from '../../helpers/testMocks';
import reducer, {
getCurrentUser,