]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-16703 [891618] Visual heading text is not marked as heading
authorWouter Admiraal <wouter.admiraal@sonarsource.com>
Thu, 28 Jul 2022 09:58:24 +0000 (11:58 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 29 Jul 2022 20:03:15 +0000 (20:03 +0000)
14 files changed:
server/sonar-web/src/main/js/app/components/nav/component/Breadcrumb.tsx
server/sonar-web/src/main/js/app/components/nav/component/__tests__/Breadcrumb-test.tsx
server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/Breadcrumb-test.tsx.snap [deleted file]
server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx
server/sonar-web/src/main/js/components/tutorials/__tests__/__snapshots__/TutorialSelectionRenderer-test.tsx.snap
server/sonar-web/src/main/js/components/tutorials/azure-pipelines/AzurePipelinesTutorial.tsx
server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/__snapshots__/AzurePipelinesTutorial-test.tsx.snap
server/sonar-web/src/main/js/components/tutorials/gitlabci/GitLabCITutorial.tsx
server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/GitLabCITutorial-test.tsx.snap
server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsTutorial.tsx
server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsTutorial-test.tsx.snap
server/sonar-web/src/main/js/components/tutorials/other/OtherTutorial.tsx
server/sonar-web/src/main/js/components/tutorials/other/__tests__/__snapshots__/OtherTutorial-test.tsx.snap
server/sonar-web/src/main/js/components/ui/NavBar.css

index f96ee9b78d09f4c1d155fd8b7b305d8590c2a0fa..d00315089d1fad3a022eb00bf3fba65f0677a444 100644 (file)
@@ -26,12 +26,12 @@ import { getComponentOverviewUrl } from '../../../../helpers/urls';
 import { BranchLike } from '../../../../types/branch-like';
 import { Component } from '../../../../types/types';
 
-interface Props {
+export interface BreadcrumbProps {
   component: Component;
   currentBranchLike: BranchLike | undefined;
 }
 
-export function Breadcrumb(props: Props) {
+export function Breadcrumb(props: BreadcrumbProps) {
   const {
     component: { breadcrumbs },
     currentBranchLike
@@ -51,16 +51,18 @@ export function Breadcrumb(props: Props) {
               <QualifierIcon className="spacer-right" qualifier={lastBreadcrumbElement.qualifier} />
             )}
             {isNoMainBranch || isNotLast ? (
-              <Link
-                className="link-no-underline text-ellipsis"
-                title={breadcrumbElement.name}
-                to={getComponentOverviewUrl(breadcrumbElement.key, breadcrumbElement.qualifier)}>
-                {breadcrumbElement.name}
-              </Link>
+              <h1>
+                <Link
+                  className="link-no-underline text-ellipsis"
+                  title={breadcrumbElement.name}
+                  to={getComponentOverviewUrl(breadcrumbElement.key, breadcrumbElement.qualifier)}>
+                  {breadcrumbElement.name}
+                </Link>
+              </h1>
             ) : (
-              <span className="text-ellipsis" title={breadcrumbElement.name}>
+              <h1 className="text-ellipsis" title={breadcrumbElement.name}>
                 {breadcrumbElement.name}
-              </span>
+              </h1>
             )}
             {isNotLast && <span className="slash-separator" />}
           </span>
index d745c37d74c10c969139f9b4d07d1082d32ab994..4d67b48719c3f17fc93150d801dc34486bfea528 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { shallow } from 'enzyme';
+import { screen } from '@testing-library/react';
 import * as React from 'react';
-import { mockMainBranch } from '../../../../../helpers/mocks/branch-like';
+import { mockBranch, mockMainBranch } from '../../../../../helpers/mocks/branch-like';
 import { mockComponent } from '../../../../../helpers/mocks/component';
+import { renderComponent } from '../../../../../helpers/testReactTestingUtils';
 import { ComponentQualifier } from '../../../../../types/component';
-import { Breadcrumb } from '../Breadcrumb';
+import { Breadcrumb, BreadcrumbProps } from '../Breadcrumb';
 
 it('should render correctly', () => {
-  const wrapper = shallowRender();
-  expect(wrapper).toMatchSnapshot();
+  renderBreadcrumb();
+  expect(screen.getByRole('link', { name: 'Parent portfolio' })).toBeInTheDocument();
+  expect(screen.getByRole('heading', { name: 'Child portfolio' })).toBeInTheDocument();
 });
 
-function shallowRender() {
-  return shallow(
+it('should render correctly when not on a main branch', () => {
+  renderBreadcrumb({ currentBranchLike: mockBranch() });
+  expect(screen.getByRole('link', { name: 'Child portfolio' })).toBeInTheDocument();
+});
+
+function renderBreadcrumb(props: Partial<BreadcrumbProps> = {}) {
+  return renderComponent(
     <Breadcrumb
       component={mockComponent({
         breadcrumbs: [
           {
             key: 'parent-portfolio',
-            name: 'parent-portfolio',
+            name: 'Parent portfolio',
             qualifier: ComponentQualifier.Portfolio
           },
           {
             key: 'child-portfolio',
-            name: 'child-portfolio',
+            name: 'Child portfolio',
             qualifier: ComponentQualifier.SubPortfolio
           }
         ]
       })}
       currentBranchLike={mockMainBranch()}
+      {...props}
     />
   );
 }
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/Breadcrumb-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/Breadcrumb-test.tsx.snap
deleted file mode 100644 (file)
index e78e2c5..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`should render correctly 1`] = `
-<div
-  className="big flex-shrink display-flex-center"
->
-  <span
-    className="flex-shrink display-flex-center"
-    key="parent-portfolio"
-  >
-    <QualifierIcon
-      className="spacer-right"
-      qualifier="SVW"
-    />
-    <Link
-      className="link-no-underline text-ellipsis"
-      title="parent-portfolio"
-      to={
-        Object {
-          "pathname": "/portfolio",
-          "search": "?id=parent-portfolio",
-        }
-      }
-    >
-      parent-portfolio
-    </Link>
-    <span
-      className="slash-separator"
-    />
-  </span>
-  <span
-    className="flex-shrink display-flex-center"
-    key="child-portfolio"
-  >
-    <span
-      className="text-ellipsis"
-      title="child-portfolio"
-    >
-      child-portfolio
-    </span>
-  </span>
-</div>
-`;
index 2370fa05b452b555f30b2dcc08d0edb88fdbee23..f08f088b8013bc0b395b8bc1f7947523470e53f3 100644 (file)
@@ -113,9 +113,9 @@ export default function TutorialSelectionRenderer(props: TutorialSelectionRender
     <>
       {selectedTutorial === undefined && (
         <>
-          <h1 className="spacer-top huge-spacer-bottom">
+          <h2 className="spacer-top huge-spacer-bottom">
             {translate('onboarding.tutorial.choose_method')}
-          </h1>
+          </h2>
 
           <div className="tutorial-selection">
             <p className="big-spacer-bottom">
index 28cd916f7a19b40e5835f4b370c0a035ccc89ccf..0b023b704dfb9bc3c404f8ff50d31430d3bdf75f 100644 (file)
@@ -2,11 +2,11 @@
 
 exports[`should render correctly for azure 1`] = `
 <Fragment>
-  <h1
+  <h2
     className="spacer-top huge-spacer-bottom"
   >
     onboarding.tutorial.choose_method
-  </h1>
+  </h2>
   <div
     className="tutorial-selection"
   >
@@ -78,11 +78,11 @@ exports[`should render correctly for azure 1`] = `
 
 exports[`should render correctly for bitbucket server 1`] = `
 <Fragment>
-  <h1
+  <h2
     className="spacer-top huge-spacer-bottom"
   >
     onboarding.tutorial.choose_method
-  </h1>
+  </h2>
   <div
     className="tutorial-selection"
   >
@@ -154,11 +154,11 @@ exports[`should render correctly for bitbucket server 1`] = `
 
 exports[`should render correctly for github 1`] = `
 <Fragment>
-  <h1
+  <h2
     className="spacer-top huge-spacer-bottom"
   >
     onboarding.tutorial.choose_method
-  </h1>
+  </h2>
   <div
     className="tutorial-selection"
   >
@@ -263,11 +263,11 @@ exports[`should render correctly for github 1`] = `
 
 exports[`should render correctly for gitlab 1`] = `
 <Fragment>
-  <h1
+  <h2
     className="spacer-top huge-spacer-bottom"
   >
     onboarding.tutorial.choose_method
-  </h1>
+  </h2>
   <div
     className="tutorial-selection"
   >
@@ -590,11 +590,11 @@ exports[`should render correctly: manual tutorial 1`] = `
 
 exports[`should render correctly: selection 1`] = `
 <Fragment>
-  <h1
+  <h2
     className="spacer-top huge-spacer-bottom"
   >
     onboarding.tutorial.choose_method
-  </h1>
+  </h2>
   <div
     className="tutorial-selection"
   >
index c42e621e2485a64f8a8a75455a519b628bd2282a..5f07e2347aa5957012fbe01afca5bb163f94aa2a 100644 (file)
@@ -91,9 +91,9 @@ export default function AzurePipelinesTutorial(props: AzurePipelinesTutorialProp
   return (
     <>
       <div className="page-header big-spacer-bottom">
-        <h1 className="page-title">
+        <h2 className="page-title">
           {translate('onboarding.tutorial.with.azure_pipelines.title')}
-        </h1>
+        </h2>
       </div>
 
       {steps.map((step, i) => (
index f1f1573b62e08ec32fb9f5d0cc66bd5af383c4a7..c180cb824f80e85cb4ab5b65cc14103361eda496 100644 (file)
@@ -5,11 +5,11 @@ exports[`should render correctly 1`] = `
   <div
     className="page-header big-spacer-bottom"
   >
-    <h1
+    <h2
       className="page-title"
     >
       onboarding.tutorial.with.azure_pipelines.title
-    </h1>
+    </h2>
   </div>
   <Step
     finished={false}
index faf5190efd75e3d8aded798191bbcc6c242b7f01..d1c7291d9b386ec7f93c0bcc2ef744599efb5189 100644 (file)
@@ -51,7 +51,7 @@ export default function GitLabCITutorial(props: GitLabCITutorialProps) {
   return (
     <>
       <div className="page-header big-spacer-bottom">
-        <h1 className="page-title">{translate('onboarding.tutorial.with.gitlab_ci.title')}</h1>
+        <h2 className="page-title">{translate('onboarding.tutorial.with.gitlab_ci.title')}</h2>
       </div>
 
       <ProjectKeyStep
index d9fa3955af6b7bc8e63117d92bded68b9145c78e..fdadfc1aa7e94c58dfbc0e4cb0d8ee8378000e36 100644 (file)
@@ -5,11 +5,11 @@ exports[`should render correctly 1`] = `
   <div
     className="page-header big-spacer-bottom"
   >
-    <h1
+    <h2
       className="page-title"
     >
       onboarding.tutorial.with.gitlab_ci.title
-    </h1>
+    </h2>
   </div>
   <withCLanguageFeature(ProjectKeyStep)
     component={
index c0aee40c051535f88b529c0e0324ce8d0a80efb1..7b667b24e2297d6d0b91d5801d96273d2dfd318f 100644 (file)
@@ -69,7 +69,7 @@ export function JenkinsTutorial(props: JenkinsTutorialProps) {
   return (
     <>
       <div className="page-header big-spacer-bottom">
-        <h1 className="page-title">{translate('onboarding.tutorial.with.jenkins.title')}</h1>
+        <h2 className="page-title">{translate('onboarding.tutorial.with.jenkins.title')}</h2>
       </div>
 
       {hasSelectAlmStep && (
index 7c2907baa6c61d6f8c83279e4ad87cf5fb5157df..925ce8e6375141d37f034275560b2c974bac543f 100644 (file)
@@ -5,11 +5,11 @@ exports[`should render correctly: branches not enabled 1`] = `
   <div
     className="page-header big-spacer-bottom"
   >
-    <h1
+    <h2
       className="page-title"
     >
       onboarding.tutorial.with.jenkins.title
-    </h1>
+    </h2>
   </div>
   <PreRequisitesStep
     alm="bitbucket"
@@ -86,11 +86,11 @@ exports[`should render correctly: default 1`] = `
   <div
     className="page-header big-spacer-bottom"
   >
-    <h1
+    <h2
       className="page-title"
     >
       onboarding.tutorial.with.jenkins.title
-    </h1>
+    </h2>
   </div>
   <PreRequisitesStep
     alm="bitbucket"
@@ -176,11 +176,11 @@ exports[`should render correctly: no project binding 1`] = `
   <div
     className="page-header big-spacer-bottom"
   >
-    <h1
+    <h2
       className="page-title"
     >
       onboarding.tutorial.with.jenkins.title
-    </h1>
+    </h2>
   </div>
   <SelectAlmStep
     onCheck={[Function]}
index 171a395ac91c2ed82711b73bbe8bc1ba254993bc..3e792e8edc30de74376e7789122c7befb3165c08 100644 (file)
@@ -60,7 +60,7 @@ export default class OtherTutorial extends React.PureComponent<Props, State> {
     return (
       <>
         <div className="page-header big-spacer-bottom">
-          <h1 className="page-title">{translate('onboarding.project_analysis.header')}</h1>
+          <h2 className="page-title">{translate('onboarding.project_analysis.header')}</h2>
           <p className="page-description">
             <InstanceMessage message={translate('onboarding.project_analysis.description')} />
           </p>
index 39298e06e9500d6dbd24f5ba324a6074d0daa3d0..cdec8d32ea87f377fc8aab02f73c259f9eb4c55a 100644 (file)
@@ -5,11 +5,11 @@ exports[`renders correctly: default 1`] = `
   <div
     className="page-header big-spacer-bottom"
   >
-    <h1
+    <h2
       className="page-title"
     >
       onboarding.project_analysis.header
-    </h1>
+    </h2>
     <p
       className="page-description"
     >
index fc0de133378dce935ff877af5c2f9b9c47e06a2f..1259a60d33886c9d0dd85c98506eb5082b53fb65 100644 (file)
   right: 0;
 }
 
+.navbar-inner h1 {
+  line-height: inherit;
+}
+
 .navbar-inner > div {
   position: relative;
   min-width: var(--minPageWidth);