From cd543e4a4eeafbd0633104c5aa70f7d248e448dc Mon Sep 17 00:00:00 2001 From: stanislavh Date: Wed, 29 Mar 2023 15:37:38 +0200 Subject: [PATCH] SONAR-18581 Migrate RTL for EncryptionApp & components/AlmIntegration --- .../sonar-web/src/main/js/api/alm-settings.ts | 2 +- .../js/api/mocks/AlmSettingsServiceMock.ts | 251 ++++++- .../main/js/api/mocks/SettingsServiceMock.ts | 25 + .../AlmBindingDefinitionBox.tsx | 32 +- .../AlmBindingDefinitionForm.tsx | 9 +- .../AlmBindingDefinitionFormField.tsx | 6 +- .../AlmBindingDefinitionFormRenderer.tsx | 4 +- .../almIntegration/AlmIntegration.tsx | 7 +- .../almIntegration/AlmIntegrationRenderer.tsx | 8 +- .../almIntegration/BitbucketForm.tsx | 4 +- .../AlmBindingDefinitionBox-test.tsx | 114 --- .../AlmBindingDefinitionForm-test.tsx | 227 ++---- .../AlmBindingDefinitionFormField-test.tsx | 80 --- .../AlmBindingDefinitionFormRenderer-test.tsx | 92 --- .../__tests__/AlmIntegration-it.tsx | 239 ++++++ .../__tests__/AlmIntegration-test.tsx | 192 ----- .../__tests__/AlmIntegrationRenderer-test.tsx | 57 -- .../almIntegration/__tests__/AlmTab-test.tsx | 92 --- .../__tests__/AlmTabRenderer-test.tsx | 110 --- .../__tests__/AzureForm-test.tsx | 38 - .../__tests__/BitbucketCloudForm-test.tsx | 40 -- .../__tests__/BitbucketForm-test.tsx | 78 -- .../__tests__/BitbucketServerForm-test.tsx | 38 - .../__tests__/CreationTooltip-test.tsx | 43 -- .../__tests__/DeleteModal-test.tsx | 33 - .../__tests__/GithubForm-test.tsx | 46 -- .../__tests__/GitlabForm-test.tsx | 38 - .../AlmBindingDefinitionBox-test.tsx.snap | 679 ------------------ .../AlmBindingDefinitionForm-test.tsx.snap | 49 -- ...lmBindingDefinitionFormField-test.tsx.snap | 277 ------- ...indingDefinitionFormRenderer-test.tsx.snap | 484 ------------- .../AlmIntegration-test.tsx.snap | 27 - .../AlmIntegrationRenderer-test.tsx.snap | 528 -------------- .../__snapshots__/AlmTab-test.tsx.snap | 26 - .../AlmTabRenderer-test.tsx.snap | 594 --------------- .../__snapshots__/AzureForm-test.tsx.snap | 143 ---- .../BitbucketCloudForm-test.tsx.snap | 170 ----- .../__snapshots__/BitbucketForm-test.tsx.snap | 119 --- .../BitbucketServerForm-test.tsx.snap | 67 -- .../CreationTooltip-test.tsx.snap | 40 -- .../__snapshots__/DeleteModal-test.tsx.snap | 62 -- .../__snapshots__/GithubForm-test.tsx.snap | 207 ------ .../__snapshots__/GitlabForm-test.tsx.snap | 135 ---- .../settings/encryption/EncryptionForm.tsx | 4 +- .../encryption/GenerateSecretKeyForm.tsx | 5 +- .../encryption/__tests__/EncryptionApp-it.tsx | 73 ++ .../__tests__/EncryptionApp-test.tsx | 59 -- .../__tests__/EncryptionForm-test.tsx | 30 - .../__tests__/GenerateSecretKeyForm-test.tsx | 30 - .../__snapshots__/EncryptionApp-test.tsx.snap | 85 --- .../EncryptionForm-test.tsx.snap | 74 -- .../GenerateSecretKeyForm-test.tsx.snap | 39 - .../resources/org/sonar/l10n/core.properties | 8 + 53 files changed, 661 insertions(+), 5258 deletions(-) delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionBox-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionFormField-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionFormRenderer-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-it.tsx delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegrationRenderer-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmTab-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmTabRenderer-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AzureForm-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/BitbucketCloudForm-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/BitbucketForm-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/BitbucketServerForm-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/CreationTooltip-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/DeleteModal-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/GithubForm-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/GitlabForm-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionBox-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionForm-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionFormField-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionFormRenderer-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmIntegration-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmIntegrationRenderer-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmTab-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmTabRenderer-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AzureForm-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/BitbucketCloudForm-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/BitbucketForm-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/BitbucketServerForm-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/CreationTooltip-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/DeleteModal-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/GithubForm-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/GitlabForm-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/settings/encryption/__tests__/EncryptionApp-it.tsx delete mode 100644 server/sonar-web/src/main/js/apps/settings/encryption/__tests__/EncryptionApp-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/settings/encryption/__tests__/EncryptionForm-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/settings/encryption/__tests__/GenerateSecretKeyForm-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/settings/encryption/__tests__/__snapshots__/EncryptionApp-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/settings/encryption/__tests__/__snapshots__/EncryptionForm-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/settings/encryption/__tests__/__snapshots__/GenerateSecretKeyForm-test.tsx.snap diff --git a/server/sonar-web/src/main/js/api/alm-settings.ts b/server/sonar-web/src/main/js/api/alm-settings.ts index 60245542e3b..1ab02a892c7 100644 --- a/server/sonar-web/src/main/js/api/alm-settings.ts +++ b/server/sonar-web/src/main/js/api/alm-settings.ts @@ -110,7 +110,7 @@ export function deleteConfiguration(key: string) { return post('/api/alm_settings/delete', { key }).catch(throwGlobalError); } -export function countBindedProjects(almSetting: string) { +export function countBoundProjects(almSetting: string) { return getJSON('/api/alm_settings/count_binding', { almSetting }) .then(({ projects }) => projects) .catch(throwGlobalError); diff --git a/server/sonar-web/src/main/js/api/mocks/AlmSettingsServiceMock.ts b/server/sonar-web/src/main/js/api/mocks/AlmSettingsServiceMock.ts index 4a79a70f888..4b15331071a 100644 --- a/server/sonar-web/src/main/js/api/mocks/AlmSettingsServiceMock.ts +++ b/server/sonar-web/src/main/js/api/mocks/AlmSettingsServiceMock.ts @@ -19,51 +19,228 @@ */ import { cloneDeep } from 'lodash'; import { mockAlmSettingsInstance } from '../../helpers/mocks/alm-settings'; -import { AlmKeys, AlmSettingsInstance } from '../../types/alm-settings'; -import { getAlmSettings } from '../alm-settings'; +import { + AlmKeys, + AlmSettingsBindingDefinitions, + AlmSettingsInstance, + AzureBindingDefinition, + BitbucketCloudBindingDefinition, + BitbucketServerBindingDefinition, + GithubBindingDefinition, + GitlabBindingDefinition, +} from '../../types/alm-settings'; +import { + countBoundProjects, + createAzureConfiguration, + createBitbucketCloudConfiguration, + createBitbucketServerConfiguration, + createGithubConfiguration, + createGitlabConfiguration, + deleteConfiguration, + getAlmDefinitions, + getAlmSettings, + updateAzureConfiguration, + updateBitbucketCloudConfiguration, + updateBitbucketServerConfiguration, + updateGithubConfiguration, + updateGitlabConfiguration, + validateAlmSettings, +} from '../alm-settings'; + +const defaultAlmDefinitions = { + [AlmKeys.Azure]: [], + [AlmKeys.BitbucketServer]: [], + [AlmKeys.BitbucketCloud]: [], + [AlmKeys.GitHub]: [], + [AlmKeys.GitLab]: [], +}; + +const defaultAlmSettings = [ + mockAlmSettingsInstance({ key: 'conf-final-1', alm: AlmKeys.GitLab }), + mockAlmSettingsInstance({ key: 'conf-final-2', alm: AlmKeys.GitLab }), + mockAlmSettingsInstance({ key: 'conf-github-1', alm: AlmKeys.GitHub, url: 'http://url' }), + mockAlmSettingsInstance({ key: 'conf-github-2', alm: AlmKeys.GitHub, url: 'http://url' }), + mockAlmSettingsInstance({ key: 'conf-github-3', alm: AlmKeys.GitHub, url: 'javascript://url' }), + mockAlmSettingsInstance({ key: 'conf-azure-1', alm: AlmKeys.Azure, url: 'url' }), + mockAlmSettingsInstance({ key: 'conf-azure-2', alm: AlmKeys.Azure, url: 'url' }), + mockAlmSettingsInstance({ + key: 'conf-bitbucketcloud-1', + alm: AlmKeys.BitbucketCloud, + url: 'url', + }), + mockAlmSettingsInstance({ + key: 'conf-bitbucketcloud-2', + alm: AlmKeys.BitbucketCloud, + url: 'url', + }), + mockAlmSettingsInstance({ + key: 'conf-bitbucketserver-1', + alm: AlmKeys.BitbucketServer, + url: 'url', + }), + mockAlmSettingsInstance({ + key: 'conf-bitbucketserver-2', + alm: AlmKeys.BitbucketServer, + url: 'url', + }), +]; export default class AlmSettingsServiceMock { - almSettings: AlmSettingsInstance[]; - defaultSetting: AlmSettingsInstance[] = [ - mockAlmSettingsInstance({ key: 'conf-final-1', alm: AlmKeys.GitLab }), - mockAlmSettingsInstance({ key: 'conf-final-2', alm: AlmKeys.GitLab }), - mockAlmSettingsInstance({ key: 'conf-github-1', alm: AlmKeys.GitHub, url: 'http://url' }), - mockAlmSettingsInstance({ key: 'conf-github-2', alm: AlmKeys.GitHub, url: 'http://url' }), - mockAlmSettingsInstance({ key: 'conf-github-3', alm: AlmKeys.GitHub, url: 'javascript://url' }), - mockAlmSettingsInstance({ key: 'conf-azure-1', alm: AlmKeys.Azure, url: 'url' }), - mockAlmSettingsInstance({ key: 'conf-azure-2', alm: AlmKeys.Azure, url: 'url' }), - mockAlmSettingsInstance({ - key: 'conf-bitbucketcloud-1', - alm: AlmKeys.BitbucketCloud, - url: 'url', - }), - mockAlmSettingsInstance({ - key: 'conf-bitbucketcloud-2', - alm: AlmKeys.BitbucketCloud, - url: 'url', - }), - mockAlmSettingsInstance({ - key: 'conf-bitbucketserver-1', - alm: AlmKeys.BitbucketServer, - url: 'url', - }), - mockAlmSettingsInstance({ - key: 'conf-bitbucketserver-2', - alm: AlmKeys.BitbucketServer, - url: 'url', - }), - ]; + #almDefinitions: AlmSettingsBindingDefinitions; + #almSettings: AlmSettingsInstance[]; + #definitionError = ''; constructor() { - this.almSettings = cloneDeep(this.defaultSetting); - jest.mocked(getAlmSettings).mockImplementation(this.getAlmSettingsHandler); + this.#almSettings = cloneDeep(defaultAlmSettings); + this.#almDefinitions = cloneDeep(defaultAlmDefinitions); + jest.mocked(getAlmSettings).mockImplementation(this.handleGetAlmSettings); + jest.mocked(getAlmDefinitions).mockImplementation(this.handleGetAlmDefinitions); + jest.mocked(countBoundProjects).mockImplementation(this.handleCountBoundProjects); + jest.mocked(validateAlmSettings).mockImplementation(this.handleValidateAlmSettings); + jest.mocked(deleteConfiguration).mockImplementation(this.handleDeleteConfiguration); + jest.mocked(createGithubConfiguration).mockImplementation(this.handleCreateGithubConfiguration); + jest.mocked(createGitlabConfiguration).mockImplementation(this.handleCreateGitlabConfiguration); + jest.mocked(createAzureConfiguration).mockImplementation(this.handleCreateAzureConfiguration); + jest + .mocked(createBitbucketServerConfiguration) + .mockImplementation(this.handleCreateBitbucketServerConfiguration); + jest + .mocked(createBitbucketCloudConfiguration) + .mockImplementation(this.handleCreateBitbucketCloudConfiguration); + jest.mocked(updateGithubConfiguration).mockImplementation(this.handleUpdateGithubConfiguration); + jest.mocked(updateGitlabConfiguration).mockImplementation(this.handleUpdateGitlabConfiguration); + jest.mocked(updateAzureConfiguration).mockImplementation(this.handleUpdateAzureConfiguration); + jest + .mocked(updateBitbucketServerConfiguration) + .mockImplementation(this.handleUpdateBitbucketServerConfiguration); + jest + .mocked(updateBitbucketCloudConfiguration) + .mockImplementation(this.handleUpdateBitbucketCloudConfiguration); } - getAlmSettingsHandler = () => { - return Promise.resolve(this.almSettings); + handleGetAlmDefinitions = () => { + return this.reply(this.#almDefinitions); + }; + + handleGetAlmSettings = () => { + return this.reply(this.#almSettings); + }; + + handleValidateAlmSettings = () => { + return this.reply(this.#definitionError); + }; + + handleCountBoundProjects = () => { + return this.reply({ projects: 5 }); + }; + + setDefinitionErrorMessage = (message: string) => { + this.#definitionError = message; + }; + + handleDeleteConfiguration = (key: string) => { + for (const definitionsGroup of Object.values(this.#almDefinitions) as [ + GithubBindingDefinition[], + GitlabBindingDefinition[], + AzureBindingDefinition[], + BitbucketCloudBindingDefinition[], + BitbucketServerBindingDefinition[] + ]) { + const foundIndex = definitionsGroup.findIndex((definition) => definition.key === key); + if (foundIndex !== -1) { + definitionsGroup.splice(foundIndex, 1); + break; + } + } + return this.reply(undefined); + }; + + handleCreateGithubConfiguration = (data: GithubBindingDefinition) => { + this.#almDefinitions[AlmKeys.GitHub].push(data); + + return this.reply(undefined); + }; + + handleCreateGitlabConfiguration = (data: GitlabBindingDefinition) => { + this.#almDefinitions[AlmKeys.GitLab].push(data); + + return this.reply(undefined); + }; + + handleCreateAzureConfiguration = (data: AzureBindingDefinition) => { + this.#almDefinitions[AlmKeys.Azure].push(data); + + return this.reply(undefined); + }; + + handleCreateBitbucketServerConfiguration = (data: BitbucketServerBindingDefinition) => { + this.#almDefinitions[AlmKeys.BitbucketServer].push(data); + + return this.reply(undefined); + }; + + handleCreateBitbucketCloudConfiguration = (data: BitbucketCloudBindingDefinition) => { + this.#almDefinitions[AlmKeys.BitbucketCloud].push(data); + + return this.reply(undefined); + }; + + handleUpdateGithubConfiguration = (data: GithubBindingDefinition & { newKey: string }) => { + const definition = this.#almDefinitions[AlmKeys.GitHub].find( + (item) => item.key === data.key + ) as GithubBindingDefinition; + Object.assign(definition, { ...data, key: data.newKey }); + + return this.reply(undefined); + }; + + handleUpdateGitlabConfiguration = (data: GitlabBindingDefinition & { newKey: string }) => { + const definition = this.#almDefinitions[AlmKeys.GitLab].find( + (item) => item.key === data.key + ) as GitlabBindingDefinition; + Object.assign(definition, { ...data, key: data.newKey }); + + return this.reply(undefined); + }; + + handleUpdateAzureConfiguration = (data: AzureBindingDefinition & { newKey: string }) => { + const definition = this.#almDefinitions[AlmKeys.Azure].find( + (item) => item.key === data.key + ) as AzureBindingDefinition; + Object.assign(definition, { ...data, key: data.newKey }); + + return this.reply(undefined); + }; + + handleUpdateBitbucketServerConfiguration = ( + data: BitbucketServerBindingDefinition & { newKey: string } + ) => { + const definition = this.#almDefinitions[AlmKeys.BitbucketServer].find( + (item) => item.key === data.key + ) as BitbucketServerBindingDefinition; + Object.assign(definition, { ...data, key: data.newKey }); + + return this.reply(undefined); + }; + + handleUpdateBitbucketCloudConfiguration = ( + data: BitbucketCloudBindingDefinition & { newKey: string } + ) => { + const definition = this.#almDefinitions[AlmKeys.BitbucketCloud].find( + (item) => item.key === data.key + ) as BitbucketCloudBindingDefinition; + Object.assign(definition, { ...data, key: data.newKey }); + + return this.reply(undefined); }; reset = () => { - this.almSettings = cloneDeep(this.defaultSetting); + this.#almSettings = cloneDeep(defaultAlmSettings); + this.#almDefinitions = cloneDeep(defaultAlmDefinitions); + this.setDefinitionErrorMessage(''); }; + + reply(response: T): Promise { + return Promise.resolve(cloneDeep(response)); + } } diff --git a/server/sonar-web/src/main/js/api/mocks/SettingsServiceMock.ts b/server/sonar-web/src/main/js/api/mocks/SettingsServiceMock.ts index b22051af84a..9d0901edcc2 100644 --- a/server/sonar-web/src/main/js/api/mocks/SettingsServiceMock.ts +++ b/server/sonar-web/src/main/js/api/mocks/SettingsServiceMock.ts @@ -29,6 +29,9 @@ import { SettingValue, } from '../../types/settings'; import { + checkSecretKey, + encryptValue, + generateSecretKey, getAllValues, getDefinitions, getValue, @@ -113,6 +116,8 @@ export default class SettingsServiceMock { #definitions: ExtendedSettingDefinition[] = cloneDeep(DEFAULT_DEFINITIONS_MOCK); + #secretKeyAvailable: boolean = false; + constructor() { jest.mocked(getDefinitions).mockImplementation(this.handleGetDefinitions); jest.mocked(getValue).mockImplementation(this.handleGetValue); @@ -120,6 +125,9 @@ export default class SettingsServiceMock { jest.mocked(getAllValues).mockImplementation(this.handleGetAllValues); jest.mocked(setSettingValue).mockImplementation(this.handleSetSettingValue); jest.mocked(resetSettingValue).mockImplementation(this.handleResetSettingValue); + jest.mocked(checkSecretKey).mockImplementation(this.handleCheckSecretKey); + jest.mocked(generateSecretKey).mockImplementation(this.handleGenerateSecretKey); + jest.mocked(encryptValue).mockImplementation(this.handleEcnryptValue); } handleGetValue = (data: { key: string; component?: string } & BranchParameters) => { @@ -193,9 +201,26 @@ export default class SettingsServiceMock { this.#definitions.push(definition); }; + handleCheckSecretKey = () => { + return this.reply({ secretKeyAvailable: this.#secretKeyAvailable }); + }; + + handleGenerateSecretKey = () => { + return this.reply({ secretKey: 'secretKey' }); + }; + + handleEcnryptValue = () => { + return this.reply({ encryptedValue: 'encryptedValue' }); + }; + + setSecretKeyAvailable = (val = false) => { + this.#secretKeyAvailable = val; + }; + reset = () => { this.#settingValues = cloneDeep(this.#defaultValues); this.#definitions = cloneDeep(DEFAULT_DEFINITIONS_MOCK); + this.#secretKeyAvailable = false; return this; }; diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionBox.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionBox.tsx index f513009699d..dc188c3cf9f 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionBox.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionBox.tsx @@ -30,7 +30,7 @@ import EditIcon from '../../../../components/icons/EditIcon'; import { Alert } from '../../../../components/ui/Alert'; import { ALM_DOCUMENTATION_PATHS, IMPORT_COMPATIBLE_ALMS } from '../../../../helpers/constants'; import { getEdition, getEditionUrl } from '../../../../helpers/editions'; -import { translate } from '../../../../helpers/l10n'; +import { translate, translateWithParameters } from '../../../../helpers/l10n'; import { AlmBindingDefinitionBase, AlmKeys, @@ -144,11 +144,28 @@ export default function AlmBindingDefinitionBox(props: AlmBindingDefinitionBoxPr return (
- - @@ -228,7 +245,14 @@ export default function AlmBindingDefinitionBox(props: AlmBindingDefinitionBoxPr )}
- diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionForm.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionForm.tsx index 4abfd2ab835..ca8d1557dc2 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionForm.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionForm.tsx @@ -47,7 +47,7 @@ import { Dict } from '../../../../types/types'; import { BITBUCKET_CLOUD_WORKSPACE_ID_FORMAT } from '../../constants'; import AlmBindingDefinitionFormRenderer from './AlmBindingDefinitionFormRenderer'; -interface Props { +export interface AlmBindingDefinitionFormProps { alm: AlmKeys; bindingDefinition?: AlmBindingDefinition; onCancel: () => void; @@ -121,9 +121,12 @@ const BINDING_PER_ALM: { }, }; -export default class AlmBindingDefinitionForm extends React.PureComponent { +export default class AlmBindingDefinitionForm extends React.PureComponent< + AlmBindingDefinitionFormProps, + State +> { mounted = false; - constructor(props: Props) { + constructor(props: AlmBindingDefinitionFormProps) { super(props); let bitbucketVariant: AlmKeys.BitbucketServer | AlmKeys.BitbucketCloud | undefined = undefined; diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionFormField.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionFormField.tsx index 767ea0ee5af..f23219298ac 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionFormField.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionFormField.tsx @@ -26,7 +26,7 @@ import ValidationInput, { } from '../../../../components/controls/ValidationInput'; import { Alert } from '../../../../components/ui/Alert'; import MandatoryFieldMarker from '../../../../components/ui/MandatoryFieldMarker'; -import { translate } from '../../../../helpers/l10n'; +import { translate, translateWithParameters } from '../../../../helpers/l10n'; import { AlmBindingDefinitionBase } from '../../../../types/alm-settings'; import '../../styles.css'; @@ -79,6 +79,10 @@ export function AlmBindingDefinitionFormField

{translate('settings.almintegration.form.secret.field')}

{ props.onFieldChange(propKey, ''); setShowField(true); diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionFormRenderer.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionFormRenderer.tsx index dbc82d76c89..238b2585192 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionFormRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionFormRenderer.tsx @@ -37,7 +37,7 @@ import BitbucketForm from './BitbucketForm'; import GithubForm from './GithubForm'; import GitlabForm from './GitlabForm'; -export interface AlmBindingDefinitionFormProps { +export interface Props { alm: AlmKeys; isUpdate: boolean; canSubmit: boolean; @@ -53,7 +53,7 @@ export interface AlmBindingDefinitionFormProps { validationError?: string; } -export default class AlmBindingDefinitionFormRenderer extends React.PureComponent { +export default class AlmBindingDefinitionFormRenderer extends React.PureComponent { renderForm = () => { const { alm, formData, isUpdate, bitbucketVariant } = this.props; diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegration.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegration.tsx index 2987ee7c7d6..0c3bf80f84f 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegration.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegration.tsx @@ -19,7 +19,7 @@ */ import * as React from 'react'; import { - countBindedProjects, + countBoundProjects, deleteConfiguration, getAlmDefinitions, validateAlmSettings, @@ -159,7 +159,7 @@ export class AlmIntegration extends React.PureComponent { handleDelete = (definitionKey: string) => { this.setState({ loadingProjectCount: true }); - return countBindedProjects(definitionKey) + return countBoundProjects(definitionKey) .then((projectCount) => { if (this.mounted) { this.setState({ @@ -212,7 +212,6 @@ export class AlmIntegration extends React.PureComponent { }; render() { - const { hasFeature } = this.props; const { currentAlmTab, definitionKeyForDeletion, @@ -226,7 +225,7 @@ export class AlmIntegration extends React.PureComponent { return ( - GitHub + {translate('settings.almintegration.tab.github')} ), }, @@ -74,7 +74,7 @@ const tabs = [ height={16} src={`${getBaseUrl()}/images/alm/bitbucket.svg`} /> - Bitbucket + {translate('settings.almintegration.tab.bitbucket')} ), }, @@ -88,7 +88,7 @@ const tabs = [ height={16} src={`${getBaseUrl()}/images/alm/azure.svg`} /> - Azure DevOps + {translate('settings.almintegration.tab.azure')} ), }, @@ -102,7 +102,7 @@ const tabs = [ height={16} src={`${getBaseUrl()}/images/alm/gitlab.svg`} /> - GitLab + {translate('settings.almintegration.tab.gitlab')} ), }, diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/BitbucketForm.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/BitbucketForm.tsx index ff0d3e5ebbc..52f34d904b9 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/BitbucketForm.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/BitbucketForm.tsx @@ -53,10 +53,10 @@ export default function BitbucketForm(props: BitbucketFormProps) { onCheck={props.onVariantChange} options={[ { - label: 'Bitbucket Server', + label: translate('alm.bitbucket.long'), value: AlmKeys.BitbucketServer, }, - { label: 'Bitbucket Cloud', value: AlmKeys.BitbucketCloud }, + { label: translate('alm.bitbucketcloud.long'), value: AlmKeys.BitbucketCloud }, ]} value={variant} /> diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionBox-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionBox-test.tsx deleted file mode 100644 index 63320ac3bfb..00000000000 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionBox-test.tsx +++ /dev/null @@ -1,114 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { - mockAlmSettingsBindingStatus, - mockAzureBindingDefinition, - mockBitbucketCloudBindingDefinition, - mockGithubBindingDefinition, - mockGitlabBindingDefinition, -} from '../../../../../helpers/mocks/alm-settings'; -import { AlmKeys, AlmSettingsBindingStatusType } from '../../../../../types/alm-settings'; -import AlmBindingDefinitionBox, { AlmBindingDefinitionBoxProps } from '../AlmBindingDefinitionBox'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('default'); - expect( - shallowRender({ - status: mockAlmSettingsBindingStatus({ - type: AlmSettingsBindingStatusType.Success, - }), - }) - ).toMatchSnapshot('success'); - expect( - shallowRender({ - status: mockAlmSettingsBindingStatus({ - failureMessage: 'Oops, something went wrong', - type: AlmSettingsBindingStatusType.Failure, - }), - }) - ).toMatchSnapshot('error'); - - expect( - shallowRender({ - status: mockAlmSettingsBindingStatus({ - alertSuccess: true, - type: AlmSettingsBindingStatusType.Success, - }), - }) - ).toMatchSnapshot('success with alert'); - - expect( - shallowRender({ - status: mockAlmSettingsBindingStatus({ - type: AlmSettingsBindingStatusType.Warning, - }), - }) - ).toMatchSnapshot('warning'); - - expect( - shallowRender({ alm: AlmKeys.Azure, definition: mockAzureBindingDefinition() }) - ).toMatchSnapshot('Azure DevOps'); - - expect( - shallowRender({ - status: mockAlmSettingsBindingStatus({ - type: AlmSettingsBindingStatusType.Success, - }), - alm: AlmKeys.GitLab, - definition: mockGitlabBindingDefinition(), - }) - ).toMatchSnapshot('success for GitLab'); - - expect( - shallowRender({ - status: mockAlmSettingsBindingStatus({ - type: AlmSettingsBindingStatusType.Success, - }), - alm: AlmKeys.BitbucketCloud, - definition: mockBitbucketCloudBindingDefinition(), - }) - ).toMatchSnapshot('success for Bitbucket Cloud'); - - expect( - shallowRender({ - branchesEnabled: false, - status: mockAlmSettingsBindingStatus({ - alertSuccess: true, - type: AlmSettingsBindingStatusType.Success, - }), - }) - ).toMatchSnapshot('success with branches disabled'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionForm-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionForm-test.tsx index 7b76ad160bb..447d1249ad2 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionForm-test.tsx @@ -17,202 +17,63 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { - createAzureConfiguration, - createBitbucketCloudConfiguration, - createBitbucketServerConfiguration, - createGithubConfiguration, - createGitlabConfiguration, - deleteConfiguration, - updateAzureConfiguration, - updateBitbucketCloudConfiguration, - updateBitbucketServerConfiguration, - updateGithubConfiguration, - updateGitlabConfiguration, - validateAlmSettings, -} from '../../../../../api/alm-settings'; -import { - mockAzureBindingDefinition, - mockBitbucketCloudBindingDefinition, - mockBitbucketServerBindingDefinition, - mockGithubBindingDefinition, - mockGitlabBindingDefinition, -} from '../../../../../helpers/mocks/alm-settings'; -import { waitAndUpdate } from '../../../../../helpers/testUtils'; -import { AlmBindingDefinition, AlmKeys } from '../../../../../types/alm-settings'; -import AlmBindingDefinitionForm from '../AlmBindingDefinitionForm'; -import AlmBindingDefinitionFormRenderer from '../AlmBindingDefinitionFormRenderer'; - -jest.mock('../../../../../api/alm-settings', () => ({ - createAzureConfiguration: jest.fn().mockResolvedValue({}), - createBitbucketCloudConfiguration: jest.fn().mockResolvedValue({}), - createBitbucketServerConfiguration: jest.fn().mockResolvedValue({}), - createGithubConfiguration: jest.fn().mockResolvedValue({}), - createGitlabConfiguration: jest.fn().mockResolvedValue({}), - updateAzureConfiguration: jest.fn().mockResolvedValue({}), - updateBitbucketCloudConfiguration: jest.fn().mockResolvedValue({}), - updateBitbucketServerConfiguration: jest.fn().mockResolvedValue({}), - updateGithubConfiguration: jest.fn().mockResolvedValue({}), - updateGitlabConfiguration: jest.fn().mockResolvedValue({}), - validateAlmSettings: jest.fn().mockResolvedValue(undefined), - deleteConfiguration: jest.fn().mockResolvedValue(undefined), -})); - -beforeEach(() => { - jest.clearAllMocks(); -}); - -it('should render correctly', () => { - expect(shallowRender({ bindingDefinition: undefined })).toMatchSnapshot('create'); - expect(shallowRender({ bindingDefinition: mockGithubBindingDefinition() })).toMatchSnapshot( - 'edit' - ); -}); - -it('should handle field changes', () => { - const formData = mockGithubBindingDefinition(); - - const wrapper = shallowRender(); - - wrapper.instance().handleFieldChange('key', formData.key); - wrapper.instance().handleFieldChange('url', formData.url); - wrapper.instance().handleFieldChange('appId', formData.appId); - wrapper.instance().handleFieldChange('clientId', formData.clientId); - wrapper.instance().handleFieldChange('clientSecret', formData.clientSecret); - wrapper.instance().handleFieldChange('privateKey', formData.privateKey); - expect(wrapper.state().formData).toEqual(formData); - expect(wrapper.state().touched).toBe(true); -}); - -it('should handle form submit', async () => { - const afterSubmit = jest.fn(); - const formData = mockGithubBindingDefinition(); - - const wrapper = shallowRender({ afterSubmit }); - - wrapper.instance().setState({ formData }); - await wrapper.instance().handleFormSubmit(); - expect(afterSubmit).toHaveBeenCalledWith(formData); -}); - -it('should handle validation error during submit, and cancellation', async () => { - const afterSubmit = jest.fn(); - const formData = mockGithubBindingDefinition(); - const error = 'This a test error message'; - (validateAlmSettings as jest.Mock).mockResolvedValueOnce(error); - - const wrapper = shallowRender({ afterSubmit, enforceValidation: true }); - - wrapper.instance().setState({ formData }); - await wrapper.instance().handleFormSubmit(); - expect(validateAlmSettings).toHaveBeenCalledWith(formData.key); - expect(wrapper.state().validationError).toBe(error); - expect(afterSubmit).not.toHaveBeenCalledWith(); - - wrapper.find(AlmBindingDefinitionFormRenderer).props().onCancel(); - expect(deleteConfiguration).toHaveBeenCalledWith(formData.key); +import userEvent from '@testing-library/user-event'; +import React from 'react'; +import { byRole } from 'testing-library-selector'; +import AlmSettingsServiceMock from '../../../../../api/mocks/AlmSettingsServiceMock'; +import { renderComponent } from '../../../../../helpers/testReactTestingUtils'; +import { AlmKeys } from '../../../../../types/alm-settings'; +import AlmBindingDefinitionForm, { + AlmBindingDefinitionFormProps, +} from '../AlmBindingDefinitionForm'; + +jest.mock('../../../../../api/alm-settings'); + +let almSettings: AlmSettingsServiceMock; + +beforeAll(() => { + almSettings = new AlmSettingsServiceMock(); }); -it.each([ - [AlmKeys.Azure, undefined, createAzureConfiguration], - [AlmKeys.Azure, mockAzureBindingDefinition(), updateAzureConfiguration], - [AlmKeys.GitLab, undefined, createGitlabConfiguration], - [AlmKeys.GitLab, mockGitlabBindingDefinition(), updateGitlabConfiguration], - [AlmKeys.GitHub, undefined, createGithubConfiguration], - [AlmKeys.GitHub, mockGithubBindingDefinition(), updateGithubConfiguration], - [AlmKeys.BitbucketServer, undefined, createBitbucketServerConfiguration], - [ - AlmKeys.BitbucketServer, - mockBitbucketServerBindingDefinition(), - updateBitbucketServerConfiguration, - ], -])( - 'should call the proper api on submit for %s | %s', - async ( - alm: AlmKeys, - bindingDefinition: AlmBindingDefinition | undefined, - api: (def: AlmBindingDefinition) => any - ) => { - const wrapper = shallowRender({ alm, bindingDefinition }); - - await waitAndUpdate(wrapper); - await wrapper.instance().handleFormSubmit(); - expect(api).toHaveBeenCalled(); - } -); - -it('should call the proper api for BBC', async () => { - const wrapper = shallowRender({ - // Reminder: due to the way the settings app works, we never pass AlmKeys.BitbucketCloud as `alm`. - alm: AlmKeys.BitbucketServer, - bindingDefinition: undefined, - }); - - wrapper.instance().handleBitbucketVariantChange(AlmKeys.BitbucketCloud); - - await waitAndUpdate(wrapper); - await wrapper.instance().handleFormSubmit(); - expect(createBitbucketCloudConfiguration).toHaveBeenCalled(); - - wrapper.setProps({ bindingDefinition: mockBitbucketCloudBindingDefinition() }); - await wrapper.instance().handleFormSubmit(); - expect(updateBitbucketCloudConfiguration).toHaveBeenCalled(); +afterEach(() => { + almSettings.reset(); }); -it('should store bitbucket variant', async () => { - const wrapper = shallowRender(); +const ui = { + bitbucketConfiguration: (almKey: AlmKeys.BitbucketCloud | AlmKeys.BitbucketServer) => + byRole('button', { name: `alm.${almKey}.long` }), + configurationInput: (id: string) => + byRole('textbox', { name: `settings.almintegration.form.${id}` }), + saveConfigurationButton: byRole('button', { name: 'settings.almintegration.form.save' }), + cancelButton: byRole('button', { name: 'cancel' }), + validationError: byRole('alert'), +}; - wrapper - .find(AlmBindingDefinitionFormRenderer) - .props() - .onBitbucketVariantChange(AlmKeys.BitbucketCloud); +const onCancel = jest.fn(); - await waitAndUpdate(wrapper); - - expect(wrapper.state().bitbucketVariant).toBe(AlmKeys.BitbucketCloud); - expect(wrapper.state().formData).toEqual({ - clientId: '', - clientSecret: '', - key: '', - workspace: '', - }); -}); +it('enforceValidation enabled', async () => { + almSettings.setDefinitionErrorMessage('Validation Error'); + renderAlmBindingDefinitionForm(); -it('should (dis)allow submit by validating its state (Bitbucket Cloud)', () => { - const wrapper = shallowRender({ - // Reminder: due to the way the settings app works, we never pass AlmKeys.BitbucketCloud as `alm`. - alm: AlmKeys.BitbucketServer, - bindingDefinition: mockBitbucketCloudBindingDefinition(), - }); - expect(wrapper.instance().canSubmit()).toBe(false); - - wrapper.setState({ - formData: mockBitbucketCloudBindingDefinition({ workspace: 'foo/bar' }), - touched: true, - }); - expect(wrapper.instance().canSubmit()).toBe(false); - - wrapper.setState({ formData: mockBitbucketCloudBindingDefinition() }); - expect(wrapper.instance().canSubmit()).toBe(true); -}); + // Fill in form + await userEvent.type(await ui.configurationInput('name.gitlab').find(), 'Name'); + await userEvent.type(ui.configurationInput('url.gitlab').get(), 'https://api.alm.com'); + await userEvent.type(ui.configurationInput('personal_access_token').get(), 'Access Token'); -it('should (dis)allow submit by validating its state (others)', () => { - const wrapper = shallowRender(); - expect(wrapper.instance().canSubmit()).toBe(false); + await userEvent.click(ui.saveConfigurationButton.get()); + expect(ui.validationError.get()).toHaveTextContent('Validation Error'); - wrapper.setState({ formData: mockGithubBindingDefinition(), touched: true }); - expect(wrapper.instance().canSubmit()).toBe(true); + await userEvent.click(ui.cancelButton.get()); + expect(onCancel).toHaveBeenCalled(); }); -function shallowRender(props: Partial = {}) { - return shallow( +function renderAlmBindingDefinitionForm(props: Partial = {}) { + return renderComponent( ); diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionFormField-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionFormField-test.tsx deleted file mode 100644 index 5b9df1530ef..00000000000 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionFormField-test.tsx +++ /dev/null @@ -1,80 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { ButtonLink } from '../../../../../components/controls/buttons'; -import { click } from '../../../../../helpers/testUtils'; -import { AlmBindingDefinitionBase } from '../../../../../types/alm-settings'; -import { - AlmBindingDefinitionFormField, - AlmBindingDefinitionFormFieldProps, -} from '../AlmBindingDefinitionFormField'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('default'); - expect(shallowRender({ help: 'help' })).toMatchSnapshot('with help'); - expect(shallowRender({ isTextArea: true })).toMatchSnapshot('textarea'); - expect(shallowRender({ optional: true })).toMatchSnapshot('optional'); - expect(shallowRender({ overwriteOnly: true })).toMatchSnapshot('secret'); - expect(shallowRender({ isSecret: true })).toMatchSnapshot('encryptable'); - expect(shallowRender({ error: 'some error message', isInvalid: true })).toMatchSnapshot( - 'invalid with error' - ); -}); - -it('should call onFieldChange', () => { - const onInputChange = jest.fn(); - shallowRender({ onFieldChange: onInputChange }) - .find('input') - .simulate('change', { currentTarget: { value: '' } }); - expect(onInputChange).toHaveBeenCalled(); - - const onTextAreaChange = jest.fn(); - shallowRender({ isTextArea: true, onFieldChange: onTextAreaChange }) - .find('textarea') - .simulate('change', { currentTarget: { value: '' } }); - expect(onTextAreaChange).toHaveBeenCalled(); -}); - -it('should correctly toggle visibility for secret fields', () => { - const onFieldChange = jest.fn(); - const wrapper = shallowRender({ onFieldChange, overwriteOnly: true }); - expect(wrapper.find('input').exists()).toBe(false); - - click(wrapper.find(ButtonLink)); - expect(onFieldChange).toHaveBeenCalledWith('key', ''); - expect(wrapper.find('input').exists()).toBe(true); -}); - -function shallowRender( - props: Partial> = {} -) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionFormRenderer-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionFormRenderer-test.tsx deleted file mode 100644 index c0060906724..00000000000 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionFormRenderer-test.tsx +++ /dev/null @@ -1,92 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { ResetButtonLink } from '../../../../../components/controls/buttons'; -import { mockGithubBindingDefinition } from '../../../../../helpers/mocks/alm-settings'; -import { click, mockEvent } from '../../../../../helpers/testUtils'; -import { AlmKeys } from '../../../../../types/alm-settings'; -import AlmBindingDefinitionFormRenderer, { - AlmBindingDefinitionFormProps, -} from '../AlmBindingDefinitionFormRenderer'; -import GithubForm from '../GithubForm'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ submitting: true })).toMatchSnapshot('submitting'); - expect(shallowRender({ isUpdate: true })).toMatchSnapshot('editing'); - expect(shallowRender({ validationError: 'this is a validation error' })).toMatchSnapshot( - 'with validation error' - ); -}); - -it.each([[AlmKeys.Azure], [AlmKeys.GitHub], [AlmKeys.GitLab], [AlmKeys.BitbucketServer]])( - 'should render correctly for %s', - (alm) => { - expect(shallowRender({ alm })).toMatchSnapshot(); - } -); - -it('should cancel properly', () => { - const onCancel = jest.fn(); - const wrapper = shallowRender({ onCancel }); - - click(wrapper.find(ResetButtonLink)); - expect(onCancel).toHaveBeenCalled(); -}); - -it('should submit properly', () => { - const onSubmit = jest.fn(); - const wrapper = shallowRender({ onSubmit }); - - const event: React.SyntheticEvent = mockEvent({ preventDefault: jest.fn() }); - - wrapper.find('form').simulate('submit', event); - - expect(event.preventDefault).toHaveBeenCalled(); - expect(onSubmit).toHaveBeenCalled(); -}); - -it('should handle field change', () => { - const onFieldChange = jest.fn(); - const wrapper = shallowRender({ onFieldChange }); - - wrapper.find(GithubForm).props().onFieldChange('key', 'test'); - - expect(onFieldChange).toHaveBeenCalledWith('key', 'test'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-it.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-it.tsx new file mode 100644 index 00000000000..4c5391703e3 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-it.tsx @@ -0,0 +1,239 @@ +/* + * SonarQube + * Copyright (C) 2009-2023 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import { screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +import React from 'react'; +import { byRole, byText } from 'testing-library-selector'; +import AlmSettingsServiceMock from '../../../../../api/mocks/AlmSettingsServiceMock'; +import { AvailableFeaturesContext } from '../../../../../app/components/available-features/AvailableFeaturesContext'; +import { renderComponent } from '../../../../../helpers/testReactTestingUtils'; +import { AlmKeys } from '../../../../../types/alm-settings'; +import { Feature } from '../../../../../types/features'; +import AlmIntegration from '../AlmIntegration'; + +jest.mock('../../../../../api/alm-settings'); + +let almSettings: AlmSettingsServiceMock; + +beforeAll(() => { + almSettings = new AlmSettingsServiceMock(); +}); + +afterEach(() => { + almSettings.reset(); +}); + +const ui = { + almHeading: byRole('heading', { name: 'settings.almintegration.title' }), + emptyIntro: (almKey: AlmKeys) => byText(`settings.almintegration.empty.${almKey}`), + createConfigurationButton: byRole('button', { name: 'settings.almintegration.create' }), + tab: (almKey: AlmKeys) => + byRole('tab', { name: `${almKey} settings.almintegration.tab.${almKey}` }), + bitbucketConfiguration: (almKey: AlmKeys.BitbucketCloud | AlmKeys.BitbucketServer) => + byRole('button', { name: `alm.${almKey}.long` }), + configurationInput: (id: string) => + byRole('textbox', { name: `settings.almintegration.form.${id}` }), + updateSecretValueButton: (key: string) => + byRole('button', { + name: `settings.almintegration.form.secret.update_field_x.settings.almintegration.form.${key}`, + }), + saveConfigurationButton: byRole('button', { name: 'settings.almintegration.form.save' }), + editConfigurationButton: (key: string) => + byRole('button', { name: `settings.almintegration.edit_configuration.${key}` }), + deleteConfigurationButton: (key: string) => + byRole('button', { name: `settings.almintegration.delete_configuration.${key}` }), + cancelButton: byRole('button', { name: 'cancel' }), + confirmDelete: byRole('button', { name: 'delete' }), + checkConfigurationButton: (key: string) => + byRole('button', { name: `settings.almintegration.check_configuration_x.${key}` }), + validationErrorMessage: byRole('alert'), + validationSuccessMessage: byRole('status'), +}; + +describe('github tab', () => { + it('can create/edit/delete new configuration', async () => { + const { rerender } = renderAlmIntegration(); + expect(await ui.almHeading.find()).toBeInTheDocument(); + expect(ui.emptyIntro(AlmKeys.GitHub).get()).toBeInTheDocument(); + + // Create new configuration + await createConfiguration('Name', { + 'name.github': 'Name', + 'url.github': 'https://api.github.com', + app_id: 'Github App ID', + 'client_id.github': 'Github Client ID', + 'client_secret.github': 'Client Secret', + private_key: 'Key', + }); + + await editConfiguration('New Name', 'Name', 'client_secret.github', AlmKeys.GitHub); + + await checkConfiguration('New Name'); + + rerender(); + expect(await screen.findByRole('heading', { name: 'New Name' })).toBeInTheDocument(); + + await deleteConfiguration('New Name'); + expect(ui.emptyIntro(AlmKeys.GitHub).get()).toBeInTheDocument(); + }); +}); + +describe.each([AlmKeys.GitLab, AlmKeys.Azure])( + '%s tab', + (almKey: AlmKeys.Azure | AlmKeys.GitLab) => { + it('can create/edit/delete new configuration', async () => { + renderAlmIntegration(); + expect(await ui.almHeading.find()).toBeInTheDocument(); + + await userEvent.click(ui.tab(almKey).get()); + expect(ui.emptyIntro(almKey).get()).toBeInTheDocument(); + + // Create new configuration + await createConfiguration('Name', { + [`name.${almKey}`]: 'Name', + [`url.${almKey}`]: 'https://api.alm.com', + personal_access_token: 'Access Token', + }); + + // Cannot create another configuration without Multiple Alm feature + expect(ui.createConfigurationButton.get()).toBeDisabled(); + + await editConfiguration('New Name', 'Name', 'personal_access_token', almKey); + + await checkConfiguration('New Name'); + + await deleteConfiguration('New Name'); + expect(ui.emptyIntro(almKey).get()).toBeInTheDocument(); + }); + } +); + +describe('bitbucket tab', () => { + it('can create/edit/delete new configuration', async () => { + renderAlmIntegration([Feature.MultipleAlm]); + expect(await ui.almHeading.find()).toBeInTheDocument(); + + await userEvent.click(ui.tab(AlmKeys.BitbucketServer).get()); + expect(ui.emptyIntro(AlmKeys.BitbucketServer).get()).toBeInTheDocument(); + + // Create new Bitbucket Server configuration + await createConfiguration( + 'Name', + { + 'name.bitbucket': 'Name', + 'url.bitbucket': 'https://api.bitbucket.com', + personal_access_token: 'Access Token', + }, + AlmKeys.BitbucketServer + ); + + // Create new Bitbucket Cloud configuration + await createConfiguration( + 'Name Cloud', + { + 'name.bitbucket': 'Name Cloud', + 'workspace.bitbucketcloud': 'workspace', + 'client_id.bitbucketcloud': 'Client ID', + 'client_secret.bitbucketcloud': 'Client Secret', + }, + AlmKeys.BitbucketCloud + ); + + // Edit, check delete Bitbucket Server configuration + await editConfiguration('New Name', 'Name', 'personal_access_token', AlmKeys.BitbucketServer); + + await checkConfiguration('New Name'); + + await deleteConfiguration('New Name'); + + // Cloud configuration still exists + expect(screen.getByRole('heading', { name: 'Name Cloud' })).toBeInTheDocument(); + }); +}); + +async function createConfiguration( + name: string, + params: { [key: string]: string }, + almKey?: AlmKeys.BitbucketCloud | AlmKeys.BitbucketServer +) { + await userEvent.click(ui.createConfigurationButton.get()); + expect(ui.saveConfigurationButton.get()).toBeDisabled(); + + if (almKey) { + await userEvent.click(ui.bitbucketConfiguration(almKey).get()); + } + + for (const [key, value] of Object.entries(params)) { + // eslint-disable-next-line no-await-in-loop + await userEvent.type(ui.configurationInput(key).get(), value); + } + expect(ui.saveConfigurationButton.get()).toBeEnabled(); + await userEvent.click(ui.saveConfigurationButton.get()); + + // New configuration is created + expect(screen.getByRole('heading', { name })).toBeInTheDocument(); +} + +async function editConfiguration( + newName: string, + currentName: string, + secretId: string, + almKey: AlmKeys +) { + almSettings.setDefinitionErrorMessage('Something is wrong'); + await userEvent.click(ui.editConfigurationButton(currentName).get()); + expect(ui.configurationInput(secretId).query()).not.toBeInTheDocument(); + await userEvent.click(ui.updateSecretValueButton(secretId).get()); + await userEvent.type(ui.configurationInput(secretId).get(), 'New Secret Value'); + await userEvent.clear(ui.configurationInput(`name.${almKey}`).get()); + await userEvent.type(ui.configurationInput(`name.${almKey}`).get(), newName); + await userEvent.click(ui.saveConfigurationButton.get()); + + // Existing configuration is edited + expect(screen.queryByRole('heading', { name: currentName })).not.toBeInTheDocument(); + expect(screen.getByRole('heading', { name: newName })).toBeInTheDocument(); + expect(ui.validationErrorMessage.get()).toHaveTextContent('Something is wrong'); +} + +async function checkConfiguration(name: string) { + almSettings.setDefinitionErrorMessage(''); + await userEvent.click(ui.checkConfigurationButton(name).get()); + expect(ui.validationSuccessMessage.getAll()[0]).toHaveTextContent( + 'alert.tooltip.successsettings.almintegration.configuration_valid' + ); +} + +async function deleteConfiguration(name: string) { + await userEvent.click(ui.deleteConfigurationButton(name).get()); + await userEvent.click(ui.cancelButton.get()); + expect(screen.getByRole('heading', { name })).toBeInTheDocument(); + + await userEvent.click(ui.deleteConfigurationButton(name).get()); + await userEvent.click(ui.confirmDelete.get()); + expect(screen.queryByRole('heading', { name })).not.toBeInTheDocument(); +} + +function renderAlmIntegration(features: Feature[] = []) { + return renderComponent( + + + + ); +} diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-test.tsx deleted file mode 100644 index 8bc8780f04e..00000000000 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-test.tsx +++ /dev/null @@ -1,192 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { - countBindedProjects, - deleteConfiguration, - getAlmDefinitions, - validateAlmSettings, -} from '../../../../../api/alm-settings'; -import { mockLocation, mockRouter } from '../../../../../helpers/testMocks'; -import { waitAndUpdate } from '../../../../../helpers/testUtils'; -import { AlmKeys, AlmSettingsBindingStatusType } from '../../../../../types/alm-settings'; -import { AlmIntegration } from '../AlmIntegration'; -import AlmIntegrationRenderer from '../AlmIntegrationRenderer'; - -jest.mock('../../../../../api/alm-settings', () => ({ - countBindedProjects: jest.fn().mockResolvedValue(0), - deleteConfiguration: jest.fn().mockResolvedValue(undefined), - getAlmDefinitions: jest - .fn() - .mockResolvedValue({ azure: [], bitbucket: [], bitbucketcloud: [], github: [], gitlab: [] }), - validateAlmSettings: jest.fn().mockResolvedValue(''), -})); - -beforeEach(() => { - jest.clearAllMocks(); -}); - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -it('should validate existing configurations', async () => { - (getAlmDefinitions as jest.Mock).mockResolvedValueOnce({ - [AlmKeys.Azure]: [{ key: 'a1' }], - [AlmKeys.BitbucketServer]: [{ key: 'b1' }], - [AlmKeys.BitbucketCloud]: [{ key: 'bc1' }], - [AlmKeys.GitHub]: [{ key: 'gh1' }, { key: 'gh2' }], - [AlmKeys.GitLab]: [{ key: 'gl1' }], - }); - - const wrapper = shallowRender(); - - await waitAndUpdate(wrapper); - - expect(validateAlmSettings).toHaveBeenCalledTimes(6); - expect(validateAlmSettings).toHaveBeenCalledWith('a1'); - expect(validateAlmSettings).toHaveBeenCalledWith('b1'); - expect(validateAlmSettings).toHaveBeenCalledWith('bc1'); - expect(validateAlmSettings).toHaveBeenCalledWith('gh1'); - expect(validateAlmSettings).toHaveBeenCalledWith('gh2'); - expect(validateAlmSettings).toHaveBeenCalledWith('gl1'); -}); - -it('should handle alm selection', async () => { - const router = mockRouter(); - const wrapper = shallowRender({ router }); - - wrapper.setState({ currentAlmTab: AlmKeys.Azure }); - - wrapper.instance().handleSelectAlm(AlmKeys.GitHub); - - await waitAndUpdate(wrapper); - - expect(wrapper.state().currentAlmTab).toBe(AlmKeys.GitHub); - expect(router.push).toHaveBeenCalled(); -}); - -it('should handle delete', async () => { - const toBeDeleted = '45672'; - (countBindedProjects as jest.Mock).mockResolvedValueOnce(7); - const wrapper = shallowRender(); - - wrapper.find(AlmIntegrationRenderer).props().onDelete(toBeDeleted); - await waitAndUpdate(wrapper); - expect(wrapper.state().projectCount).toBe(7); - expect(wrapper.state().definitionKeyForDeletion).toBe(toBeDeleted); - - wrapper.find(AlmIntegrationRenderer).props().onCancelDelete(); - await waitAndUpdate(wrapper); - expect(wrapper.state().projectCount).toBeUndefined(); - expect(wrapper.state().definitionKeyForDeletion).toBeUndefined(); -}); - -it('should delete configuration', async () => { - (deleteConfiguration as jest.Mock).mockResolvedValueOnce(undefined); - const wrapper = shallowRender(); - wrapper.instance().handleConfirmDelete('8345678'); - - await waitAndUpdate(wrapper); - expect(wrapper.state().projectCount).toBeUndefined(); - expect(wrapper.state().definitionKeyForDeletion).toBeUndefined(); -}); - -it('should validate a configuration', async () => { - const definitionKey = 'validated-key'; - const failureMessage = 'an error occured'; - - const wrapper = shallowRender(); - await waitAndUpdate(wrapper); - - (validateAlmSettings as jest.Mock) - .mockRejectedValueOnce(undefined) - .mockResolvedValueOnce(failureMessage) - .mockResolvedValueOnce('') - .mockResolvedValueOnce(''); - - await wrapper.instance().handleCheck(definitionKey); - - expect(wrapper.state().definitionStatus[definitionKey]).toEqual({ - alertSuccess: true, - failureMessage: '', - type: AlmSettingsBindingStatusType.Warning, - }); - - await wrapper.instance().handleCheck(definitionKey); - - expect(wrapper.state().definitionStatus[definitionKey]).toEqual({ - alertSuccess: true, - failureMessage, - type: AlmSettingsBindingStatusType.Failure, - }); - - await wrapper.instance().handleCheck(definitionKey); - - expect(wrapper.state().definitionStatus[definitionKey]).toEqual({ - alertSuccess: true, - failureMessage: '', - type: AlmSettingsBindingStatusType.Success, - }); -}); - -it('should fetch settings', async () => { - const definitions = { - [AlmKeys.Azure]: [{ key: 'a1' }], - [AlmKeys.BitbucketServer]: [{ key: 'b1' }], - [AlmKeys.BitbucketCloud]: [{ key: 'bc1' }], - [AlmKeys.GitHub]: [{ key: 'gh1' }], - [AlmKeys.GitLab]: [{ key: 'gl1' }], - }; - - const wrapper = shallowRender(); - await waitAndUpdate(wrapper); - - (getAlmDefinitions as jest.Mock).mockResolvedValueOnce(definitions); - - await wrapper.instance().fetchPullRequestDecorationSetting(); - - expect(getAlmDefinitions).toHaveBeenCalled(); - expect(wrapper.state().definitions).toEqual(definitions); - expect(wrapper.state().loadingAlmDefinitions).toBe(false); -}); - -it('should detect the current ALM from the query', () => { - let wrapper = shallowRender({ location: mockLocation() }); - expect(wrapper.state().currentAlmTab).toBe(AlmKeys.GitHub); - - wrapper = shallowRender({ location: mockLocation({ query: { alm: AlmKeys.BitbucketCloud } }) }); - expect(wrapper.state().currentAlmTab).toBe(AlmKeys.BitbucketServer); - - wrapper.setProps({ location: mockLocation({ query: { alm: AlmKeys.GitLab } }) }); - expect(wrapper.state().currentAlmTab).toBe(AlmKeys.GitLab); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegrationRenderer-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegrationRenderer-test.tsx deleted file mode 100644 index cb9802ba261..00000000000 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegrationRenderer-test.tsx +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { AlmKeys } from '../../../../../types/alm-settings'; -import AlmIntegrationRenderer, { AlmIntegrationRendererProps } from '../AlmIntegrationRenderer'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('default'); - expect(shallowRender({ loadingAlmDefinitions: true, loadingProjectCount: true })).toMatchSnapshot( - 'loading' - ); - expect(shallowRender({ definitionKeyForDeletion: 'keyToDelete' })).toMatchSnapshot( - 'delete modal' - ); - expect(shallowRender({ currentAlmTab: AlmKeys.Azure })).toMatchSnapshot('azure'); - expect(shallowRender({ currentAlmTab: AlmKeys.BitbucketServer })).toMatchSnapshot('bitbucket'); - expect(shallowRender({ currentAlmTab: AlmKeys.GitLab })).toMatchSnapshot('gitlab'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmTab-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmTab-test.tsx deleted file mode 100644 index 086602242bd..00000000000 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmTab-test.tsx +++ /dev/null @@ -1,92 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { mockAzureBindingDefinition } from '../../../../../helpers/mocks/alm-settings'; -import { waitAndUpdate } from '../../../../../helpers/testUtils'; -import { AlmKeys } from '../../../../../types/alm-settings'; -import AlmTab from '../AlmTab'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -it('should handle cancel', async () => { - const wrapper = shallowRender(); - - wrapper.setState({ - editedDefinition: mockAzureBindingDefinition(), - }); - - wrapper.instance().handleCancel(); - - await waitAndUpdate(wrapper); - - expect(wrapper.state().editedDefinition).toBeUndefined(); -}); - -it('should handle edit', async () => { - const config = mockAzureBindingDefinition(); - const wrapper = shallowRender({ definitions: [config] }); - - wrapper.instance().handleEdit(config.key); - await waitAndUpdate(wrapper); - expect(wrapper.state().editedDefinition).toEqual(config); -}); - -it('should handle create', async () => { - const wrapper = shallowRender(); - - wrapper.instance().handleCreate(); - await waitAndUpdate(wrapper); - expect(wrapper.state().editedDefinition).toBeUndefined(); -}); - -it('should handle afterSubmit', async () => { - const onUpdateDefinitions = jest.fn(); - const onCheck = jest.fn(); - const binding = mockAzureBindingDefinition(); - - const wrapper = shallowRender({ onUpdateDefinitions, onCheck }); - - wrapper.instance().handleAfterSubmit(binding); - await waitAndUpdate(wrapper); - expect(wrapper.state().editedDefinition).toBeUndefined(); - expect(onUpdateDefinitions).toHaveBeenCalled(); - expect(onCheck).toHaveBeenCalledWith(binding.key); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmTabRenderer-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmTabRenderer-test.tsx deleted file mode 100644 index 345d0b5befa..00000000000 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmTabRenderer-test.tsx +++ /dev/null @@ -1,110 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { - mockAzureBindingDefinition, - mockBitbucketCloudBindingDefinition, - mockGithubBindingDefinition, -} from '../../../../../helpers/mocks/alm-settings'; -import { AlmKeys } from '../../../../../types/alm-settings'; -import AlmTabRenderer, { AlmTabRendererProps } from '../AlmTabRenderer'; - -it('should render correctly for multi-ALM binding', () => { - expect(shallowRenderAzure({ loadingAlmDefinitions: true })).toMatchSnapshot( - 'loading ALM definitions' - ); - expect(shallowRenderAzure({ loadingProjectCount: true })).toMatchSnapshot( - 'loading project count' - ); - expect(shallowRenderAzure({})).toMatchSnapshot('loaded'); - expect(shallowRenderAzure({ editedDefinition: mockAzureBindingDefinition() })).toMatchSnapshot( - 'editing a definition' - ); -}); - -it('should render correctly for single-ALM binding', () => { - expect( - shallowRenderAzure({ loadingAlmDefinitions: true, multipleAlmEnabled: false }) - ).toMatchSnapshot(); - expect(shallowRenderAzure({ multipleAlmEnabled: false })).toMatchSnapshot(); - expect( - shallowRenderAzure({ definitions: [mockAzureBindingDefinition()], multipleAlmEnabled: false }) - ).toMatchSnapshot(); -}); - -it('should render correctly with validation', () => { - const githubProps = { - alm: AlmKeys.GitHub, - definitions: [mockGithubBindingDefinition()], - }; - expect(shallowRender(githubProps)).toMatchSnapshot('default'); - expect(shallowRender({ ...githubProps, definitions: [] })).toMatchSnapshot('empty'); - - expect( - shallowRender({ - ...githubProps, - editedDefinition: mockGithubBindingDefinition(), - }) - ).toMatchSnapshot('create a second'); - - expect( - shallowRender({ - ...githubProps, - definitions: [], - editedDefinition: mockGithubBindingDefinition(), - }) - ).toMatchSnapshot('create a first'); - - expect( - shallowRender({ - almTab: AlmKeys.BitbucketServer, // BitbucketServer will be passed for both Bitbucket variants. - definitions: [mockBitbucketCloudBindingDefinition()], - }) - ).toMatchSnapshot('pass the correct key for bitbucket cloud'); -}); - -function shallowRenderAzure(props: Partial) { - return shallowRender({ - definitions: [mockAzureBindingDefinition()], - ...props, - }); -} - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AzureForm-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AzureForm-test.tsx deleted file mode 100644 index c1c6a2ef73e..00000000000 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AzureForm-test.tsx +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { mockAzureBindingDefinition } from '../../../../../helpers/mocks/alm-settings'; -import AzureForm, { AzureFormProps } from '../AzureForm'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('create'); - expect(shallowRender({ formData: mockAzureBindingDefinition() })).toMatchSnapshot('edit'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/BitbucketCloudForm-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/BitbucketCloudForm-test.tsx deleted file mode 100644 index 71f5774354b..00000000000 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/BitbucketCloudForm-test.tsx +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { mockBitbucketCloudBindingDefinition } from '../../../../../helpers/mocks/alm-settings'; -import BitbucketCloudForm, { BitbucketCloudFormProps } from '../BitbucketCloudForm'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('default'); - expect( - shallowRender({ formData: mockBitbucketCloudBindingDefinition({ workspace: 'my/workspace' }) }) - ).toMatchSnapshot('invalid workspace ID'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/BitbucketForm-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/BitbucketForm-test.tsx deleted file mode 100644 index 026caea6631..00000000000 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/BitbucketForm-test.tsx +++ /dev/null @@ -1,78 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import ButtonToggle from '../../../../../components/controls/ButtonToggle'; -import { - mockBitbucketCloudBindingDefinition, - mockBitbucketServerBindingDefinition, -} from '../../../../../helpers/mocks/alm-settings'; -import { AlmKeys } from '../../../../../types/alm-settings'; -import BitbucketForm, { BitbucketFormProps } from '../BitbucketForm'; - -it('should render correctly', () => { - let wrapper = shallowRender({ - variant: AlmKeys.BitbucketServer, - formData: mockBitbucketServerBindingDefinition(), - }); - expect(wrapper).toMatchSnapshot('bbs'); - - wrapper = shallowRender({ - variant: AlmKeys.BitbucketCloud, - formData: mockBitbucketCloudBindingDefinition(), - }); - expect(wrapper).toMatchSnapshot('bbc'); - - wrapper = shallowRender({ - isUpdate: true, - variant: AlmKeys.BitbucketServer, - formData: mockBitbucketServerBindingDefinition(), - }); - expect(wrapper).toMatchSnapshot('update bbs'); - - wrapper = shallowRender({ - isUpdate: true, - variant: AlmKeys.BitbucketCloud, - formData: mockBitbucketCloudBindingDefinition(), - }); - expect(wrapper).toMatchSnapshot('update bbc'); -}); - -it('should render propagete variant properly', () => { - const onVariantChange = jest.fn(); - const wrapper = shallowRender({ onVariantChange }); - - wrapper.find(ButtonToggle).props().onCheck(AlmKeys.BitbucketServer); - - expect(onVariantChange).toHaveBeenCalledWith(AlmKeys.BitbucketServer); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/BitbucketServerForm-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/BitbucketServerForm-test.tsx deleted file mode 100644 index 9e9f1bf0e74..00000000000 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/BitbucketServerForm-test.tsx +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { mockBitbucketServerBindingDefinition } from '../../../../../helpers/mocks/alm-settings'; -import BitbucketServerForm, { BitbucketServerFormProps } from '../BitbucketServerForm'; - -it('should render correctly', () => { - const wrapper = shallowRender(); - expect(wrapper).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/CreationTooltip-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/CreationTooltip-test.tsx deleted file mode 100644 index f27de39099e..00000000000 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/CreationTooltip-test.tsx +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { mockAppState } from '../../../../../helpers/testMocks'; -import { AlmKeys } from '../../../../../types/alm-settings'; -import { EditionKey } from '../../../../../types/editions'; -import { CreationTooltip, CreationTooltipProps } from '../CreationTooltip'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ preventCreation: false })).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - Child - - ); -} diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/DeleteModal-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/DeleteModal-test.tsx deleted file mode 100644 index 50481dd5896..00000000000 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/DeleteModal-test.tsx +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import DeleteModal, { DeleteModalProps } from '../DeleteModal'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ projectCount: undefined })).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/GithubForm-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/GithubForm-test.tsx deleted file mode 100644 index ed1485adacb..00000000000 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/GithubForm-test.tsx +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { mockGithubBindingDefinition } from '../../../../../helpers/mocks/alm-settings'; -import GithubForm, { GithubFormProps } from '../GithubForm'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ formData: mockGithubBindingDefinition() })).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/GitlabForm-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/GitlabForm-test.tsx deleted file mode 100644 index 9963245c710..00000000000 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/GitlabForm-test.tsx +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { mockGitlabBindingDefinition } from '../../../../../helpers/mocks/alm-settings'; -import GitlabForm, { GitlabFormProps } from '../GitlabForm'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ formData: mockGitlabBindingDefinition() })).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionBox-test.tsx.snap b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionBox-test.tsx.snap deleted file mode 100644 index f72efa1d911..00000000000 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionBox-test.tsx.snap +++ /dev/null @@ -1,679 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: Azure DevOps 1`] = ` -
-
- - -
-
-

- key -

-
- - settings.almintegration.checking_configuration -
-`; - -exports[`should render correctly: default 1`] = ` -
-
- - -
-
-

- key -

- - http://github.enterprise.com - -
- - settings.almintegration.checking_configuration -
-`; - -exports[`should render correctly: error 1`] = ` -
-
- - -
-
-

- key -

- - http://github.enterprise.com - -
-
-
- - - settings.almintegration.feature.status_reporting.title - - - -
-
- - - settings.almintegration.feature.alm_repo_import.title - - - -
-
-
- - Oops, something went wrong - -
- -
-`; - -exports[`should render correctly: success 1`] = ` -
-
- - -
-
-

- key -

- - http://github.enterprise.com - -
-
-
- - - settings.almintegration.feature.status_reporting.title - - - -
-
- - - settings.almintegration.feature.alm_repo_import.title - - - -
-
-
- -
-`; - -exports[`should render correctly: success for Bitbucket Cloud 1`] = ` -
-
- - -
-
-

- key -

-
-
-
- - - settings.almintegration.feature.status_reporting.title - - - -
-
- - - settings.almintegration.feature.alm_repo_import.title - - - -
-
-
- -
-`; - -exports[`should render correctly: success for GitLab 1`] = ` -
-
- - -
-
-

- foo -

-
-
-
- - - settings.almintegration.feature.status_reporting.title - - - -
-
- - - settings.almintegration.feature.alm_repo_import.title - - -
- - settings.almintegration.feature.alm_repo_import.disabled - - -
-
-
-
- -
-`; - -exports[`should render correctly: success with alert 1`] = ` -
-
- - -
-
-

- key -

- - http://github.enterprise.com - -
-
-
- - - settings.almintegration.feature.status_reporting.title - - - -
-
- - - settings.almintegration.feature.alm_repo_import.title - - - -
-
-
- - settings.almintegration.configuration_valid - - - - learn_more - , - } - } - /> - -
- -
-`; - -exports[`should render correctly: success with branches disabled 1`] = ` -
-
- - -
-
-

- key -

- - http://github.enterprise.com - -
-
-
- - - settings.almintegration.feature.status_reporting.title - - -
- - settings.almintegration.feature.pr_decoration.disabled - - - settings.almintegration.feature.pr_decoration.disabled.no_branches.link - , - } - } - /> - } - /> -
-
-
- - - settings.almintegration.feature.alm_repo_import.title - - - -
-
-
- - settings.almintegration.configuration_valid - - - - learn_more - , - } - } - /> - -
- -
-`; - -exports[`should render correctly: warning 1`] = ` -
-
- - -
-
-

- key -

- - http://github.enterprise.com - -
-
- - settings.almintegration.could_not_validate - -
- -
-`; diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionForm-test.tsx.snap b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionForm-test.tsx.snap deleted file mode 100644 index f086eb31184..00000000000 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionForm-test.tsx.snap +++ /dev/null @@ -1,49 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: create 1`] = ` - -`; - -exports[`should render correctly: edit 1`] = ` - -`; diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionFormField-test.tsx.snap b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionFormField-test.tsx.snap deleted file mode 100644 index 21193865848..00000000000 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionFormField-test.tsx.snap +++ /dev/null @@ -1,277 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: default 1`] = ` -
-
- - -
-
- - - -
-
-`; - -exports[`should render correctly: encryptable 1`] = ` -
-
- - -
-
- - - - - - learn_more - , - } - } - /> - -
-
-`; - -exports[`should render correctly: invalid with error 1`] = ` -
-
- - -
-
- - - -
-
-`; - -exports[`should render correctly: optional 1`] = ` -
-
- -
-
- - - -
-
-`; - -exports[`should render correctly: secret 1`] = ` -
-
- - -
-
-
-

- settings.almintegration.form.secret.field -

- - settings.almintegration.form.secret.update_field - -
-
-
-`; - -exports[`should render correctly: textarea 1`] = ` -
-
- - -
-
-