Browse Source

SONAR-16948 Buttons have same name but different actions

tags/9.7.0.61563
Mathieu Suen 1 year ago
parent
commit
41672d85da

+ 16
- 14
server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewer-it.tsx View File

@@ -186,7 +186,8 @@ it('should show SCM information', async () => {
).toBeInTheDocument();
await user.click(
firstRowScreen.getByRole('button', {
name: 'source_viewer.author_X.stas.vilchik@sonarsource.com, source_viewer.click_for_scm_info'
name:
'source_viewer.author_X.stas.vilchik@sonarsource.com, source_viewer.click_for_scm_info.1'
})
);

@@ -210,48 +211,49 @@ it('should show SCM information', async () => {
// SCM with no date
row = await screen.findByRole('row', { name: /\* mailto:info AT sonarsource DOT com$/ });
expect(row).toBeInTheDocument();
const thirdRowScreen = within(row);
const fourthRowScreen = within(row);
await user.click(
thirdRowScreen.getByRole('button', {
name: 'source_viewer.author_X.stas.vilchik@sonarsource.com, source_viewer.click_for_scm_info'
fourthRowScreen.getByRole('button', {
name:
'source_viewer.author_X.stas.vilchik@sonarsource.com, source_viewer.click_for_scm_info.4'
})
);

expect(
await thirdRowScreen.findByRole('heading', { level: 4, name: 'author' })
await fourthRowScreen.findByRole('heading', { level: 4, name: 'author' })
).toBeInTheDocument();
expect(
thirdRowScreen.queryByRole('heading', {
fourthRowScreen.queryByRole('heading', {
level: 4,
name: 'source_viewer.tooltip.scm.commited_on'
})
).not.toBeInTheDocument();
expect(
thirdRowScreen.getByRole('heading', { level: 4, name: 'source_viewer.tooltip.scm.revision' })
fourthRowScreen.getByRole('heading', { level: 4, name: 'source_viewer.tooltip.scm.revision' })
).toBeInTheDocument();

// SCM with no date no author
row = await screen.findByRole('row', { name: /\* 5$/ });
expect(row).toBeInTheDocument();
const fourthRowScreen = within(row);
expect(fourthRowScreen.getByText('…')).toBeInTheDocument();
const fithRowScreen = within(row);
expect(fithRowScreen.getByText('…')).toBeInTheDocument();
await user.click(
fourthRowScreen.getByRole('button', {
name: 'source_viewer.click_for_scm_info'
fithRowScreen.getByRole('button', {
name: 'source_viewer.click_for_scm_info.5'
})
);

expect(
fourthRowScreen.queryByRole('heading', { level: 4, name: 'author' })
fithRowScreen.queryByRole('heading', { level: 4, name: 'author' })
).not.toBeInTheDocument();
expect(
fourthRowScreen.queryByRole('heading', {
fithRowScreen.queryByRole('heading', {
level: 4,
name: 'source_viewer.tooltip.scm.commited_on'
})
).not.toBeInTheDocument();
expect(
fourthRowScreen.getByRole('heading', { level: 4, name: 'source_viewer.tooltip.scm.revision' })
fithRowScreen.getByRole('heading', { level: 4, name: 'source_viewer.tooltip.scm.revision' })
).toBeInTheDocument();

// No SCM Popup

+ 2
- 2
server/sonar-web/src/main/js/components/SourceViewer/components/LineSCM.tsx View File

@@ -20,7 +20,7 @@
import * as React from 'react';
import Dropdown from '../../../components/controls/Dropdown';
import { PopupPlacement } from '../../../components/ui/popups';
import { translate, translateWithParameters } from '../../../helpers/l10n';
import { translateWithParameters } from '../../../helpers/l10n';
import { SourceLine } from '../../../types/types';
import { ButtonPlain } from '../../controls/buttons';
import SCMPopup from './SCMPopup';
@@ -39,7 +39,7 @@ export function LineSCM({ line, previousLine }: LineSCMProps) {
);

if (hasPopup) {
let ariaLabel = translate('source_viewer.click_for_scm_info');
let ariaLabel = translateWithParameters('source_viewer.click_for_scm_info', line.line);
if (line.scmAuthor) {
ariaLabel = `${translateWithParameters(
'source_viewer.author_X',

+ 1
- 1
sonar-core/src/main/resources/org/sonar/l10n/core.properties View File

@@ -2868,7 +2868,7 @@ source_viewer.covered=Covered by the following tests
source_viewer.not_covered=Not covered by tests
source_viewer.conditions=conditions
source_viewer.line_X=Line: {0}
source_viewer.click_for_scm_info=Click to see SCM information
source_viewer.click_for_scm_info=Click to see SCM information for line {0}
source_viewer.author_X=Author: {0}
source_viewer.click_to_copy_filepath=Click to copy the filepath to clipboard


Loading…
Cancel
Save