Skip to content

Fix the testing type badges #6211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/badge/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import React from "react";
import s from "./style.module.css";
import { BadgeProps } from "./types";

function classNames(...classes) {
function classNames(...classes: string[]) {
return classes.filter(Boolean).join(" ");
}

export default function Badge({ type, path, children }: BadgeProps) {
return (
<>
{path && (
<a href={path}>
<a href={path} style={{ borderBottom: 'none' }}>
<div className={classNames(`${s.badge}`, `${s[type]}`)}>
{children}
</div>
Expand Down
23 changes: 18 additions & 5 deletions src/components/product-heading/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import Icon from '@cypress-design/react-icon'
import Badge from "@site/src/components/badge"
import s from './style.module.css'
import {useDoc} from '@docusaurus/theme-common/internal';
import E2EOnlyBadge from "@site/src/components/e2e-only-badge";
import ComponentOnlyBadge from "@site/src/components/component-only-badge";

import React from 'react';

// Define the types for the props
interface ProductHeadingProps {
product: 'app' | 'cloud' | 'accessibility' | 'ui-coverage'
plan?: 'team' | 'business' | 'enterprise'
badge?: React.ReactNode
}

// Build the Button component with the specified props
const ProductHeading: React.FC<ProductHeadingProps> = ({
const DocProductHeading: React.FC<ProductHeadingProps> = ({
product, // The product to display
plan, // The plan to display for Cloud product
badge, // The badge to display
}) => {
const productName = product === 'ui-coverage' ? 'UI Coverage' : product === 'accessibility' ? 'Cypress Accessibility' : product === 'cloud' ? 'Cypress Cloud' : 'Cypress App'
const iconName = product === 'ui-coverage' ? 'technology-ui-coverage' : product === 'accessibility' ? 'cypress-accessibility-outline' : 'technology-cypress'
Expand All @@ -26,15 +31,14 @@ const ProductHeading: React.FC<ProductHeadingProps> = ({
}

return (
<div className={s.productHeading}>
<div className={s.productHeading} style={{display: 'flex', alignItems: 'center', gap: '0.5rem'}}>
<Icon
name={iconName}
className={s.productHeadingIcon}
/>
<span className={s.productHeadingText}>
{productName}
</span>

<a
href={`https://www.cypress.io/${linkPath}?utm_source=docs&utm_medium=product-heading-${product}&utm_content=${badgeContent}`}
target="_blank"
Expand All @@ -43,9 +47,18 @@ const ProductHeading: React.FC<ProductHeadingProps> = ({
>
{ product !== 'app' && <Badge type="success">{badgeContent}</Badge>}
</a>

<span className={s.productHeadingBadge}>{badge}</span>
</div>
)
}

export default ProductHeading
const ProductHeading: React.FC<Omit<ProductHeadingProps, 'badge'>> = (props) => {
const { frontMatter } = useDoc();
const e2eSpecific = (frontMatter as any).e2eSpecific;
const componentSpecific = (frontMatter as any).componentSpecific;
const testTypePill = (e2eSpecific && <E2EOnlyBadge />) || (componentSpecific && <ComponentOnlyBadge />);
return <DocProductHeading {...props} badge={testTypePill} />;
};

export default ProductHeading;
export { ProductHeading, DocProductHeading };
6 changes: 6 additions & 0 deletions src/components/product-heading/style.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@
.productHeadingText {
font-size: 1.2rem;
margin-right: 0.5rem;
}

.productHeadingBadge {
margin-left: auto;
display: flex;
align-items: center;
}
6 changes: 1 addition & 5 deletions src/theme/DocItem/Content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ function useSyntheticTitle() {
}
return metadata.title;
}
export default function DocItemContent({children}) {

const { frontMatter: {e2eSpecific, componentSpecific} } = useDoc();
const testTypePill = e2eSpecific && <E2EOnlyBadge /> || componentSpecific && <ComponentOnlyBadge />
export default function DocItemContent({children}: {children: React.ReactNode}) {

const syntheticTitle = useSyntheticTitle();
return (
Expand All @@ -41,7 +38,6 @@ return (
<div className={s.mainContentHeader}>
<div className={s.headerWrapper}>
<Heading as="h1">{syntheticTitle}</Heading>
{testTypePill}
</div>
</div>
</header>
Expand Down