From 8223c3f001f453f58850cfd3e9e4e969174ed711 Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Thu, 12 Sep 2024 14:11:24 +0200 Subject: [PATCH] SONAR-23036 Upgrade Echoes and adapt to the new Select --- server/sonar-web/design-system/package.json | 2 +- server/sonar-web/package.json | 2 +- .../__tests__/AssigneeSelect-test.tsx | 4 +- .../branches/__tests__/ActivityPanel-it.tsx | 4 +- .../components/__tests__/AllProjects-test.tsx | 2 + .../quality-gates/components/MetricSelect.tsx | 31 +- .../components/__tests__/QualityGate-it.tsx | 24 +- .../__tests__/QualityProfilesApp-it.tsx | 12 +- .../components/HotspotViewerTabs.tsx | 4 +- .../components/__tests__/Definition-it.tsx | 2 +- .../__tests__/EmailNotification-it.tsx | 2 +- server/sonar-web/yarn.lock | 466 +++++------------- 12 files changed, 170 insertions(+), 385 deletions(-) diff --git a/server/sonar-web/design-system/package.json b/server/sonar-web/design-system/package.json index 684a70bbe0b..eb061894246 100644 --- a/server/sonar-web/design-system/package.json +++ b/server/sonar-web/design-system/package.json @@ -23,7 +23,7 @@ "@babel/preset-typescript": "7.24.7", "@emotion/babel-plugin": "11.12.0", "@emotion/babel-plugin-jsx-pragmatic": "0.2.1", - "@sonarsource/echoes-react": "0.6.0", + "@sonarsource/echoes-react": "0.7.0", "@testing-library/dom": "10.4.0", "@testing-library/jest-dom": "6.5.0", "@testing-library/react": "16.0.1", diff --git a/server/sonar-web/package.json b/server/sonar-web/package.json index 41e3cb7dcbd..f1e5a264dc7 100644 --- a/server/sonar-web/package.json +++ b/server/sonar-web/package.json @@ -13,7 +13,7 @@ "@primer/octicons-react": "19.11.0", "@react-spring/rafz": "9.7.4", "@react-spring/web": "9.7.4", - "@sonarsource/echoes-react": "0.6.0", + "@sonarsource/echoes-react": "0.7.0", "@tanstack/react-query": "5.54.1", "@types/validator": "13.12.1", "axios": "1.7.2", 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 fd139ca464b..556ebb4090d 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 @@ -20,7 +20,7 @@ import { screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import * as React from 'react'; -import { byLabelText } from '~sonar-aligned/helpers/testSelector'; +import { byRole } from '~sonar-aligned/helpers/testSelector'; import CurrentUserContextProvider from '../../../../app/components/current-user/CurrentUserContextProvider'; import { mockUserBase } from '../../../../helpers/mocks/users'; import { mockCurrentUser, mockIssue, mockLoggedInUser } from '../../../../helpers/testMocks'; @@ -53,7 +53,7 @@ jest.mock('../../utils', () => ({ })); const ui = { - combobox: byLabelText('issue_bulk_change.assignee.change'), + combobox: byRole('combobox', { name: 'issue_bulk_change.assignee.change' }), }; it('should show correct suggestions when there is assignable issue for the current user', async () => { diff --git a/server/sonar-web/src/main/js/apps/overview/branches/__tests__/ActivityPanel-it.tsx b/server/sonar-web/src/main/js/apps/overview/branches/__tests__/ActivityPanel-it.tsx index a5a8262743a..8b49e156574 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/__tests__/ActivityPanel-it.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/__tests__/ActivityPanel-it.tsx @@ -52,8 +52,8 @@ it('should render correctly', async () => { expect(screen.getByText('event.sqUpgrade10.2')).toBeInTheDocument(); // Checking measures variations - expect(screen.getAllByText(/project_activity\.graphs\.coverage$/)).toHaveLength(3); - expect(screen.getAllByText(/project_activity\.graphs\.duplications$/)).toHaveLength(3); + expect(screen.getAllByText(/% project_activity\.graphs\.coverage$/)).toHaveLength(3); + expect(screen.getAllByText(/% project_activity\.graphs\.duplications$/)).toHaveLength(3); // Analysis 1 (latest) expect(screen.getByText(/^-5 project_activity\.graphs\.issues$/)).toBeInTheDocument(); expect(screen.getByText(/^\+6\.5% project_activity\.graphs\.duplications$/)).toBeInTheDocument(); diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/AllProjects-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/AllProjects-test.tsx index 698bc1abb13..11270e4abc3 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/AllProjects-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/AllProjects-test.tsx @@ -74,6 +74,8 @@ beforeEach(() => { it('renders correctly', async () => { renderProjects(`${BASE_PATH}?gate=OK`); + expect(await ui.sortSelect.find()).toBeInTheDocument(); + expect(await ui.perspectiveSelect.find()).toBeInTheDocument(); expect(await ui.projects.findAll()).toHaveLength(20); }); diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/MetricSelect.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/MetricSelect.tsx index 73626d20cb1..b7b876f50fb 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/MetricSelect.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/MetricSelect.tsx @@ -17,7 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { Select, SelectOption } from '@sonarsource/echoes-react'; +import { Select } from '@sonarsource/echoes-react'; +import { groupBy, sortBy } from 'lodash'; import * as React from 'react'; import withMetricsContext from '../../../app/components/metrics/withMetricsContext'; import { translate } from '../../../helpers/l10n'; @@ -47,11 +48,10 @@ export function MetricSelect({ } }; - const options: SelectOption[] = metricsArray.map((m) => ({ - value: m.key, - label: getLocalizedMetricNameNoDiffMetric(m, metrics), - group: m.domain, - })); + const options = React.useMemo( + () => groupByDomain(metricsArray, metrics), + [metricsArray, metrics], + ); return (