From: Mathieu Suen Date: Wed, 14 Jun 2023 12:51:46 +0000 (+0200) Subject: [NO JIRA] Remove react-testing-selector library and replace it X-Git-Tag: 10.1.0.73491~26 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e0d97545525f136e27b5f3c0c492d91bab6e9d93;p=sonarqube.git [NO JIRA] Remove react-testing-selector library and replace it --- diff --git a/server/sonar-web/build.gradle b/server/sonar-web/build.gradle index 3e552ca8d45..cac9ab0dd73 100644 --- a/server/sonar-web/build.gradle +++ b/server/sonar-web/build.gradle @@ -2,7 +2,7 @@ sonar { properties { property "sonar.projectName", "${projectTitle} :: Web" property "sonar.sources", "src/main/js" - property "sonar.exclusions", "src/main/js/**/__tests__/**,src/main/js/**/__mocks__/**,src/main/js/@types/**,src/main/js/helpers/mocks/**,src/main/js/api/mocks/**,src/main/js/helpers/testUtils.ts,src/main/js/helpers/testMocks.ts,src/main/js/helpers/testReactTestingUtils.tsx" + property "sonar.exclusions", "src/main/js/**/__tests__/**,src/main/js/**/__mocks__/**,src/main/js/@types/**,src/main/js/helpers/mocks/**,src/main/js/api/mocks/**,src/main/js/helpers/testUtils.ts,src/main/js/helpers/testMocks.ts,src/main/js/helpers/testReactTestingUtils.tsx,src/main/js/helpers/testSelector.ts" property "sonar.tests", "src/main/js" property "sonar.test.inclusions", "src/main/js/**/__tests__/**" property "sonar.coverage.exclusions", "src/main/js/api/**,src/main/js/**/routes.ts,src/main/js/app/index.ts,src/main/js/app/utils/startReactApp.tsx,src/main/js/components/icons/**" diff --git a/server/sonar-web/package.json b/server/sonar-web/package.json index 0ffafc16ab7..8ea7e0a1cbf 100644 --- a/server/sonar-web/package.json +++ b/server/sonar-web/package.json @@ -104,7 +104,6 @@ "prettier": "2.8.7", "react-select-event": "5.5.1", "tailwindcss": "3.3.1", - "testing-library-selector": "0.2.1", "turbo": "1.8.8", "typescript": "5.0.3", "whatwg-fetch": "3.6.2" diff --git a/server/sonar-web/src/main/js/app/components/global-search/__tests__/GlobalSearch-it.tsx b/server/sonar-web/src/main/js/app/components/global-search/__tests__/GlobalSearch-it.tsx index 5a71453adab..ae3197eb2a7 100644 --- a/server/sonar-web/src/main/js/app/components/global-search/__tests__/GlobalSearch-it.tsx +++ b/server/sonar-web/src/main/js/app/components/global-search/__tests__/GlobalSearch-it.tsx @@ -19,10 +19,10 @@ */ import userEvent from '@testing-library/user-event'; import React from 'react'; -import { byRole, byText } from 'testing-library-selector'; import { getSuggestions } from '../../../../api/components'; import { mockRouter } from '../../../../helpers/testMocks'; import { renderComponent } from '../../../../helpers/testReactTestingUtils'; +import { byRole, byText } from '../../../../helpers/testSelector'; import GlobalSearch, { GlobalSearch as GlobalSearchWithoutRouter } from '../GlobalSearch'; jest.mock('../../../../api/components', () => ({ @@ -117,7 +117,8 @@ it('load more results', async () => { await user.keyboard('foo'); expect(getSuggestions).toHaveBeenLastCalledWith('foo', []); - (getSuggestions as jest.Mock).mockResolvedValueOnce({ + jest.mocked(getSuggestions).mockResolvedValueOnce({ + projects: [], results: [ { items: [ @@ -127,7 +128,6 @@ it('load more results', async () => { key: 'bar', match: 'Bar', name: 'Bar', - organization: 'org', project: 'bar', }, ], diff --git a/server/sonar-web/src/main/js/apps/account/__tests__/Account-it.tsx b/server/sonar-web/src/main/js/apps/account/__tests__/Account-it.tsx index dbacff25417..173e9fa7723 100644 --- a/server/sonar-web/src/main/js/apps/account/__tests__/Account-it.tsx +++ b/server/sonar-web/src/main/js/apps/account/__tests__/Account-it.tsx @@ -21,7 +21,6 @@ import { screen, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { UserEvent } from '@testing-library/user-event/dist/types/setup/setup'; import selectEvent from 'react-select-event'; -import { byRole, byText } from 'testing-library-selector'; import { getMyProjects, getScannableProjects } from '../../../api/components'; import NotificationsMock from '../../../api/mocks/NotificationsMock'; import UserTokensMock from '../../../api/mocks/UserTokensMock'; @@ -29,6 +28,7 @@ import { mockUserToken } from '../../../helpers/mocks/token'; import { setKeyboardShortcutEnabled } from '../../../helpers/preferences'; import { mockCurrentUser, mockLoggedInUser } from '../../../helpers/testMocks'; import { renderAppRoutes } from '../../../helpers/testReactTestingUtils'; +import { byRole, byText } from '../../../helpers/testSelector'; import { NotificationGlobalType, NotificationProjectType } from '../../../types/notifications'; import { Permissions } from '../../../types/permissions'; import { TokenType } from '../../../types/token'; diff --git a/server/sonar-web/src/main/js/apps/audit-logs/components/__tests__/AuditApp-it.tsx b/server/sonar-web/src/main/js/apps/audit-logs/components/__tests__/AuditApp-it.tsx index a015819f6d6..1eecde71085 100644 --- a/server/sonar-web/src/main/js/apps/audit-logs/components/__tests__/AuditApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/audit-logs/components/__tests__/AuditApp-it.tsx @@ -20,11 +20,11 @@ import { screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { getDate, getMonth, getYear, subDays } from 'date-fns'; -import { byPlaceholderText, byRole, byText } from 'testing-library-selector'; import SettingsServiceMock from '../../../../api/mocks/SettingsServiceMock'; import { now } from '../../../../helpers/dates'; import { getMonthName } from '../../../../helpers/l10n'; import { renderAppWithAdminContext } from '../../../../helpers/testReactTestingUtils'; +import { byPlaceholderText, byRole, byText } from '../../../../helpers/testSelector'; import { AdminPageExtension } from '../../../../types/extension'; import { SettingsKey } from '../../../../types/settings'; import routes from '../../routes'; diff --git a/server/sonar-web/src/main/js/apps/background-tasks/__tests__/BackgroundTasks-it.tsx b/server/sonar-web/src/main/js/apps/background-tasks/__tests__/BackgroundTasks-it.tsx index c13b0281b47..a0ab84e8311 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/__tests__/BackgroundTasks-it.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/__tests__/BackgroundTasks-it.tsx @@ -19,7 +19,6 @@ */ import { screen, waitFor, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import { byLabelText, byPlaceholderText, byRole, byText } from 'testing-library-selector'; import ComputeEngineServiceMock from '../../../api/mocks/ComputeEngineServiceMock'; import { parseDate } from '../../../helpers/dates'; import { mockAppState } from '../../../helpers/testMocks'; @@ -28,6 +27,7 @@ import { dateInputEvent, renderAppWithAdminContext, } from '../../../helpers/testReactTestingUtils'; +import { byLabelText, byPlaceholderText, byRole, byText } from '../../../helpers/testSelector'; import { EditionKey } from '../../../types/editions'; import { TaskStatuses, TaskTypes } from '../../../types/tasks'; import routes from '../routes'; @@ -47,7 +47,7 @@ describe('The Global background task page', () => { renderGlobalBackgroundTasksApp(); await ui.appLoaded(); - expect(within(ui.numberOfWorkers.get()).getByText('2')).toBeInTheDocument(); + expect(ui.numberOfWorkers(2).get()).toBeInTheDocument(); const editWorkersButton = screen.getByRole('button', { name: 'background_tasks.change_number_of_workers', @@ -72,7 +72,7 @@ describe('The Global background task page', () => { await user.click(within(modal).getByRole('button', { name: 'save' })); - expect(within(ui.numberOfWorkers.get()).getByText('4')).toBeInTheDocument(); + expect(ui.numberOfWorkers(4).get()).toBeInTheDocument(); }); it('should display the list of tasks', async () => { @@ -311,7 +311,8 @@ function getPageObject() { const selectors = { loading: byLabelText('loading'), pageHeading: byRole('heading', { name: 'background_tasks.page' }), - numberOfWorkers: byText('background_tasks.number_of_workers'), + numberOfWorkers: (count: number) => + byText('background_tasks.number_of_workers').byText(`${count}`), onlyLatestAnalysis: byRole('checkbox', { name: 'yes' }), search: byPlaceholderText('background_tasks.search_by_task_or_component'), fromDateInput: byRole('textbox', { name: 'start_date' }), diff --git a/server/sonar-web/src/main/js/apps/change-admin-password/__tests__/ChangeAdminPasswordApp-it.tsx b/server/sonar-web/src/main/js/apps/change-admin-password/__tests__/ChangeAdminPasswordApp-it.tsx index 01fa22603a4..f764ee14d99 100644 --- a/server/sonar-web/src/main/js/apps/change-admin-password/__tests__/ChangeAdminPasswordApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/change-admin-password/__tests__/ChangeAdminPasswordApp-it.tsx @@ -19,10 +19,10 @@ */ import userEvent from '@testing-library/user-event'; import * as React from 'react'; -import { byLabelText, byRole, byText } from 'testing-library-selector'; import { changePassword } from '../../../api/users'; import { mockAppState } from '../../../helpers/testMocks'; import { renderApp } from '../../../helpers/testReactTestingUtils'; +import { byLabelText, byRole, byText } from '../../../helpers/testSelector'; import { AppState } from '../../../types/appstate'; import ChangeAdminPasswordApp from '../ChangeAdminPasswordApp'; import { DEFAULT_ADMIN_PASSWORD } from '../constants'; diff --git a/server/sonar-web/src/main/js/apps/code/__tests__/Code-it.ts b/server/sonar-web/src/main/js/apps/code/__tests__/Code-it.ts index 61b202ab4dc..3c5d7607135 100644 --- a/server/sonar-web/src/main/js/apps/code/__tests__/Code-it.ts +++ b/server/sonar-web/src/main/js/apps/code/__tests__/Code-it.ts @@ -22,13 +22,13 @@ import userEvent from '@testing-library/user-event'; import { UserEvent } from '@testing-library/user-event/dist/types/setup/setup'; import { keyBy, times } from 'lodash'; import { act } from 'react-dom/test-utils'; -import { byRole, byText } from 'testing-library-selector'; import ComponentsServiceMock from '../../../api/mocks/ComponentsServiceMock'; import IssuesServiceMock from '../../../api/mocks/IssuesServiceMock'; import { isDiffMetric } from '../../../helpers/measures'; import { mockComponent } from '../../../helpers/mocks/component'; import { mockMeasure } from '../../../helpers/testMocks'; import { renderAppWithComponentContext } from '../../../helpers/testReactTestingUtils'; +import { ReactTestingQuery, byRole, byText } from '../../../helpers/testSelector'; import { ComponentQualifier } from '../../../types/component'; import { MetricKey } from '../../../types/metrics'; import { Component } from '../../../types/types'; @@ -235,7 +235,7 @@ it('should correctly show measures for a project', async () => { await ui.appLoaded(component.name); // Folder A - const folderRow = ui.measureRow(/folderA/).get(); + const folderRow = ui.measureRow(/folderA/); [ [MetricKey.ncloc, '2'], [MetricKey.bugs, '2'], @@ -249,7 +249,7 @@ it('should correctly show measures for a project', async () => { }); // index.tsx - const fileRow = ui.measureRow(/index\.tsx/).get(); + const fileRow = ui.measureRow(/index\.tsx/); [ [MetricKey.ncloc, '—'], [MetricKey.bugs, '—'], @@ -312,7 +312,7 @@ it('should correctly show new VS overall measures for Portfolios', async () => { expect(ui.newCodeBtn.get()).toHaveAttribute('aria-current', 'true'); // Child 1 - let child1Row = ui.measureRow(/^Child 1/).get(); + let child1Row = ui.measureRow(/^Child 1/); [ ['Releasability', 'OK'], ['Reliability', 'C'], @@ -326,7 +326,7 @@ it('should correctly show new VS overall measures for Portfolios', async () => { }); // Child 2 - let child2Row = ui.measureRow(/^Child 2/).get(); + let child2Row = ui.measureRow(/^Child 2/); [ ['Releasability', 'ERROR'], ['Reliability', '—'], @@ -343,7 +343,7 @@ it('should correctly show new VS overall measures for Portfolios', async () => { await ui.showOverallCode(); // Child 1 - child1Row = ui.measureRow(/^Child 1/).get(); + child1Row = ui.measureRow(/^Child 1/); [ ['Releasability', 'OK'], ['Reliability', 'B'], @@ -356,7 +356,7 @@ it('should correctly show new VS overall measures for Portfolios', async () => { }); // Child 2 - child2Row = ui.measureRow(/^Child 2/).get(); + child2Row = ui.measureRow(/^Child 2/); [ ['Releasability', 'ERROR'], ['Reliability', '—'], @@ -384,7 +384,7 @@ function getPageObject(user: UserEvent) { newCodeBtn: byRole('radio', { name: 'projects.view.new_code' }), overallCodeBtn: byRole('radio', { name: 'projects.view.overall_code' }), measureRow: (name: string | RegExp) => byRole('row', { name, exact: false }), - measureValueCell: (row: HTMLElement, name: string, value: string) => { + measureValueCell: (row: ReactTestingQuery, name: string, value: string) => { const i = Array.from(screen.getAllByRole('columnheader')).findIndex((c) => c.textContent?.includes(name) ); @@ -394,8 +394,7 @@ function getPageObject(user: UserEvent) { throw new Error(`Couldn't locate column with header ${name}`); } - const { getAllByRole } = within(row); - const cell = getAllByRole('cell').at(i); + const cell = row.byRole('cell').getAll().at(i); if (cell === undefined) { throw new Error(`Couldn't locate cell with value ${value} for header ${name}`); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/__tests__/CodingRules-it.ts b/server/sonar-web/src/main/js/apps/coding-rules/__tests__/CodingRules-it.ts index 75ce058a6f9..098dc46d64c 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/__tests__/CodingRules-it.ts +++ b/server/sonar-web/src/main/js/apps/coding-rules/__tests__/CodingRules-it.ts @@ -19,10 +19,10 @@ */ import { fireEvent, screen, waitFor, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import { byPlaceholderText, byRole } from 'testing-library-selector'; import CodingRulesServiceMock from '../../../api/mocks/CodingRulesServiceMock'; import { mockCurrentUser, mockLoggedInUser } from '../../../helpers/testMocks'; import { renderAppRoutes } from '../../../helpers/testReactTestingUtils'; +import { byPlaceholderText, byRole } from '../../../helpers/testSelector'; import { CurrentUser } from '../../../types/users'; import routes from '../routes'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/__tests__/ComponentMeasures-it.tsx b/server/sonar-web/src/main/js/apps/component-measures/__tests__/ComponentMeasures-it.tsx index afa8beb7fd1..86d197d88bb 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/__tests__/ComponentMeasures-it.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/__tests__/ComponentMeasures-it.tsx @@ -21,7 +21,6 @@ import { act, screen, waitFor, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { times } from 'lodash'; import selectEvent from 'react-select-event'; -import { byLabelText, byRole, byTestId, byText } from 'testing-library-selector'; import ComponentsServiceMock from '../../../api/mocks/ComponentsServiceMock'; import IssuesServiceMock from '../../../api/mocks/IssuesServiceMock'; import { MeasuresServiceMock } from '../../../api/mocks/MeasuresServiceMock'; @@ -29,6 +28,7 @@ import { mockPullRequest } from '../../../helpers/mocks/branch-like'; import { mockComponent } from '../../../helpers/mocks/component'; import { mockMeasure, mockMetric } from '../../../helpers/testMocks'; import { renderAppWithComponentContext } from '../../../helpers/testReactTestingUtils'; +import { byLabelText, byRole, byTestId, byText } from '../../../helpers/testSelector'; import { ComponentContextShape, ComponentQualifier } from '../../../types/component'; import { MetricKey } from '../../../types/metrics'; import routes from '../routes'; diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/Azure-it.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/Azure-it.tsx index db729469f48..a22e6d6b32f 100644 --- a/server/sonar-web/src/main/js/apps/create/project/__tests__/Azure-it.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/Azure-it.tsx @@ -22,12 +22,12 @@ import { act, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import * as React from 'react'; import selectEvent from 'react-select-event'; -import { byLabelText, byRole, byText } from 'testing-library-selector'; import { searchAzureRepositories } from '../../../../api/alm-integrations'; import AlmIntegrationsServiceMock from '../../../../api/mocks/AlmIntegrationsServiceMock'; import AlmSettingsServiceMock from '../../../../api/mocks/AlmSettingsServiceMock'; import NewCodePeriodsServiceMock from '../../../../api/mocks/NewCodePeriodsServiceMock'; import { renderApp } from '../../../../helpers/testReactTestingUtils'; +import { byLabelText, byRole, byText } from '../../../../helpers/testSelector'; import CreateProjectPage, { CreateProjectPageProps } from '../CreateProjectPage'; jest.mock('../../../../api/alm-integrations'); diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/Bitbucket-it.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/Bitbucket-it.tsx index d980905f2e9..17d513bfb5d 100644 --- a/server/sonar-web/src/main/js/apps/create/project/__tests__/Bitbucket-it.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/Bitbucket-it.tsx @@ -22,12 +22,12 @@ import { act, screen, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import * as React from 'react'; import selectEvent from 'react-select-event'; -import { byLabelText, byRole, byText } from 'testing-library-selector'; import { searchForBitbucketServerRepositories } from '../../../../api/alm-integrations'; import AlmIntegrationsServiceMock from '../../../../api/mocks/AlmIntegrationsServiceMock'; import AlmSettingsServiceMock from '../../../../api/mocks/AlmSettingsServiceMock'; import NewCodePeriodsServiceMock from '../../../../api/mocks/NewCodePeriodsServiceMock'; import { renderApp } from '../../../../helpers/testReactTestingUtils'; +import { byLabelText, byRole, byText } from '../../../../helpers/testSelector'; import CreateProjectPage, { CreateProjectPageProps } from '../CreateProjectPage'; jest.mock('../../../../api/alm-integrations'); diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketCloud-it.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketCloud-it.tsx index 376024a2e44..58796cf522d 100644 --- a/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketCloud-it.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketCloud-it.tsx @@ -22,12 +22,12 @@ import { act, screen, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import * as React from 'react'; import selectEvent from 'react-select-event'; -import { byLabelText, byRole, byText } from 'testing-library-selector'; import { searchForBitbucketCloudRepositories } from '../../../../api/alm-integrations'; import AlmIntegrationsServiceMock from '../../../../api/mocks/AlmIntegrationsServiceMock'; import AlmSettingsServiceMock from '../../../../api/mocks/AlmSettingsServiceMock'; import NewCodePeriodsServiceMock from '../../../../api/mocks/NewCodePeriodsServiceMock'; import { renderApp } from '../../../../helpers/testReactTestingUtils'; +import { byLabelText, byRole, byText } from '../../../../helpers/testSelector'; import CreateProjectPage, { CreateProjectPageProps } from '../CreateProjectPage'; jest.mock('../../../../api/alm-integrations'); diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/GitHub-it.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/GitHub-it.tsx index 0f2de817cb7..2662258a07b 100644 --- a/server/sonar-web/src/main/js/apps/create/project/__tests__/GitHub-it.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/GitHub-it.tsx @@ -22,12 +22,12 @@ import { screen, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import * as React from 'react'; import selectEvent from 'react-select-event'; -import { byLabelText, byText } from 'testing-library-selector'; import { getGithubRepositories } from '../../../../api/alm-integrations'; import AlmIntegrationsServiceMock from '../../../../api/mocks/AlmIntegrationsServiceMock'; import AlmSettingsServiceMock from '../../../../api/mocks/AlmSettingsServiceMock'; import NewCodePeriodsServiceMock from '../../../../api/mocks/NewCodePeriodsServiceMock'; import { renderApp } from '../../../../helpers/testReactTestingUtils'; +import { byLabelText, byText } from '../../../../helpers/testSelector'; import CreateProjectPage from '../CreateProjectPage'; jest.mock('../../../../api/alm-integrations'); diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/GitLab-it.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/GitLab-it.tsx index c3e0080516f..f53f2aef511 100644 --- a/server/sonar-web/src/main/js/apps/create/project/__tests__/GitLab-it.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/GitLab-it.tsx @@ -21,12 +21,12 @@ import { act, screen, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import * as React from 'react'; import selectEvent from 'react-select-event'; -import { byLabelText, byRole, byText } from 'testing-library-selector'; import { getGitlabProjects } from '../../../../api/alm-integrations'; import AlmIntegrationsServiceMock from '../../../../api/mocks/AlmIntegrationsServiceMock'; import AlmSettingsServiceMock from '../../../../api/mocks/AlmSettingsServiceMock'; import NewCodePeriodsServiceMock from '../../../../api/mocks/NewCodePeriodsServiceMock'; import { renderApp } from '../../../../helpers/testReactTestingUtils'; +import { byLabelText, byRole, byText } from '../../../../helpers/testSelector'; import CreateProjectPage, { CreateProjectPageProps } from '../CreateProjectPage'; jest.mock('../../../../api/alm-integrations'); @@ -94,9 +94,7 @@ it('should show import project feature when PAT is already set', async () => { expect(screen.getByText('Gitlab project 1')).toBeInTheDocument(); expect(screen.getByText('Gitlab project 2')).toBeInTheDocument(); - projectItem = screen.getByRole('row', { - name: 'qualifier.TRK Gitlab project 1 Company / Best Projects opens_in_new_window onboarding.create_project.gitlab.link onboarding.create_project.repository_imported', - }); + projectItem = screen.getByRole('row', { name: /Gitlab project 1/ }); expect( within(projectItem).getByText('onboarding.create_project.repository_imported') ).toBeInTheDocument(); diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/Manual-it.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/Manual-it.tsx index 06bb6cb7c3e..7fc9af55881 100644 --- a/server/sonar-web/src/main/js/apps/create/project/__tests__/Manual-it.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/Manual-it.tsx @@ -20,15 +20,15 @@ import userEvent from '@testing-library/user-event'; import { UserEvent } from '@testing-library/user-event/dist/types/setup/setup'; import * as React from 'react'; -import { byRole, byText } from 'testing-library-selector'; import AlmSettingsServiceMock from '../../../../api/mocks/AlmSettingsServiceMock'; +import NewCodePeriodsServiceMock from '../../../../api/mocks/NewCodePeriodsServiceMock'; import { getNewCodePeriod } from '../../../../api/newCodePeriod'; import { mockProject } from '../../../../helpers/mocks/projects'; import { mockAppState } from '../../../../helpers/testMocks'; import { renderApp } from '../../../../helpers/testReactTestingUtils'; +import { byRole, byText } from '../../../../helpers/testSelector'; import { NewCodePeriodSettingType } from '../../../../types/types'; import CreateProjectPage, { CreateProjectPageProps } from '../CreateProjectPage'; -import NewCodePeriodsServiceMock from '../../../../api/mocks/NewCodePeriodsServiceMock'; jest.mock('../../../../api/alm-settings'); jest.mock('../../../../api/newCodePeriod'); diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/ManualProjectCreate-test.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/ManualProjectCreate-test.tsx index 8bcecd0dd45..1bf27b9b489 100644 --- a/server/sonar-web/src/main/js/apps/create/project/__tests__/ManualProjectCreate-test.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/ManualProjectCreate-test.tsx @@ -20,9 +20,9 @@ import { screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import * as React from 'react'; -import { byRole } from 'testing-library-selector'; import { doesComponentExists } from '../../../../api/components'; import { renderComponent } from '../../../../helpers/testReactTestingUtils'; +import { byRole } from '../../../../helpers/testSelector'; import ManualProjectCreate from '../manual/ManualProjectCreate'; const ui = { diff --git a/server/sonar-web/src/main/js/apps/groups/__tests__/GroupsApp-it.tsx b/server/sonar-web/src/main/js/apps/groups/__tests__/GroupsApp-it.tsx index b18762192b5..3c8e2ef4a1c 100644 --- a/server/sonar-web/src/main/js/apps/groups/__tests__/GroupsApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/groups/__tests__/GroupsApp-it.tsx @@ -22,11 +22,11 @@ import { screen, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import * as React from 'react'; import { act } from 'react-dom/test-utils'; -import { byRole, byText } from 'testing-library-selector'; import AuthenticationServiceMock from '../../../api/mocks/AuthenticationServiceMock'; import GroupsServiceMock from '../../../api/mocks/GroupsServiceMock'; import { Provider } from '../../../components/hooks/useManageProvider'; import { renderApp } from '../../../helpers/testReactTestingUtils'; +import { byRole, byText } from '../../../helpers/testSelector'; import { Feature } from '../../../types/features'; import { TaskStatuses } from '../../../types/tasks'; import GroupsApp from '../GroupsApp'; diff --git a/server/sonar-web/src/main/js/apps/issues/__tests__/IssuesSourceViewer-it.tsx b/server/sonar-web/src/main/js/apps/issues/__tests__/IssuesSourceViewer-it.tsx index 59d2f52ade8..52d0908623e 100644 --- a/server/sonar-web/src/main/js/apps/issues/__tests__/IssuesSourceViewer-it.tsx +++ b/server/sonar-web/src/main/js/apps/issues/__tests__/IssuesSourceViewer-it.tsx @@ -19,7 +19,7 @@ */ import { screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import { byRole } from 'testing-library-selector'; +import { byRole } from '../../../helpers/testSelector'; import { componentsHandler, issuesHandler, diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/AssigneeSelect-test.tsx b/server/sonar-web/src/main/js/apps/issues/components/__tests__/AssigneeSelect-test.tsx index b471b83dc05..a2f9cc0c33a 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/AssigneeSelect-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/AssigneeSelect-test.tsx @@ -21,11 +21,11 @@ import { screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import * as React from 'react'; import { act } from 'react-dom/test-utils'; -import { byLabelText } from 'testing-library-selector'; import CurrentUserContextProvider from '../../../../app/components/current-user/CurrentUserContextProvider'; import { mockUserBase } from '../../../../helpers/mocks/users'; import { mockCurrentUser, mockIssue, mockLoggedInUser } from '../../../../helpers/testMocks'; import { renderComponent } from '../../../../helpers/testReactTestingUtils'; +import { byLabelText } from '../../../../helpers/testSelector'; import { CurrentUser } from '../../../../types/users'; import AssigneeSelect, { AssigneeSelectProps, MIN_QUERY_LENGTH } from '../AssigneeSelect'; diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/IssueSourceViewerHeader-test.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/IssueSourceViewerHeader-test.tsx index b8c65e22bb4..e758996e1fc 100644 --- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/IssueSourceViewerHeader-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/IssueSourceViewerHeader-test.tsx @@ -18,10 +18,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { byRole, byText } from 'testing-library-selector'; import { mockMainBranch } from '../../../../helpers/mocks/branch-like'; import { mockSourceViewerFile } from '../../../../helpers/mocks/sources'; import { renderComponent } from '../../../../helpers/testReactTestingUtils'; +import { byRole, byText } from '../../../../helpers/testSelector'; import IssueSourceViewerHeader, { Props } from '../IssueSourceViewerHeader'; const ui = { diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/SnippetViewer-test.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/SnippetViewer-test.tsx index df138d37b67..ac9da7c0565 100644 --- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/SnippetViewer-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/SnippetViewer-test.tsx @@ -20,9 +20,9 @@ import { screen } from '@testing-library/react'; import { range } from 'lodash'; import * as React from 'react'; -import { byRole } from 'testing-library-selector'; import { mockSourceLine, mockSourceViewerFile } from '../../../../helpers/mocks/sources'; import { renderComponent } from '../../../../helpers/testReactTestingUtils'; +import { byRole } from '../../../../helpers/testSelector'; import SnippetViewer, { SnippetViewerProps } from '../SnippetViewer'; beforeEach(() => { diff --git a/server/sonar-web/src/main/js/apps/issues/issues-subnavigation/__tests__/SubnavigationIssues-it.tsx b/server/sonar-web/src/main/js/apps/issues/issues-subnavigation/__tests__/SubnavigationIssues-it.tsx index 17826853c37..3962f6ba981 100644 --- a/server/sonar-web/src/main/js/apps/issues/issues-subnavigation/__tests__/SubnavigationIssues-it.tsx +++ b/server/sonar-web/src/main/js/apps/issues/issues-subnavigation/__tests__/SubnavigationIssues-it.tsx @@ -20,9 +20,9 @@ import { screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import * as React from 'react'; -import { byRole, byText } from 'testing-library-selector'; import { mockFlowLocation, mockIssue, mockPaging } from '../../../../helpers/testMocks'; import { renderComponent } from '../../../../helpers/testReactTestingUtils'; +import { byRole, byText } from '../../../../helpers/testSelector'; import { FCProps } from '../../../../helpers/testUtils'; import { FlowType, Issue } from '../../../../types/types'; import { VISIBLE_LOCATIONS_COLLAPSE } from '../IssueLocationsCrossFile'; diff --git a/server/sonar-web/src/main/js/apps/issues/test-utils.tsx b/server/sonar-web/src/main/js/apps/issues/test-utils.tsx index ced46d9607c..77f8033af10 100644 --- a/server/sonar-web/src/main/js/apps/issues/test-utils.tsx +++ b/server/sonar-web/src/main/js/apps/issues/test-utils.tsx @@ -19,12 +19,12 @@ */ import { waitFor } from '@testing-library/react'; import React from 'react'; -import { byLabelText, byPlaceholderText, byRole, byTestId } from 'testing-library-selector'; import ComponentsServiceMock from '../../api/mocks/ComponentsServiceMock'; import IssuesServiceMock from '../../api/mocks/IssuesServiceMock'; import { mockComponent } from '../../helpers/mocks/component'; import { mockCurrentUser } from '../../helpers/testMocks'; import { renderApp, renderAppWithComponentContext } from '../../helpers/testReactTestingUtils'; +import { byLabelText, byPlaceholderText, byRole, byTestId } from '../../helpers/testSelector'; import { Component } from '../../types/types'; import { CurrentUser } from '../../types/users'; import IssuesApp from './components/IssuesApp'; diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/__tests__/PermissionTemplatesApp-it.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/__tests__/PermissionTemplatesApp-it.tsx index a4d8002edb9..412d3bd93ff 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/__tests__/PermissionTemplatesApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/__tests__/PermissionTemplatesApp-it.tsx @@ -21,7 +21,6 @@ import { act, screen, waitFor, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { UserEvent } from '@testing-library/user-event/dist/types/setup/setup'; import { uniq } from 'lodash'; -import { byLabelText, byRole } from 'testing-library-selector'; import PermissionsServiceMock from '../../../../api/mocks/PermissionsServiceMock'; import { mockPermissionGroup, mockPermissionUser } from '../../../../helpers/mocks/permissions'; import { PERMISSIONS_ORDER_FOR_PROJECT_TEMPLATE } from '../../../../helpers/permissions'; @@ -30,6 +29,7 @@ import { findTooltipWithContent, renderAppWithAdminContext, } from '../../../../helpers/testReactTestingUtils'; +import { byLabelText, byRole } from '../../../../helpers/testSelector'; import { ComponentQualifier } from '../../../../types/component'; import { Permissions } from '../../../../types/permissions'; import { PermissionGroup, PermissionUser } from '../../../../types/types'; diff --git a/server/sonar-web/src/main/js/apps/permissions/test-utils.ts b/server/sonar-web/src/main/js/apps/permissions/test-utils.ts index eab1858e81f..9d6cc707c76 100644 --- a/server/sonar-web/src/main/js/apps/permissions/test-utils.ts +++ b/server/sonar-web/src/main/js/apps/permissions/test-utils.ts @@ -20,7 +20,7 @@ import { waitFor } from '@testing-library/react'; import { UserEvent } from '@testing-library/user-event/dist/types/setup/setup'; import selectEvent from 'react-select-event'; -import { byLabelText, byRole, byText } from 'testing-library-selector'; +import { byLabelText, byRole, byText } from '../../helpers/testSelector'; import { Visibility } from '../../types/component'; import { Permissions } from '../../types/permissions'; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityApp-it.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityApp-it.tsx index 87132b7d8bf..f1c8eeb9311 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityApp-it.tsx @@ -25,7 +25,6 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; import { Route } from 'react-router-dom'; import selectEvent from 'react-select-event'; -import { byLabelText, byRole, byText } from 'testing-library-selector'; import { ProjectActivityServiceMock } from '../../../../api/mocks/ProjectActivityServiceMock'; import { TimeMachineServiceMock } from '../../../../api/mocks/TimeMachineServiceMock'; import { parseDate } from '../../../../helpers/dates'; @@ -42,6 +41,7 @@ import { dateInputEvent, renderAppWithComponentContext, } from '../../../../helpers/testReactTestingUtils'; +import { byLabelText, byRole, byText } from '../../../../helpers/testSelector'; import { ComponentQualifier } from '../../../../types/component'; import { MetricKey, MetricType } from '../../../../types/metrics'; import { diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/ProjectBaselineApp-it.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/ProjectBaselineApp-it.tsx index c51eb64863a..c26cbc5c972 100644 --- a/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/ProjectBaselineApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/ProjectBaselineApp-it.tsx @@ -21,7 +21,6 @@ import { within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { first, last } from 'lodash'; import selectEvent from 'react-select-event'; -import { byRole, byText } from 'testing-library-selector'; import NewCodePeriodsServiceMock from '../../../../api/mocks/NewCodePeriodsServiceMock'; import { ProjectActivityServiceMock } from '../../../../api/mocks/ProjectActivityServiceMock'; import { mockBranch } from '../../../../helpers/mocks/branch-like'; @@ -29,9 +28,10 @@ import { mockComponent } from '../../../../helpers/mocks/component'; import { mockNewCodePeriodBranch } from '../../../../helpers/mocks/new-code-period'; import { mockAppState } from '../../../../helpers/testMocks'; import { - renderAppWithComponentContext, RenderContext, + renderAppWithComponentContext, } from '../../../../helpers/testReactTestingUtils'; +import { byRole, byText } from '../../../../helpers/testSelector'; import { Feature } from '../../../../types/features'; import { NewCodePeriodSettingType } from '../../../../types/types'; import routes from '../../routes'; diff --git a/server/sonar-web/src/main/js/apps/projectBranches/__tests__/ProjectBranchesApp-it.tsx b/server/sonar-web/src/main/js/apps/projectBranches/__tests__/ProjectBranchesApp-it.tsx index 749c5c8830d..9c8ebf99afe 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/__tests__/ProjectBranchesApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/__tests__/ProjectBranchesApp-it.tsx @@ -21,7 +21,6 @@ import { act, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React, { useEffect, useState } from 'react'; -import { byRole } from 'testing-library-selector'; import BranchesServiceMock from '../../../api/mocks/BranchesServiceMock'; import SettingsServiceMock from '../../../api/mocks/SettingsServiceMock'; import BranchStatusContextProvider from '../../../app/components/branch-status/BranchStatusContextProvider'; @@ -30,6 +29,7 @@ import { ComponentContext } from '../../../app/components/componentContext/Compo import { mockComponent } from '../../../helpers/mocks/component'; import { mockAppState } from '../../../helpers/testMocks'; import { renderComponent } from '../../../helpers/testReactTestingUtils'; +import { byRole } from '../../../helpers/testSelector'; import { AppState } from '../../../types/appstate'; import { BranchLike } from '../../../types/branch-like'; import { SettingsKey } from '../../../types/settings'; diff --git a/server/sonar-web/src/main/js/apps/projectDump/__tests__/ProjectDumpApp-it.tsx b/server/sonar-web/src/main/js/apps/projectDump/__tests__/ProjectDumpApp-it.tsx index b0ae3c87562..e926d657f91 100644 --- a/server/sonar-web/src/main/js/apps/projectDump/__tests__/ProjectDumpApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/projectDump/__tests__/ProjectDumpApp-it.tsx @@ -19,11 +19,11 @@ */ import { screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import { byRole, byText } from 'testing-library-selector'; import ComputeEngineServiceMock from '../../../api/mocks/ComputeEngineServiceMock'; import { ProjectDumpServiceMock } from '../../../api/mocks/ProjectDumpServiceMock'; import { mockComponent } from '../../../helpers/mocks/component'; import { renderAppWithComponentContext } from '../../../helpers/testReactTestingUtils'; +import { byRole, byText } from '../../../helpers/testSelector'; import { Feature } from '../../../types/features'; import { TaskStatuses, TaskTypes } from '../../../types/tasks'; import routes from '../routes'; diff --git a/server/sonar-web/src/main/js/apps/projectKey/__tests__/ProjectKeyApp-it.tsx b/server/sonar-web/src/main/js/apps/projectKey/__tests__/ProjectKeyApp-it.tsx index c01b73576d8..74ac67a5f49 100644 --- a/server/sonar-web/src/main/js/apps/projectKey/__tests__/ProjectKeyApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/projectKey/__tests__/ProjectKeyApp-it.tsx @@ -23,9 +23,9 @@ import { last } from 'lodash'; import React from 'react'; import { act } from 'react-dom/test-utils'; import { Route } from 'react-router-dom'; -import { byRole } from 'testing-library-selector'; import ComponentsServiceMock from '../../../api/mocks/ComponentsServiceMock'; import { renderAppWithComponentContext } from '../../../helpers/testReactTestingUtils'; +import { byRole } from '../../../helpers/testSelector'; import ProjectKeyApp from '../ProjectKeyApp'; const componentsMock = new ComponentsServiceMock(); diff --git a/server/sonar-web/src/main/js/apps/projectLinks/__tests__/ProjectLinksApp-it.tsx b/server/sonar-web/src/main/js/apps/projectLinks/__tests__/ProjectLinksApp-it.tsx index 317ccea3a18..0eb160dbf01 100644 --- a/server/sonar-web/src/main/js/apps/projectLinks/__tests__/ProjectLinksApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/projectLinks/__tests__/ProjectLinksApp-it.tsx @@ -21,10 +21,10 @@ import userEvent from '@testing-library/user-event'; import { last } from 'lodash'; import React from 'react'; import { Route } from 'react-router-dom'; -import { byRole, byText } from 'testing-library-selector'; import ProjectLinksServiceMock from '../../../api/mocks/ProjectLinksServiceMock'; import { mockComponent } from '../../../helpers/mocks/component'; import { renderAppWithComponentContext } from '../../../helpers/testReactTestingUtils'; +import { byRole, byText } from '../../../helpers/testSelector'; import ProjectLinksApp from '../ProjectLinksApp'; jest.mock('../../../api/projectLinks'); diff --git a/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/ProjectQualityGateApp-it.tsx b/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/ProjectQualityGateApp-it.tsx index 2865c4b984a..6fbfac1660a 100644 --- a/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/ProjectQualityGateApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/ProjectQualityGateApp-it.tsx @@ -19,7 +19,6 @@ */ import userEvent from '@testing-library/user-event'; import selectEvent from 'react-select-event'; -import { byRole, byText } from 'testing-library-selector'; import { QualityGatesServiceMock } from '../../../api/mocks/QualityGatesServiceMock'; import handleRequiredAuthorization from '../../../app/utils/handleRequiredAuthorization'; import { mockComponent } from '../../../helpers/mocks/component'; @@ -27,6 +26,7 @@ import { RenderContext, renderAppWithComponentContext, } from '../../../helpers/testReactTestingUtils'; +import { byRole, byText } from '../../../helpers/testSelector'; import { Component } from '../../../types/types'; import routes from '../routes'; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/__tests__/QualityProfilesApp-it.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/__tests__/QualityProfilesApp-it.tsx index 4ada7aae19b..a3fa9b46259 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/__tests__/QualityProfilesApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/__tests__/QualityProfilesApp-it.tsx @@ -20,10 +20,10 @@ import { act, getByText } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import selectEvent from 'react-select-event'; -import { byRole } from 'testing-library-selector'; import QualityProfilesServiceMock from '../../../api/mocks/QualityProfilesServiceMock'; import { mockPaging, mockRule } from '../../../helpers/testMocks'; import { renderAppRoutes } from '../../../helpers/testReactTestingUtils'; +import { byRole } from '../../../helpers/testSelector'; import routes from '../routes'; jest.mock('../../../api/quality-profiles'); diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/__tests__/SecurityHotspotsApp-it.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/__tests__/SecurityHotspotsApp-it.tsx index 086527df353..69f8f057701 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/__tests__/SecurityHotspotsApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/__tests__/SecurityHotspotsApp-it.tsx @@ -21,7 +21,6 @@ import { act, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; import { Route } from 'react-router-dom'; -import { byDisplayValue, byRole, byTestId, byText } from 'testing-library-selector'; import CodingRulesServiceMock from '../../../api/mocks/CodingRulesServiceMock'; import SecurityHotspotServiceMock from '../../../api/mocks/SecurityHotspotServiceMock'; import { getSecurityHotspots, setSecurityHotspotStatus } from '../../../api/security-hotspots'; @@ -32,6 +31,7 @@ import { openHotspot, probeSonarLintServers } from '../../../helpers/sonarlint'; import { get, save } from '../../../helpers/storage'; import { mockLoggedInUser } from '../../../helpers/testMocks'; import { renderAppWithComponentContext } from '../../../helpers/testReactTestingUtils'; +import { byDisplayValue, byRole, byTestId, byText } from '../../../helpers/testSelector'; import { ComponentContextShape } from '../../../types/component'; import SecurityHotspotsApp from '../SecurityHotspotsApp'; import useScrollDownCompress from '../hooks/useScrollDownCompress'; diff --git a/server/sonar-web/src/main/js/apps/settings/components/__tests__/AnalysisScope-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/__tests__/AnalysisScope-test.tsx index c3ca56437c3..a57e0876dba 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/__tests__/AnalysisScope-test.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/__tests__/AnalysisScope-test.tsx @@ -19,12 +19,12 @@ */ import { uniq } from 'lodash'; import * as React from 'react'; -import { byRole, byText } from 'testing-library-selector'; import SettingsServiceMock, { DEFAULT_DEFINITIONS_MOCK, } from '../../../../api/mocks/SettingsServiceMock'; import { mockComponent } from '../../../../helpers/mocks/component'; import { renderComponent } from '../../../../helpers/testReactTestingUtils'; +import { byRole, byText } from '../../../../helpers/testSelector'; import { AdditionalCategoryComponentProps } from '../AdditionalCategories'; import { AnalysisScope } from '../AnalysisScope'; diff --git a/server/sonar-web/src/main/js/apps/settings/components/__tests__/Definition-it.tsx b/server/sonar-web/src/main/js/apps/settings/components/__tests__/Definition-it.tsx index 6abf3403c8a..9e872e76ef3 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/__tests__/Definition-it.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/__tests__/Definition-it.tsx @@ -22,13 +22,13 @@ import userEvent from '@testing-library/user-event'; import { last } from 'lodash'; import React from 'react'; import selectEvent from 'react-select-event'; -import { byLabelText, byRole, byText } from 'testing-library-selector'; import SettingsServiceMock, { DEFAULT_DEFINITIONS_MOCK, } from '../../../../api/mocks/SettingsServiceMock'; import { mockComponent } from '../../../../helpers/mocks/component'; import { mockDefinition } from '../../../../helpers/mocks/settings'; import { renderComponent } from '../../../../helpers/testReactTestingUtils'; +import { byLabelText, byRole, byText } from '../../../../helpers/testSelector'; import { ExtendedSettingDefinition, SettingType, SettingValue } from '../../../../types/settings'; import { Component } from '../../../../types/types'; import Definition from '../Definition'; diff --git a/server/sonar-web/src/main/js/apps/settings/components/__tests__/Languages-it.tsx b/server/sonar-web/src/main/js/apps/settings/components/__tests__/Languages-it.tsx index a2dbdd092f9..b2e09b51263 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/__tests__/Languages-it.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/__tests__/Languages-it.tsx @@ -21,12 +21,12 @@ import { screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { last } from 'lodash'; import React from 'react'; -import { byRole, byText } from 'testing-library-selector'; import SettingsServiceMock, { DEFAULT_DEFINITIONS_MOCK, } from '../../../../api/mocks/SettingsServiceMock'; import { mockComponent } from '../../../../helpers/mocks/component'; import { renderApp } from '../../../../helpers/testReactTestingUtils'; +import { byRole, byText } from '../../../../helpers/testSelector'; import { AdditionalCategoryComponentProps } from '../AdditionalCategories'; import Languages from '../Languages'; diff --git a/server/sonar-web/src/main/js/apps/settings/components/__tests__/NewCodePeriod-it.tsx b/server/sonar-web/src/main/js/apps/settings/components/__tests__/NewCodePeriod-it.tsx index 406b219b470..f8aba024f2e 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/__tests__/NewCodePeriod-it.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/__tests__/NewCodePeriod-it.tsx @@ -20,9 +20,9 @@ import { screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import * as React from 'react'; -import { byRole, byText } from 'testing-library-selector'; import NewCodePeriodsServiceMock from '../../../../api/mocks/NewCodePeriodsServiceMock'; import { renderComponent } from '../../../../helpers/testReactTestingUtils'; +import { byRole, byText } from '../../../../helpers/testSelector'; import { NewCodePeriodSettingType } from '../../../../types/types'; import NewCodePeriod from '../NewCodePeriod'; diff --git a/server/sonar-web/src/main/js/apps/settings/components/__tests__/SettingsApp-it.tsx b/server/sonar-web/src/main/js/apps/settings/components/__tests__/SettingsApp-it.tsx index d86504bdef6..cc4622d85d3 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/__tests__/SettingsApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/__tests__/SettingsApp-it.tsx @@ -22,7 +22,6 @@ import userEvent from '@testing-library/user-event'; import React from 'react'; import { Route } from 'react-router-dom'; import selectEvent from 'react-select-event'; -import { byRole } from 'testing-library-selector'; import SettingsServiceMock from '../../../../api/mocks/SettingsServiceMock'; import { KeyboardKeys } from '../../../../helpers/keycodes'; import { mockComponent } from '../../../../helpers/mocks/component'; @@ -31,6 +30,7 @@ import { renderAppWithComponentContext, RenderContext, } from '../../../../helpers/testReactTestingUtils'; +import { byRole } from '../../../../helpers/testSelector'; import { Feature } from '../../../../types/features'; import { Component } from '../../../../types/types'; import routes from '../../routes'; diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionForm-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionForm-test.tsx index bf4bce05fa0..7bd6b1295d9 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionForm-test.tsx @@ -19,9 +19,9 @@ */ import userEvent from '@testing-library/user-event'; import React from 'react'; -import { byRole, byText } from 'testing-library-selector'; import AlmSettingsServiceMock from '../../../../../api/mocks/AlmSettingsServiceMock'; import { renderComponent } from '../../../../../helpers/testReactTestingUtils'; +import { byRole, byText } from '../../../../../helpers/testSelector'; import { AlmKeys } from '../../../../../types/alm-settings'; import AlmBindingDefinitionForm, { AlmBindingDefinitionFormProps, diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-it.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-it.tsx index 5d7308fa443..c811df5d983 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-it.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-it.tsx @@ -20,10 +20,10 @@ import { screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; -import { byRole, byText } from 'testing-library-selector'; import AlmSettingsServiceMock from '../../../../../api/mocks/AlmSettingsServiceMock'; import { AvailableFeaturesContext } from '../../../../../app/components/available-features/AvailableFeaturesContext'; import { renderComponent } from '../../../../../helpers/testReactTestingUtils'; +import { byRole, byText } from '../../../../../helpers/testSelector'; import { AlmKeys } from '../../../../../types/alm-settings'; import { Feature } from '../../../../../types/features'; import AlmIntegration from '../AlmIntegration'; diff --git a/server/sonar-web/src/main/js/apps/settings/components/authentication/__tests__/Authentication-it.tsx b/server/sonar-web/src/main/js/apps/settings/components/authentication/__tests__/Authentication-it.tsx index a3b51f575eb..445d35ded8a 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/authentication/__tests__/Authentication-it.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/authentication/__tests__/Authentication-it.tsx @@ -21,7 +21,6 @@ import { act, screen, waitFor, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { UserEvent } from '@testing-library/user-event/dist/types/setup/setup'; import React from 'react'; -import { byRole, byText } from 'testing-library-selector'; import AuthenticationServiceMock from '../../../../../api/mocks/AuthenticationServiceMock'; import ComputeEngineServiceMock from '../../../../../api/mocks/ComputeEngineServiceMock'; import SettingsServiceMock from '../../../../../api/mocks/SettingsServiceMock'; @@ -29,6 +28,7 @@ import SystemServiceMock from '../../../../../api/mocks/SystemServiceMock'; import { AvailableFeaturesContext } from '../../../../../app/components/available-features/AvailableFeaturesContext'; import { definitions } from '../../../../../helpers/mocks/definitions-list'; import { renderComponent } from '../../../../../helpers/testReactTestingUtils'; +import { byRole, byText } from '../../../../../helpers/testSelector'; import { Feature } from '../../../../../types/features'; import { GitHubProvisioningStatus } from '../../../../../types/provisioning'; import { TaskStatuses } from '../../../../../types/tasks'; diff --git a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecorationBinding/__tests__/PRDecorationBinding-it.tsx b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecorationBinding/__tests__/PRDecorationBinding-it.tsx index 76feb1ec980..e37aff3ec47 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecorationBinding/__tests__/PRDecorationBinding-it.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecorationBinding/__tests__/PRDecorationBinding-it.tsx @@ -20,12 +20,12 @@ import userEvent from '@testing-library/user-event'; import React from 'react'; import selectEvent from 'react-select-event'; -import { byRole, byText } from 'testing-library-selector'; import AlmSettingsServiceMock from '../../../../../api/mocks/AlmSettingsServiceMock'; import CurrentUserContextProvider from '../../../../../app/components/current-user/CurrentUserContextProvider'; import { mockComponent } from '../../../../../helpers/mocks/component'; import { mockCurrentUser } from '../../../../../helpers/testMocks'; import { renderComponent } from '../../../../../helpers/testReactTestingUtils'; +import { byRole, byText } from '../../../../../helpers/testSelector'; import { AlmKeys, ProjectAlmBindingConfigurationErrorScope, diff --git a/server/sonar-web/src/main/js/apps/settings/encryption/__tests__/EncryptionApp-it.tsx b/server/sonar-web/src/main/js/apps/settings/encryption/__tests__/EncryptionApp-it.tsx index 8cec5e46fa3..bc1c67b1d7a 100644 --- a/server/sonar-web/src/main/js/apps/settings/encryption/__tests__/EncryptionApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/settings/encryption/__tests__/EncryptionApp-it.tsx @@ -19,9 +19,9 @@ */ import userEvent from '@testing-library/user-event'; import React from 'react'; -import { byRole } from 'testing-library-selector'; import SettingsServiceMock from '../../../../api/mocks/SettingsServiceMock'; import { renderComponent } from '../../../../helpers/testReactTestingUtils'; +import { byRole } from '../../../../helpers/testSelector'; import EncryptionApp from '../EncryptionApp'; let settingsMock: SettingsServiceMock; diff --git a/server/sonar-web/src/main/js/apps/system/components/__tests__/SystemApp-it.tsx b/server/sonar-web/src/main/js/apps/system/components/__tests__/SystemApp-it.tsx index 79d23690ab7..f1ec48b95f0 100644 --- a/server/sonar-web/src/main/js/apps/system/components/__tests__/SystemApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/system/components/__tests__/SystemApp-it.tsx @@ -20,9 +20,9 @@ import { screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { first } from 'lodash'; -import { byRole, byText } from 'testing-library-selector'; import SystemServiceMock from '../../../../api/mocks/SystemServiceMock'; import { renderAppRoutes } from '../../../../helpers/testReactTestingUtils'; +import { byRole, byText } from '../../../../helpers/testSelector'; import routes from '../../routes'; import { LogsLevels } from '../../utils'; 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 2ffddececf8..2129f201339 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,12 +17,12 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -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 { mockCurrentUser, mockLoggedInUser } from '../../../../helpers/testMocks'; import { renderAppRoutes } from '../../../../helpers/testReactTestingUtils'; +import { byLabelText, byRole } from '../../../../helpers/testSelector'; import { Permissions } from '../../../../types/permissions'; import routes from '../../routes'; diff --git a/server/sonar-web/src/main/js/apps/users/__tests__/UsersApp-it.tsx b/server/sonar-web/src/main/js/apps/users/__tests__/UsersApp-it.tsx index 20043e921b4..3ca72375a73 100644 --- a/server/sonar-web/src/main/js/apps/users/__tests__/UsersApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/users/__tests__/UsersApp-it.tsx @@ -22,7 +22,6 @@ import { act, screen, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import * as React from 'react'; import selectEvent from 'react-select-event'; -import { byLabelText, byRole, byText } from 'testing-library-selector'; import AuthenticationServiceMock from '../../../api/mocks/AuthenticationServiceMock'; import ComponentsServiceMock from '../../../api/mocks/ComponentsServiceMock'; import SettingsServiceMock from '../../../api/mocks/SettingsServiceMock'; @@ -30,6 +29,7 @@ import UserTokensMock from '../../../api/mocks/UserTokensMock'; import UsersServiceMock from '../../../api/mocks/UsersServiceMock'; import { mockCurrentUser, mockLoggedInUser } from '../../../helpers/testMocks'; import { renderApp } from '../../../helpers/testReactTestingUtils'; +import { byLabelText, byRole, byText } from '../../../helpers/testSelector'; import { Feature } from '../../../types/features'; import { TaskStatuses } from '../../../types/tasks'; import { ChangePasswordResults, CurrentUser } from '../../../types/users'; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewer-it.tsx b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewer-it.tsx index 3f11fccd9d1..e067668bf1e 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewer-it.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewer-it.tsx @@ -21,12 +21,12 @@ import { queryHelpers, screen, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import * as React from 'react'; import { act } from 'react-dom/test-utils'; -import { byText } from 'testing-library-selector'; import ComponentsServiceMock from '../../../api/mocks/ComponentsServiceMock'; import IssuesServiceMock from '../../../api/mocks/IssuesServiceMock'; import { HttpStatus } from '../../../helpers/request'; import { mockIssue } from '../../../helpers/testMocks'; import { renderComponent } from '../../../helpers/testReactTestingUtils'; +import { byText } from '../../../helpers/testSelector'; import SourceViewer from '../SourceViewer'; import loadIssues from '../helpers/loadIssues'; diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/ActivityGraph-it.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/ActivityGraph-it.tsx index c967173eb99..c4256bf96f8 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/ActivityGraph-it.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/ActivityGraph-it.tsx @@ -22,11 +22,11 @@ import userEvent from '@testing-library/user-event'; import { times } from 'lodash'; import * as React from 'react'; import selectEvent from 'react-select-event'; -import { byLabelText, byPlaceholderText, byRole, byText } from 'testing-library-selector'; import { parseDate } from '../../../helpers/dates'; import { mockHistoryItem, mockMeasureHistory } from '../../../helpers/mocks/project-activity'; import { mockMetric } from '../../../helpers/testMocks'; import { renderComponent } from '../../../helpers/testReactTestingUtils'; +import { byLabelText, byPlaceholderText, byRole, byText } from '../../../helpers/testSelector'; import { MetricKey } from '../../../types/metrics'; import { GraphType, MeasureHistory } from '../../../types/project-activity'; import { Metric } from '../../../types/types'; diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/EventInner-it.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/EventInner-it.tsx index daa09bcfc8f..46540d728c7 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/EventInner-it.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/EventInner-it.tsx @@ -21,11 +21,11 @@ import { screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import * as React from 'react'; import { Route } from 'react-router-dom'; -import { byRole, byText } from 'testing-library-selector'; import { isMainBranch } from '../../../helpers/branch-like'; import { mockBranch, mockMainBranch } from '../../../helpers/mocks/branch-like'; import { mockAnalysisEvent } from '../../../helpers/mocks/project-activity'; import { renderAppWithComponentContext } from '../../../helpers/testReactTestingUtils'; +import { byRole, byText } from '../../../helpers/testSelector'; import { BranchLike } from '../../../types/branch-like'; import { ComponentContextShape } from '../../../types/component'; import { diff --git a/server/sonar-web/src/main/js/components/common/__tests__/DocumentationTooltip-test.tsx b/server/sonar-web/src/main/js/components/common/__tests__/DocumentationTooltip-test.tsx index 197fd1c97b4..d0523e90963 100644 --- a/server/sonar-web/src/main/js/components/common/__tests__/DocumentationTooltip-test.tsx +++ b/server/sonar-web/src/main/js/components/common/__tests__/DocumentationTooltip-test.tsx @@ -19,7 +19,7 @@ */ import userEvent from '@testing-library/user-event'; import * as React from 'react'; -import { byRole, byTestId } from 'testing-library-selector'; +import { byRole, byTestId } from '../../../helpers/testSelector'; import { renderComponent } from '../../../helpers/testReactTestingUtils'; import DocumentationTooltip, { DocumentationTooltipProps } from '../DocumentationTooltip'; diff --git a/server/sonar-web/src/main/js/components/common/__tests__/MultiSelect-test.tsx b/server/sonar-web/src/main/js/components/common/__tests__/MultiSelect-test.tsx index 2c9db394bbd..88b5403f22b 100644 --- a/server/sonar-web/src/main/js/components/common/__tests__/MultiSelect-test.tsx +++ b/server/sonar-web/src/main/js/components/common/__tests__/MultiSelect-test.tsx @@ -20,7 +20,7 @@ import { render } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import * as React from 'react'; -import { byRole, byText } from 'testing-library-selector'; +import { byRole, byText } from '../../../helpers/testSelector'; import MultiSelect from '../MultiSelect'; const ui = { diff --git a/server/sonar-web/src/main/js/components/controls/__tests__/Toggler-test.tsx b/server/sonar-web/src/main/js/components/controls/__tests__/Toggler-test.tsx index 061ce0d6ea8..827d0bb6de2 100644 --- a/server/sonar-web/src/main/js/components/controls/__tests__/Toggler-test.tsx +++ b/server/sonar-web/src/main/js/components/controls/__tests__/Toggler-test.tsx @@ -21,7 +21,7 @@ import { act, render } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { UserEvent } from '@testing-library/user-event/dist/types/setup/setup'; import * as React from 'react'; -import { byRole } from 'testing-library-selector'; +import { byRole } from '../../../helpers/testSelector'; import Toggler from '../Toggler'; beforeAll(() => { diff --git a/server/sonar-web/src/main/js/components/issue/__tests__/Issue-it.tsx b/server/sonar-web/src/main/js/components/issue/__tests__/Issue-it.tsx index 96517b9dc68..9c116a3ac7b 100644 --- a/server/sonar-web/src/main/js/components/issue/__tests__/Issue-it.tsx +++ b/server/sonar-web/src/main/js/components/issue/__tests__/Issue-it.tsx @@ -22,11 +22,11 @@ import { act, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { omit, pick } from 'lodash'; import * as React from 'react'; -import { byLabelText, byRole, byText } from 'testing-library-selector'; import IssuesServiceMock from '../../../api/mocks/IssuesServiceMock'; import { KeyboardKeys } from '../../../helpers/keycodes'; import { mockIssue, mockLoggedInUser, mockRawIssue } from '../../../helpers/testMocks'; import { findTooltipWithContent, renderApp } from '../../../helpers/testReactTestingUtils'; +import { byLabelText, byRole, byText } from '../../../helpers/testSelector'; import { IssueActions, IssueSeverity, 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 bc2e9c8b811..ce925bf9437 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 @@ -21,7 +21,6 @@ import { screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { UserEvent } from '@testing-library/user-event/dist/types/setup/setup'; import * as React from 'react'; -import { byLabelText, byRole, byText } from 'testing-library-selector'; import { getAlmSettingsNoCatch } from '../../../api/alm-settings'; import { getScannableProjects } from '../../../api/components'; import SettingsServiceMock from '../../../api/mocks/SettingsServiceMock'; @@ -33,6 +32,7 @@ import { import { mockComponent } from '../../../helpers/mocks/component'; import { mockLoggedInUser } from '../../../helpers/testMocks'; import { renderApp } from '../../../helpers/testReactTestingUtils'; +import { byLabelText, byRole, byText } from '../../../helpers/testSelector'; import { AlmKeys } from '../../../types/alm-settings'; import { Feature } from '../../../types/features'; import { Permissions } from '../../../types/permissions'; 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 b42006e882f..afd7e458101 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 @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { byRole } from 'testing-library-selector'; import { renderComponent } from '../../../../helpers/testReactTestingUtils'; +import { byRole } from '../../../../helpers/testSelector'; import { OSs, TutorialModes } from '../../types'; import GithubCFamilyExampleRepositories, { GithubCFamilyExampleRepositoriesProps, 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 index 60c73e54192..0031a56f1dd 100644 --- 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 @@ -20,11 +20,11 @@ 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 { RenderContext, renderApp } from '../../../../helpers/testReactTestingUtils'; +import { byRole, byText } from '../../../../helpers/testSelector'; import { AlmKeys } from '../../../../types/alm-settings'; import { Feature } from '../../../../types/features'; import { 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 f91ff4835ce..e0cc60ca784 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 @@ -21,11 +21,11 @@ import userEvent from '@testing-library/user-event'; import React from 'react'; import selectEvent from 'react-select-event'; -import { byRole, byText } from 'testing-library-selector'; 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 { RenderContext, renderApp } from '../../../../helpers/testReactTestingUtils'; +import { byRole, byText } from '../../../../helpers/testSelector'; import { getCopyToClipboardValue, getTutorialActionButtons, 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 4fa5d81d13d..0ccebaa586a 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,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { screen } from '@testing-library/react'; -import { byRole, byText } from 'testing-library-selector'; +import { byRole, byText } from '../../helpers/testSelector'; import { BuildTools, GradleBuildDSL, OSs, TutorialModes } from './types'; const CI_TRANSLATE_MAP: Partial> = { diff --git a/server/sonar-web/src/main/js/helpers/testSelector.ts b/server/sonar-web/src/main/js/helpers/testSelector.ts new file mode 100644 index 00000000000..e558c9ce014 --- /dev/null +++ b/server/sonar-web/src/main/js/helpers/testSelector.ts @@ -0,0 +1,398 @@ +/* + * 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 { + BoundFunction, + GetByBoundAttribute, + GetByRole, + GetByText, + screen, + waitForOptions, + within, +} from '@testing-library/react'; + +function maybeScreen(container?: HTMLElement) { + return container ? within(container) : screen; +} + +export interface ReactTestingQuery { + find( + container?: HTMLElement, + waitForOptions?: waitForOptions + ): Promise; + findAll( + container?: HTMLElement, + waitForOptions?: waitForOptions + ): Promise; + get(container?: HTMLElement): T; + getAll(container?: HTMLElement): T[]; + query(container?: HTMLElement): T | null; + queryAll(container?: HTMLElement): T[] | null; + + byText(...args: Parameters>): ReactTestingQuery; + byRole(...args: Parameters>): ReactTestingQuery; + byPlaceholderText(...args: Parameters>): ReactTestingQuery; + byLabelText(...args: Parameters>): ReactTestingQuery; + byTestId(...args: Parameters>): ReactTestingQuery; + byDisplayValue(...args: Parameters>): ReactTestingQuery; +} + +abstract class ChainingQuery implements ReactTestingQuery { + abstract find( + container?: HTMLElement, + waitForOptions?: waitForOptions + ): Promise; + + abstract findAll( + container?: HTMLElement, + waitForOptions?: waitForOptions + ): Promise; + + abstract get(container?: HTMLElement): T; + + abstract getAll(container?: HTMLElement): T[]; + + abstract query(container?: HTMLElement): T | null; + + abstract queryAll(container?: HTMLElement): T[] | null; + + byText(...args: Parameters>): ReactTestingQuery { + return new ChainDispatch(this, new DispatchByText(args)); + } + + byRole(...args: Parameters>): ReactTestingQuery { + return new ChainDispatch(this, new DispatchByRole(args)); + } + + byPlaceholderText(...args: Parameters>): ReactTestingQuery { + return new ChainDispatch(this, new DispatchByPlaceholderText(args)); + } + + byLabelText(...args: Parameters>): ReactTestingQuery { + return new ChainDispatch(this, new DispatchByLabelText(args)); + } + + byTestId(...args: Parameters>): ReactTestingQuery { + return new ChainDispatch(this, new DispatchByTestId(args)); + } + + byDisplayValue(...args: Parameters>): ReactTestingQuery { + return new ChainDispatch(this, new DispatchByDisplayValue(args)); + } +} + +class ChainDispatch extends ChainingQuery { + insideQuery: ReactTestingQuery; + elementQuery: ReactTestingQuery; + + constructor(insideQuery: ReactTestingQuery, elementQuery: ReactTestingQuery) { + super(); + this.insideQuery = insideQuery; + this.elementQuery = elementQuery; + } + + async find( + container?: HTMLElement, + waitForOptions?: waitForOptions + ) { + return this.elementQuery.get(await this.insideQuery.find(container, waitForOptions)); + } + + async findAll( + container?: HTMLElement, + waitForOptions?: waitForOptions + ) { + return this.elementQuery.getAll(await this.insideQuery.find(container, waitForOptions)); + } + + get(container?: HTMLElement) { + return this.elementQuery.get(this.insideQuery.get(container)); + } + + getAll(container?: HTMLElement) { + return this.elementQuery.getAll(this.insideQuery.get(container)); + } + + query(container?: HTMLElement) { + return this.elementQuery.query(this.insideQuery.get(container)); + } + + queryAll(container?: HTMLElement) { + return this.elementQuery.queryAll(this.insideQuery.get(container)); + } +} + +class DispatchByText extends ChainingQuery { + readonly args: Parameters>; + + constructor(args: Parameters>) { + super(); + this.args = args; + } + + find( + container?: HTMLElement, + waitForOptions?: waitForOptions + ) { + return maybeScreen(container).findByText(...this.args, waitForOptions); + } + + findAll( + container?: HTMLElement, + waitForOptions?: waitForOptions + ) { + return maybeScreen(container).findAllByText(...this.args, waitForOptions); + } + + get(container?: HTMLElement) { + return maybeScreen(container).getByText(...this.args); + } + + getAll(container?: HTMLElement) { + return maybeScreen(container).getAllByText(...this.args); + } + + query(container?: HTMLElement) { + return maybeScreen(container).queryByText(...this.args); + } + + queryAll(container?: HTMLElement) { + return maybeScreen(container).queryAllByText(...this.args); + } +} + +class DispatchByLabelText extends ChainingQuery { + readonly args: Parameters>; + + constructor(args: Parameters>) { + super(); + this.args = args; + } + + find( + container?: HTMLElement, + waitForOptions?: waitForOptions + ) { + return maybeScreen(container).findByLabelText(...this.args, waitForOptions); + } + + findAll( + container?: HTMLElement, + waitForOptions?: waitForOptions + ) { + return maybeScreen(container).findAllByLabelText(...this.args, waitForOptions); + } + + get(container?: HTMLElement) { + return maybeScreen(container).getByLabelText(...this.args); + } + + getAll(container?: HTMLElement) { + return maybeScreen(container).getAllByLabelText(...this.args); + } + + query(container?: HTMLElement) { + return maybeScreen(container).queryByLabelText(...this.args); + } + + queryAll(container?: HTMLElement) { + return maybeScreen(container).queryAllByLabelText(...this.args); + } +} + +class DispatchByRole extends ChainingQuery { + readonly args: Parameters>; + + constructor(args: Parameters>) { + super(); + this.args = args; + } + + find( + container?: HTMLElement, + waitForOptions?: waitForOptions + ) { + return maybeScreen(container).findByRole(...this.args, waitForOptions); + } + + findAll( + container?: HTMLElement, + waitForOptions?: waitForOptions + ) { + return maybeScreen(container).findAllByRole(...this.args, waitForOptions); + } + + get(container?: HTMLElement) { + return maybeScreen(container).getByRole(...this.args); + } + + getAll(container?: HTMLElement) { + return maybeScreen(container).getAllByRole(...this.args); + } + + query(container?: HTMLElement) { + return maybeScreen(container).queryByRole(...this.args); + } + + queryAll(container?: HTMLElement) { + return maybeScreen(container).queryAllByRole(...this.args); + } +} + +class DispatchByTestId extends ChainingQuery { + readonly args: Parameters>; + + constructor(args: Parameters>) { + super(); + this.args = args; + } + + find( + container?: HTMLElement, + waitForOptions?: waitForOptions + ) { + return maybeScreen(container).findByTestId(...this.args, waitForOptions); + } + + findAll( + container?: HTMLElement, + waitForOptions?: waitForOptions + ) { + return maybeScreen(container).findAllByTestId(...this.args, waitForOptions); + } + + get(container?: HTMLElement) { + return maybeScreen(container).getByTestId(...this.args); + } + + getAll(container?: HTMLElement) { + return maybeScreen(container).getAllByTestId(...this.args); + } + + query(container?: HTMLElement) { + return maybeScreen(container).queryByTestId(...this.args); + } + + queryAll(container?: HTMLElement) { + return maybeScreen(container).queryAllByTestId(...this.args); + } +} + +class DispatchByDisplayValue extends ChainingQuery { + readonly args: Parameters>; + + constructor(args: Parameters>) { + super(); + this.args = args; + } + + find( + container?: HTMLElement, + waitForOptions?: waitForOptions + ) { + return maybeScreen(container).findByDisplayValue(...this.args, waitForOptions); + } + + findAll( + container?: HTMLElement, + waitForOptions?: waitForOptions + ) { + return maybeScreen(container).findAllByDisplayValue(...this.args, waitForOptions); + } + + get(container?: HTMLElement) { + return maybeScreen(container).getByDisplayValue(...this.args); + } + + getAll(container?: HTMLElement) { + return maybeScreen(container).getAllByDisplayValue(...this.args); + } + + query(container?: HTMLElement) { + return maybeScreen(container).queryByDisplayValue(...this.args); + } + + queryAll(container?: HTMLElement) { + return maybeScreen(container).queryAllByDisplayValue(...this.args); + } +} + +class DispatchByPlaceholderText extends ChainingQuery { + readonly args: Parameters>; + + constructor(args: Parameters>) { + super(); + this.args = args; + } + + find( + container?: HTMLElement, + waitForOptions?: waitForOptions + ) { + return maybeScreen(container).findByPlaceholderText(...this.args, waitForOptions); + } + + findAll( + container?: HTMLElement, + waitForOptions?: waitForOptions + ) { + return maybeScreen(container).findAllByPlaceholderText(...this.args, waitForOptions); + } + + get(container?: HTMLElement) { + return maybeScreen(container).getByPlaceholderText(...this.args); + } + + getAll(container?: HTMLElement) { + return maybeScreen(container).getAllByPlaceholderText(...this.args); + } + + query(container?: HTMLElement) { + return maybeScreen(container).queryByPlaceholderText(...this.args); + } + + queryAll(container?: HTMLElement) { + return maybeScreen(container).queryAllByPlaceholderText(...this.args); + } +} + +export function byText(...args: Parameters>) { + return new DispatchByText(args); +} + +export function byRole(...args: Parameters>) { + return new DispatchByRole(args); +} + +export function byPlaceholderText(...args: Parameters>) { + return new DispatchByPlaceholderText(args); +} + +export function byLabelText(...args: Parameters>) { + return new DispatchByLabelText(args); +} + +export function byTestId(...args: Parameters>) { + return new DispatchByTestId(args); +} + +export function byDisplayValue(...args: Parameters>) { + return new DispatchByDisplayValue(args); +} diff --git a/server/sonar-web/yarn.lock b/server/sonar-web/yarn.lock index 598b2b41906..0caa169d4e6 100644 --- a/server/sonar-web/yarn.lock +++ b/server/sonar-web/yarn.lock @@ -4620,7 +4620,6 @@ __metadata: react-virtualized: 9.22.3 regenerator-runtime: 0.13.11 tailwindcss: 3.3.1 - testing-library-selector: 0.2.1 turbo: 1.8.8 typescript: 5.0.3 valid-url: 1.0.9 @@ -12138,15 +12137,6 @@ __metadata: languageName: node linkType: hard -"testing-library-selector@npm:0.2.1": - version: 0.2.1 - resolution: "testing-library-selector@npm:0.2.1" - peerDependencies: - "@testing-library/dom": ^8.2.0 - checksum: 4bb6d071f20b89f7954b03addd6c97479817e348c5a63f2c40693a5a93010b40418d90e30c0dfd7dc2a05e2f66a880ff4b1fa9004e7def5fbf489130b70b050b - languageName: node - linkType: hard - "text-table@npm:^0.2.0": version: 0.2.0 resolution: "text-table@npm:0.2.0"