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
26 changes: 9 additions & 17 deletions apps/web/__tests__/components/habits/habit-card.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('HabitCard', () => {
const habit = createMockHabit()
render(<HabitCard habit={habit} />)
const article = screen.getByLabelText('Exercise')
expect(article.tagName).toBe('ARTICLE')
expect(article.tagName).toBe('BUTTON')
})

it('calls onDetail when card is clicked', () => {
Expand Down Expand Up @@ -129,7 +129,7 @@ describe('HabitCard', () => {
it('applies opacity-40 when habit is completed', () => {
const habit = createMockHabit({ isCompleted: true })
const { container } = render(<HabitCard habit={habit} />)
const article = container.querySelector('article')
const article = container.querySelector('button[aria-label]')
expect(article?.className).toContain('opacity-40')
})

Expand Down Expand Up @@ -352,21 +352,13 @@ describe('HabitCard', () => {
expect(screen.getByText('habits.actions.openSubHabits')).toBeDefined()
})

it('handles keyboard Enter to trigger card click', () => {
it('card button is focusable and clickable (Enter/Space handled natively)', () => {
const onDetail = vi.fn()
const habit = createMockHabit()
render(<HabitCard habit={habit} onDetail={onDetail} />)
const article = screen.getByLabelText('Exercise')
fireEvent.keyDown(article, { key: 'Enter' })
expect(onDetail).toHaveBeenCalledOnce()
})

it('handles keyboard Space to trigger card click', () => {
const onDetail = vi.fn()
const habit = createMockHabit()
render(<HabitCard habit={habit} onDetail={onDetail} />)
const article = screen.getByLabelText('Exercise')
fireEvent.keyDown(article, { key: ' ' })
const card = screen.getByLabelText('Exercise')
expect(card.tagName).toBe('BUTTON')
fireEvent.click(card)
expect(onDetail).toHaveBeenCalledOnce()
})

Expand All @@ -380,14 +372,14 @@ describe('HabitCard', () => {
it('uses child CSS classes at depth > 0', () => {
const habit = createMockHabit()
const { container } = render(<HabitCard habit={habit} depth={1} />)
const article = container.querySelector('article')
const article = container.querySelector('button[aria-label]')
expect(article?.className).toContain('habit-card-child')
})

it('uses parent CSS classes at depth 0', () => {
const habit = createMockHabit()
const { container } = render(<HabitCard habit={habit} depth={0} />)
const article = container.querySelector('article')
const article = container.querySelector('button[aria-label]')
expect(article?.className).toContain('habit-card-parent')
})

Expand All @@ -396,7 +388,7 @@ describe('HabitCard', () => {
const { container } = render(
<HabitCard habit={habit} isSelectMode={true} isSelected={true} />,
)
const article = container.querySelector('article')
const article = container.querySelector('button[aria-label]')
expect(article?.className).toContain('ring-2')
})

Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/(app)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@
const { tags } = useTags()

// Show general on today preference (local storage)
const [showGeneralOnToday] = useState(() => {
const [showGeneralOnToday, _setShowGeneralOnToday] = useState(() => {

Check warning on line 281 in apps/web/app/(app)/page.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

useState call is not destructured into value + setter pair

See more on https://sonarcloud.io/project/issues?id=thomasluizon_orbit-ui-mobile&issues=AZ1byLLHS1usNdOdhTPB&open=AZ1byLLHS1usNdOdhTPB&pullRequest=7
if (typeof globalThis === 'undefined' || typeof globalThis.localStorage === 'undefined') return true // NOSONAR - SSR guard
return localStorage.getItem('orbit_show_general_on_today') !== 'false'
})
Expand Down
Loading
Loading