Skip to content
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
18 changes: 9 additions & 9 deletions frontend/__tests__/unit/components/ChapterMap.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,24 +266,24 @@ describe('ChapterMap', () => {
})

describe('Interactive Overlay', () => {
it('displays overlay with "Click to interact with map" message initially', () => {
it('displays overlay with "Unlock map" message initially', () => {
const { getByText } = render(<ChapterMap {...defaultProps} />)
expect(getByText('Click to interact with map')).toBeInTheDocument()
expect(getByText('Unlock map')).toBeInTheDocument()
})

it('removes overlay when clicked', () => {
const { getByText, queryByText } = render(<ChapterMap {...defaultProps} />)

const overlay = getByText('Click to interact with map').closest('button')
const overlay = getByText('Unlock map').closest('button')
fireEvent.click(overlay!)

expect(queryByText('Click to interact with map')).not.toBeInTheDocument()
expect(queryByText('Unlock map')).not.toBeInTheDocument()
})

it('enables scroll wheel zoom when overlay is clicked', () => {
const { getByText } = render(<ChapterMap {...defaultProps} />)

const overlay = getByText('Click to interact with map').closest('button')
const overlay = getByText('Unlock map').closest('button')
fireEvent.click(overlay!)

expect(mockMap.scrollWheelZoom.enable).toHaveBeenCalled()
Expand All @@ -292,7 +292,7 @@ describe('ChapterMap', () => {
it('handles keyboard interaction with Enter key', () => {
const { getByText } = render(<ChapterMap {...defaultProps} />)

const overlay = getByText('Click to interact with map').closest('button')
const overlay = getByText('Unlock map').closest('button')
fireEvent.keyDown(overlay!, { key: 'Enter' })

expect(mockMap.scrollWheelZoom.enable).toHaveBeenCalled()
Expand All @@ -301,7 +301,7 @@ describe('ChapterMap', () => {
it('handles keyboard interaction with Space key', () => {
const { getByText } = render(<ChapterMap {...defaultProps} />)

const overlay = getByText('Click to interact with map').closest('button')
const overlay = getByText('Unlock map').closest('button')
fireEvent.keyDown(overlay!, { key: ' ' })

expect(mockMap.scrollWheelZoom.enable).toHaveBeenCalled()
Expand All @@ -310,9 +310,9 @@ describe('ChapterMap', () => {
it('has proper accessibility attributes', () => {
const { getByText } = render(<ChapterMap {...defaultProps} />)

const overlay = getByText('Click to interact with map').closest('button')
const overlay = getByText('Unlock map').closest('button')
expect(overlay).toHaveAttribute('tabIndex', '0')
expect(overlay).toHaveAttribute('aria-label', 'Click to interact with map')
expect(overlay).toHaveAttribute('aria-label', 'Unlock map')
})
})

Expand Down
10 changes: 5 additions & 5 deletions frontend/src/components/ChapterMap.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client'
import { faLocationDot } from '@fortawesome/free-solid-svg-icons'
import { faLocationDot, faUnlock } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { Button } from '@heroui/button'
import { Tooltip } from '@heroui/tooltip'
Expand Down Expand Up @@ -195,10 +195,11 @@ const ChapterMap = ({
setIsMapActive(true)
}
}}
aria-label="Click to interact with map"
aria-label="Unlock map"
>
<p className="pointer-events-auto rounded-md bg-white/90 px-5 py-3 text-sm font-medium text-gray-700 shadow-lg dark:bg-gray-700 dark:text-white">
Click to interact with map
<p className="pointer-events-auto flex items-center gap-2 rounded-md bg-white/90 px-5 py-3 text-sm font-medium text-gray-700 shadow-lg transition-colors hover:bg-gray-200 hover:text-gray-900 dark:bg-gray-700 dark:text-white dark:hover:bg-gray-600 dark:hover:text-white">
<FontAwesomeIcon icon={faUnlock} aria-hidden="true" />
Unlock map
</p>
</button>
)}
Expand Down Expand Up @@ -227,5 +228,4 @@ const ChapterMap = ({
</div>
)
}

export default ChapterMap