Skip to content

Commit

Permalink
Merge pull request #573 from UKHSA-Internal/feat/CDD-2349-feedback-fi…
Browse files Browse the repository at this point in the history
…eldtypes-hiddenField

Feat/cdd 2349 feedback fieldtypes hidden field
  • Loading branch information
Temiakinsoto authored Feb 10, 2025
2 parents 646ca82 + d2e1065 commit 11c17c8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/app/components/cms/Feedback/Fields/Hidden/HiddenField.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
interface HiddenFieldType {
cleanName: string
}

export default function HiddenField({ cleanName }: Readonly<HiddenFieldType>) {
return (
<input
aria-label="Unused Hidden Date Input"
className="govuk-visually-hidden"
name={cleanName}
id={cleanName}
value={cleanName}
/>
)
}
19 changes: 19 additions & 0 deletions src/app/components/cms/Feedback/Fields/Hidden/Hiddenfield.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { render, screen } from '@/config/test-utils'

import HiddenField from './HiddenField'

describe('HiddenField component', () => {
test('renders a hidden input with the correct attributes', () => {
const cleanName = 'userId'

render(<HiddenField cleanName={cleanName} />)

const inputElement = screen.getByRole('textbox')
expect(inputElement).toBeInTheDocument()
expect(inputElement).toHaveAttribute('name', cleanName)
expect(inputElement).toHaveAttribute('id', cleanName)
expect(inputElement).toHaveAttribute('value', cleanName)
expect(inputElement).toHaveClass('govuk-visually-hidden')
expect(inputElement).toHaveAttribute('aria-label', 'Unused Hidden Date Input')
})
})

1 comment on commit 11c17c8

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit tests coverage

Lines Statements Branches Functions
Coverage: 96%
94.65% (1931/2040) 85.08% (485/570) 94.59% (315/333)
Tests Skipped Failures Errors Time
564 0 💤 0 ❌ 0 🔥 17.522s ⏱️

Please sign in to comment.