Skip to content

Commit ea19198

Browse files
Fixing anchor title for consistent behaviour (OWASP#1428)
* fixing anchor title for consistent behaviour * Update code --------- Co-authored-by: Arkadii Yakovets <[email protected]>
1 parent a909db8 commit ea19198

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

frontend/__tests__/unit/pages/About.test.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ describe('About Component', () => {
252252
test('renders roadmap correctly', async () => {
253253
render(<About />)
254254

255-
const roadmapSection = screen.getByText('Roadmap').closest('div')
255+
const roadmapSection = screen.getByRole('heading', { name: 'Roadmap' }).closest('div')
256256
expect(roadmapSection).toBeInTheDocument()
257257

258258
const roadmapItems = within(roadmapSection).getAllByRole('listitem')
@@ -262,7 +262,9 @@ describe('About Component', () => {
262262
expect(screen.getByText('Feature 2')).toBeInTheDocument()
263263
expect(screen.getByText('Feature 3')).toBeInTheDocument()
264264

265-
const links = within(roadmapSection).getAllByRole('link')
265+
const links = within(roadmapSection)
266+
.getAllByRole('link')
267+
.filter((link) => link.getAttribute('href') !== '#roadmap')
266268
expect(links[0].getAttribute('href')).toBe('https://github.com/owasp/test/issues/1')
267269
})
268270

frontend/src/app/about/page.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { GET_LEADER_DATA } from 'server/queries/userQueries'
1616
import { ProjectTypeGraphql } from 'types/project'
1717
import { aboutText, roadmap, technologies } from 'utils/aboutData'
1818
import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper'
19+
import AnchorTitle from 'components/AnchorTitle'
1920
import AnimatedCounter from 'components/AnimatedCounter'
2021
import LoadingSpinner from 'components/LoadingSpinner'
2122
import Markdown from 'components/MarkdownWrapper'
@@ -75,7 +76,7 @@ const About = () => {
7576
<div className="min-h-screen p-8 text-gray-600 dark:bg-[#212529] dark:text-gray-300">
7677
<div className="mx-auto max-w-6xl">
7778
<h1 className="mb-6 mt-4 text-4xl font-bold">About</h1>
78-
<SecondaryCard icon={faScroll} title="History">
79+
<SecondaryCard icon={faScroll} title={<AnchorTitle title="History" />}>
7980
{aboutText.map((text) => (
8081
<div key={text} className="mb-4">
8182
<div key={text}>
@@ -85,7 +86,7 @@ const About = () => {
8586
))}
8687
</SecondaryCard>
8788

88-
<SecondaryCard icon={faArrowUpRightFromSquare} title="Leaders">
89+
<SecondaryCard icon={faArrowUpRightFromSquare} title={<AnchorTitle title="Leaders" />}>
8990
<div className="flex w-full flex-col items-center justify-around overflow-hidden md:flex-row">
9091
{Object.keys(leaders).map((username) => (
9192
<div key={username}>
@@ -104,7 +105,7 @@ const About = () => {
104105
/>
105106
)}
106107

107-
<SecondaryCard icon={faTools} title="Technologies & Tools">
108+
<SecondaryCard icon={faTools} title={<AnchorTitle title="Technologies & Tools" />}>
108109
<div className="w-full">
109110
<div className="grid w-full grid-cols-1 justify-center sm:grid-cols-2 lg:grid-cols-4 lg:pl-8">
110111
{technologies.map((tech) => (
@@ -137,7 +138,7 @@ const About = () => {
137138
</div>
138139
</SecondaryCard>
139140

140-
<SecondaryCard icon={faMapSigns} title="Roadmap">
141+
<SecondaryCard icon={faMapSigns} title={<AnchorTitle title="Roadmap" />}>
141142
<ul>
142143
{roadmap.map((item) => (
143144
<li key={item.title} className="mb-4 flex flex-row items-center gap-2 pl-4 md:pl-6">

frontend/src/components/ToggleableList.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ const ToggleableList = ({
2626
return (
2727
<div className="rounded-lg bg-gray-100 p-6 shadow-md dark:bg-gray-800">
2828
<h2 className="mb-4 text-2xl font-semibold">
29-
{icon && <FontAwesomeIcon icon={icon} className="mr-2 h-5 w-5" />}
30-
{label}
29+
<div className="flex items-center">
30+
<div className="flex items-center space-x-2">
31+
{icon && <FontAwesomeIcon icon={icon} className="mr-2 h-5 w-5" />}
32+
</div>
33+
<span>{label}</span>
34+
</div>
3135
</h2>
3236
<div className="flex flex-wrap gap-2">
3337
{(showAll ? items : items.slice(0, limit)).map((item, index) => (

0 commit comments

Comments
 (0)