From: stanislavh Date: Tue, 21 Feb 2023 14:45:45 +0000 (+0100) Subject: SONAR-18444 RTL migration tutorials X-Git-Tag: 10.0.0.68432~193 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a8dc47ae3cf1514739f969023285bd9270e3de30;p=sonarqube.git SONAR-18444 RTL migration tutorials --- diff --git a/server/sonar-web/src/main/js/apps/tutorials/components/__tests__/TutorialsApp-test.tsx b/server/sonar-web/src/main/js/apps/tutorials/components/__tests__/TutorialsApp-test.tsx index 50275e0a31d..98595918047 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/components/__tests__/TutorialsApp-test.tsx +++ b/server/sonar-web/src/main/js/apps/tutorials/components/__tests__/TutorialsApp-test.tsx @@ -17,28 +17,55 @@ * 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 { byLabelText, byRole } from 'testing-library-selector'; +import SettingsServiceMock from '../../../../api/mocks/SettingsServiceMock'; +import UserTokensMock from '../../../../api/mocks/UserTokensMock'; import handleRequiredAuthentication from '../../../../helpers/handleRequiredAuthentication'; -import { mockProjectAzureBindingResponse } from '../../../../helpers/mocks/alm-settings'; -import { mockComponent } from '../../../../helpers/mocks/component'; import { mockCurrentUser, mockLoggedInUser } from '../../../../helpers/testMocks'; -import { TutorialsApp, TutorialsAppProps } from '../TutorialsApp'; +import { renderAppRoutes } from '../../../../helpers/testReactTestingUtils'; +import { Permissions } from '../../../../types/permissions'; +import routes from '../../routes'; + +jest.mock('../../../../api/settings'); +jest.mock('../../../../api/user-tokens'); jest.mock('../../../../helpers/handleRequiredAuthentication', () => jest.fn()); -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ projectBinding: mockProjectAzureBindingResponse() })).toMatchSnapshot(); +let settingsMock: SettingsServiceMock; +let tokenMock: UserTokensMock; + +beforeAll(() => { + settingsMock = new SettingsServiceMock(); + tokenMock = new UserTokensMock(); +}); + +afterEach(() => { + tokenMock.reset(); + settingsMock.reset(); +}); + +beforeEach(jest.clearAllMocks); + +const ui = { + loading: byLabelText('loading'), + localScanButton: byRole('button', { name: 'onboarding.tutorial.choose_method.local' }), +}; + +it('renders tutorials page', async () => { + renderTutorialsApp(mockLoggedInUser({ permissions: { global: [Permissions.Scan] } })); + expect(ui.loading.get()).toBeInTheDocument(); + expect(await ui.localScanButton.find()).toBeInTheDocument(); }); it('should redirect if user is not logged in', () => { - shallowRender({ currentUser: mockCurrentUser() }); + renderTutorialsApp(); expect(handleRequiredAuthentication).toHaveBeenCalled(); + expect(ui.loading.query()).not.toBeInTheDocument(); + expect(ui.localScanButton.query()).not.toBeInTheDocument(); }); -function shallowRender(overrides: Partial = {}) { - return shallow( - - ); +function renderTutorialsApp(currentUser = mockCurrentUser()) { + return renderAppRoutes('tutorials', routes, { + currentUser, + }); } diff --git a/server/sonar-web/src/main/js/apps/tutorials/components/__tests__/__snapshots__/TutorialsApp-test.tsx.snap b/server/sonar-web/src/main/js/apps/tutorials/components/__tests__/__snapshots__/TutorialsApp-test.tsx.snap deleted file mode 100644 index 52fa708d935..00000000000 --- a/server/sonar-web/src/main/js/apps/tutorials/components/__tests__/__snapshots__/TutorialsApp-test.tsx.snap +++ /dev/null @@ -1,97 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -
- -
-`; - -exports[`should render correctly 2`] = ` -
- -
-`; diff --git a/server/sonar-web/src/main/js/components/tutorials/__tests__/TutorialSelection-it.tsx b/server/sonar-web/src/main/js/components/tutorials/__tests__/TutorialSelection-it.tsx index 5349d91cd9f..89cfc0bcee5 100644 --- a/server/sonar-web/src/main/js/components/tutorials/__tests__/TutorialSelection-it.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/__tests__/TutorialSelection-it.tsx @@ -84,7 +84,7 @@ it.each([ [TutorialModes.AzurePipelines, 'onboarding.tutorial.with.azure_pipelines.title'], [ TutorialModes.BitbucketPipelines, - 'onboarding.tutorial.with.bitbucket_pipelines.create_secret.title', + 'onboarding.tutorial.with.bitbucket_pipelines.variables.title', ], [TutorialModes.GitHubActions, 'onboarding.tutorial.with.github_action.create_secret.title'], [TutorialModes.GitLabCI, 'onboarding.tutorial.with.gitlab_ci.title'], diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/AnalysisCommand.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/AnalysisCommand.tsx index 3998cb59bcc..b30644f81f0 100644 --- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/AnalysisCommand.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/AnalysisCommand.tsx @@ -59,10 +59,6 @@ export function AnalysisCommand(props: AnalysisCommandProps) { const { buildTool, mainBranchName, component } = props; const branchSupportEnabled = props.hasFeature(Feature.BranchSupport); - if (!buildTool) { - return null; - } - const yamlTemplate = YamlTemplate[buildTool]( branchSupportEnabled, mainBranchName, diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/BitbucketPipelinesTutorial.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/BitbucketPipelinesTutorial.tsx index 937b57e8e71..f697f99b000 100644 --- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/BitbucketPipelinesTutorial.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/BitbucketPipelinesTutorial.tsx @@ -80,7 +80,7 @@ export default function BitbucketPipelinesTutorial(props: BitbucketPipelinesTuto /> )} stepNumber={Steps.REPOSITORY_VARIABLES} - stepTitle={translate('onboarding.tutorial.with.bitbucket_pipelines.create_secret.title')} + stepTitle={translate('onboarding.tutorial.with.bitbucket_pipelines.variables.title')} /> Steps.YAML} diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/AnalysisCommand-test.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/AnalysisCommand-test.tsx deleted file mode 100644 index 6441311b363..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/AnalysisCommand-test.tsx +++ /dev/null @@ -1,49 +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 { mockComponent } from '../../../../helpers/mocks/component'; -import { BuildTools } from '../../types'; -import { AnalysisCommand, AnalysisCommandProps } from '../AnalysisCommand'; - -it.each([ - [BuildTools.CFamily], - [BuildTools.DotNet], - [BuildTools.Gradle], - [BuildTools.Maven], - [BuildTools.Other], -])('should render correctly for %s', (buildTool) => { - expect(shallowRender({ buildTool })).toMatchSnapshot(); - expect(shallowRender({ hasFeature: () => true, buildTool })).toMatchSnapshot( - 'with branch enabled' - ); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/BitbucketPipelinesTutorial-it.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/BitbucketPipelinesTutorial-it.tsx new file mode 100644 index 00000000000..7d85f9e2ca5 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/BitbucketPipelinesTutorial-it.tsx @@ -0,0 +1,166 @@ +/* + * 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 userEvent from '@testing-library/user-event'; +import React from 'react'; +import selectEvent from 'react-select-event'; +import UserTokensMock from '../../../../api/mocks/UserTokensMock'; +import { + mockAlmSettingsInstance, + mockProjectAlmBindingResponse, +} from '../../../../helpers/mocks/alm-settings'; +import { mockComponent } from '../../../../helpers/mocks/component'; +import { mockLanguage, mockLoggedInUser } from '../../../../helpers/testMocks'; +import { renderApp, RenderContext } from '../../../../helpers/testReactTestingUtils'; +import { AlmKeys } from '../../../../types/alm-settings'; +import { Feature } from '../../../../types/features'; +import { + getCommonNodes, + getCopyToClipboardValue, + getTutorialActionButtons, + getTutorialBuildButtons, +} from '../../test-utils'; +import { TutorialModes } from '../../types'; +import BitbucketPipelinesTutorial, { + BitbucketPipelinesTutorialProps, +} from '../BitbucketPipelinesTutorial'; + +jest.mock('../../../../api/user-tokens'); + +jest.mock('../../../../api/settings', () => ({ + getAllValues: jest.fn().mockResolvedValue([]), +})); + +const tokenMock = new UserTokensMock(); + +afterEach(() => { + tokenMock.reset(); +}); + +const ui = { + ...getCommonNodes(TutorialModes.BitbucketPipelines), + ...getTutorialActionButtons(), + ...getTutorialBuildButtons(), +}; + +it('should follow and complete all steps', async () => { + const user = userEvent.setup(); + renderBitbucketPipelinesTutorial(); + + expect(await ui.secretsStepTitle.find()).toBeInTheDocument(); + + // Env variables step + expect(getCopyToClipboardValue()).toMatchSnapshot('sonar token key'); + expect(getCopyToClipboardValue(1)).toMatchSnapshot('sonarqube host url key'); + expect(getCopyToClipboardValue(2)).toMatchSnapshot('sonarqube host url value'); + await user.click(ui.continueButton.get()); + + // Create/update configuration file step + // Maven + await user.click(ui.mavenBuildButton.get()); + expect(getCopyToClipboardValue(1)).toMatchSnapshot('Maven: bitbucket-pipelines.yml'); + + // Gradle + await user.click(ui.gradleBuildButton.get()); + expect(getCopyToClipboardValue(1)).toMatchSnapshot('Gradle: build.gradle'); + expect(getCopyToClipboardValue(3)).toMatchSnapshot('Gradle: bitbucket-pipelines.yml'); + + // .NET + await user.click(ui.dotnetBuildButton.get()); + expect(getCopyToClipboardValue(1)).toMatchSnapshot('.NET: bitbucket-pipelines.yml'); + + // CFamily + await user.click(ui.cFamilyBuildButton.get()); + expect(getCopyToClipboardValue()).toMatchSnapshot('CFamily: sonar-project.properties'); + expect(getCopyToClipboardValue(2)).toMatchSnapshot('CFamily: bitbucket-pipelines.yml'); + + // Other + await user.click(ui.otherBuildButton.get()); + expect(getCopyToClipboardValue()).toMatchSnapshot('Other: sonar-project.properties'); + expect(getCopyToClipboardValue(2)).toMatchSnapshot('Other: .github/workflows/build.yml'); + + await user.click(ui.finishTutorialButton.get()); + expect(ui.allSetSentence.get()).toBeInTheDocument(); +}); + +it('should generate/delete a new token or use existing one', async () => { + const user = userEvent.setup(); + renderBitbucketPipelinesTutorial(); + + expect(await ui.secretsStepTitle.find()).toBeInTheDocument(); + + // Generate token + await user.click(ui.genTokenDialogButton.get()); + await user.click(ui.generateTokenButton.get()); + expect(getCopyToClipboardValue(3)).toEqual('generatedtoken2'); + + // Revoke current token and create new one + await user.click(ui.deleteTokenButton.get()); + await user.type(ui.tokenNameInput.get(), 'newtoken'); + await selectEvent.select(ui.expiresInSelect.get(), 'users.tokens.expiration.365'); + await user.click(ui.generateTokenButton.get()); + expect(ui.tokenValue.get()).toBeInTheDocument(); + await user.click(ui.continueButton.getAll()[1]); + expect(ui.tokenValue.query()).not.toBeInTheDocument(); +}); + +it('navigates between steps', async () => { + const user = userEvent.setup(); + renderBitbucketPipelinesTutorial({ + almBinding: mockAlmSettingsInstance({ + alm: AlmKeys.BitbucketCloud, + url: 'http://localhost/qube', + }), + projectBinding: mockProjectAlmBindingResponse({ + alm: AlmKeys.BitbucketCloud, + repository: 'my-project', + }), + }); + + // If project is bound, link to repo is visible + expect(await ui.linkToRepo.find()).toBeInTheDocument(); + + await user.click(await ui.continueButton.find()); + await user.click(ui.mavenBuildButton.get()); + await user.click(ui.finishTutorialButton.get()); + expect(ui.allSetSentence.get()).toBeInTheDocument(); + + await user.click(ui.ymlFileStepTitle.get()); + expect(ui.mavenBuildButton.get()).toBeInTheDocument(); + await user.click(ui.secretsStepTitle.get()); + expect(ui.genTokenDialogButton.get()).toBeInTheDocument(); +}); + +function renderBitbucketPipelinesTutorial( + overrides: Partial = {}, + { languages = { c: mockLanguage({ key: 'c' }) } }: RenderContext = {} +) { + return renderApp( + '/', + , + { languages, featureList: [Feature.BranchSupport] } + ); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/BitbucketPipelinesTutorial-test.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/BitbucketPipelinesTutorial-test.tsx deleted file mode 100644 index 028336c7c39..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/BitbucketPipelinesTutorial-test.tsx +++ /dev/null @@ -1,65 +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 { - mockAlmSettingsInstance, - mockProjectBitbucketCloudBindingResponse, -} from '../../../../helpers/mocks/alm-settings'; -import { mockComponent } from '../../../../helpers/mocks/component'; -import { mockLoggedInUser } from '../../../../helpers/testMocks'; -import Step from '../../components/Step'; -import { renderStepContent } from '../../test-utils'; -import BitbucketPipelinesTutorial, { - BitbucketPipelinesTutorialProps, -} from '../BitbucketPipelinesTutorial'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('default'); - expect(shallowRender({ almBinding: undefined })).toMatchSnapshot('no binding'); - expect(renderStepContent(shallowRender())).toMatchSnapshot('repo variable step content'); - expect(renderStepContent(shallowRender(), 1)).toMatchSnapshot('yaml file step content'); -}); - -it('should correctly navigate through the steps', () => { - const wrapper = shallowRender(); - - expect(wrapper.find(Step).at(0).props().open).toBe(true); - expect(wrapper.find(Step).at(1).props().open).toBe(false); - - wrapper.find(Step).at(1).simulate('open'); - expect(wrapper.find(Step).at(0).props().open).toBe(false); - expect(wrapper.find(Step).at(1).props().open).toBe(true); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/PreambuleYaml-test.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/PreambuleYaml-test.tsx deleted file mode 100644 index 61be1a1906a..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/PreambuleYaml-test.tsx +++ /dev/null @@ -1,37 +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 { mockComponent } from '../../../../helpers/mocks/component'; -import { BuildTools } from '../../types'; -import { PreambuleYaml, PreambuleYamlProps } from '../PreambuleYaml'; - -it.each([[BuildTools.DotNet], [BuildTools.Gradle], [BuildTools.CFamily], [BuildTools.Other]])( - 'should render correctly for %s', - (buildTool) => { - expect(shallowRender({ buildTool })).toMatchSnapshot(); - } -); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/RepositoryVariables-test.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/RepositoryVariables-test.tsx deleted file mode 100644 index df538bafa24..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/RepositoryVariables-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 { - mockAlmSettingsInstance, - mockProjectBitbucketCloudBindingResponse, -} from '../../../../helpers/mocks/alm-settings'; -import { mockComponent } from '../../../../helpers/mocks/component'; -import { mockLoggedInUser } from '../../../../helpers/testMocks'; -import RepositoryVariables, { RepositoryVariablesProps } from '../RepositoryVariables'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap deleted file mode 100644 index ac895b8390a..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap +++ /dev/null @@ -1,591 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly for cfamily 1`] = ` - - - - - $HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output - - sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output - caches: - sonar: ~/.sonar - -clone: - depth: full - -pipelines: - branches: - '{main}': - - step: *build-step -" - /> - - -`; - -exports[`should render correctly for cfamily: with branch enabled 1`] = ` - - - - - $HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output - - sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output - caches: - sonar: ~/.sonar - -clone: - depth: full - -pipelines: - branches: - '{main}': - - step: *build-step - - pull-requests: - '**': - - step: *build-step" - /> - - -`; - -exports[`should render correctly for dotnet 1`] = ` - - - - -`; - -exports[`should render correctly for dotnet: with branch enabled 1`] = ` - - - - -`; - -exports[`should render correctly for gradle 1`] = ` - - - - -`; - -exports[`should render correctly for gradle: with branch enabled 1`] = ` - - - - -`; - -exports[`should render correctly for maven 1`] = ` - - - - -`; - -exports[`should render correctly for maven: with branch enabled 1`] = ` - - - - -`; - -exports[`should render correctly for other 1`] = ` - - - - -`; - -exports[`should render correctly for other: with branch enabled 1`] = ` - - - - -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/BitbucketPipelinesTutorial-it.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/BitbucketPipelinesTutorial-it.tsx.snap new file mode 100644 index 00000000000..ee7000676dd --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/BitbucketPipelinesTutorial-it.tsx.snap @@ -0,0 +1,174 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should follow and complete all steps: .NET: bitbucket-pipelines.yml 1`] = ` +"image: mcr.microsoft.com/dotnet/core/sdk:latest + +definitions: + steps: + - step: &build-step + name: SonarQube analysis + caches: + - dotnetcore + - sonar + script: + - apt-get update + - apt-get install --yes openjdk-11-jre + - dotnet tool install --global dotnet-sonarscanner + - export PATH="$PATH:/root/.dotnet/tools" + - dotnet sonarscanner begin /k:"my-project" /d:"sonar.login=\${SONAR_TOKEN}" /d:"sonar.host.url=\${SONAR_HOST_URL}" + - dotnet build + - dotnet sonarscanner end /d:"sonar.login=\${SONAR_TOKEN}" + caches: + sonar: ~/.sonar + +pipelines: + branches: + '{main}': + - step: *build-step + + pull-requests: + '**': + - step: *build-step" +`; + +exports[`should follow and complete all steps: CFamily: bitbucket-pipelines.yml 1`] = ` +"image: + +definitions: + steps: + - step: &build-step + name: Build the project, and run the SonarQube analysis + script: + - export SONAR_SCANNER_VERSION=4.6.2.2472 + - mkdir $HOME/.sonar + - curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip \${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-x86.zip + - unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ + - curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${SONAR_SCANNER_VERSION}-linux.zip + - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ + - export PATH="$PATH:$HOME/.sonar/sonar-scanner-\${SONAR_SCANNER_VERSION}-linux/bin" + - + - $HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output + - sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output + caches: + sonar: ~/.sonar + +clone: + depth: full + +pipelines: + branches: + '{main}': + - step: *build-step + + pull-requests: + '**': + - step: *build-step" +`; + +exports[`should follow and complete all steps: CFamily: sonar-project.properties 1`] = `"sonar.projectKey=my-project"`; + +exports[`should follow and complete all steps: Gradle: bitbucket-pipelines.yml 1`] = ` +"image: openjdk:8 + +definitions: + steps: + - step: &build-step + name: SonarQube analysis + caches: + - gradle + - sonar + script: + - bash ./gradlew sonar + caches: + sonar: ~/.sonar + +clone: + depth: full + +pipelines: + branches: + '{main}': + - step: *build-step + + pull-requests: + '**': + - step: *build-step" +`; + +exports[`should follow and complete all steps: Gradle: build.gradle 1`] = ` +"plugins { + id "org.sonarqube" version "3.5.0.2730" +} + +sonar { + properties { + property "sonar.projectKey", "my-project" + property "sonar.projectName", "MyProject" + } +}" +`; + +exports[`should follow and complete all steps: Maven: bitbucket-pipelines.yml 1`] = ` +"image: maven:3-openjdk-11 + +definitions: + steps: + - step: &build-step + name: SonarQube analysis + caches: + - maven + - sonar + script: + - mvn verify sonar:sonar -Dsonar.projectKey=my-project -Dsonar.projectName='MyProject' + caches: + sonar: ~/.sonar + +clone: + depth: full + +pipelines: + branches: + '{main}': + - step: *build-step + + pull-requests: + '**': + - step: *build-step" +`; + +exports[`should follow and complete all steps: Other: .github/workflows/build.yml 1`] = ` +"image: maven:3.3.9 + +definitions: + steps: + - step: &build-step + name: SonarQube analysis + script: + - pipe: sonarsource/sonarqube-scan:1.0.0 + variables: + SONAR_HOST_URL: \${SONAR_HOST_URL} # Get the value from the repository/workspace variable. + SONAR_TOKEN: \${SONAR_TOKEN} # Get the value from the repository/workspace variable. You shouldn't set secret in clear text here. + caches: + sonar: ~/.sonar + +clone: + depth: full + +pipelines: + branches: + '{main}': + - step: *build-step + + pull-requests: + '**': + - step: *build-step +" +`; + +exports[`should follow and complete all steps: Other: sonar-project.properties 1`] = `"sonar.projectKey=my-project"`; + +exports[`should follow and complete all steps: sonar token key 1`] = `"SONAR_TOKEN"`; + +exports[`should follow and complete all steps: sonarqube host url key 1`] = `"SONAR_HOST_URL"`; + +exports[`should follow and complete all steps: sonarqube host url value 1`] = `"http://localhost:9000"`; diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/BitbucketPipelinesTutorial-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/BitbucketPipelinesTutorial-test.tsx.snap deleted file mode 100644 index 001c0cbe6ad..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/BitbucketPipelinesTutorial-test.tsx.snap +++ /dev/null @@ -1,116 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: default 1`] = ` - - - - - -`; - -exports[`should render correctly: no binding 1`] = ` - - - - - -`; - -exports[`should render correctly: repo variable step content 1`] = ` - -`; - -exports[`should render correctly: yaml file step content 1`] = ` - - [Function] - -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/PreambuleYaml-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/PreambuleYaml-test.tsx.snap deleted file mode 100644 index f4662e442ec..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/PreambuleYaml-test.tsx.snap +++ /dev/null @@ -1,99 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly for cfamily 1`] = ` - -`; - -exports[`should render correctly for dotnet 1`] = `""`; - -exports[`should render correctly for gradle 1`] = ` -
  • - - - build.gradle - - - , - "sq": - org.sonarqube - , - } - } - /> - -
  • -`; - -exports[`should render correctly for other 1`] = ` - -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/RepositoryVariables-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/RepositoryVariables-test.tsx.snap deleted file mode 100644 index 7a8eff48339..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/RepositoryVariables-test.tsx.snap +++ /dev/null @@ -1,164 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -
    -

    - - onboarding.tutorial.with.bitbucket_pipelines.variables.intro.link - , - } - } - /> -

    -
      -
    1. - - - SONAR_TOKEN - - -
    2. - -
    3. - -
    4. -
    5. - -
    6. -
    -
    -
      -
    1. - - - SONAR_HOST_URL - - -
    2. -
    3. - , - "field": - onboarding.tutorial.env_variables.field - , - "value": - test - , - } - } - /> -
    4. -
    5. - -
    6. -
    - -
    -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/components/EditTokenModal.tsx b/server/sonar-web/src/main/js/components/tutorials/components/EditTokenModal.tsx index 708e99b3c4a..ef9f3b4ab09 100644 --- a/server/sonar-web/src/main/js/components/tutorials/components/EditTokenModal.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/components/EditTokenModal.tsx @@ -196,7 +196,7 @@ export default class EditTokenModal extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/AllSet-test.tsx b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/AllSet-test.tsx deleted file mode 100644 index 2a9afa2146f..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/AllSet-test.tsx +++ /dev/null @@ -1,35 +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 { AllSet, AllSetProps } from '../AllSet'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ hasFeature: () => false })).toMatchSnapshot('without branch'); - expect(shallowRender({ willRefreshAutomatically: true })).toMatchSnapshot('with auto refresh'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/CompilationInfo-test.tsx b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/CompilationInfo-test.tsx deleted file mode 100644 index e03ee25d020..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/CompilationInfo-test.tsx +++ /dev/null @@ -1,30 +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 { CompilationInfo } from '../CompilationInfo'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender() { - return shallow(); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/CreateYmlFile-test.tsx b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/CreateYmlFile-test.tsx deleted file mode 100644 index b9315e6cb94..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/CreateYmlFile-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 { GradleProps } from '../../github-action/commands/Gradle'; -import CreateYmlFile, { CreateYmlFileProps } from '../CreateYmlFile'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/DefaultProjectKey-test.tsx b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/DefaultProjectKey-test.tsx deleted file mode 100644 index a11723d89ba..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/DefaultProjectKey-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 { mockComponent } from '../../../../helpers/mocks/component'; -import DefaultProjectKey, { DefaultProjectKeyProps } from '../DefaultProjectKey'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/EditTokenModal-test.tsx b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/EditTokenModal-test.tsx index cb32b3a99fc..478430b58d7 100644 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/EditTokenModal-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/EditTokenModal-test.tsx @@ -87,7 +87,7 @@ it('should behave correctly', async () => { expect(screen.getByRole('button', { name: 'copy_to_clipboard' })).toBeInTheDocument(); // Revoke token. - await clickButton(user, 'users.tokens.revoke_token'); + await clickButton(user, 'onboarding.token.delete'); expect(tokenMock.tokens.map((t) => t.name)).not.toContain(lastToken.name); // Generate a new token. diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/FinishButton-test.tsx b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/FinishButton-test.tsx deleted file mode 100644 index 2bf0ef8c949..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/FinishButton-test.tsx +++ /dev/null @@ -1,30 +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 FinishButton, { FinishButtonProps } from '../FinishButton'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow(); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/GithubCFamilyExampleRepositories-test.tsx b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/GithubCFamilyExampleRepositories-test.tsx index c44fdfb15e7..b42006e882f 100644 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/GithubCFamilyExampleRepositories-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/GithubCFamilyExampleRepositories-test.tsx @@ -17,20 +17,36 @@ * 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 { byRole } from 'testing-library-selector'; +import { renderComponent } from '../../../../helpers/testReactTestingUtils'; import { OSs, TutorialModes } from '../../types'; import GithubCFamilyExampleRepositories, { GithubCFamilyExampleRepositoriesProps, } from '../GithubCFamilyExampleRepositories'; -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ os: OSs.MacOS, ci: TutorialModes.AzurePipelines })).toMatchSnapshot(); -}); +const ui = { + cfamilyExamplesLink: byRole('link', { name: /sonarsource-cfamily-examples/ }), +}; -function shallowRender(props: Partial = {}) { - return shallow( - +it.each([ + [OSs.Linux, TutorialModes.Jenkins, 'linux', 'jenkins'], + [OSs.MacOS, TutorialModes.AzurePipelines, 'macos', 'azure'], +])( + 'should set correct value for CFamily examples link for %s and %ss', + async (os: OSs, ci: TutorialModes, formattedOS: string, formattedCI: string) => { + renderGithubCFamilyExampleRepositories({ os, ci }); + expect(await ui.cfamilyExamplesLink.find()).toHaveAttribute( + 'href', + `https://github.com/orgs/sonarsource-cfamily-examples/repositories?q=sq+${formattedOS}+${formattedCI}` + ); + } +); + +function renderGithubCFamilyExampleRepositories( + overrides: Partial = {} +) { + return renderComponent( + ); } diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/LabelActionPair-test.tsx b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/LabelActionPair-test.tsx deleted file mode 100644 index b1f3f1e8dd9..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/LabelActionPair-test.tsx +++ /dev/null @@ -1,30 +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 LabelActionPair, { LabelActionPairProps } from '../LabelActionPair'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow(); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/LabelValuePair-test.tsx b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/LabelValuePair-test.tsx deleted file mode 100644 index 54c7d4c4b6b..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/LabelValuePair-test.tsx +++ /dev/null @@ -1,32 +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 LabelValuePair, { LabelValuePairProps } from '../LabelValuePair'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/RenderOptions-test.tsx b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/RenderOptions-test.tsx deleted file mode 100644 index bfbd2cb596c..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/RenderOptions-test.tsx +++ /dev/null @@ -1,41 +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 RenderOptions, { RenderOptionsProps } from '../RenderOptions'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('default'); - expect(shallowRender({ checked: 'baz' })).toMatchSnapshot('option checked'); - expect(shallowRender({ titleLabelKey: 'title.key' })).toMatchSnapshot('with title'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/SentenceWithFilename-test.tsx b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/SentenceWithFilename-test.tsx deleted file mode 100644 index 7ee0b30cd3a..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/SentenceWithFilename-test.tsx +++ /dev/null @@ -1,32 +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 SentenceWithFilename, { SentenceWithFilenameProps } from '../SentenceWithFilename'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/SentenceWithHighlights-test.tsx b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/SentenceWithHighlights-test.tsx deleted file mode 100644 index aed2beed9de..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/SentenceWithHighlights-test.tsx +++ /dev/null @@ -1,32 +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 SentenceWithHighlights, { SentenceWithHighlightsProps } from '../SentenceWithHighlights'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/Step-test.tsx b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/Step-test.tsx deleted file mode 100644 index d358150b67d..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/Step-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 { click } from '../../../../helpers/testUtils'; -import Step from '../Step'; - -it('renders', () => { - const wrapper = shallow( -
    form
    } - renderResult={() =>
    result
    } - stepNumber={1} - stepTitle="First Step" - /> - ); - expect(wrapper).toMatchSnapshot(); - wrapper.setProps({ open: false }); - expect(wrapper).toMatchSnapshot(); -}); - -it('re-opens', () => { - const onOpen = jest.fn(); - const wrapper = shallow( -
    form
    } - renderResult={() =>
    result
    } - stepNumber={1} - stepTitle="First Step" - /> - ); - click(wrapper); - expect(onOpen).toHaveBeenCalled(); -}); diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/TokenStepGenerator-test.tsx b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/TokenStepGenerator-test.tsx deleted file mode 100644 index 767019cc864..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/TokenStepGenerator-test.tsx +++ /dev/null @@ -1,34 +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 { mockComponent } from '../../../../helpers/mocks/component'; -import { mockLoggedInUser } from '../../../../helpers/testMocks'; -import TokenStepGenerator, { TokenStepGeneratorProps } from '../TokenStepGenerator'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/YamlFileStep-test.tsx b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/YamlFileStep-test.tsx deleted file mode 100644 index a6bde485946..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/YamlFileStep-test.tsx +++ /dev/null @@ -1,41 +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 { BuildTools } from '../../types'; -import RenderOptions from '../RenderOptions'; -import { YamlFileStep, YamlFileStepProps } from '../YamlFileStep'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('C unavailable'); - expect(shallowRender({ hasCLanguageFeature: true })).toMatchSnapshot('C available'); -}); - -it('should render child correctly', () => { - const children = jest.fn(); - const wrapper = shallowRender({ children }); - expect(wrapper).toMatchSnapshot('C unavailable'); - wrapper.find(RenderOptions).simulate('check', BuildTools.DotNet); - expect(children).toHaveBeenCalledWith(BuildTools.DotNet); -}); - -function shallowRender(props: Partial = {}) { - return shallow(); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/AllSet-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/AllSet-test.tsx.snap deleted file mode 100644 index 056a8d8d40b..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/AllSet-test.tsx.snap +++ /dev/null @@ -1,168 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - -
    -

    - -

    -
    -
    - -
    -
    -

    - - onboarding.tutorial.ci_outro.commit - -

    -

    - onboarding.tutorial.ci_outro.commit.why.github -

    -
    -
    -
    -
    -`; - -exports[`should render correctly: with auto refresh 1`] = ` - -
    -

    - -

    -
    -
    - -
    -
    -

    - - onboarding.tutorial.ci_outro.commit - -

    -

    - onboarding.tutorial.ci_outro.commit.why.github -

    -
    -
    -
    -
    - -
    -
    -

    - - onboarding.tutorial.ci_outro.refresh - -

    -

    - onboarding.tutorial.ci_outro.refresh.why -

    -
    -
    -
    -
    - - onboarding.tutorial.ci_outro.waiting_for_fist_analysis -
    -
    -`; - -exports[`should render correctly: without branch 1`] = ` - -
    -

    - -

    -
    -
    - -
    -
    -

    - - onboarding.tutorial.ci_outro.commit - -

    -

    - onboarding.tutorial.ci_outro.commit.why.no_branches -

    -
    -
    -
    -
    -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/CompilationInfo-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/CompilationInfo-test.tsx.snap deleted file mode 100644 index 327efdd8576..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/CompilationInfo-test.tsx.snap +++ /dev/null @@ -1,41 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - -

    - - onboarding.tutorial.cfamilly.compilation_database_info.link - , - } - } - /> -

    -

    - - onboarding.tutorial.cfamilly.speed_caching.link - , - } - } - /> -

    -
    -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/CreateYmlFile-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/CreateYmlFile-test.tsx.snap deleted file mode 100644 index d9976c97110..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/CreateYmlFile-test.tsx.snap +++ /dev/null @@ -1,29 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -
  • - - - test.yml - - - , - } - } - /> - -
  • -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/DefaultProjectKey-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/DefaultProjectKey-test.tsx.snap deleted file mode 100644 index cb21627f326..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/DefaultProjectKey-test.tsx.snap +++ /dev/null @@ -1,15 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -
  • - - -
  • -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/FinishButton-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/FinishButton-test.tsx.snap deleted file mode 100644 index fe4e12192d2..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/FinishButton-test.tsx.snap +++ /dev/null @@ -1,13 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/GithubCFamilyExampleRepositories-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/GithubCFamilyExampleRepositories-test.tsx.snap deleted file mode 100644 index 14cb44eb1f0..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/GithubCFamilyExampleRepositories-test.tsx.snap +++ /dev/null @@ -1,59 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -
    -
    - - - sonarsource-cfamily-examples - -
    -

    - onboarding.tutorial.cfamily.examples_repositories_description -

    -
    -`; - -exports[`should render correctly 2`] = ` -
    -
    - - - sonarsource-cfamily-examples - -
    -

    - onboarding.tutorial.cfamily.examples_repositories_description -

    -
    -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/LabelActionPair-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/LabelActionPair-test.tsx.snap deleted file mode 100644 index 574d189ee6a..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/LabelActionPair-test.tsx.snap +++ /dev/null @@ -1,12 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - - - foo.label - : - - - foo.action - -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/LabelValuePair-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/LabelValuePair-test.tsx.snap deleted file mode 100644 index 99305242996..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/LabelValuePair-test.tsx.snap +++ /dev/null @@ -1,20 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -
    - - foo.label - : - - - bar - -
    -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/RenderOptions-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/RenderOptions-test.tsx.snap deleted file mode 100644 index d62e8722c21..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/RenderOptions-test.tsx.snap +++ /dev/null @@ -1,76 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: default 1`] = ` -
    - -
    -`; - -exports[`should render correctly: option checked 1`] = ` -
    - -
    -`; - -exports[`should render correctly: with title 1`] = ` -
    -

    - title.key -

    - -
    -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/SentenceWithFilename-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/SentenceWithFilename-test.tsx.snap deleted file mode 100644 index 9e8423f097d..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/SentenceWithFilename-test.tsx.snap +++ /dev/null @@ -1,19 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - - - foo.txt - , - } - } - /> - -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/SentenceWithHighlights-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/SentenceWithHighlights-test.tsx.snap deleted file mode 100644 index 594f5ba1d9f..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/SentenceWithHighlights-test.tsx.snap +++ /dev/null @@ -1,18 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - - foo.sentence.hello - , - "world": - foo.sentence.world - , - } - } -/> -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/Step-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/Step-test.tsx.snap deleted file mode 100644 index e386e0596d6..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/Step-test.tsx.snap +++ /dev/null @@ -1,53 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`renders 1`] = ` -
    -
    - 1 -
    -
    -

    - First Step -

    -
    -
    -
    - form -
    -
    -
    -`; - -exports[`renders 2`] = ` -
    -
    - 1 -
    -
    - result -
    -
    -

    - First Step -

    -
    -
    -
    -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/TokenStepGenerator-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/TokenStepGenerator-test.tsx.snap deleted file mode 100644 index e3f4357fa4d..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/TokenStepGenerator-test.tsx.snap +++ /dev/null @@ -1,28 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - -
  • - - onboarding.token.generate.long - , - "field": - onboarding.tutorial.env_variables.field - , - "value": "onboarding.tutorial.env_variables.token_generator.value", - } - } - /> -
  • -
    -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/YamlFileStep-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/YamlFileStep-test.tsx.snap deleted file mode 100644 index 763c04d0ab1..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/YamlFileStep-test.tsx.snap +++ /dev/null @@ -1,77 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render child correctly: C unavailable 1`] = ` -
      -
    1. - onboarding.build - -
    2. -
    -`; - -exports[`should render correctly: C available 1`] = ` -
      -
    1. - onboarding.build - -
    2. -
    -`; - -exports[`should render correctly: C unavailable 1`] = ` -
      -
    1. - onboarding.build - -
    2. -
    -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/AnalysisCommand.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/AnalysisCommand.tsx index e6d736dcb26..6204a994d68 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/AnalysisCommand.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/AnalysisCommand.tsx @@ -41,10 +41,6 @@ export function AnalysisCommand(props: AnalysisCommandProps) { const { buildTool, component, mainBranchName } = props; const branchSupportEnabled = props.hasFeature(Feature.BranchSupport); - if (!buildTool) { - return null; - } - switch (buildTool) { case BuildTools.Maven: return ( diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/AnalysisCommand-test.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/AnalysisCommand-test.tsx deleted file mode 100644 index f3ad33a525f..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/AnalysisCommand-test.tsx +++ /dev/null @@ -1,48 +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 { mockComponent } from '../../../../helpers/mocks/component'; -import { BuildTools } from '../../types'; -import { AnalysisCommand, AnalysisCommandProps } from '../AnalysisCommand'; - -it.each([ - undefined, - BuildTools.CFamily, - BuildTools.DotNet, - BuildTools.Gradle, - BuildTools.Maven, - BuildTools.Other, -])('should render correctly for %p', (buildTool) => { - expect(shallowRender({ buildTool })).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/GitHubActionTutorial-test.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/GitHubActionTutorial-test.tsx deleted file mode 100644 index a32c9d27d6e..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/GitHubActionTutorial-test.tsx +++ /dev/null @@ -1,63 +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 { - mockAlmSettingsInstance, - mockProjectGithubBindingResponse, -} from '../../../../helpers/mocks/alm-settings'; -import { mockComponent } from '../../../../helpers/mocks/component'; -import { mockLoggedInUser } from '../../../../helpers/testMocks'; -import Step from '../../components/Step'; -import { renderStepContent } from '../../test-utils'; -import GitHubActionTutorial, { GitHubActionTutorialProps } from '../GitHubActionTutorial'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('default'); - expect(shallowRender({ almBinding: undefined })).toMatchSnapshot('no binding'); - expect(renderStepContent(shallowRender())).toMatchSnapshot('secrets step content'); - expect(renderStepContent(shallowRender(), 1)).toMatchSnapshot('yaml file step content'); -}); - -it('should correctly navigate through the steps', () => { - const wrapper = shallowRender(); - - expect(wrapper.find(Step).at(0).props().open).toBe(true); - expect(wrapper.find(Step).at(1).props().open).toBe(false); - - wrapper.find(Step).at(1).simulate('open'); - expect(wrapper.find(Step).at(0).props().open).toBe(false); - expect(wrapper.find(Step).at(1).props().open).toBe(true); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/GithubActionTutorial-it.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/GithubActionTutorial-it.tsx new file mode 100644 index 00000000000..22bd3452109 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/GithubActionTutorial-it.tsx @@ -0,0 +1,168 @@ +/* + * 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 userEvent from '@testing-library/user-event'; +import React from 'react'; +import selectEvent from 'react-select-event'; +import UserTokensMock from '../../../../api/mocks/UserTokensMock'; +import { + mockAlmSettingsInstance, + mockProjectAlmBindingResponse, +} from '../../../../helpers/mocks/alm-settings'; +import { mockComponent } from '../../../../helpers/mocks/component'; +import { mockLanguage, mockLoggedInUser } from '../../../../helpers/testMocks'; +import { renderApp, RenderContext } from '../../../../helpers/testReactTestingUtils'; +import { AlmKeys } from '../../../../types/alm-settings'; +import { Feature } from '../../../../types/features'; +import { + getCommonNodes, + getCopyToClipboardValue, + getTutorialActionButtons, + getTutorialBuildButtons, +} from '../../test-utils'; +import { TutorialModes } from '../../types'; +import GitHubActionTutorial, { GitHubActionTutorialProps } from '../GitHubActionTutorial'; + +jest.mock('../../../../api/user-tokens'); + +jest.mock('../../../../api/settings', () => ({ + getAllValues: jest.fn().mockResolvedValue([]), +})); + +const tokenMock = new UserTokensMock(); + +afterEach(() => { + tokenMock.reset(); +}); + +const ui = { + ...getCommonNodes(TutorialModes.GitHubActions), + ...getTutorialActionButtons(), + ...getTutorialBuildButtons(), +}; + +it('should follow and complete all steps', async () => { + const user = userEvent.setup(); + renderGithubActionTutorial(); + + expect(await ui.secretsStepTitle.find()).toBeInTheDocument(); + + // Env variables step + expect(getCopyToClipboardValue()).toMatchSnapshot('sonar token key'); + expect(getCopyToClipboardValue(1)).toMatchSnapshot('sonarqube host url key'); + expect(getCopyToClipboardValue(2)).toMatchSnapshot('sonarqube host url value'); + await user.click(ui.continueButton.get()); + + // Create/update configuration file step + // Maven + await user.click(ui.mavenBuildButton.get()); + expect(getCopyToClipboardValue(1)).toMatchSnapshot('Maven: .github/workflows/build.yml'); + + // Gradle + await user.click(ui.gradleBuildButton.get()); + expect(getCopyToClipboardValue(1)).toMatchSnapshot('Gradle: build.gradle'); + expect(getCopyToClipboardValue(3)).toMatchSnapshot('Gradle: .github/workflows/build.yml'); + + // .NET + await user.click(ui.dotnetBuildButton.get()); + expect(getCopyToClipboardValue(1)).toMatchSnapshot('.NET: .github/workflows/build.yml'); + + // CFamily + await user.click(ui.cFamilyBuildButton.get()); + expect(getCopyToClipboardValue()).toMatchSnapshot('CFamily: sonar-project.properties'); + await user.click(ui.linuxButton.get()); + expect(getCopyToClipboardValue(2)).toMatchSnapshot('CFamily Linux: .github/workflows/build.yml'); + await user.click(ui.windowsButton.get()); + expect(getCopyToClipboardValue(2)).toMatchSnapshot( + 'CFamily Windows: .github/workflows/build.yml' + ); + await user.click(ui.macosButton.get()); + expect(getCopyToClipboardValue(2)).toMatchSnapshot('CFamily MacOS: .github/workflows/build.yml'); + + // Other + await user.click(ui.otherBuildButton.get()); + expect(getCopyToClipboardValue()).toMatchSnapshot('Other: sonar-project.properties'); + expect(getCopyToClipboardValue(2)).toMatchSnapshot('Other: .github/workflows/build.yml'); + + await user.click(ui.finishTutorialButton.get()); + expect(ui.allSetSentence.get()).toBeInTheDocument(); +}); + +it('should generate/delete a new token or use existing one', async () => { + const user = userEvent.setup(); + renderGithubActionTutorial(); + + expect(await ui.secretsStepTitle.find()).toBeInTheDocument(); + + // Generate token + await user.click(ui.genTokenDialogButton.get()); + await user.click(ui.generateTokenButton.get()); + expect(getCopyToClipboardValue(3)).toEqual('generatedtoken2'); + + // Revoke current token and create new one + await user.click(ui.deleteTokenButton.get()); + await user.type(ui.tokenNameInput.get(), 'newtoken'); + await selectEvent.select(ui.expiresInSelect.get(), 'users.tokens.expiration.365'); + await user.click(ui.generateTokenButton.get()); + expect(ui.tokenValue.get()).toBeInTheDocument(); + await user.click(ui.continueButton.getAll()[1]); + expect(ui.tokenValue.query()).not.toBeInTheDocument(); +}); + +it('navigates between steps', async () => { + const user = userEvent.setup(); + renderGithubActionTutorial({ + almBinding: mockAlmSettingsInstance({ + alm: AlmKeys.GitHub, + url: 'http://localhost/qube', + }), + projectBinding: mockProjectAlmBindingResponse({ alm: AlmKeys.GitHub }), + }); + + // If project is bound, link to repo is visible + expect(await ui.linkToRepo.find()).toBeInTheDocument(); + + await user.click(await ui.continueButton.find()); + await user.click(ui.mavenBuildButton.get()); + await user.click(ui.finishTutorialButton.get()); + expect(ui.allSetSentence.get()).toBeInTheDocument(); + + await user.click(ui.ymlFileStepTitle.get()); + expect(ui.mavenBuildButton.get()).toBeInTheDocument(); + await user.click(ui.secretsStepTitle.get()); + expect(ui.genTokenDialogButton.get()).toBeInTheDocument(); +}); + +function renderGithubActionTutorial( + overrides: Partial = {}, + { languages = { c: mockLanguage({ key: 'c' }) } }: RenderContext = {} +) { + return renderApp( + '/', + , + { languages, featureList: [Feature.BranchSupport] } + ); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/SecretStep-test.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/SecretStep-test.tsx deleted file mode 100644 index 73d222200ce..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/SecretStep-test.tsx +++ /dev/null @@ -1,50 +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 { - mockAlmSettingsInstance, - mockProjectGithubBindingResponse, -} from '../../../../helpers/mocks/alm-settings'; -import { mockComponent } from '../../../../helpers/mocks/component'; -import { mockLoggedInUser } from '../../../../helpers/testMocks'; -import SecretStep, { SecretStepProps } from '../SecretStep'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('default'); - expect( - shallowRender({ - almBinding: mockAlmSettingsInstance({ url: 'http://github.enterprise.com/api/v3' }), - projectBinding: mockProjectGithubBindingResponse(), - }) - ).toMatchSnapshot('with binding information'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap deleted file mode 100644 index a9d3a81d8c3..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap +++ /dev/null @@ -1,153 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly for "cfamily" 1`] = ` - -`; - -exports[`should render correctly for "dotnet" 1`] = ` - -`; - -exports[`should render correctly for "gradle" 1`] = ` - -`; - -exports[`should render correctly for "maven" 1`] = ` - -`; - -exports[`should render correctly for "other" 1`] = ` - -`; - -exports[`should render correctly for undefined 1`] = `""`; diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/GitHubActionTutorial-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/GitHubActionTutorial-test.tsx.snap deleted file mode 100644 index 475632028ab..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/GitHubActionTutorial-test.tsx.snap +++ /dev/null @@ -1,116 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: default 1`] = ` - - - - - -`; - -exports[`should render correctly: no binding 1`] = ` - - - - - -`; - -exports[`should render correctly: secrets step content 1`] = ` - -`; - -exports[`should render correctly: yaml file step content 1`] = ` - - [Function] - -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/GithubActionTutorial-it.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/GithubActionTutorial-it.tsx.snap new file mode 100644 index 00000000000..98f9cf959a1 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/GithubActionTutorial-it.tsx.snap @@ -0,0 +1,325 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should follow and complete all steps: .NET: .github/workflows/build.yml 1`] = ` +"name: Build + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + name: Build + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 1.11 + - name: Cache SonarQube packages + uses: actions/cache@v1 + with: + path: ~\\sonar\\cache + key: \${{ runner.os }}-sonar + restore-keys: \${{ runner.os }}-sonar + - name: Cache SonarQube scanner + id: cache-sonar-scanner + uses: actions/cache@v1 + with: + path: .\\.sonar\\scanner + key: \${{ runner.os }}-sonar-scanner + restore-keys: \${{ runner.os }}-sonar-scanner + - name: Install SonarQube scanner + if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' + shell: powershell + run: | + New-Item -Path .\\.sonar\\scanner -ItemType Directory + dotnet tool update dotnet-sonarscanner --tool-path .\\.sonar\\scanner + - name: Build and analyze + env: + GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + shell: powershell + run: | + .\\.sonar\\scanner\\dotnet-sonarscanner begin /k:"my-project" /d:sonar.login="\${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="\${{ secrets.SONAR_HOST_URL }}" + dotnet build + .\\.sonar\\scanner\\dotnet-sonarscanner end /d:sonar.login="\${{ secrets.SONAR_TOKEN }}"" +`; + +exports[`should follow and complete all steps: CFamily Linux: .github/workflows/build.yml 1`] = ` +"name: Build + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + name: Build + runs-on: + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Download and install the build wrapper, build the project + run: | + mkdir $HOME/.sonar + curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip \${{ secrets.SONAR_HOST_URL }}/static/cpp/build-wrapper-linux-x86.zip + unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ + $HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output + env: + SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }} + + - name: Download and install the SonarScanner + env: + SONAR_SCANNER_VERSION: 4.6.2.2472 + run: | + curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${{ env.SONAR_SCANNER_VERSION }}-linux.zip + unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ + echo "$HOME/.sonar/sonar-scanner-\${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH + + - name: SonarQube analysis + run: | + sonar-scanner --define sonar.cfamily.build-wrapper-output=bw-output + env: + SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }}" +`; + +exports[`should follow and complete all steps: CFamily MacOS: .github/workflows/build.yml 1`] = ` +"name: Build + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + name: Build + runs-on: + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Download and install the build wrapper + run: | + mkdir $HOME/.sonar + curl -sSLo $HOME/.sonar/build-wrapper-macosx-x86.zip \${{ secrets.SONAR_HOST_URL }}/static/cpp/build-wrapper-macosx-x86.zip + unzip -o $HOME/.sonar/build-wrapper-macosx-x86.zip -d $HOME/.sonar/ + env: + SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }} + + - name: Download and install the SonarScanner + run: | + curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472-macosx.zip + unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ + + - name: Build and analyse the project + run: | + # Potential improvement : add these paths to the PATH env var. + $HOME/.sonar/build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir bw-output + $HOME/.sonar/sonar-scanner-4.6.2.2472-macosx/bin/sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output + env: + SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }}" +`; + +exports[`should follow and complete all steps: CFamily Windows: .github/workflows/build.yml 1`] = ` +"name: Build + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + name: Build + runs-on: + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Download and install the build wrapper + shell: powershell + run: | + $path = "$HOME/.sonar/build-wrapper-win-x86.zip" + mkdir $HOME/.sonar + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + (New-Object System.Net.WebClient).DownloadFile("\${{ secrets.SONAR_HOST_URL }}/static/cpp/build-wrapper-win-x86.zip", $path) + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($path, "$HOME/.sonar") + env: + SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }} + + - name: Download and install the SonarScanner + shell: powershell + run: | + $path = "$HOME/.sonar/sonar-scanner-cli-4.6.2.2472-windows.zip" + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + (New-Object System.Net.WebClient).DownloadFile("https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472-windows.zip", $path) + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($path, "$HOME/.sonar") + + - name: Build and analyse the project + shell: powershell + run: | + $env:Path += ";$HOME/.sonar/build-wrapper-win-x86;$HOME/.sonar/sonar-scanner-4.6.2.2472-windows/bin" + build-wrapper-win-x86-64 --out-dir bw-output + sonar-scanner.bat "-Dsonar.cfamily.build-wrapper-output=bw-output" + env: + SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }}" +`; + +exports[`should follow and complete all steps: CFamily: sonar-project.properties 1`] = `"sonar.projectKey=my-project"`; + +exports[`should follow and complete all steps: Gradle: .github/workflows/build.yml 1`] = ` +"name: Build + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Cache SonarQube packages + uses: actions/cache@v1 + with: + path: ~/.sonar/cache + key: \${{ runner.os }}-sonar + restore-keys: \${{ runner.os }}-sonar + - name: Cache Gradle packages + uses: actions/cache@v1 + with: + path: ~/.gradle/caches + key: \${{ runner.os }}-gradle-\${{ hashFiles('**/*.gradle') }} + restore-keys: \${{ runner.os }}-gradle + - name: Build and analyze + env: + GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }} + run: ./gradlew build sonar --info" +`; + +exports[`should follow and complete all steps: Gradle: build.gradle 1`] = ` +"plugins { + id "org.sonarqube" version "3.5.0.2730" +} + +sonar { + properties { + property "sonar.projectKey", "my-project" + property "sonar.projectName", "MyProject" + } +}" +`; + +exports[`should follow and complete all steps: Maven: .github/workflows/build.yml 1`] = ` +"name: Build + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Cache SonarQube packages + uses: actions/cache@v1 + with: + path: ~/.sonar/cache + key: \${{ runner.os }}-sonar + restore-keys: \${{ runner.os }}-sonar + - name: Cache Maven packages + uses: actions/cache@v1 + with: + path: ~/.m2 + key: \${{ runner.os }}-m2-\${{ hashFiles('**/pom.xml') }} + restore-keys: \${{ runner.os }}-m2 + - name: Build and analyze + env: + GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }} + run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=my-project -Dsonar.projectName='MyProject'" +`; + +exports[`should follow and complete all steps: Other: .github/workflows/build.yml 1`] = ` +"name: Build + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - uses: sonarsource/sonarqube-scan-action@master + env: + SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }} + # If you wish to fail your job when the Quality Gate is red, uncomment the + # following lines. This would typically be used to fail a deployment. + # We do not recommend to use this in a pull request. Prefer using pull request + # decoration instead. + # - uses: sonarsource/sonarqube-quality-gate-action@master + # timeout-minutes: 5 + # env: + # SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }}" +`; + +exports[`should follow and complete all steps: Other: sonar-project.properties 1`] = `"sonar.projectKey=my-project"`; + +exports[`should follow and complete all steps: sonar token key 1`] = `"SONAR_TOKEN"`; + +exports[`should follow and complete all steps: sonarqube host url key 1`] = `"SONAR_HOST_URL"`; + +exports[`should follow and complete all steps: sonarqube host url value 1`] = `"http://localhost:9000"`; diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/SecretStep-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/SecretStep-test.tsx.snap deleted file mode 100644 index 1e8933b185f..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/SecretStep-test.tsx.snap +++ /dev/null @@ -1,351 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: default 1`] = ` -
    -

    - - onboarding.tutorial.with.github_action.secret.intro.link - , - } - } - /> -

    -
      -
    1. - -
    2. -
    3. - - - SONAR_TOKEN - - -
    4. - -
    5. - -
    6. -
    -
    -
      -
    1. - -
    2. -
    3. - - - SONAR_HOST_URL - - -
    4. -
    5. - , - "field": - onboarding.tutorial.env_variables.field - , - "value": - test - , - } - } - /> -
    6. -
    7. - -
    8. -
    - -
    -`; - -exports[`should render correctly: with binding information 1`] = ` -
    -

    - - onboarding.tutorial.with.github_action.secret.intro.link - , - } - } - /> -

    -
      -
    1. - -
    2. -
    3. - - - SONAR_TOKEN - - -
    4. - -
    5. - -
    6. -
    -
    -
      -
    1. - -
    2. -
    3. - - - SONAR_HOST_URL - - -
    4. -
    5. - , - "field": - onboarding.tutorial.env_variables.field - , - "value": - test - , - } - } - /> -
    6. -
    7. - -
    8. -
    - -
    -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/CFamily-test.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/CFamily-test.tsx deleted file mode 100644 index 598a54daf58..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/CFamily-test.tsx +++ /dev/null @@ -1,51 +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 { mockComponent } from '../../../../../helpers/mocks/component'; -import RenderOptions from '../../../components/RenderOptions'; -import { OSs } from '../../../types'; -import CFamily, { CFamilyProps } from '../CFamily'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -it.each([ - [OSs.Linux, false], - [OSs.MacOS, true], - [OSs.Windows, true], -])('should render correctly for %s', (os: OSs, branchesEnabled: boolean) => { - const wrapper = shallowRender({ branchesEnabled }); - wrapper.find(RenderOptions).props().onCheck(os); - expect(wrapper).toMatchSnapshot(`branches ${branchesEnabled ? 'enabled' : 'disabled'}`); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/DotNet-test.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/DotNet-test.tsx deleted file mode 100644 index ec42d71ebbe..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/DotNet-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 { mockComponent } from '../../../../../helpers/mocks/component'; -import DotNet, { DotNetProps } from '../DotNet'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ branchesEnabled: false })).toMatchSnapshot('without branch enabled'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/Gradle-test.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/Gradle-test.tsx deleted file mode 100644 index 9b587d7ac2a..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/Gradle-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 { mockComponent } from '../../../../../helpers/mocks/component'; -import Gradle, { GradleProps } from '../Gradle'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ branchesEnabled: false })).toMatchSnapshot('without branch enabled'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/JavaMaven-test.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/JavaMaven-test.tsx deleted file mode 100644 index a3fbb2a51fd..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/JavaMaven-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 { mockComponent } from '../../../../../helpers/mocks/component'; -import JavaMaven, { JavaMavenProps } from '../../commands/JavaMaven'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ branchesEnabled: false })).toMatchSnapshot('without branch enabled'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/Others-test.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/Others-test.tsx deleted file mode 100644 index efc223b8d3a..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/Others-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 { mockComponent } from '../../../../../helpers/mocks/component'; -import Others, { OthersProps } from '../../commands/Others'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ branchesEnabled: false })).toMatchSnapshot('without branch enabled'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/CFamily-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/CFamily-test.tsx.snap deleted file mode 100644 index d431922411b..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/CFamily-test.tsx.snap +++ /dev/null @@ -1,362 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - - -
  • - - onboarding.build.other.os - - -
  • -
    -`; - -exports[`should render correctly for linux: branches disabled 1`] = ` - - -
  • - - onboarding.build.other.os - - - -
  • - > $GITHUB_PATH - - - name: SonarQube analysis - run: | - sonar-scanner --define sonar.cfamily.build-wrapper-output=bw-output - env: - SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }}" - /> - - -
    -`; - -exports[`should render correctly for mac: branches enabled 1`] = ` - - -
  • - - onboarding.build.other.os - - - -
  • - - - -
    -`; - -exports[`should render correctly for win: branches enabled 1`] = ` - - -
  • - - onboarding.build.other.os - - - -
  • - - sonar-scanner.bat "-Dsonar.cfamily.build-wrapper-output=bw-output" - env: - SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }}" - /> - - -
    -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/DotNet-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/DotNet-test.tsx.snap deleted file mode 100644 index ae9060f3d71..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/DotNet-test.tsx.snap +++ /dev/null @@ -1,118 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - - - - -`; - -exports[`should render correctly: without branch enabled 1`] = ` - - - - -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/Gradle-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/Gradle-test.tsx.snap deleted file mode 100644 index c57af2d85a5..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/Gradle-test.tsx.snap +++ /dev/null @@ -1,178 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - -
  • - - - build.gradle - - - , - "sq": - org.sonarqube - , - } - } - /> - -
  • - - -
    -`; - -exports[`should render correctly: without branch enabled 1`] = ` - -
  • - - - build.gradle - - - , - "sq": - org.sonarqube - , - } - } - /> - -
  • - - -
    -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/JavaMaven-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/JavaMaven-test.tsx.snap deleted file mode 100644 index 4b5b2b2a6db..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/JavaMaven-test.tsx.snap +++ /dev/null @@ -1,100 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - - - - -`; - -exports[`should render correctly: without branch enabled 1`] = ` - - - - -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/Others-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/Others-test.tsx.snap deleted file mode 100644 index ef6da9199ce..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/Others-test.tsx.snap +++ /dev/null @@ -1,126 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - - - - - -`; - -exports[`should render correctly: without branch enabled 1`] = ` - - - - - -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/EnvironmentVariablesStep.tsx b/server/sonar-web/src/main/js/components/tutorials/gitlabci/EnvironmentVariablesStep.tsx index 779f066ac57..4c0f3fa42cb 100644 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/EnvironmentVariablesStep.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/EnvironmentVariablesStep.tsx @@ -38,7 +38,7 @@ export interface EnvironmentVariablesStepProps { } const pipelineDescriptionLinkLabel = translate( - 'onboarding.tutorial.with.gitlab_ci.env_variables.description.link' + 'onboarding.tutorial.with.gitlab_ci.variables.description.link' ); export default function EnvironmentVariablesStep(props: EnvironmentVariablesStepProps) { @@ -51,14 +51,14 @@ export default function EnvironmentVariablesStep(props: EnvironmentVariablesStep
    1. - {translate('onboarding.tutorial.with.gitlab_ci.env_variables.section.title')} + {translate('onboarding.tutorial.with.gitlab_ci.variables.section.title')}

      {pipelineDescriptionLinkLabel}, @@ -69,12 +69,12 @@ export default function EnvironmentVariablesStep(props: EnvironmentVariablesStep
    2. , field: ( - {translate('onboarding.tutorial.with.gitlab_ci.env_variables.step1')} + {translate('onboarding.tutorial.with.gitlab_ci.variables.step1')} ), value: SONAR_TOKEN, @@ -84,12 +84,12 @@ export default function EnvironmentVariablesStep(props: EnvironmentVariablesStep
    3. - {translate('onboarding.tutorial.with.gitlab_ci.env_variables.step3.value')} + {translate('onboarding.tutorial.with.gitlab_ci.variables.step3.value')} ), }} @@ -98,14 +98,14 @@ export default function EnvironmentVariablesStep(props: EnvironmentVariablesStep
    4. {translate( - 'onboarding.tutorial.with.gitlab_ci.env_variables.section.step4.value' + 'onboarding.tutorial.with.gitlab_ci.variables.section.step4.value' )} ), @@ -117,14 +117,14 @@ export default function EnvironmentVariablesStep(props: EnvironmentVariablesStep
    5. - {translate('onboarding.tutorial.with.gitlab_ci.env_variables.section2.title')} + {translate('onboarding.tutorial.with.gitlab_ci.variables.section2.title')}

      {pipelineDescriptionLinkLabel}, @@ -135,12 +135,12 @@ export default function EnvironmentVariablesStep(props: EnvironmentVariablesStep
    6. , field: ( - {translate('onboarding.tutorial.with.gitlab_ci.env_variables.step1')} + {translate('onboarding.tutorial.with.gitlab_ci.variables.step1')} ), value: SONAR_HOST_URL, @@ -150,7 +150,7 @@ export default function EnvironmentVariablesStep(props: EnvironmentVariablesStep
    7. , field: {translate('onboarding.tutorial.env_variables.field')}, @@ -160,12 +160,12 @@ export default function EnvironmentVariablesStep(props: EnvironmentVariablesStep
    8. - {translate('onboarding.tutorial.with.gitlab_ci.env_variables.step3.value')} + {translate('onboarding.tutorial.with.gitlab_ci.variables.step3.value')} ), }} @@ -174,14 +174,14 @@ export default function EnvironmentVariablesStep(props: EnvironmentVariablesStep
    9. {translate( - 'onboarding.tutorial.with.gitlab_ci.env_variables.section.step4.value' + 'onboarding.tutorial.with.gitlab_ci.variables.section.step4.value' )} ), @@ -205,7 +205,7 @@ export default function EnvironmentVariablesStep(props: EnvironmentVariablesStep open={open} renderForm={renderForm} stepNumber={1} - stepTitle={translate('onboarding.tutorial.with.gitlab_ci.env_variables.title')} + stepTitle={translate('onboarding.tutorial.with.gitlab_ci.variables.title')} /> ); } diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/YmlFileStep.tsx b/server/sonar-web/src/main/js/components/tutorials/gitlabci/YmlFileStep.tsx index e66962d295c..ea255c15c0f 100644 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/YmlFileStep.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/YmlFileStep.tsx @@ -137,17 +137,17 @@ export function YmlFileStep(props: YmlFileStepProps) {
    10. - {translate('onboarding.tutorial.with.gitlab_ci.yml.filename')} + {translate('onboarding.tutorial.with.gitlab_ci.yaml.filename')} ), @@ -165,10 +165,10 @@ export function YmlFileStep(props: YmlFileStepProps) {

      {branchSupportEnabled - ? translate('onboarding.tutorial.with.gitlab_ci.yml.baseconfig') - : translate('onboarding.tutorial.with.gitlab_ci.yml.baseconfig.no_branches')} + ? translate('onboarding.tutorial.with.gitlab_ci.yaml.baseconfig') + : translate('onboarding.tutorial.with.gitlab_ci.yaml.baseconfig.no_branches')}

      -

      {translate('onboarding.tutorial.with.gitlab_ci.yml.existing')}

      +

      {translate('onboarding.tutorial.with.gitlab_ci.yaml.existing')}

    11. )} @@ -183,7 +183,7 @@ export function YmlFileStep(props: YmlFileStepProps) { open={open} renderForm={renderForm} stepNumber={2} - stepTitle={translate('onboarding.tutorial.with.gitlab_ci.yml.title')} + stepTitle={translate('onboarding.tutorial.with.gitlab_ci.yaml.title')} /> ); } diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/EnvironmentVariablesStep-test.tsx b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/EnvironmentVariablesStep-test.tsx deleted file mode 100644 index 90df517f0d0..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/EnvironmentVariablesStep-test.tsx +++ /dev/null @@ -1,48 +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 { mockComponent } from '../../../../helpers/mocks/component'; -import { mockLoggedInUser } from '../../../../helpers/testMocks'; -import { renderStepContent } from '../../test-utils'; -import EnvironmentVariablesStep, { - EnvironmentVariablesStepProps, -} from '../EnvironmentVariablesStep'; - -it('should render correctly', () => { - const wrapper = shallowRender(); - expect(wrapper).toMatchSnapshot('Step wrapper'); - expect(renderStepContent(wrapper)).toMatchSnapshot('initial content'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/GitLabCITutorial-it.tsx b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/GitLabCITutorial-it.tsx new file mode 100644 index 00000000000..d251382f17c --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/GitLabCITutorial-it.tsx @@ -0,0 +1,147 @@ +/* + * 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 userEvent from '@testing-library/user-event'; +import React from 'react'; +import selectEvent from 'react-select-event'; +import UserTokensMock from '../../../../api/mocks/UserTokensMock'; +import { mockComponent } from '../../../../helpers/mocks/component'; +import { mockLanguage, mockLoggedInUser } from '../../../../helpers/testMocks'; +import { renderApp, RenderContext } from '../../../../helpers/testReactTestingUtils'; +import { + getCommonNodes, + getCopyToClipboardValue, + getTutorialActionButtons, + getTutorialBuildButtons, +} from '../../test-utils'; +import { TutorialModes } from '../../types'; +import GitLabCITutorial, { GitLabCITutorialProps } from '../GitLabCITutorial'; + +jest.mock('../../../../api/user-tokens'); + +jest.mock('../../../../api/settings', () => ({ + getAllValues: jest.fn().mockResolvedValue([]), +})); + +const tokenMock = new UserTokensMock(); + +afterEach(() => { + tokenMock.reset(); +}); + +const ui = { + ...getCommonNodes(TutorialModes.GitLabCI), + ...getTutorialActionButtons(), + ...getTutorialBuildButtons(), +}; + +it('should follow and complete all steps', async () => { + const user = userEvent.setup(); + renderGitLabTutorial(); + + expect(await ui.secretsStepTitle.find()).toBeInTheDocument(); + + // Env variables step + expect(getCopyToClipboardValue()).toMatchSnapshot('sonar token key'); + expect(getCopyToClipboardValue(1)).toMatchSnapshot('sonarqube host url key'); + expect(getCopyToClipboardValue(2)).toMatchSnapshot('sonarqube host url value'); + await user.click(ui.continueButton.get()); + + // Create/update configuration file step + // Maven + await user.click(ui.mavenBuildButton.get()); + expect(getCopyToClipboardValue(1)).toMatchSnapshot('Maven: pom.xml'); + expect(getCopyToClipboardValue(3)).toMatchSnapshot('Maven: gitlab-ci.yml'); + + // Gradle + await user.click(ui.gradleBuildButton.get()); + expect(getCopyToClipboardValue(1)).toMatchSnapshot('Gradle: build.gradle'); + expect(getCopyToClipboardValue(3)).toMatchSnapshot('Gradle: gitlab-ci.yml'); + + // .NET + await user.click(ui.dotnetBuildButton.get()); + expect(getCopyToClipboardValue(1)).toMatchSnapshot('.NET: gitlab-ci.yml'); + + // CFamily + await user.click(ui.cFamilyBuildButton.get()); + expect(getCopyToClipboardValue(1)).toMatchSnapshot('CFamily: sonar-project.properties'); + expect(getCopyToClipboardValue(3)).toMatchSnapshot('CFamily: gitlab-ci.yml'); + + // Other + await user.click(ui.otherBuildButton.get()); + expect(getCopyToClipboardValue(1)).toMatchSnapshot('Other: sonar-project.properties'); + expect(getCopyToClipboardValue(3)).toMatchSnapshot('Other: gitlab-ci.yml'); + + await user.click(ui.finishTutorialButton.get()); + expect(ui.allSetSentence.get()).toBeInTheDocument(); +}); + +it('should generate/delete a new token or use existing one', async () => { + const user = userEvent.setup(); + renderGitLabTutorial(); + + expect(await ui.secretsStepTitle.find()).toBeInTheDocument(); + + // Generate token + await user.click(ui.genTokenDialogButton.get()); + await user.click(ui.generateTokenButton.get()); + expect(getCopyToClipboardValue(3)).toEqual('generatedtoken2'); + + // Revoke current token and create new one + await user.click(ui.deleteTokenButton.get()); + await user.type(ui.tokenNameInput.get(), 'newtoken'); + await selectEvent.select(ui.expiresInSelect.get(), 'users.tokens.expiration.365'); + await user.click(ui.generateTokenButton.get()); + expect(ui.tokenValue.get()).toBeInTheDocument(); + await user.click(ui.continueButton.getAll()[1]); + expect(ui.tokenValue.query()).not.toBeInTheDocument(); +}); + +it('navigates between steps', async () => { + const user = userEvent.setup(); + renderGitLabTutorial(); + + await user.click(await ui.continueButton.find()); + await user.click(ui.mavenBuildButton.get()); + await user.click(ui.finishTutorialButton.get()); + expect(ui.allSetSentence.get()).toBeInTheDocument(); + + await user.click(ui.ymlFileStepTitle.get()); + expect(ui.finishTutorialButton.get()).toBeInTheDocument(); + await user.click(ui.secretsStepTitle.get()); + expect(ui.continueButton.get()).toBeInTheDocument(); +}); + +function renderGitLabTutorial( + overrides: Partial = {}, + { languages = { c: mockLanguage({ key: 'c' }) } }: RenderContext = {} +) { + return renderApp( + '/', + , + { languages } + ); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/GitLabCITutorial-test.tsx b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/GitLabCITutorial-test.tsx deleted file mode 100644 index cc83a76ce55..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/GitLabCITutorial-test.tsx +++ /dev/null @@ -1,41 +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 { mockComponent } from '../../../../helpers/mocks/component'; -import { mockLoggedInUser } from '../../../../helpers/testMocks'; -import GitLabCITutorial, { GitLabCITutorialProps } from '../GitLabCITutorial'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/YmlFileStep-test.tsx b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/YmlFileStep-test.tsx deleted file mode 100644 index ecb14c207c9..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/YmlFileStep-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 { mockComponent } from '../../../../helpers/mocks/component'; -import { renderStepContent } from '../../test-utils'; -import { YmlFileStep, YmlFileStepProps } from '../YmlFileStep'; - -it('should render correctly', () => { - const wrapper = shallowRender(); - expect(wrapper).toMatchSnapshot('Step wrapper'); - expect(renderStepContent(wrapper)).toMatchSnapshot('initial content'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/EnvironmentVariablesStep-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/EnvironmentVariablesStep-test.tsx.snap deleted file mode 100644 index 0840eb18349..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/EnvironmentVariablesStep-test.tsx.snap +++ /dev/null @@ -1,241 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: Step wrapper 1`] = ` - -`; - -exports[`should render correctly: initial content 1`] = ` -
      -
        -
      1. -

        - onboarding.tutorial.with.gitlab_ci.env_variables.section.title -

        - - onboarding.tutorial.with.gitlab_ci.env_variables.description.link - , - } - } - /> -
          -
        • - , - "field": - onboarding.tutorial.with.gitlab_ci.env_variables.step1 - , - "value": - SONAR_TOKEN - , - } - } - /> -
        • - -
        • - - onboarding.tutorial.with.gitlab_ci.env_variables.step3.value - , - } - } - /> -
        • -
        • - - onboarding.tutorial.with.gitlab_ci.env_variables.section.step4.value - , - } - } - /> -
        • -
        -
        -
      2. -
      3. -

        - onboarding.tutorial.with.gitlab_ci.env_variables.section2.title -

        - - onboarding.tutorial.with.gitlab_ci.env_variables.description.link - , - } - } - /> -
          -
        • - , - "field": - onboarding.tutorial.with.gitlab_ci.env_variables.step1 - , - "value": - SONAR_HOST_URL - , - } - } - /> -
        • -
        • - , - "field": - onboarding.tutorial.env_variables.field - , - "value": - http://localhost:9000 - , - } - } - /> -
        • -
        • - - onboarding.tutorial.with.gitlab_ci.env_variables.step3.value - , - } - } - /> -
        • -
        • - - onboarding.tutorial.with.gitlab_ci.env_variables.section.step4.value - , - } - } - /> -
        • -
        - -
      4. -
      -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/GitLabCITutorial-it.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/GitLabCITutorial-it.tsx.snap new file mode 100644 index 00000000000..7768ee78fe6 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/GitLabCITutorial-it.tsx.snap @@ -0,0 +1,151 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should follow and complete all steps: .NET: gitlab-ci.yml 1`] = ` +"sonarqube-check: + image: mcr.microsoft.com/dotnet/core/sdk:latest + variables: + SONAR_USER_HOME: "\${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache + GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task + cache: + key: "\${CI_JOB_NAME}" + paths: + - .sonar/cache + script: + - "apt-get update" + - "apt-get install --yes openjdk-11-jre" + - "dotnet tool install --global dotnet-sonarscanner" + - "export PATH=\\"$PATH:$HOME/.dotnet/tools\\"" + - "dotnet sonarscanner begin /k:\\"my-project\\" /d:sonar.login=\\"$SONAR_TOKEN\\" /d:\\"sonar.host.url=$SONAR_HOST_URL\\" " + - "dotnet build" + - "dotnet sonarscanner end /d:sonar.login=\\"$SONAR_TOKEN\\"" + allow_failure: true + rules: + - if: $CI_COMMIT_BRANCH == 'main' +" +`; + +exports[`should follow and complete all steps: CFamily: gitlab-ci.yml 1`] = ` +"image: + +cache: + paths: + - .sonar + +stages: + - download + - build + - scan + +download: + stage: download + script: + - mkdir -p .sonar + - curl -sSLo build-wrapper-linux-x86.zip $SONAR_HOST_URL/static/cpp/build-wrapper-linux-x86.zip + - unzip -o build-wrapper-linux-x86.zip -d .sonar + +build: + stage: build + script: + - .sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir .sonar/bw-output + +sonarqube-check: + stage: scan + script: + - curl -sSLo sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472-linux.zip + - unzip -o sonar-scanner.zip -d .sonar + - .sonar/sonar-scanner-4.6.2.2472-linux/bin/sonar-scanner -Dsonar.cfamily.build-wrapper-output=.sonar/bw-output + allow_failure: true" +`; + +exports[`should follow and complete all steps: CFamily: sonar-project.properties 1`] = ` +"sonar.projectKey=my-project +sonar.qualitygate.wait=true +" +`; + +exports[`should follow and complete all steps: Gradle: build.gradle 1`] = ` +"plugins { + id "org.sonarqube" version "3.5.0.2730" +} + +sonar { + properties { + property "sonar.projectKey", "my-project" + property "sonar.projectName", "MyProject" + property "sonar.qualitygate.wait", true + } +}" +`; + +exports[`should follow and complete all steps: Gradle: gitlab-ci.yml 1`] = ` +"sonarqube-check: + image: gradle:jre11-slim + variables: + SONAR_USER_HOME: "\${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache + GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task + cache: + key: "\${CI_JOB_NAME}" + paths: + - .sonar/cache + script: gradle sonar + allow_failure: true + rules: + - if: $CI_COMMIT_BRANCH == 'main' +" +`; + +exports[`should follow and complete all steps: Maven: gitlab-ci.yml 1`] = ` +"sonarqube-check: + image: maven:3.6.3-jdk-11 + variables: + SONAR_USER_HOME: "\${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache + GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task + cache: + key: "\${CI_JOB_NAME}" + paths: + - .sonar/cache + script: + - mvn verify sonar:sonar -Dsonar.projectKey=my-project -Dsonar.projectName='MyProject' + allow_failure: true + rules: + - if: $CI_COMMIT_BRANCH == 'main' +" +`; + +exports[`should follow and complete all steps: Maven: pom.xml 1`] = ` +" + true +" +`; + +exports[`should follow and complete all steps: Other: gitlab-ci.yml 1`] = ` +"sonarqube-check: + image: + name: sonarsource/sonar-scanner-cli:latest + entrypoint: [""] + variables: + SONAR_USER_HOME: "\${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache + GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task + cache: + key: "\${CI_JOB_NAME}" + paths: + - .sonar/cache + script: + - sonar-scanner + allow_failure: true + rules: + - if: $CI_COMMIT_BRANCH == 'main' +" +`; + +exports[`should follow and complete all steps: Other: sonar-project.properties 1`] = ` +"sonar.projectKey=my-project +sonar.qualitygate.wait=true +" +`; + +exports[`should follow and complete all steps: sonar token key 1`] = `"SONAR_TOKEN"`; + +exports[`should follow and complete all steps: sonarqube host url key 1`] = `"SONAR_HOST_URL"`; + +exports[`should follow and complete all steps: sonarqube host url value 1`] = `"http://localhost:9000"`; diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/GitLabCITutorial-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/GitLabCITutorial-test.tsx.snap deleted file mode 100644 index ce506bca402..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/GitLabCITutorial-test.tsx.snap +++ /dev/null @@ -1,91 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - -
      -

      - onboarding.tutorial.with.gitlab_ci.title -

      -
      - - - -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/YmlFileStep-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/YmlFileStep-test.tsx.snap deleted file mode 100644 index b8da45dea71..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/YmlFileStep-test.tsx.snap +++ /dev/null @@ -1,40 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: Step wrapper 1`] = ` - -`; - -exports[`should render correctly: initial content 1`] = ` -
      -
        -
      1. - onboarding.build - -
      2. -
      -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/__tests__/PipeCommand-test.tsx b/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/__tests__/PipeCommand-test.tsx deleted file mode 100644 index 1715a1fc1cb..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/__tests__/PipeCommand-test.tsx +++ /dev/null @@ -1,54 +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 { BuildTools } from '../../../types'; -import PipeCommand from '../PipeCommand'; - -it.each([ - [BuildTools.Maven], - [BuildTools.Gradle], - [BuildTools.DotNet], - [BuildTools.CFamily], - [BuildTools.Other], -])('should render correctly for %s', (buildTool) => { - expect( - shallow( - - ) - ).toMatchSnapshot('branches enabled'); - expect( - shallow( - - ) - ).toMatchSnapshot('branches not enabled'); -}); diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/__tests__/__snapshots__/PipeCommand-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/__tests__/__snapshots__/PipeCommand-test.tsx.snap deleted file mode 100644 index b079bcadbc1..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/__tests__/__snapshots__/PipeCommand-test.tsx.snap +++ /dev/null @@ -1,283 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly for cfamily: branches enabled 1`] = ` - - - - -`; - -exports[`should render correctly for cfamily: branches not enabled 1`] = ` - - - - -`; - -exports[`should render correctly for dotnet: branches enabled 1`] = ` - - - -`; - -exports[`should render correctly for dotnet: branches not enabled 1`] = ` - - - -`; - -exports[`should render correctly for gradle: branches enabled 1`] = ` - - - -`; - -exports[`should render correctly for gradle: branches not enabled 1`] = ` - - - -`; - -exports[`should render correctly for maven: branches enabled 1`] = ` - - - -`; - -exports[`should render correctly for maven: branches not enabled 1`] = ` - - - -`; - -exports[`should render correctly for other: branches enabled 1`] = ` - - - -`; - -exports[`should render correctly for other: branches not enabled 1`] = ` - - - -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/JenkinsTutorial-it.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/JenkinsTutorial-it.tsx new file mode 100644 index 00000000000..045672dea7a --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/JenkinsTutorial-it.tsx @@ -0,0 +1,252 @@ +/* + * 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 userEvent from '@testing-library/user-event'; +import React from 'react'; +import { byRole, byText } from 'testing-library-selector'; +import UserTokensMock from '../../../../api/mocks/UserTokensMock'; +import { mockComponent } from '../../../../helpers/mocks/component'; +import { mockLanguage } from '../../../../helpers/testMocks'; +import { renderApp, RenderContext } from '../../../../helpers/testReactTestingUtils'; +import { AlmKeys } from '../../../../types/alm-settings'; +import { Feature } from '../../../../types/features'; +import { + getCopyToClipboardValue, + getTutorialActionButtons, + getTutorialBuildButtons, +} from '../../test-utils'; +import JenkinsTutorial, { JenkinsTutorialProps } from '../JenkinsTutorial'; + +jest.mock('../../../../api/user-tokens'); + +jest.mock('../../../../api/settings', () => ({ + getAllValues: jest.fn().mockResolvedValue([]), +})); + +const tokenMock = new UserTokensMock(); + +afterEach(() => { + tokenMock.reset(); +}); + +const ui = { + devopsPlatformTitle: byRole('heading', { + name: 'onboarding.tutorial.with.jenkins.alm_selection.title', + }), + devopsPlatformButton: (alm: AlmKeys) => byRole('button', { name: `alm.${alm}.long` }), + prerequisitesTitle: byRole('heading', { name: 'onboarding.tutorial.with.jenkins.prereqs.title' }), + branchSourcePluginBulletPoint: (alm: AlmKeys) => + byText(`onboarding.tutorial.with.jenkins.prereqs.plugins.branch_source.${alm}`), + configureAnalysisButton: byRole('button', { + name: 'onboarding.tutorial.with.jenkins.prereqs.done', + }), + multiBranchStepTitle: byRole('heading', { + name: 'onboarding.tutorial.with.jenkins.multi_branch_pipeline.title', + }), + multiBranchPipelineSecondListItem: (alm: AlmKeys) => + byText(`onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.${alm}.sentence`), + pipelineStepTitle: byRole('heading', { name: 'onboarding.tutorial.with.jenkins.pipeline.title' }), + pipelineIntroText: byText('onboarding.tutorial.with.jenkins.pipeline.intro'), + webhookStepTitle: (alm: AlmKeys) => + byRole('heading', { + name: `onboarding.tutorial.with.jenkins.webhook.${alm}.title`, + }), + webhookStepIntroSentence: byText('onboarding.tutorial.with.jenkins.webhook.intro.sentence'), + webhookGHLink: byRole('link', { + name: 'onboarding.tutorial.with.jenkins.webhook.github.step1.link', + }), + webhookAlmLink: (alm: AlmKeys) => + byRole('link', { + name: new RegExp(`onboarding.tutorial.with.jenkins.webhook.${alm}.step1.link`), + }), + jenkinsStepTitle: byRole('heading', { + name: 'onboarding.tutorial.with.jenkins.jenkinsfile.title', + }), + allSetSentence: byText('onboarding.tutorial.ci_outro.all_set.sentence'), + ...getTutorialActionButtons(), + ...getTutorialBuildButtons(), +}; + +it.each([AlmKeys.BitbucketCloud, AlmKeys.BitbucketServer, AlmKeys.GitHub, AlmKeys.GitLab])( + '%s: can select devops platform and complete all the steps with copying code snippets', + async (alm: AlmKeys) => { + const user = userEvent.setup(); + renderJenkinsTutorial(); + + expect(await ui.devopsPlatformTitle.find()).toBeInTheDocument(); + + // 1. Select platform and go to prerequisites step + await user.click(ui.devopsPlatformButton(alm).get()); + + // 2. Prerequisites + expect(ui.branchSourcePluginBulletPoint(alm).get()).toBeInTheDocument(); + + await user.click(ui.configureAnalysisButton.get()); + + // 3. Multibranch Pipeline Job + expect(ui.multiBranchPipelineSecondListItem(alm).get()).toBeInTheDocument(); + expect(getCopyToClipboardValue()).toMatchSnapshot(`ref spec`); + + await user.click(ui.continueButton.get()); + + // 4. Create DevOps platform webhook + expect(ui.webhookStepTitle(alm).get()).toBeInTheDocument(); + expect(getCopyToClipboardValue()).toMatchSnapshot(`jenkins url`); + + await user.click(ui.continueButton.get()); + + // 5. Create jenkinsfile + // Maven + await user.click(ui.mavenBuildButton.get()); + expect(getCopyToClipboardValue()).toMatchSnapshot(`maven jenkinsfile`); + + // Gradle + await user.click(ui.gradleBuildButton.get()); + expect(getCopyToClipboardValue()).toMatchSnapshot(`build.gradle file`); + expect(getCopyToClipboardValue(1)).toMatchSnapshot(`gradle jenkinsfile`); + + // .NET + await user.click(ui.dotnetBuildButton.get()); + await user.click(ui.windowsDotnetCoreButton.get()); + expect(getCopyToClipboardValue(1)).toMatchSnapshot(`windows dotnet core jenkinsfile`); + + await user.click(ui.windowsDotnetFrameworkButton.get()); + expect(getCopyToClipboardValue(2)).toMatchSnapshot(`windows dotnet framework jenkinsfile`); + + await user.click(ui.linuxDotnetCoreButton.get()); + expect(getCopyToClipboardValue(1)).toMatchSnapshot(`linux dotnet core jenkinsfile`); + + // CFamilly + await user.click(ui.cFamilyBuildButton.get()); + expect(getCopyToClipboardValue()).toMatchSnapshot(`sonar-project.properties code`); + + await user.click(ui.linuxButton.get()); + expect(getCopyToClipboardValue(1)).toMatchSnapshot(`cfamily linux jenkinsfile`); + + await user.click(ui.windowsButton.get()); + expect(getCopyToClipboardValue(1)).toMatchSnapshot(`cfamily windows jenkinsfile`); + + await user.click(ui.macosButton.get()); + expect(getCopyToClipboardValue(1)).toMatchSnapshot(`cfamily macos jenkinsfile`); + + // Other + await user.click(ui.otherBuildButton.get()); + expect(getCopyToClipboardValue()).toMatchSnapshot( + `other build tools sonar-project.properties code` + ); + expect(getCopyToClipboardValue(1)).toMatchSnapshot(`other build tools jenkinsfile`); + + await user.click(ui.finishTutorialButton.get()); + expect(ui.allSetSentence.get()).toBeInTheDocument(); + } +); + +it.each([AlmKeys.GitHub, AlmKeys.GitLab, AlmKeys.BitbucketCloud])( + '%s: has Pipeline step instead of MultiBranchPipeline step if branchSupport is not enabled', + async (alm: AlmKeys) => { + const user = userEvent.setup(); + renderJenkinsTutorial({}, { featureList: [] }); + + expect(await ui.devopsPlatformTitle.find()).toBeInTheDocument(); + await user.click(ui.devopsPlatformButton(alm).get()); + await user.click(ui.configureAnalysisButton.get()); + expect(ui.pipelineIntroText.get()).toBeInTheDocument(); + await user.click(ui.continueButton.get()); + // navigate back and forth + await user.click(ui.pipelineStepTitle.get()); + await user.click(ui.continueButton.get()); + expect(ui.webhookStepIntroSentence.get()).toBeInTheDocument(); + } +); + +it.each([AlmKeys.GitHub, AlmKeys.BitbucketCloud])( + '%s: completes tutorial with bound alm and project', + async (alm: AlmKeys) => { + const user = userEvent.setup(); + renderJenkinsTutorial({ + almBinding: { + alm, + url: 'http://localhost/qube', + key: 'my-project', + }, + projectBinding: { + alm, + key: 'my-project', + repository: 'my-project', + monorepo: true, + }, + }); + + expect(ui.devopsPlatformTitle.query()).not.toBeInTheDocument(); + + await user.click(ui.configureAnalysisButton.get()); + await user.click(ui.continueButton.get()); + + expect(ui.webhookAlmLink(alm).get()).toBeInTheDocument(); + + await user.click(ui.continueButton.get()); + await user.click(ui.mavenBuildButton.get()); + await user.click(ui.finishTutorialButton.get()); + expect(ui.allSetSentence.get()).toBeInTheDocument(); + } +); + +it('navigates between steps', async () => { + const user = userEvent.setup(); + renderJenkinsTutorial(); + + await user.click(ui.devopsPlatformButton(AlmKeys.GitHub).get()); + await user.click(ui.configureAnalysisButton.get()); + await user.click(ui.continueButton.get()); + await user.click(ui.continueButton.get()); + await user.click(ui.mavenBuildButton.get()); + await user.click(ui.finishTutorialButton.get()); + expect(ui.allSetSentence.get()).toBeInTheDocument(); + + // Navigate back + await user.click(ui.jenkinsStepTitle.get()); + expect(ui.mavenBuildButton.get()).toBeInTheDocument(); + + await user.click(ui.webhookStepTitle(AlmKeys.GitHub).get()); + expect(ui.webhookStepIntroSentence.get()).toBeInTheDocument(); + + await user.click(ui.multiBranchStepTitle.get()); + expect(ui.multiBranchPipelineSecondListItem(AlmKeys.GitHub).get()).toBeInTheDocument(); + + await user.click(ui.prerequisitesTitle.get()); + expect(ui.configureAnalysisButton.get()).toBeInTheDocument(); + + await user.click(ui.devopsPlatformTitle.get()); + expect(ui.devopsPlatformButton(AlmKeys.BitbucketCloud).get()).toBeInTheDocument(); +}); + +function renderJenkinsTutorial( + overrides: Partial = {}, + { + featureList = [Feature.BranchSupport], + languages = { c: mockLanguage({ key: 'c' }) }, + }: RenderContext = {} +) { + return renderApp( + '/', + , + { featureList, languages } + ); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/JenkinsTutorial-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/JenkinsTutorial-test.tsx deleted file mode 100644 index 9d59001a1cd..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/JenkinsTutorial-test.tsx +++ /dev/null @@ -1,99 +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 { mockProjectBitbucketBindingResponse } from '../../../../helpers/mocks/alm-settings'; -import { mockComponent } from '../../../../helpers/mocks/component'; -import { AlmKeys } from '../../../../types/alm-settings'; -import JenkinsfileStep from '../JenkinsfileStep'; -import { JenkinsTutorial, JenkinsTutorialProps } from '../JenkinsTutorial'; -import MultiBranchPipelineStep from '../MultiBranchPipelineStep'; -import PreRequisitesStep from '../PreRequisitesStep'; -import SelectAlmStep from '../SelectAlmStep'; -import WebhookStep from '../WebhookStep'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('default'); - expect(shallowRender({ hasFeature: () => false })).toMatchSnapshot('branches not enabled'); - expect(shallowRender({ projectBinding: undefined })).toMatchSnapshot('no project binding'); -}); - -it('should correctly navigate between steps', () => { - const wrapper = shallowRender(); - - expect(wrapper.find(PreRequisitesStep).props().open).toBe(true); - expect(wrapper.find(MultiBranchPipelineStep).props().open).toBe(false); - expect(wrapper.find(WebhookStep).props().open).toBe(false); - expect(wrapper.find(JenkinsfileStep).props().open).toBe(false); - - // Pre-reqs done. - wrapper.find(PreRequisitesStep).props().onDone(); - expect(wrapper.find(PreRequisitesStep).props().open).toBe(false); - expect(wrapper.find(MultiBranchPipelineStep).props().open).toBe(true); - expect(wrapper.find(WebhookStep).props().open).toBe(false); - expect(wrapper.find(JenkinsfileStep).props().open).toBe(false); - - // Multibranch done. - wrapper.find(MultiBranchPipelineStep).props().onDone(); - expect(wrapper.find(PreRequisitesStep).props().open).toBe(false); - expect(wrapper.find(MultiBranchPipelineStep).props().open).toBe(false); - expect(wrapper.find(WebhookStep).props().open).toBe(true); - expect(wrapper.find(JenkinsfileStep).props().open).toBe(false); - - // Webhook done. - wrapper.find(WebhookStep).props().onDone(); - expect(wrapper.find(PreRequisitesStep).props().open).toBe(false); - expect(wrapper.find(MultiBranchPipelineStep).props().open).toBe(false); - expect(wrapper.find(WebhookStep).props().open).toBe(false); - expect(wrapper.find(JenkinsfileStep).props().open).toBe(true); - - // Open Pre-reqs. - wrapper.find(PreRequisitesStep).props().onOpen(); - expect(wrapper.find(PreRequisitesStep).props().open).toBe(true); - - // Open Multibranch. - wrapper.find(MultiBranchPipelineStep).props().onOpen(); - expect(wrapper.find(MultiBranchPipelineStep).props().open).toBe(true); - - // Open Webhook. - wrapper.find(WebhookStep).props().onOpen(); - expect(wrapper.find(WebhookStep).props().open).toBe(true); -}); - -it('should correctly select an ALM if no project is bound', () => { - const wrapper = shallowRender({ projectBinding: undefined }); - expect(wrapper.find(PreRequisitesStep).exists()).toBe(false); - wrapper.find(SelectAlmStep).props().onCheck(AlmKeys.BitbucketCloud); - expect(wrapper.find(SelectAlmStep).props().open).toBe(false); - expect(wrapper.find(PreRequisitesStep).exists()).toBe(true); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/JenkinsfileStep-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/JenkinsfileStep-test.tsx deleted file mode 100644 index 0b3a8a0b0be..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/JenkinsfileStep-test.tsx +++ /dev/null @@ -1,79 +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, ShallowWrapper } from 'enzyme'; -import * as React from 'react'; -import { mockComponent } from '../../../../helpers/mocks/component'; -import RenderOptions from '../../components/RenderOptions'; -import Step from '../../components/Step'; -import { renderStepContent } from '../../test-utils'; -import { BuildTools } from '../../types'; -import { JenkinsfileStep, JenkinsfileStepProps } from '../JenkinsfileStep'; - -it('should render correctly', () => { - const wrapper = shallowRender(); - expect(wrapper).toMatchSnapshot('Step wrapper'); - wrapper.setProps({ hasCLanguageFeature: true }); - expect(wrapper).toMatchSnapshot('Step wrapper with C'); - expect(renderStepContent(wrapper)).toMatchSnapshot('initial content'); -}); - -it('should render correctly for Maven', () => { - const wrapper = shallowRender(); - selectBuildTool(wrapper, BuildTools.Maven); - expect(wrapper.find(Step).props().renderForm()).toMatchSnapshot(); -}); - -it('should render correctly for Gradle', () => { - const wrapper = shallowRender(); - selectBuildTool(wrapper, BuildTools.Gradle); - expect(renderStepContent(wrapper)).toMatchSnapshot(); -}); - -it('should render correctly for .NET', () => { - const wrapper = shallowRender(); - selectBuildTool(wrapper, BuildTools.DotNet); - expect(renderStepContent(wrapper)).toMatchSnapshot(); -}); - -it('should render correctly for Other', () => { - const wrapper = shallowRender(); - selectBuildTool(wrapper, BuildTools.Other); - expect(renderStepContent(wrapper)).toMatchSnapshot(); -}); - -function selectBuildTool(wrapper: ShallowWrapper, tool: BuildTools) { - const content = new ShallowWrapper(renderStepContent(wrapper) as JSX.Element); - content.find(RenderOptions).prop('onCheck')(tool); -} - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/MultiBranchPipelineStep-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/MultiBranchPipelineStep-test.tsx deleted file mode 100644 index 3bd020a31d1..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/MultiBranchPipelineStep-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 { - mockAlmSettingsInstance, - mockProjectBitbucketBindingResponse, - mockProjectBitbucketCloudBindingResponse, - mockProjectGithubBindingResponse, - mockProjectGitLabBindingResponse, -} from '../../../../helpers/mocks/alm-settings'; -import { AlmKeys } from '../../../../types/alm-settings'; -import { renderStepContent } from '../../test-utils'; -import MultiBranchPipelineStep, { MultiBranchPipelineStepProps } from '../MultiBranchPipelineStep'; - -it('should render correctly', () => { - const wrapper = shallowRender(); - expect(wrapper).toMatchSnapshot('Step wrapper'); - expect(renderStepContent(wrapper)).toMatchSnapshot('content for bitbucket'); - expect(renderStepContent(shallowRender({ projectBinding: undefined }))).toMatchSnapshot( - 'content for bitbucket, no binding' - ); - expect( - renderStepContent( - shallowRender({ - alm: AlmKeys.BitbucketCloud, - almBinding: mockAlmSettingsInstance({ url: 'https://bitbucket.org/workspaceId/' }), - projectBinding: mockProjectBitbucketCloudBindingResponse(), - }) - ) - ).toMatchSnapshot('content for bitbucket cloud'); - expect( - renderStepContent( - shallowRender({ - alm: AlmKeys.BitbucketCloud, - projectBinding: undefined, - }) - ) - ).toMatchSnapshot('content for bitbucket cloud, no binding'); - expect( - renderStepContent( - shallowRender({ - alm: AlmKeys.GitHub, - almBinding: mockAlmSettingsInstance({ url: 'https://api.github.com/' }), - projectBinding: mockProjectGithubBindingResponse(), - }) - ) - ).toMatchSnapshot('content for github'); - expect( - renderStepContent( - shallowRender({ - alm: AlmKeys.GitHub, - }) - ) - ).toMatchSnapshot('content for github, no binding'); - expect( - renderStepContent( - shallowRender({ alm: AlmKeys.GitLab, projectBinding: mockProjectGitLabBindingResponse() }) - ) - ).toMatchSnapshot('content for gitlab'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/PipelineStep-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/PipelineStep-test.tsx deleted file mode 100644 index 75132b45d28..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/PipelineStep-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 { AlmKeys } from '../../../../types/alm-settings'; -import { renderStepContent } from '../../test-utils'; -import PipelineStep, { PipelineStepProps } from '../PipelineStep'; - -it('should render correctly', () => { - const wrapper = shallowRender(); - expect(wrapper).toMatchSnapshot('Step wrapper'); - expect(renderStepContent(wrapper)).toMatchSnapshot('content'); - expect(renderStepContent(shallowRender({ alm: AlmKeys.GitLab }))).toMatchSnapshot( - 'gitlab content' - ); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/PreRequisitesStep-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/PreRequisitesStep-test.tsx deleted file mode 100644 index 28df4450898..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/PreRequisitesStep-test.tsx +++ /dev/null @@ -1,51 +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 { renderStepContent } from '../../test-utils'; -import PreRequisitesStep, { PreRequisitesStepProps } from '../PreRequisitesStep'; - -it('should render correctly', () => { - const wrapper = shallowRender(); - expect(wrapper).toMatchSnapshot('Step wrapper'); - expect(renderStepContent(wrapper)).toMatchSnapshot('content'); - - expect(renderStepContent(shallowRender({ branchesEnabled: false }))).toMatchSnapshot( - 'content for branches disabled' - ); - expect( - renderStepContent(shallowRender({ alm: AlmKeys.GitLab, branchesEnabled: false })) - ).toMatchSnapshot('content for branches disabled, gitlab'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/SelectAlmStep-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/SelectAlmStep-test.tsx deleted file mode 100644 index 1a63bc73c69..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/SelectAlmStep-test.tsx +++ /dev/null @@ -1,47 +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 Step from '../../components/Step'; -import SelectAlmStep, { SelectAlmStepProps } from '../SelectAlmStep'; - -jest.mock('../../../../helpers/l10n', () => ({ - hasMessage: (_a: string, k: string, _b: string) => k === AlmKeys.BitbucketCloud, - translate: (...k: string[]) => k.join('.'), -})); - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('default'); - expect(shallowRender().find(Step).props().renderForm()).toMatchSnapshot('form, default'); - expect(shallowRender({ alm: AlmKeys.Azure }).find(Step).props().renderForm()).toMatchSnapshot( - 'form, with alm' - ); - expect(shallowRender().find(Step).props().renderResult!()).toBeUndefined(); - expect( - shallowRender({ alm: AlmKeys.BitbucketCloud }).find(Step).props().renderResult!() - ).toMatchSnapshot('result, with alm'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/WebhookStep-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/WebhookStep-test.tsx deleted file mode 100644 index 20c94c90a38..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/WebhookStep-test.tsx +++ /dev/null @@ -1,59 +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 { - mockAlmSettingsInstance, - mockProjectAlmBindingResponse, - mockProjectBitbucketBindingResponse, - mockProjectBitbucketCloudBindingResponse, - mockProjectGithubBindingResponse, -} from '../../../../helpers/mocks/alm-settings'; -import { AlmKeys } from '../../../../types/alm-settings'; -import { renderStepContent } from '../../test-utils'; -import WebhookStep, { WebhookStepProps } from '../WebhookStep'; - -it.each([ - [AlmKeys.Azure, mockProjectAlmBindingResponse({ alm: AlmKeys.Azure })], - [AlmKeys.BitbucketCloud, mockProjectBitbucketCloudBindingResponse()], - [AlmKeys.BitbucketServer, mockProjectBitbucketBindingResponse()], - [AlmKeys.GitHub, mockProjectGithubBindingResponse()], - [AlmKeys.GitLab, mockProjectAlmBindingResponse({ alm: AlmKeys.GitLab })], -])('should render correctly for %s', (alm, projectBinding) => { - const wrapper = shallowRender({ alm, projectBinding }); - expect(wrapper).toMatchSnapshot('wrapper'); - expect(renderStepContent(wrapper)).toMatchSnapshot('content'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/WebhookStepBitbucket-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/WebhookStepBitbucket-test.tsx deleted file mode 100644 index 33c6eb6946c..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/WebhookStepBitbucket-test.tsx +++ /dev/null @@ -1,60 +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 { - mockAlmSettingsInstance, - mockProjectBitbucketBindingResponse, - mockProjectBitbucketCloudBindingResponse, -} from '../../../../helpers/mocks/alm-settings'; -import { AlmKeys } from '../../../../types/alm-settings'; -import WebhookStepBitbucket, { WebhookStepBitbucketProps } from '../WebhookStepBitbucket'; - -it.each([ - [ - AlmKeys.BitbucketServer, - mockProjectBitbucketBindingResponse(), - mockAlmSettingsInstance({ url: 'http://bbs.enterprise.com' }), - ], - [ - AlmKeys.BitbucketCloud, - mockProjectBitbucketCloudBindingResponse(), - mockAlmSettingsInstance({ url: 'http://bitbucket.org/workspace/' }), - ], -])('should render correctly for %s', (alm, projectBinding, almBinding) => { - expect(shallowRender({ alm, projectBinding, almBinding })).toMatchSnapshot(); - expect(shallowRender({ alm, projectBinding, almBinding: undefined })).toMatchSnapshot( - 'with no alm binding' - ); - expect( - shallowRender({ alm, projectBinding, almBinding, branchesEnabled: false }) - ).toMatchSnapshot('with branches disabled'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/WebhookStepGitLab-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/WebhookStepGitLab-test.tsx deleted file mode 100644 index 774b77c15d5..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/WebhookStepGitLab-test.tsx +++ /dev/null @@ -1,31 +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 WebhookStepGitLab, { WebhookStepGitLabProps } from '../WebhookStepGitLab'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('default'); - expect(shallowRender({ branchesEnabled: false })).toMatchSnapshot('with branches disabled'); -}); - -function shallowRender(props: Partial = {}) { - return shallow(); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/WebhookStepGithub-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/WebhookStepGithub-test.tsx deleted file mode 100644 index 48e426cf0ed..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/WebhookStepGithub-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 { - mockAlmSettingsInstance, - mockProjectGithubBindingResponse, -} from '../../../../helpers/mocks/alm-settings'; -import WebhookStepGithub, { WebhookStepGithubProps } from '../WebhookStepGithub'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ almBinding: undefined })).toMatchSnapshot('with no alm binding'); - expect(shallowRender({ branchesEnabled: false })).toMatchSnapshot('with branches disabled'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsTutorial-it.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsTutorial-it.tsx.snap new file mode 100644 index 00000000000..f4f14802daf --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsTutorial-it.tsx.snap @@ -0,0 +1,777 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: build.gradle file 1`] = ` +"plugins { + id "org.sonarqube" version "3.5.0.2730" +} + +sonar { + properties { + property "sonar.projectKey", "my-project" + property "sonar.projectName", "MyProject" + } +}" +`; + +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: cfamily linux jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('Download Build Wrapper') { + sh "mkdir -p .sonar" + sh "curl -sSLo build-wrapper-linux-x86.zip http://localhost:9000/static/cpp/build-wrapper-linux-x86.zip" + sh "unzip -o build-wrapper-linux-x86.zip -d .sonar" + } + stage('Build') { + sh ".sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output " + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner'; + withSonarQubeEnv() { + sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output" + } + } +}" +`; + +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: cfamily macos jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('Download Build Wrapper') { + sh ''' + mkdir -p .sonar + curl -sSLo build-wrapper-macosx-x86.zip http://localhost:9000/static/cpp/build-wrapper-macosx-x86.zip + unzip -o build-wrapper-macosx-x86.zip -d .sonar + ''' + } + stage('Build') { + sh ''' + .sonar/build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir bw-output + ''' + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner'; + withSonarQubeEnv() { + sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output" + } + } +}" +`; + +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: cfamily windows jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('Download Build Wrapper') { + powershell ''' + $path = "$HOME/.sonar/build-wrapper-win-x86.zip" + rm build-wrapper-win-x86 -Recurse -Force -ErrorAction SilentlyContinue + rm $path -Force -ErrorAction SilentlyContinue + mkdir $HOME/.sonar + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + (New-Object System.Net.WebClient).DownloadFile(http://localhost:9000/static/cpp/build-wrapper-win-x86.zip", $path) + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($path, "$HOME/.sonar") + ''' + } + stage('Build') { + powershell ''' + $env:Path += ";$HOME/.sonar/build-wrapper-win-x86" + build-wrapper-win-x86-64 --out-dir bw-output + ''' + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner'; + withSonarQubeEnv() { + powershell "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output" + } + } +}" +`; + +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: gradle jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + withSonarQubeEnv() { + sh "./gradlew sonar" + } + } +}" +`; + +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: jenkins url 1`] = `"***JENKINS_SERVER_URL***/bitbucket-scmsource-hook/notify?server_url=***BITBUCKET_URL***"`; + +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: linux dotnet core jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner for MSBuild' + withSonarQubeEnv() { + sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll begin /k:\\"my-project\\"" + sh "dotnet build" + sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll end" + } + } +} +" +`; + +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: maven jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def mvn = tool 'Default Maven'; + withSonarQubeEnv() { + sh "\${mvn}/bin/mvn clean verify sonar:sonar -Dsonar.projectKey=my-project -Dsonar.projectName='MyProject'" + } + } +}" +`; + +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: other build tools jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner'; + withSonarQubeEnv() { + sh "\${scannerHome}/bin/sonar-scanner" + } + } +}" +`; + +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: other build tools sonar-project.properties code 1`] = `"sonar.projectKey=my-project"`; + +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: ref spec 1`] = `"+refs/heads/*:refs/remotes/@{remote}/*"`; + +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: sonar-project.properties code 1`] = `"sonar.projectKey=my-project"`; + +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: windows dotnet core jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner for MSBuild' + withSonarQubeEnv() { + bat "dotnet \${scannerHome}\\\\SonarScanner.MSBuild.dll begin /k:\\"my-project\\"" + bat "dotnet build" + bat "dotnet \${scannerHome}\\\\SonarScanner.MSBuild.dll end" + } + } +} +" +`; + +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: windows dotnet framework jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def msbuildHome = tool 'Default MSBuild' + def scannerHome = tool 'SonarScanner for MSBuild' + withSonarQubeEnv() { + bat "\\"\${scannerHome}\\\\SonarScanner.MSBuild.exe\\" begin /k:\\"my-project\\"" + bat "\\"\${msbuildHome}\\\\MSBuild.exe\\" /t:Rebuild" + bat "\\"\${scannerHome}\\\\SonarScanner.MSBuild.exe\\" end" + } + } +} +" +`; + +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: build.gradle file 1`] = ` +"plugins { + id "org.sonarqube" version "3.5.0.2730" +} + +sonar { + properties { + property "sonar.projectKey", "my-project" + property "sonar.projectName", "MyProject" + } +}" +`; + +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: cfamily linux jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('Download Build Wrapper') { + sh "mkdir -p .sonar" + sh "curl -sSLo build-wrapper-linux-x86.zip http://localhost:9000/static/cpp/build-wrapper-linux-x86.zip" + sh "unzip -o build-wrapper-linux-x86.zip -d .sonar" + } + stage('Build') { + sh ".sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output " + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner'; + withSonarQubeEnv() { + sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output" + } + } +}" +`; + +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: cfamily macos jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('Download Build Wrapper') { + sh ''' + mkdir -p .sonar + curl -sSLo build-wrapper-macosx-x86.zip http://localhost:9000/static/cpp/build-wrapper-macosx-x86.zip + unzip -o build-wrapper-macosx-x86.zip -d .sonar + ''' + } + stage('Build') { + sh ''' + .sonar/build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir bw-output + ''' + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner'; + withSonarQubeEnv() { + sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output" + } + } +}" +`; + +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: cfamily windows jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('Download Build Wrapper') { + powershell ''' + $path = "$HOME/.sonar/build-wrapper-win-x86.zip" + rm build-wrapper-win-x86 -Recurse -Force -ErrorAction SilentlyContinue + rm $path -Force -ErrorAction SilentlyContinue + mkdir $HOME/.sonar + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + (New-Object System.Net.WebClient).DownloadFile(http://localhost:9000/static/cpp/build-wrapper-win-x86.zip", $path) + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($path, "$HOME/.sonar") + ''' + } + stage('Build') { + powershell ''' + $env:Path += ";$HOME/.sonar/build-wrapper-win-x86" + build-wrapper-win-x86-64 --out-dir bw-output + ''' + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner'; + withSonarQubeEnv() { + powershell "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output" + } + } +}" +`; + +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: gradle jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + withSonarQubeEnv() { + sh "./gradlew sonar" + } + } +}" +`; + +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: jenkins url 1`] = `"***JENKINS_SERVER_URL***/bitbucket-scmsource-hook/notify"`; + +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: linux dotnet core jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner for MSBuild' + withSonarQubeEnv() { + sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll begin /k:\\"my-project\\"" + sh "dotnet build" + sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll end" + } + } +} +" +`; + +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: maven jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def mvn = tool 'Default Maven'; + withSonarQubeEnv() { + sh "\${mvn}/bin/mvn clean verify sonar:sonar -Dsonar.projectKey=my-project -Dsonar.projectName='MyProject'" + } + } +}" +`; + +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: other build tools jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner'; + withSonarQubeEnv() { + sh "\${scannerHome}/bin/sonar-scanner" + } + } +}" +`; + +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: other build tools sonar-project.properties code 1`] = `"sonar.projectKey=my-project"`; + +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: ref spec 1`] = `"+refs/heads/*:refs/remotes/@{remote}/*"`; + +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: sonar-project.properties code 1`] = `"sonar.projectKey=my-project"`; + +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: windows dotnet core jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner for MSBuild' + withSonarQubeEnv() { + bat "dotnet \${scannerHome}\\\\SonarScanner.MSBuild.dll begin /k:\\"my-project\\"" + bat "dotnet build" + bat "dotnet \${scannerHome}\\\\SonarScanner.MSBuild.dll end" + } + } +} +" +`; + +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: windows dotnet framework jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def msbuildHome = tool 'Default MSBuild' + def scannerHome = tool 'SonarScanner for MSBuild' + withSonarQubeEnv() { + bat "\\"\${scannerHome}\\\\SonarScanner.MSBuild.exe\\" begin /k:\\"my-project\\"" + bat "\\"\${msbuildHome}\\\\MSBuild.exe\\" /t:Rebuild" + bat "\\"\${scannerHome}\\\\SonarScanner.MSBuild.exe\\" end" + } + } +} +" +`; + +exports[`github: can select devops platform and complete all the steps with copying code snippets: build.gradle file 1`] = ` +"plugins { + id "org.sonarqube" version "3.5.0.2730" +} + +sonar { + properties { + property "sonar.projectKey", "my-project" + property "sonar.projectName", "MyProject" + } +}" +`; + +exports[`github: can select devops platform and complete all the steps with copying code snippets: cfamily linux jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('Download Build Wrapper') { + sh "mkdir -p .sonar" + sh "curl -sSLo build-wrapper-linux-x86.zip http://localhost:9000/static/cpp/build-wrapper-linux-x86.zip" + sh "unzip -o build-wrapper-linux-x86.zip -d .sonar" + } + stage('Build') { + sh ".sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output " + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner'; + withSonarQubeEnv() { + sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output" + } + } +}" +`; + +exports[`github: can select devops platform and complete all the steps with copying code snippets: cfamily macos jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('Download Build Wrapper') { + sh ''' + mkdir -p .sonar + curl -sSLo build-wrapper-macosx-x86.zip http://localhost:9000/static/cpp/build-wrapper-macosx-x86.zip + unzip -o build-wrapper-macosx-x86.zip -d .sonar + ''' + } + stage('Build') { + sh ''' + .sonar/build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir bw-output + ''' + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner'; + withSonarQubeEnv() { + sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output" + } + } +}" +`; + +exports[`github: can select devops platform and complete all the steps with copying code snippets: cfamily windows jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('Download Build Wrapper') { + powershell ''' + $path = "$HOME/.sonar/build-wrapper-win-x86.zip" + rm build-wrapper-win-x86 -Recurse -Force -ErrorAction SilentlyContinue + rm $path -Force -ErrorAction SilentlyContinue + mkdir $HOME/.sonar + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + (New-Object System.Net.WebClient).DownloadFile(http://localhost:9000/static/cpp/build-wrapper-win-x86.zip", $path) + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($path, "$HOME/.sonar") + ''' + } + stage('Build') { + powershell ''' + $env:Path += ";$HOME/.sonar/build-wrapper-win-x86" + build-wrapper-win-x86-64 --out-dir bw-output + ''' + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner'; + withSonarQubeEnv() { + powershell "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output" + } + } +}" +`; + +exports[`github: can select devops platform and complete all the steps with copying code snippets: gradle jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + withSonarQubeEnv() { + sh "./gradlew sonar" + } + } +}" +`; + +exports[`github: can select devops platform and complete all the steps with copying code snippets: jenkins url 1`] = `"***JENKINS_SERVER_URL***/github-webhook/"`; + +exports[`github: can select devops platform and complete all the steps with copying code snippets: linux dotnet core jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner for MSBuild' + withSonarQubeEnv() { + sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll begin /k:\\"my-project\\"" + sh "dotnet build" + sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll end" + } + } +} +" +`; + +exports[`github: can select devops platform and complete all the steps with copying code snippets: maven jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def mvn = tool 'Default Maven'; + withSonarQubeEnv() { + sh "\${mvn}/bin/mvn clean verify sonar:sonar -Dsonar.projectKey=my-project -Dsonar.projectName='MyProject'" + } + } +}" +`; + +exports[`github: can select devops platform and complete all the steps with copying code snippets: other build tools jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner'; + withSonarQubeEnv() { + sh "\${scannerHome}/bin/sonar-scanner" + } + } +}" +`; + +exports[`github: can select devops platform and complete all the steps with copying code snippets: other build tools sonar-project.properties code 1`] = `"sonar.projectKey=my-project"`; + +exports[`github: can select devops platform and complete all the steps with copying code snippets: ref spec 1`] = `"+refs/heads/*:refs/remotes/@{remote}/*"`; + +exports[`github: can select devops platform and complete all the steps with copying code snippets: sonar-project.properties code 1`] = `"sonar.projectKey=my-project"`; + +exports[`github: can select devops platform and complete all the steps with copying code snippets: windows dotnet core jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner for MSBuild' + withSonarQubeEnv() { + bat "dotnet \${scannerHome}\\\\SonarScanner.MSBuild.dll begin /k:\\"my-project\\"" + bat "dotnet build" + bat "dotnet \${scannerHome}\\\\SonarScanner.MSBuild.dll end" + } + } +} +" +`; + +exports[`github: can select devops platform and complete all the steps with copying code snippets: windows dotnet framework jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def msbuildHome = tool 'Default MSBuild' + def scannerHome = tool 'SonarScanner for MSBuild' + withSonarQubeEnv() { + bat "\\"\${scannerHome}\\\\SonarScanner.MSBuild.exe\\" begin /k:\\"my-project\\"" + bat "\\"\${msbuildHome}\\\\MSBuild.exe\\" /t:Rebuild" + bat "\\"\${scannerHome}\\\\SonarScanner.MSBuild.exe\\" end" + } + } +} +" +`; + +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: build.gradle file 1`] = ` +"plugins { + id "org.sonarqube" version "3.5.0.2730" +} + +sonar { + properties { + property "sonar.projectKey", "my-project" + property "sonar.projectName", "MyProject" + } +}" +`; + +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: cfamily linux jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('Download Build Wrapper') { + sh "mkdir -p .sonar" + sh "curl -sSLo build-wrapper-linux-x86.zip http://localhost:9000/static/cpp/build-wrapper-linux-x86.zip" + sh "unzip -o build-wrapper-linux-x86.zip -d .sonar" + } + stage('Build') { + sh ".sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output " + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner'; + withSonarQubeEnv() { + sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output" + } + } +}" +`; + +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: cfamily macos jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('Download Build Wrapper') { + sh ''' + mkdir -p .sonar + curl -sSLo build-wrapper-macosx-x86.zip http://localhost:9000/static/cpp/build-wrapper-macosx-x86.zip + unzip -o build-wrapper-macosx-x86.zip -d .sonar + ''' + } + stage('Build') { + sh ''' + .sonar/build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir bw-output + ''' + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner'; + withSonarQubeEnv() { + sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output" + } + } +}" +`; + +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: cfamily windows jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('Download Build Wrapper') { + powershell ''' + $path = "$HOME/.sonar/build-wrapper-win-x86.zip" + rm build-wrapper-win-x86 -Recurse -Force -ErrorAction SilentlyContinue + rm $path -Force -ErrorAction SilentlyContinue + mkdir $HOME/.sonar + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + (New-Object System.Net.WebClient).DownloadFile(http://localhost:9000/static/cpp/build-wrapper-win-x86.zip", $path) + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($path, "$HOME/.sonar") + ''' + } + stage('Build') { + powershell ''' + $env:Path += ";$HOME/.sonar/build-wrapper-win-x86" + build-wrapper-win-x86-64 --out-dir bw-output + ''' + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner'; + withSonarQubeEnv() { + powershell "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output" + } + } +}" +`; + +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: gradle jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + withSonarQubeEnv() { + sh "./gradlew sonar" + } + } +}" +`; + +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: jenkins url 1`] = `"***JENKINS_SERVER_URL***/gitlab-webhook/post"`; + +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: linux dotnet core jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner for MSBuild' + withSonarQubeEnv() { + sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll begin /k:\\"my-project\\"" + sh "dotnet build" + sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll end" + } + } +} +" +`; + +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: maven jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def mvn = tool 'Default Maven'; + withSonarQubeEnv() { + sh "\${mvn}/bin/mvn clean verify sonar:sonar -Dsonar.projectKey=my-project -Dsonar.projectName='MyProject'" + } + } +}" +`; + +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: other build tools jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner'; + withSonarQubeEnv() { + sh "\${scannerHome}/bin/sonar-scanner" + } + } +}" +`; + +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: other build tools sonar-project.properties code 1`] = `"sonar.projectKey=my-project"`; + +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: ref spec 1`] = `"+refs/heads/*:refs/remotes/@{remote}/*"`; + +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: sonar-project.properties code 1`] = `"sonar.projectKey=my-project"`; + +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: windows dotnet core jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner for MSBuild' + withSonarQubeEnv() { + bat "dotnet \${scannerHome}\\\\SonarScanner.MSBuild.dll begin /k:\\"my-project\\"" + bat "dotnet build" + bat "dotnet \${scannerHome}\\\\SonarScanner.MSBuild.dll end" + } + } +} +" +`; + +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: windows dotnet framework jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def msbuildHome = tool 'Default MSBuild' + def scannerHome = tool 'SonarScanner for MSBuild' + withSonarQubeEnv() { + bat "\\"\${scannerHome}\\\\SonarScanner.MSBuild.exe\\" begin /k:\\"my-project\\"" + bat "\\"\${msbuildHome}\\\\MSBuild.exe\\" /t:Rebuild" + bat "\\"\${scannerHome}\\\\SonarScanner.MSBuild.exe\\" end" + } + } +} +" +`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsTutorial-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsTutorial-test.tsx.snap deleted file mode 100644 index d86ca3f98be..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsTutorial-test.tsx.snap +++ /dev/null @@ -1,191 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: branches not enabled 1`] = ` - -
      -

      - onboarding.tutorial.with.jenkins.title -

      -
      - - - - - -
      -`; - -exports[`should render correctly: default 1`] = ` - -
      -

      - onboarding.tutorial.with.jenkins.title -

      -
      - - - - - -
      -`; - -exports[`should render correctly: no project binding 1`] = ` - -
      -

      - onboarding.tutorial.with.jenkins.title -

      -
      - -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsfileStep-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsfileStep-test.tsx.snap deleted file mode 100644 index 1dba24aa64b..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsfileStep-test.tsx.snap +++ /dev/null @@ -1,267 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly for .NET 1`] = ` -
      -
        -
      1. - onboarding.build - -
      2. - -
      -
      -`; - -exports[`should render correctly for Gradle 1`] = ` -
      -
        -
      1. - onboarding.build - -
      2. - -
      -
      -`; - -exports[`should render correctly for Maven 1`] = ` -
      -
        -
      1. - onboarding.build - -
      2. - -
      -
      -`; - -exports[`should render correctly for Other 1`] = ` -
      -
        -
      1. - onboarding.build - -
      2. - -
      -
      -`; - -exports[`should render correctly: Step wrapper 1`] = ` - -`; - -exports[`should render correctly: Step wrapper with C 1`] = ` - -`; - -exports[`should render correctly: initial content 1`] = ` -
      -
        -
      1. - onboarding.build - -
      2. -
      -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/MultiBranchPipelineStep-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/MultiBranchPipelineStep-test.tsx.snap deleted file mode 100644 index 233913fe993..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/MultiBranchPipelineStep-test.tsx.snap +++ /dev/null @@ -1,1161 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: Step wrapper 1`] = ` - -`; - -exports[`should render correctly: content for bitbucket 1`] = ` -
      -

      - onboarding.tutorial.with.jenkins.multi_branch_pipeline.intro -

      -
        -
      1. - -
      2. -
      3. - -
          - -
        • - -
        • -
        • - -
        • -
        • - -
        • -
        • - -
        • -
          -
        • - - onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.behaviors.label - : - -
            -
          1. - -
          2. -
          3. - -
          4. -
          5. - - onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.behaviors.ref_specs.label - : - -
              -
            • - -
            • -
            • - - -
            • -
            -
          6. -
          -
        • -
        -

        - onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.leave_defaults -

        -
      4. -
      5. - -
          -
        • - -
        • -
        • - -
        • -
        -
      6. -
      7. - -
      8. -
      - -
      -`; - -exports[`should render correctly: content for bitbucket cloud 1`] = ` -
      -

      - onboarding.tutorial.with.jenkins.multi_branch_pipeline.intro -

      -
        -
      1. - -
      2. -
      3. - -
          - -
        • - -
        • -
        • - -
        • -
        • - -
        • -
        • - -
        • -
          -
        • - - onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.behaviors.label - : - -
            -
          1. - -
          2. -
          3. - -
          4. -
          5. - - onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.behaviors.ref_specs.label - : - -
              -
            • - -
            • -
            • - - -
            • -
            -
          6. -
          -
        • -
        -

        - onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.leave_defaults -

        -
      4. -
      5. - -
          -
        • - -
        • -
        • - -
        • -
        -
      6. -
      7. - -
      8. -
      - -
      -`; - -exports[`should render correctly: content for bitbucket cloud, no binding 1`] = ` -
      -

      - onboarding.tutorial.with.jenkins.multi_branch_pipeline.intro -

      -
        -
      1. - -
      2. -
      3. - -
          - -
        • - -
        • -
        • - -
        • -
        • - -
        • -
        • - -
        • -
          -
        • - - onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.behaviors.label - : - -
            -
          1. - -
          2. -
          3. - -
          4. -
          5. - - onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.behaviors.ref_specs.label - : - -
              -
            • - -
            • -
            • - - -
            • -
            -
          6. -
          -
        • -
        -

        - onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.leave_defaults -

        -
      4. -
      5. - -
          -
        • - -
        • -
        • - -
        • -
        -
      6. -
      7. - -
      8. -
      - -
      -`; - -exports[`should render correctly: content for bitbucket, no binding 1`] = ` -
      -

      - onboarding.tutorial.with.jenkins.multi_branch_pipeline.intro -

      -
        -
      1. - -
      2. -
      3. - -
          - -
        • - -
        • -
        • - -
        • -
        • - -
        • -
        • - -
        • -
          -
        • - - onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.behaviors.label - : - -
            -
          1. - -
          2. -
          3. - -
          4. -
          5. - - onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.behaviors.ref_specs.label - : - -
              -
            • - -
            • -
            • - - -
            • -
            -
          6. -
          -
        • -
        -

        - onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.leave_defaults -

        -
      4. -
      5. - -
          -
        • - -
        • -
        • - -
        • -
        -
      6. -
      7. - -
      8. -
      - -
      -`; - -exports[`should render correctly: content for github 1`] = ` -
      -

      - onboarding.tutorial.with.jenkins.multi_branch_pipeline.intro -

      -
        -
      1. - -
      2. -
      3. - -
          - -
        • - -
        • -
        • - -
        • -
          -
        • - - onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.behaviors.label - : - -
            -
          1. - -
          2. -
          3. - -
          4. -
          5. - - onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.behaviors.ref_specs.label - : - -
              -
            • - -
            • -
            • - - -
            • -
            -
          6. -
          -
        • -
        -

        - onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.leave_defaults -

        -
      4. -
      5. - -
          -
        • - -
        • -
        • - -
        • -
        -
      6. -
      7. - -
      8. -
      - -
      -`; - -exports[`should render correctly: content for github, no binding 1`] = ` -
      -

      - onboarding.tutorial.with.jenkins.multi_branch_pipeline.intro -

      -
        -
      1. - -
      2. -
      3. - -
          - -
        • - -
        • -
        • - -
        • -
          -
        • - - onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.behaviors.label - : - -
            -
          1. - -
          2. -
          3. - -
          4. -
          5. - - onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.behaviors.ref_specs.label - : - -
              -
            • - -
            • -
            • - - -
            • -
            -
          6. -
          -
        • -
        -

        - onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.leave_defaults -

        -
      4. -
      5. - -
          -
        • - -
        • -
        • - -
        • -
        -
      6. -
      7. - -
      8. -
      - -
      -`; - -exports[`should render correctly: content for gitlab 1`] = ` -
      -

      - onboarding.tutorial.with.jenkins.multi_branch_pipeline.intro -

      -
        -
      1. - -
      2. -
      3. - -
          - -
        • - -
        • -
        • - -
        • -
        • - -
        • -
          -
        • - - onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.behaviors.label - : - -
            -
          1. - -
          2. -
          3. - -
          4. -
          5. - - onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.behaviors.ref_specs.label - : - -
              -
            • - -
            • -
            • - - -
            • -
            -
          6. -
          -
        • -
        -

        - onboarding.tutorial.with.jenkins.multi_branch_pipeline.step2.leave_defaults -

        -
      4. -
      5. - -
          -
        • - -
        • -
        • - -
        • -
        -
      6. -
      7. - -
      8. -
      - -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/PipelineStep-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/PipelineStep-test.tsx.snap deleted file mode 100644 index 659205b0726..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/PipelineStep-test.tsx.snap +++ /dev/null @@ -1,234 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: Step wrapper 1`] = ` - -`; - -exports[`should render correctly: content 1`] = ` -
      -

      - onboarding.tutorial.with.jenkins.pipeline.intro -

      -
        -
      1. - -
      2. -
      3. - -
      4. -
      5. - -
          -
        • - -
        • -
        • - -
        • -
        • - -
        • -
        -
      6. -
      7. - -
      8. -
      - -
      -`; - -exports[`should render correctly: gitlab content 1`] = ` -
      -

      - onboarding.tutorial.with.jenkins.pipeline.intro -

      -
        -
      1. - -
      2. -
      3. - - -
          -
        • - -
        • -
        • - -
        • -
        • - -
        • -
        -
        -
      4. -
      5. - -
          -
        • - -
        • -
        • - -
        • -
        • - -
        • -
        -
      6. -
      7. - -
      8. -
      - -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/PreRequisitesStep-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/PreRequisitesStep-test.tsx.snap deleted file mode 100644 index 1e17f87e2c0..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/PreRequisitesStep-test.tsx.snap +++ /dev/null @@ -1,194 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: Step wrapper 1`] = ` - -`; - -exports[`should render correctly: content 1`] = ` -
      - - - -
        -
      • - onboarding.tutorial.with.jenkins.prereqs.plugins.branch_source.bitbucket -
      • -
      • - onboarding.tutorial.with.jenkins.prereqs.plugins.sonar_scanner -
      • -
      -

      - - onboarding.tutorial.with.jenkins.prereqs.step_by_step_guide.link - , - } - } - /> -

      -

      - onboarding.tutorial.with.jenkins.prereqs.following_are_recommendations -

      - -
      -`; - -exports[`should render correctly: content for branches disabled 1`] = ` -
      - - - -
        -
      • - onboarding.tutorial.with.jenkins.prereqs.plugins.sonar_scanner -
      • -
      -

      - - onboarding.tutorial.with.jenkins.prereqs.step_by_step_guide.link - , - } - } - /> -

      -

      - onboarding.tutorial.with.jenkins.prereqs.following_are_recommendations -

      - -
      -`; - -exports[`should render correctly: content for branches disabled, gitlab 1`] = ` -
      - - - -
        -
      • - onboarding.tutorial.with.jenkins.prereqs.plugins.gitlab_plugin -
      • -
      • - onboarding.tutorial.with.jenkins.prereqs.plugins.sonar_scanner -
      • -
      -

      - - onboarding.tutorial.with.jenkins.prereqs.step_by_step_guide.link - , - } - } - /> -

      -

      - onboarding.tutorial.with.jenkins.prereqs.following_are_recommendations -

      - -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/SelectAlmStep-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/SelectAlmStep-test.tsx.snap deleted file mode 100644 index fb76d738b05..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/SelectAlmStep-test.tsx.snap +++ /dev/null @@ -1,86 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: default 1`] = ` - -`; - -exports[`should render correctly: form, default 1`] = ` -
      - -
      -`; - -exports[`should render correctly: form, with alm 1`] = ` -
      - -
      -`; - -exports[`should render correctly: result, with alm 1`] = ` -
      - - alm.bitbucketcloud.long -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/WebhookStep-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/WebhookStep-test.tsx.snap deleted file mode 100644 index b342803bd14..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/WebhookStep-test.tsx.snap +++ /dev/null @@ -1,297 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly for azure: content 1`] = ` -
      -

      - - onboarding.tutorial.with.jenkins.webhook.intro.link - , - } - } - /> -

      -
        - -
      -`; - -exports[`should render correctly for azure: wrapper 1`] = ` - -`; - -exports[`should render correctly for bitbucket: content 1`] = ` -
      -

      - - onboarding.tutorial.with.jenkins.webhook.intro.link - , - } - } - /> -

      -
        - -
      - -
      -`; - -exports[`should render correctly for bitbucket: wrapper 1`] = ` - -`; - -exports[`should render correctly for bitbucketcloud: content 1`] = ` -
      -

      - - onboarding.tutorial.with.jenkins.webhook.intro.link - , - } - } - /> -

      -
        - -
      - -
      -`; - -exports[`should render correctly for bitbucketcloud: wrapper 1`] = ` - -`; - -exports[`should render correctly for github: content 1`] = ` -
      -

      - - onboarding.tutorial.with.jenkins.webhook.intro.link - , - } - } - /> -

      -
        - -
      - -
      -`; - -exports[`should render correctly for github: wrapper 1`] = ` - -`; - -exports[`should render correctly for gitlab: content 1`] = ` -
      -

      - - onboarding.tutorial.with.jenkins.webhook.intro.link - , - } - } - /> -

      -
        - -
      - -
      -`; - -exports[`should render correctly for gitlab: wrapper 1`] = ` - -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/WebhookStepBitbucket-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/WebhookStepBitbucket-test.tsx.snap deleted file mode 100644 index b33311f1931..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/WebhookStepBitbucket-test.tsx.snap +++ /dev/null @@ -1,460 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly for bitbucket 1`] = ` - -
    12. - - onboarding.tutorial.with.jenkins.webhook.bitbucket.step1.link - , - } - } - /> -
        -
      • - -
      • -
      • -

        - -

        - - - onboarding.tutorial.with.jenkins.webhook.bitbucket.step1.url.warning - -
      • -
      -
    13. -
    14. - -
        -
      • - -
      • -
      • - -
      • -
      -
    15. -
    16. - -
    17. -
      -`; - -exports[`should render correctly for bitbucket: with branches disabled 1`] = ` - -
    18. - - onboarding.tutorial.with.jenkins.webhook.bitbucket.step1.link - , - } - } - /> -
        -
      • - -
      • -
      • -

        - -

        - -
      • -
      -
    19. -
    20. - -
        -
      • - -
      • -
      -
    21. -
    22. - -
    23. -
      -`; - -exports[`should render correctly for bitbucket: with no alm binding 1`] = ` - -
    24. - - onboarding.tutorial.with.jenkins.webhook.bitbucket.step1.link - , - } - } - /> -
        -
      • - -
      • -
      • -

        - -

        - - - onboarding.tutorial.with.jenkins.webhook.bitbucket.step1.url.warning - -
      • -
      -
    25. -
    26. - -
        -
      • - -
      • -
      • - -
      • -
      -
    27. -
    28. - -
    29. -
      -`; - -exports[`should render correctly for bitbucketcloud 1`] = ` - -
    30. - - onboarding.tutorial.with.jenkins.webhook.bitbucketcloud.step1.link - , - } - } - /> -
        -
      • - -
      • -
      • -

        - -

        - -
      • -
      -
    31. -
    32. - -
        -
      • - -
      • -
      • - -
      • -
      -
    33. -
    34. - -
    35. -
      -`; - -exports[`should render correctly for bitbucketcloud: with branches disabled 1`] = ` - -
    36. - - onboarding.tutorial.with.jenkins.webhook.bitbucketcloud.step1.link - , - } - } - /> -
        -
      • - -
      • -
      • -

        - -

        - -
      • -
      -
    37. -
    38. - -
        -
      • - -
      • -
      -
    39. -
    40. - -
    41. -
      -`; - -exports[`should render correctly for bitbucketcloud: with no alm binding 1`] = ` - -
    42. - - onboarding.tutorial.with.jenkins.webhook.bitbucketcloud.step1.link - , - } - } - /> -
        -
      • - -
      • -
      • -

        - -

        - -
      • -
      -
    43. -
    44. - -
        -
      • - -
      • -
      • - -
      • -
      -
    45. -
    46. - -
    47. -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/WebhookStepGitLab-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/WebhookStepGitLab-test.tsx.snap deleted file mode 100644 index a52bf393eda..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/WebhookStepGitLab-test.tsx.snap +++ /dev/null @@ -1,127 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: default 1`] = ` - -
    48. - -
        -
      • -

        - -

        - -
      • -
      -
    49. -
    50. - -
        -
      • - - onboarding.tutorial.with.jenkins.webhook.gitlab.step2.repo - -
      • -
      • - - onboarding.tutorial.with.jenkins.webhook.gitlab.step2.mr - -
      • -
      -
    51. -
    52. - -
    53. -
      -`; - -exports[`should render correctly: with branches disabled 1`] = ` - -
    54. - -
        -
      • - -
      • -
      • - -
      • -
      -
    55. -
    56. - -
        -
      • - - onboarding.tutorial.with.jenkins.webhook.gitlab.step2.repo - -
      • -
      -
    57. -
    58. - -
    59. -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/WebhookStepGithub-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/WebhookStepGithub-test.tsx.snap deleted file mode 100644 index a8ee7b0ea5b..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/WebhookStepGithub-test.tsx.snap +++ /dev/null @@ -1,212 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - -
    60. - - onboarding.tutorial.with.jenkins.webhook.github.step1.link - , - } - } - /> -
        -
      • -

        - -

        - -
      • -
      -
    61. -
    62. - -
        -
      • - - onboarding.tutorial.with.jenkins.webhook.github.step2.repo - -
      • -
      • - - onboarding.tutorial.with.jenkins.webhook.github.step2.pr - -
      • -
      -
    63. -
    64. - -
    65. -
      -`; - -exports[`should render correctly: with branches disabled 1`] = ` - -
    66. - - onboarding.tutorial.with.jenkins.webhook.github.step1.link - , - } - } - /> -
        -
      • -

        - -

        - -
      • -
      -
    67. -
    68. - -
        -
      • - - onboarding.tutorial.with.jenkins.webhook.github.step2.repo - -
      • -
      -
    69. -
    70. - -
    71. -
      -`; - -exports[`should render correctly: with no alm binding 1`] = ` - -
    72. - - onboarding.tutorial.with.jenkins.webhook.github.step1.link - , - } - } - /> -
        -
      • -

        - -

        - -
      • -
      -
    73. -
    74. - -
        -
      • - - onboarding.tutorial.with.jenkins.webhook.github.step2.repo - -
      • -
      • - - onboarding.tutorial.with.jenkins.webhook.github.step2.pr - -
      • -
      -
    75. -
    76. - -
    77. -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/CFamilly-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/CFamilly-test.tsx deleted file mode 100644 index d0a9f824f1a..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/CFamilly-test.tsx +++ /dev/null @@ -1,42 +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 { mockComponent } from '../../../../../helpers/mocks/component'; -import RenderOptions from '../../../components/RenderOptions'; -import { OSs } from '../../../types'; -import { LanguageProps } from '../../JenkinsfileStep'; -import CFamilly from '../CFamilly'; - -it('should render correctly for', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -it.each([[OSs.Linux], [OSs.MacOS], [OSs.Windows]])('should render correctly for %s', (os) => { - const wrapper = shallowRender(); - wrapper.find(RenderOptions).simulate('check', os); - expect(wrapper).toMatchSnapshot(os); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/CreateJenkinsfileBulletPoint-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/CreateJenkinsfileBulletPoint-test.tsx deleted file mode 100644 index b12c790b3d6..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/CreateJenkinsfileBulletPoint-test.tsx +++ /dev/null @@ -1,35 +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 CreateJenkinsfileBulletPoint, { - CreateJenkinsfileBulletPointProps, -} from '../CreateJenkinsfileBulletPoint'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('default'); - expect(shallowRender({ alertTranslationKeyPart: 'baz' })).toMatchSnapshot('with alert'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNet-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNet-test.tsx deleted file mode 100644 index b6de1d7b71b..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNet-test.tsx +++ /dev/null @@ -1,34 +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 { mockComponent } from '../../../../../helpers/mocks/component'; -import { LanguageProps } from '../../JenkinsfileStep'; -import DotNet from '../DotNet'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetCore-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetCore-test.tsx deleted file mode 100644 index 65a1ad6863d..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetCore-test.tsx +++ /dev/null @@ -1,36 +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 { mockComponent } from '../../../../../helpers/mocks/component'; -import { OSs } from '../../../types'; -import { DotNetCoreFrameworkProps } from '../DotNet'; -import DotNetCore from '../DotNetCore'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('win'); - expect(shallowRender({ os: OSs.Linux })).toMatchSnapshot('linux'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetFramework-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetFramework-test.tsx deleted file mode 100644 index ab089d7c41f..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetFramework-test.tsx +++ /dev/null @@ -1,35 +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 { mockComponent } from '../../../../../helpers/mocks/component'; -import { OSs } from '../../../types'; -import { DotNetCoreFrameworkProps } from '../DotNet'; -import DotNetFramework from '../DotNetFramework'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetPrereqsMSBuild-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetPrereqsMSBuild-test.tsx deleted file mode 100644 index 2de66d8234e..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetPrereqsMSBuild-test.tsx +++ /dev/null @@ -1,30 +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 DotNetPrereqsMSBuild from '../DotNetPrereqsMSBuild'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender() { - return shallow(); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetPrereqsScanner-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetPrereqsScanner-test.tsx deleted file mode 100644 index 3ef5141ee40..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetPrereqsScanner-test.tsx +++ /dev/null @@ -1,30 +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 DotNetPrereqsScanner from '../DotNetPrereqsScanner'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender() { - return shallow(); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/Gradle-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/Gradle-test.tsx deleted file mode 100644 index 916de79c157..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/Gradle-test.tsx +++ /dev/null @@ -1,34 +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 { mockComponent } from '../../../../../helpers/mocks/component'; -import { LanguageProps } from '../../JenkinsfileStep'; -import Gradle from '../Gradle'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/Maven-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/Maven-test.tsx deleted file mode 100644 index bb073b388f3..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/Maven-test.tsx +++ /dev/null @@ -1,34 +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 { mockComponent } from '../../../../../helpers/mocks/component'; -import { LanguageProps } from '../../JenkinsfileStep'; -import Maven from '../Maven'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/Other-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/Other-test.tsx deleted file mode 100644 index 9448fe50852..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/Other-test.tsx +++ /dev/null @@ -1,34 +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 { mockComponent } from '../../../../../helpers/mocks/component'; -import { LanguageProps } from '../../JenkinsfileStep'; -import Other from '../Other'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/CFamilly-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/CFamilly-test.tsx.snap deleted file mode 100644 index 485d34fdda9..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/CFamilly-test.tsx.snap +++ /dev/null @@ -1,298 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly for 1`] = ` - - -
    78. - onboarding.build.other.os - -
    79. -
      -`; - -exports[`should render correctly for linux: linux 1`] = ` - - -
    80. - onboarding.build.other.os - - -
    81. - " - } - stage('SonarQube Analysis') { - def scannerHome = tool 'SonarScanner'; - withSonarQubeEnv() { - sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output" - } - } -}" - > - - - -
      -`; - -exports[`should render correctly for mac: mac 1`] = ` - - -
    82. - onboarding.build.other.os - - -
    83. - - - - -
      -`; - -exports[`should render correctly for win: win 1`] = ` - - -
    84. - onboarding.build.other.os - - -
    85. - - ''' - } - stage('SonarQube Analysis') { - def scannerHome = tool 'SonarScanner'; - withSonarQubeEnv() { - powershell "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output" - } - } -}" - > - - - -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/CreateJenkinsfileBulletPoint-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/CreateJenkinsfileBulletPoint-test.tsx.snap deleted file mode 100644 index d2a3aef7eda..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/CreateJenkinsfileBulletPoint-test.tsx.snap +++ /dev/null @@ -1,77 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: default 1`] = ` -
    86. - - -
    87. -`; - -exports[`should render correctly: with alert 1`] = ` -
    88. - - -
      - - -

      - -

      -

      - -

      - - } - /> -
      -
      - -
    89. -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNet-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNet-test.tsx.snap deleted file mode 100644 index ab0aff418c5..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNet-test.tsx.snap +++ /dev/null @@ -1,21 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - -
    90. - onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.build_agent - -
    91. -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetCore-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetCore-test.tsx.snap deleted file mode 100644 index 337c2c5f79a..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetCore-test.tsx.snap +++ /dev/null @@ -1,61 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: linux 1`] = ` - - -
    92. - - -
    93. -
      -`; - -exports[`should render correctly: win 1`] = ` - - -
    94. - - -
    95. -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetFramework-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetFramework-test.tsx.snap deleted file mode 100644 index 5fc76c1bae1..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetFramework-test.tsx.snap +++ /dev/null @@ -1,33 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - - - -
    96. - - -
    97. -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetPrereqsMSBuild-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetPrereqsMSBuild-test.tsx.snap deleted file mode 100644 index d1290fac87f..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetPrereqsMSBuild-test.tsx.snap +++ /dev/null @@ -1,67 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -
    98. - - - onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.info - -
        -
      1. - -
      2. -
      3. - -
      4. -
      5. - - - Default MSBuild - - -
      6. -
      -
    99. -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetPrereqsScanner-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetPrereqsScanner-test.tsx.snap deleted file mode 100644 index 50ac585d6f4..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetPrereqsScanner-test.tsx.snap +++ /dev/null @@ -1,75 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -
    100. - - - onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.info - -
        -
      1. - -
      2. -
      3. - -
      4. -
      5. - - - SonarScanner for MSBuild - - -
      6. -
      7. - -
      8. -
      -
    101. -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/Gradle-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/Gradle-test.tsx.snap deleted file mode 100644 index b231c344316..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/Gradle-test.tsx.snap +++ /dev/null @@ -1,41 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - -
    102. - - -
    103. - - -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/Maven-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/Maven-test.tsx.snap deleted file mode 100644 index 185cf0bacfd..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/Maven-test.tsx.snap +++ /dev/null @@ -1,23 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - - - - -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/Other-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/Other-test.tsx.snap deleted file mode 100644 index 3a68d7c54e3..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/Other-test.tsx.snap +++ /dev/null @@ -1,47 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - - - - - -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/other/__tests__/OtherTutorial-it.tsx b/server/sonar-web/src/main/js/components/tutorials/other/__tests__/OtherTutorial-it.tsx index d7c7133c872..42d50464aae 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/__tests__/OtherTutorial-it.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/__tests__/OtherTutorial-it.tsx @@ -26,7 +26,11 @@ import UserTokensMock from '../../../../api/mocks/UserTokensMock'; import { mockComponent } from '../../../../helpers/mocks/component'; import { mockLanguage, mockLoggedInUser } from '../../../../helpers/testMocks'; import { renderApp, RenderContext } from '../../../../helpers/testReactTestingUtils'; -import { getCopyToClipboardValue, getTutorialBuildButtons } from '../../test-utils'; +import { + getCopyToClipboardValue, + getTutorialActionButtons, + getTutorialBuildButtons, +} from '../../test-utils'; import OtherTutorial from '../OtherTutorial'; jest.mock('../../../../api/user-tokens'); @@ -48,11 +52,9 @@ const ui = { existingTokenRadio: byRole('radio', { name: 'onboarding.token.use_existing_token' }), tokenNameInput: byRole('textbox', { name: 'onboarding.token.name.label' }), expiresInSelect: byRole('combobox', { name: '' }), - generateTokenButton: byRole('button', { name: 'onboarding.token.generate' }), - deleteTokenButton: byRole('button', { name: 'onboarding.token.delete' }), tokenValueInput: byRole('textbox', { name: 'onboarding.token.use_existing_token.label' }), invalidTokenValueMessage: byText('onboarding.token.invalid_format'), - continueButton: byRole('button', { name: 'continue' }), + ...getTutorialActionButtons(), ...getTutorialBuildButtons(), }; diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/AnalysisCommand-test.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/AnalysisCommand-test.tsx deleted file mode 100644 index 9427ff04c80..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/AnalysisCommand-test.tsx +++ /dev/null @@ -1,62 +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 { mockComponent } from '../../../../../helpers/mocks/component'; -import { BuildTools, OSs } from '../../../types'; -import AnalysisCommand, { AnalysisCommandProps } from '../AnalysisCommand'; - -jest.mock('../../../../../helpers/urls', () => ({ - getHostUrl: () => 'HOST', -})); - -it('renders correctly', () => { - expect(shallowRender({ languageConfig: { buildTool: BuildTools.Gradle } })).toMatchSnapshot( - 'gradle' - ); - expect(shallowRender({ languageConfig: { buildTool: BuildTools.Maven } })).toMatchSnapshot( - 'maven' - ); - expect(shallowRender({ languageConfig: { buildTool: BuildTools.DotNet } })).toMatchSnapshot( - '.NET' - ); - expect( - shallowRender({ languageConfig: { buildTool: BuildTools.CFamily, os: OSs.Linux } }) - ).toMatchSnapshot('CFamily'); - expect(shallowRender({ languageConfig: { buildTool: BuildTools.CFamily } })).toMatchSnapshot( - 'Empty CFamily' - ); - expect( - shallowRender({ languageConfig: { buildTool: BuildTools.Other, os: OSs.Windows } }) - ).toMatchSnapshot('other'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/CLangGCCCommand-test.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/CLangGCCCommand-test.tsx deleted file mode 100644 index 1e0ecfb3d0b..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/CLangGCCCommand-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 { mockComponent } from '../../../../../helpers/mocks/component'; -import { OSs } from '../../../types'; -import ClangGCCCommand from '../ClangGCCCommand'; - -it('should render correctly', () => { - expect( - shallow( - - ) - ).toMatchSnapshot(); -}); diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotNet-test.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotNet-test.tsx deleted file mode 100644 index 3228f32cd2e..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotNet-test.tsx +++ /dev/null @@ -1,31 +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 { mockComponent } from '../../../../../helpers/mocks/component'; -import DotNet from '../DotNet'; - -it('should render correctly', () => { - expect( - shallow( - - ) - ).toMatchSnapshot(); -}); diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotNetExecute-test.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotNetExecute-test.tsx deleted file mode 100644 index e22e7c06cac..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotNetExecute-test.tsx +++ /dev/null @@ -1,29 +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 { mockComponent } from '../../../../../helpers/mocks/component'; -import DotNetExecute from '../DotNetExecute'; - -it('should render correctly', () => { - expect( - shallow() - ).toMatchSnapshot(); -}); diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotNetFramework-test.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotNetFramework-test.tsx deleted file mode 100644 index 84bac887894..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotNetFramework-test.tsx +++ /dev/null @@ -1,35 +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 { mockComponent } from '../../../../../helpers/mocks/component'; -import DotNetFramework from '../DotNetFramework'; - -it('should render correctly', () => { - expect( - shallow( - - ) - ).toMatchSnapshot(); -}); diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotnetCore-test.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotnetCore-test.tsx deleted file mode 100644 index 432c1fd3782..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotnetCore-test.tsx +++ /dev/null @@ -1,31 +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 { mockComponent } from '../../../../../helpers/mocks/component'; -import DotNetCore from '../DotNetCore'; - -it('should render correctly', () => { - expect( - shallow( - - ) - ).toMatchSnapshot(); -}); diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DownloadBuildWrapper-test.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DownloadBuildWrapper-test.tsx deleted file mode 100644 index 4022b42a419..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DownloadBuildWrapper-test.tsx +++ /dev/null @@ -1,34 +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 { OSs } from '../../../types'; -import DownloadBuildWrapper, { DownloadBuildWrapperProps } from '../DownloadBuildWrapper'; - -it.each([OSs.Linux, OSs.Windows, OSs.MacOS])('should render correctly for %p', (os) => { - expect(shallowRender({ os, isLocal: false })).toMatchSnapshot('remote'); - expect(shallowRender({ os })).toMatchSnapshot('local'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DownloadScanner-test.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DownloadScanner-test.tsx deleted file mode 100644 index 0c1498421d0..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DownloadScanner-test.tsx +++ /dev/null @@ -1,34 +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 { OSs } from '../../../types'; -import DownloadScanner, { DownloadScannerProps } from '../DownloadScanner'; - -it.each([OSs.Linux, OSs.Windows, OSs.MacOS])('should render correctly for %p', (os) => { - expect(shallowRender({ isLocal: false, os })).toMatchSnapshot('remote'); - expect(shallowRender({ os })).toMatchSnapshot('local'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/ExecBuildWrapper-test.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/ExecBuildWrapper-test.tsx deleted file mode 100644 index 9470d9e123e..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/ExecBuildWrapper-test.tsx +++ /dev/null @@ -1,27 +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 { OSs } from '../../../types'; -import ExecBuildWrapper from '../ExecBuildWrapper'; - -it.each([OSs.Linux, OSs.Windows, OSs.MacOS])('Shoud renders for %p correctly', (os) => { - expect(shallow()).toMatchSnapshot(); -}); diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/ExecScanner-test.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/ExecScanner-test.tsx deleted file mode 100644 index 3306e6f63a8..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/ExecScanner-test.tsx +++ /dev/null @@ -1,49 +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 { mockComponent } from '../../../../../helpers/mocks/component'; -import { OSs } from '../../../types'; -import ExecScanner, { ExecScannerProps } from '../ExecScanner'; - -it.each([OSs.Linux, OSs.Windows, OSs.MacOS])('should render correctly for %p', (os) => { - expect(shallowRender({ os })).toMatchSnapshot(); -}); - -it('should render correctly for cfamily', () => { - expect(shallowRender({ cfamily: true })).toMatchSnapshot(); -}); - -it('should render correctly for remote execution', () => { - expect(shallowRender({ isLocal: false })).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/JavaGradle-test.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/JavaGradle-test.tsx deleted file mode 100644 index 794c4e80973..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/JavaGradle-test.tsx +++ /dev/null @@ -1,31 +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 { mockComponent } from '../../../../../helpers/mocks/component'; -import JavaGradle from '../JavaGradle'; - -it('renders correctly', () => { - expect( - shallow( - - ) - ).toMatchSnapshot(); -}); diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/JavaMaven-test.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/JavaMaven-test.tsx deleted file mode 100644 index 3e8f5a9a2f3..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/JavaMaven-test.tsx +++ /dev/null @@ -1,31 +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 { mockComponent } from '../../../../../helpers/mocks/component'; -import JavaMaven from '../JavaMaven'; - -it('renders correctly', () => { - expect( - shallow( - - ) - ).toMatchSnapshot(); -}); diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/Other-test.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/Other-test.tsx deleted file mode 100644 index f4c12c2f853..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/Other-test.tsx +++ /dev/null @@ -1,41 +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 { mockComponent } from '../../../../../helpers/mocks/component'; -import { OSs } from '../../../types'; -import Other, { OtherProps } from '../Other'; - -it('renders correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap deleted file mode 100644 index ca8fa01afab..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap +++ /dev/null @@ -1,152 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`renders correctly: .NET 1`] = ` - -`; - -exports[`renders correctly: CFamily 1`] = ` - -`; - -exports[`renders correctly: Empty CFamily 1`] = `""`; - -exports[`renders correctly: gradle 1`] = ` - -`; - -exports[`renders correctly: maven 1`] = ` - -`; - -exports[`renders correctly: other 1`] = ` - -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/CLangGCCCommand-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/CLangGCCCommand-test.tsx.snap deleted file mode 100644 index a9ac958d7c3..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/CLangGCCCommand-test.tsx.snap +++ /dev/null @@ -1,49 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -
      - - - - - -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/DotNet-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/DotNet-test.tsx.snap deleted file mode 100644 index 154a1863dbb..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/DotNet-test.tsx.snap +++ /dev/null @@ -1,45 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - - - - -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/DotNetExecute-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/DotNetExecute-test.tsx.snap deleted file mode 100644 index 7f477ebc18f..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/DotNetExecute-test.tsx.snap +++ /dev/null @@ -1,65 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - -

      - onboarding.analysis.sq_scanner.execute -

      - - - - - -

      - - onboarding.analysis.msbuild.docs_link - , - } - } - /> -

      - -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/DotNetFramework-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/DotNetFramework-test.tsx.snap deleted file mode 100644 index 3145cee5f66..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/DotNetFramework-test.tsx.snap +++ /dev/null @@ -1,64 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -
      -
      -

      - onboarding.analysis.msbuild.header -

      -

      - - %PATH% - , - "link": - onboarding.analysis.msbuild.docs_link - , - } - } - /> -

      -
      - -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/DotnetCore-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/DotnetCore-test.tsx.snap deleted file mode 100644 index a24b6be0158..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/DotnetCore-test.tsx.snap +++ /dev/null @@ -1,56 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -
      -

      - onboarding.analysis.dotnetcore.global -

      -

      - onboarding.analysis.dotnetcore.global.text -

      - - - onboarding.analysis.dotnetcore.global.text.path - - -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/DownloadBuildWrapper-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/DownloadBuildWrapper-test.tsx.snap deleted file mode 100644 index 42c9604d362..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/DownloadBuildWrapper-test.tsx.snap +++ /dev/null @@ -1,173 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly for "linux": local 1`] = ` -
      -

      - onboarding.analysis.build_wrapper.header.linux -

      -

      - - PATH - , - } - } - /> -

      -

      - - download_verb - -

      -
      -`; - -exports[`should render correctly for "linux": remote 1`] = ` -
      -

      - onboarding.analysis.build_wrapper.header.linux -

      - -
      -`; - -exports[`should render correctly for "mac": local 1`] = ` -
      -

      - onboarding.analysis.build_wrapper.header.mac -

      -

      - - PATH - , - } - } - /> -

      -

      - - download_verb - -

      -
      -`; - -exports[`should render correctly for "mac": remote 1`] = ` -
      -

      - onboarding.analysis.build_wrapper.header.mac -

      - -
      -`; - -exports[`should render correctly for "win": local 1`] = ` -
      -

      - onboarding.analysis.build_wrapper.header.win -

      -

      - - %PATH% - , - } - } - /> -

      -

      - - download_verb - -

      -
      -`; - -exports[`should render correctly for "win": remote 1`] = ` -
      -

      - onboarding.analysis.build_wrapper.header.win -

      - -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/DownloadScanner-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/DownloadScanner-test.tsx.snap deleted file mode 100644 index d935a1644b4..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/DownloadScanner-test.tsx.snap +++ /dev/null @@ -1,273 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly for "linux": local 1`] = ` -
      -

      - onboarding.analysis.sq_scanner.header.linux -

      -

      - - bin - , - "env_var": - PATH - , - "link": - onboarding.analysis.sq_scanner.docs_link - , - } - } - /> -

      -
      -`; - -exports[`should render correctly for "linux": remote 1`] = ` -
      -

      - onboarding.analysis.sq_scanner.header.linux -

      - -

      - onboarding.analysis.sq_scanner.sonar_token_env.header -

      -
        -
      • - onboarding.analysis.sq_scanner.sonar_token_env.var_name - : - - - SONAR_TOKEN - - -
      • -
      • - onboarding.analysis.sq_scanner.sonar_token_env.var_value - : - - - token - - -
      • -
      -
      -`; - -exports[`should render correctly for "mac": local 1`] = ` -
      -

      - onboarding.analysis.sq_scanner.header.mac -

      -

      - - bin - , - "env_var": - PATH - , - "link": - onboarding.analysis.sq_scanner.docs_link - , - } - } - /> -

      -
      -`; - -exports[`should render correctly for "mac": remote 1`] = ` -
      -

      - onboarding.analysis.sq_scanner.header.mac -

      - -

      - onboarding.analysis.sq_scanner.sonar_token_env.header -

      -
        -
      • - onboarding.analysis.sq_scanner.sonar_token_env.var_name - : - - - SONAR_TOKEN - - -
      • -
      • - onboarding.analysis.sq_scanner.sonar_token_env.var_value - : - - - token - - -
      • -
      -
      -`; - -exports[`should render correctly for "win": local 1`] = ` -
      -

      - onboarding.analysis.sq_scanner.header.win -

      -

      - - bin - , - "env_var": - %PATH% - , - "link": - onboarding.analysis.sq_scanner.docs_link - , - } - } - /> -

      -
      -`; - -exports[`should render correctly for "win": remote 1`] = ` -
      -

      - onboarding.analysis.sq_scanner.header.win -

      - -

      - onboarding.analysis.sq_scanner.sonar_token_env.header -

      -
        -
      • - onboarding.analysis.sq_scanner.sonar_token_env.var_name - : - - - SONAR_TOKEN - - -
      • -
      • - onboarding.analysis.sq_scanner.sonar_token_env.var_value - : - - - token - - -
      • -
      -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/ExecBuildWrapper-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/ExecBuildWrapper-test.tsx.snap deleted file mode 100644 index d0b6e2525c9..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/ExecBuildWrapper-test.tsx.snap +++ /dev/null @@ -1,106 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Shoud renders for "linux" correctly 1`] = ` - -

      - onboarding.analysis.build_wrapper.execute -

      -

      - onboarding.analysis.build_wrapper.execute_text -

      - -

      - - onboarding.analysis.build_wrapper.docs_link - , - } - } - /> -

      -
      -`; - -exports[`Shoud renders for "mac" correctly 1`] = ` - -

      - onboarding.analysis.build_wrapper.execute -

      -

      - onboarding.analysis.build_wrapper.execute_text -

      - -

      - - onboarding.analysis.build_wrapper.docs_link - , - } - } - /> -

      -
      -`; - -exports[`Shoud renders for "win" correctly 1`] = ` - -

      - onboarding.analysis.build_wrapper.execute -

      -

      - onboarding.analysis.build_wrapper.execute_text -

      - -

      - - onboarding.analysis.build_wrapper.docs_link - , - } - } - /> -

      -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/ExecScanner-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/ExecScanner-test.tsx.snap deleted file mode 100644 index a50a09d702e..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/ExecScanner-test.tsx.snap +++ /dev/null @@ -1,346 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly for "linux" 1`] = ` -
      -

      - onboarding.analysis.sq_scanner.execute -

      - - - - -

      - - onboarding.analysis.sq_scanner.docs_link - , - } - } - /> -

      - -
      -`; - -exports[`should render correctly for "mac" 1`] = ` -
      -

      - onboarding.analysis.sq_scanner.execute -

      - - - - -

      - - onboarding.analysis.sq_scanner.docs_link - , - } - } - /> -

      - -
      -`; - -exports[`should render correctly for "win" 1`] = ` -
      -

      - onboarding.analysis.sq_scanner.execute -

      - - - - -

      - - onboarding.analysis.sq_scanner.docs_link - , - } - } - /> -

      - -
      -`; - -exports[`should render correctly for cfamily 1`] = ` -
      -

      - onboarding.analysis.sq_scanner.execute -

      - - - - -

      - - onboarding.analysis.sq_scanner.docs_link - , - } - } - /> -

      - -
      -`; - -exports[`should render correctly for remote execution 1`] = ` -
      -

      - onboarding.analysis.sq_scanner.execute -

      - - - - -

      - - onboarding.analysis.sq_scanner.docs_link - , - } - } - /> -

      - -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/JavaGradle-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/JavaGradle-test.tsx.snap deleted file mode 100644 index 15ad59728f8..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/JavaGradle-test.tsx.snap +++ /dev/null @@ -1,99 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`renders correctly 1`] = ` -
      -

      - onboarding.analysis.java.gradle.header -

      - - - - -

      - - - here - , - } - } - /> - -

      -

      - onboarding.analysis.java.gradle.text.2 -

      - -

      - - onboarding.analysis.java.gradle.docs_link - , - } - } - /> -

      - -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/JavaMaven-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/JavaMaven-test.tsx.snap deleted file mode 100644 index 68797299257..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/JavaMaven-test.tsx.snap +++ /dev/null @@ -1,70 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`renders correctly 1`] = ` -
      -

      - onboarding.analysis.java.maven.header -

      -

      - -

      - -

      - - onboarding.analysis.java.maven.docs_link - , - } - } - /> -

      - -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/Other-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/Other-test.tsx.snap deleted file mode 100644 index 6af41dafc42..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/Other-test.tsx.snap +++ /dev/null @@ -1,39 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`renders correctly 1`] = ` -
      - - -
      -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/test-utils.ts b/server/sonar-web/src/main/js/components/tutorials/test-utils.ts index 5ef1aa0f407..f57a2722b0d 100644 --- a/server/sonar-web/src/main/js/components/tutorials/test-utils.ts +++ b/server/sonar-web/src/main/js/components/tutorials/test-utils.ts @@ -18,19 +18,53 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { screen } from '@testing-library/react'; -import { ShallowWrapper } from 'enzyme'; -import { byRole } from 'testing-library-selector'; -import Step from './components/Step'; -import { BuildTools, OSs } from './types'; +import { byRole, byText } from 'testing-library-selector'; +import { BuildTools, OSs, TutorialModes } from './types'; -export function renderStepContent(wrapper: ShallowWrapper, n = 0) { - return wrapper.find(Step).at(n).props().renderForm(); -} +const CI_TRANSLATE_MAP: Partial> = { + [TutorialModes.BitbucketPipelines]: 'bitbucket_pipelines', + [TutorialModes.GitHubActions]: 'github_action', + [TutorialModes.GitLabCI]: 'gitlab_ci', +}; export function getCopyToClipboardValue(i = 0, name = 'copy_to_clipboard') { return screen.getAllByRole('button', { name })[i].getAttribute('data-clipboard-text'); } +export function getCommonNodes(ci: TutorialModes) { + return { + secretsStepTitle: byRole('heading', { + name: `onboarding.tutorial.with.${CI_TRANSLATE_MAP[ci]}.${ + ci === TutorialModes.GitHubActions ? 'create_secret' : 'variables' + }.title`, + }), + ymlFileStepTitle: byRole('heading', { + name: `onboarding.tutorial.with.${CI_TRANSLATE_MAP[ci]}.yaml.title`, + }), + genTokenDialogButton: byRole('button', { + name: 'onboarding.token.generate.long', + }), + tokenNameInput: byRole('textbox', { name: 'onboarding.token.name.label' }), + expiresInSelect: byRole('combobox', { name: '' }), + tokenValue: byText('generatedtoken2'), + linkToRepo: byRole('link', { + name: `onboarding.tutorial.with.${CI_TRANSLATE_MAP[ci]}.${ + ci === TutorialModes.GitHubActions ? 'secret' : 'variables' + }.intro.link`, + }), + allSetSentence: byText('onboarding.tutorial.ci_outro.all_set.sentence'), + }; +} + +export function getTutorialActionButtons() { + return { + continueButton: byRole('button', { name: 'continue' }), + generateTokenButton: byRole('button', { name: 'onboarding.token.generate' }), + deleteTokenButton: byRole('button', { name: 'onboarding.token.delete' }), + finishTutorialButton: byRole('button', { name: 'tutorials.finish' }), + }; +} + export function getTutorialBuildButtons() { return { describeBuildTitle: byRole('heading', { name: 'onboarding.build' }), @@ -39,9 +73,20 @@ export function getTutorialBuildButtons() { dotnetBuildButton: byRole('button', { name: `onboarding.build.${BuildTools.DotNet}` }), cFamilyBuildButton: byRole('button', { name: `onboarding.build.${BuildTools.CFamily}` }), otherBuildButton: byRole('button', { name: `onboarding.build.${BuildTools.Other}` }), - dotnetCoreButton: byRole('button', { name: 'onboarding.build.dotnet.variant.dotnet_core' }), + windowsDotnetCoreButton: byRole('button', { + name: `onboarding.build.${BuildTools.DotNet}.win_core`, + }), + windowsDotnetFrameworkButton: byRole('button', { + name: `onboarding.build.${BuildTools.DotNet}.win_msbuild`, + }), + linuxDotnetCoreButton: byRole('button', { + name: `onboarding.build.${BuildTools.DotNet}.linux_core`, + }), + dotnetCoreButton: byRole('button', { + name: `onboarding.build.${BuildTools.DotNet}.variant.dotnet_core`, + }), dotnetFrameworkButton: byRole('button', { - name: 'onboarding.build.dotnet.variant.dotnet_framework', + name: `onboarding.build.${BuildTools.DotNet}.variant.dotnet_framework`, }), linuxButton: byRole('button', { name: `onboarding.build.other.os.${OSs.Linux}` }), windowsButton: byRole('button', { name: `onboarding.build.other.os.${OSs.Windows}` }), diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index c54379d9344..b55aa2e6881 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -3825,7 +3825,7 @@ onboarding.tutorial.with.yaml.gradle=Update your {gradle} file with the {sq} plu -onboarding.tutorial.with.bitbucket_pipelines.create_secret.title=Create repository variables +onboarding.tutorial.with.bitbucket_pipelines.variables.title=Create repository variables onboarding.tutorial.with.bitbucket_pipelines.yaml.title=Create your pipelines builds configuration onboarding.tutorial.with.bitbucket_pipelines.variables.intro=In your Bitbucket repository, go to {repository_variables} and create two new variables: onboarding.tutorial.with.bitbucket_pipelines.variables.intro.link=Repository settings > Repository variables @@ -3856,26 +3856,26 @@ onboarding.tutorial.with.gitlab_ci.project_key.other.step2=Create a {file} file onboarding.tutorial.with.gitlab_ci.project_key.dotnet.step2=Create a {file} file in your repository and paste the following code: onboarding.tutorial.with.gitlab_ci.project_key.cfamily.step2=Create a {file} file in your repository and paste the following code: -onboarding.tutorial.with.gitlab_ci.env_variables.title=Add environment variables -onboarding.tutorial.with.gitlab_ci.env_variables.description.link=Settings > CI/CD > Variables -onboarding.tutorial.with.gitlab_ci.env_variables.section.title=Define the SonarQube Token environment variable. -onboarding.tutorial.with.gitlab_ci.env_variables.section.description=In GitLab, go to {link} to add the following variable and make sure it is available for your project: -onboarding.tutorial.with.gitlab_ci.env_variables.edit.token.tooltip=Use an existing token or generate a new one. -onboarding.tutorial.with.gitlab_ci.env_variables.step1=Key - -onboarding.tutorial.with.gitlab_ci.env_variables.step3=Uncheck the {value} checkbox. -onboarding.tutorial.with.gitlab_ci.env_variables.step3.value=Protect Variable -onboarding.tutorial.with.gitlab_ci.env_variables.section.step4=Check the {value} checkbox. -onboarding.tutorial.with.gitlab_ci.env_variables.section.step4.value=Mask Variable -onboarding.tutorial.with.gitlab_ci.env_variables.section2.title=Define the SonarQube URL environment variable. -onboarding.tutorial.with.gitlab_ci.env_variables.section2.description=Still in {link} add a new variable and make sure it is available for your project: -onboarding.tutorial.with.gitlab_ci.env_variables.section2.step4=Leave the {value} checkbox unchecked. -onboarding.tutorial.with.gitlab_ci.yml.title=Create or update the configuration file -onboarding.tutorial.with.gitlab_ci.yml.description=Create or update your {filename} file with the following content. -onboarding.tutorial.with.gitlab_ci.yml.filename=.gitlab-ci.yml -onboarding.tutorial.with.gitlab_ci.yml.baseconfig=Note that this is a minimal base configuration to run a SonarQube analysis on your main branch and merge requests. -onboarding.tutorial.with.gitlab_ci.yml.baseconfig.no_branches=Note that this is a minimal base configuration to run a SonarQube analysis on your main branch. -onboarding.tutorial.with.gitlab_ci.yml.existing=If you already have a pipeline configured and running, you might want to add the example from this step to your existing yml file. +onboarding.tutorial.with.gitlab_ci.variables.title=Add environment variables +onboarding.tutorial.with.gitlab_ci.variables.description.link=Settings > CI/CD > Variables +onboarding.tutorial.with.gitlab_ci.variables.section.title=Define the SonarQube Token environment variable. +onboarding.tutorial.with.gitlab_ci.variables.section.description=In GitLab, go to {link} to add the following variable and make sure it is available for your project: +onboarding.tutorial.with.gitlab_ci.variables.edit.token.tooltip=Use an existing token or generate a new one. +onboarding.tutorial.with.gitlab_ci.variables.step1=Key + +onboarding.tutorial.with.gitlab_ci.variables.step3=Uncheck the {value} checkbox. +onboarding.tutorial.with.gitlab_ci.variables.step3.value=Protect Variable +onboarding.tutorial.with.gitlab_ci.variables.section.step4=Check the {value} checkbox. +onboarding.tutorial.with.gitlab_ci.variables.section.step4.value=Mask Variable +onboarding.tutorial.with.gitlab_ci.variables.section2.title=Define the SonarQube URL environment variable. +onboarding.tutorial.with.gitlab_ci.variables.section2.description=Still in {link} add a new variable and make sure it is available for your project: +onboarding.tutorial.with.gitlab_ci.variables.section2.step4=Leave the {value} checkbox unchecked. +onboarding.tutorial.with.gitlab_ci.yaml.title=Create or update the configuration file +onboarding.tutorial.with.gitlab_ci.yaml.description=Create or update your {filename} file with the following content. +onboarding.tutorial.with.gitlab_ci.yaml.filename=.gitlab-ci.yml +onboarding.tutorial.with.gitlab_ci.yaml.baseconfig=Note that this is a minimal base configuration to run a SonarQube analysis on your main branch and merge requests. +onboarding.tutorial.with.gitlab_ci.yaml.baseconfig.no_branches=Note that this is a minimal base configuration to run a SonarQube analysis on your main branch. +onboarding.tutorial.with.gitlab_ci.yaml.existing=If you already have a pipeline configured and running, you might want to add the example from this step to your existing yml file. onboarding.tutorial.with.jenkins.title=Analyze your project with Jenkins onboarding.tutorial.with.jenkins.alm_selection.title=Select your DevOps platform