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
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('EntityActions a11y', () => {
/>
)

const toggleButton = screen.getByTestId('program-actions-button')
const toggleButton = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(toggleButton)

const results = await axe(container)
Expand Down
2 changes: 1 addition & 1 deletion frontend/__tests__/a11y/components/Footer.a11y.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Footer a11y', () => {
it('should not have any accessibility violations when section is opened', async () => {
const { container } = render(<Footer />)

const button = screen.getByTestId('footer-section-button-Resources')
const button = screen.getByRole('button', { name: /Resources/ })
fireEvent.click(button)

const results = await axe(container)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('RepositoryCard a11y', () => {
const repositories = Array.from({ length: 6 }, (_, i) => createMockRepository(i))
const { container } = render(<RepositoryCard repositories={repositories} />)

const showMoreButton = screen.getByTestId('show-more-button')
const showMoreButton = screen.getByRole('button', { name: /show more/i })
fireEvent.click(showMoreButton)

const results = await axe(container)
Expand Down
10 changes: 5 additions & 5 deletions frontend/__tests__/unit/components/ContributionStats.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ describe('ContributionStats', () => {
it('renders all react-icons correctly', () => {
render(<ContributionStats {...defaultProps} />)

const container = screen.getByTestId('contribution-stats')
const container = screen.getByRole('region')
const icons = container.querySelectorAll('svg')
expect(icons).toHaveLength(5) // Title icon + 4 stat icons

// Verify specific icon data attributes
expect(screen.getByTestId('contribution-stats')).toBeInTheDocument()
expect(screen.getByRole('region')).toBeInTheDocument()
expect(screen.getByText('Test Contribution Activity')).toBeInTheDocument()
})

Expand Down Expand Up @@ -229,7 +229,7 @@ describe('ContributionStats', () => {
render(<ContributionStats {...defaultProps} />)

// Check that the container exists and the grid has proper classes
const container = screen.getByTestId('contribution-stats')
const container = screen.getByRole('region')
expect(container).toBeInTheDocument()

// The mb-6 class is on the grid div, not the container
Expand Down Expand Up @@ -293,7 +293,7 @@ describe('ContributionStats', () => {
it('renders with proper CSS classes for styling', () => {
render(<ContributionStats {...defaultProps} />)

const container = screen.getByTestId('contribution-stats')
const container = screen.getByRole('region')
expect(container).toBeInTheDocument()

const heading = container.querySelector('h2')
Expand All @@ -307,7 +307,7 @@ describe('ContributionStats', () => {
it('renders all required icons with proper attributes', () => {
render(<ContributionStats {...defaultProps} />)

const container = screen.getByTestId('contribution-stats')
const container = screen.getByRole('region')
const icons = container.querySelectorAll('svg')
expect(icons).toHaveLength(5)

Expand Down
62 changes: 31 additions & 31 deletions frontend/__tests__/unit/components/EntityActions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('EntityActions', () => {
describe('Program Actions - Create Module', () => {
it('navigates to create module page when Add Module is clicked', () => {
render(<EntityActions type="program" programKey="test-program" />)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)

const addModuleButton = screen.getByText('Add Module')
Expand All @@ -31,7 +31,7 @@ describe('EntityActions', () => {

it('closes dropdown after clicking Add Module', () => {
render(<EntityActions type="program" programKey="test-program" />)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)
expect(button).toHaveAttribute('aria-expanded', 'true')

Expand All @@ -45,7 +45,7 @@ describe('EntityActions', () => {
describe('Module Actions - Edit Module', () => {
it('navigates to edit module page when Edit is clicked with moduleKey', () => {
render(<EntityActions type="module" programKey="test-program" moduleKey="test-module" />)
const button = screen.getByTestId('module-actions-button')
const button = screen.getByRole('button', { name: /Module actions menu/ })
fireEvent.click(button)

const editButton = screen.getByText('Edit')
Expand All @@ -58,7 +58,7 @@ describe('EntityActions', () => {

it('does not navigate when moduleKey is missing for edit action', () => {
render(<EntityActions type="module" programKey="test-program" />)
const button = screen.getByTestId('module-actions-button')
const button = screen.getByRole('button', { name: /Module actions menu/ })
fireEvent.click(button)

const editButton = screen.getByText('Edit')
Expand All @@ -69,7 +69,7 @@ describe('EntityActions', () => {

it('closes dropdown after clicking Edit', () => {
render(<EntityActions type="module" programKey="test-program" moduleKey="test-module" />)
const button = screen.getByTestId('module-actions-button')
const button = screen.getByRole('button', { name: /Module actions menu/ })
fireEvent.click(button)
expect(button).toHaveAttribute('aria-expanded', 'true')

Expand All @@ -83,7 +83,7 @@ describe('EntityActions', () => {
describe('Module Actions - View Issues', () => {
it('navigates to view issues page when View Issues is clicked with moduleKey', () => {
render(<EntityActions type="module" programKey="test-program" moduleKey="test-module" />)
const button = screen.getByTestId('module-actions-button')
const button = screen.getByRole('button', { name: /Module actions menu/ })
fireEvent.click(button)

const viewIssuesButton = screen.getByText('View Issues')
Expand All @@ -96,7 +96,7 @@ describe('EntityActions', () => {

it('does not navigate when moduleKey is missing for view issues action', () => {
render(<EntityActions type="module" programKey="test-program" />)
const button = screen.getByTestId('module-actions-button')
const button = screen.getByRole('button', { name: /Module actions menu/ })
fireEvent.click(button)

const viewIssuesButton = screen.getByText('View Issues')
Expand All @@ -107,7 +107,7 @@ describe('EntityActions', () => {

it('closes dropdown after clicking View Issues', () => {
render(<EntityActions type="module" programKey="test-program" moduleKey="test-module" />)
const button = screen.getByTestId('module-actions-button')
const button = screen.getByRole('button', { name: /Module actions menu/ })
fireEvent.click(button)
expect(button).toHaveAttribute('aria-expanded', 'true')

Expand All @@ -129,7 +129,7 @@ describe('EntityActions', () => {
setStatus={mockSetStatus}
/>
)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)

const publishButton = screen.getByText('Publish')
Expand All @@ -142,7 +142,7 @@ describe('EntityActions', () => {
render(
<EntityActions type="program" programKey="test-program" status={ProgramStatusEnum.Draft} />
)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)

expect(screen.getByText('Publish')).toBeInTheDocument()
Expand All @@ -156,7 +156,7 @@ describe('EntityActions', () => {
status={ProgramStatusEnum.Published}
/>
)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)

expect(screen.queryByText('Publish')).not.toBeInTheDocument()
Expand All @@ -172,7 +172,7 @@ describe('EntityActions', () => {
setStatus={mockSetStatus}
/>
)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)
expect(button).toHaveAttribute('aria-expanded', 'true')

Expand All @@ -194,7 +194,7 @@ describe('EntityActions', () => {
setStatus={mockSetStatus}
/>
)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)

const unpublishButton = screen.getByText('Unpublish')
Expand All @@ -213,7 +213,7 @@ describe('EntityActions', () => {
setStatus={mockSetStatus}
/>
)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)

const unpublishButton = screen.getByText('Unpublish')
Expand All @@ -230,7 +230,7 @@ describe('EntityActions', () => {
status={ProgramStatusEnum.Published}
/>
)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)

expect(screen.getByText('Unpublish')).toBeInTheDocument()
Expand All @@ -244,7 +244,7 @@ describe('EntityActions', () => {
status={ProgramStatusEnum.Completed}
/>
)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)

expect(screen.getByText('Unpublish')).toBeInTheDocument()
Expand All @@ -254,7 +254,7 @@ describe('EntityActions', () => {
render(
<EntityActions type="program" programKey="test-program" status={ProgramStatusEnum.Draft} />
)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)

expect(screen.queryByText('Unpublish')).not.toBeInTheDocument()
Expand All @@ -270,7 +270,7 @@ describe('EntityActions', () => {
setStatus={mockSetStatus}
/>
)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)
expect(button).toHaveAttribute('aria-expanded', 'true')

Expand All @@ -292,7 +292,7 @@ describe('EntityActions', () => {
setStatus={mockSetStatus}
/>
)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)

const completedButton = screen.getByText('Mark as Completed')
Expand All @@ -309,7 +309,7 @@ describe('EntityActions', () => {
status={ProgramStatusEnum.Published}
/>
)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)

expect(screen.getByText('Mark as Completed')).toBeInTheDocument()
Expand All @@ -319,7 +319,7 @@ describe('EntityActions', () => {
render(
<EntityActions type="program" programKey="test-program" status={ProgramStatusEnum.Draft} />
)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)

expect(screen.queryByText('Mark as Completed')).not.toBeInTheDocument()
Expand All @@ -333,7 +333,7 @@ describe('EntityActions', () => {
status={ProgramStatusEnum.Completed}
/>
)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)

expect(screen.queryByText('Mark as Completed')).not.toBeInTheDocument()
Expand All @@ -349,7 +349,7 @@ describe('EntityActions', () => {
setStatus={mockSetStatus}
/>
)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)
expect(button).toHaveAttribute('aria-expanded', 'true')

Expand All @@ -363,7 +363,7 @@ describe('EntityActions', () => {
describe('Click Outside Behavior', () => {
it('closes dropdown when clicking outside', async () => {
render(<EntityActions type="program" programKey="test-program" />)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)
expect(button).toHaveAttribute('aria-expanded', 'true')

Expand All @@ -376,7 +376,7 @@ describe('EntityActions', () => {

it('does not close dropdown when clicking inside', () => {
render(<EntityActions type="program" programKey="test-program" />)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)
expect(button).toHaveAttribute('aria-expanded', 'true')

Expand All @@ -403,7 +403,7 @@ describe('EntityActions', () => {
render(
<EntityActions type="program" programKey="test-program" status={ProgramStatusEnum.Draft} />
)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)

const publishButton = screen.getByText('Publish')
Expand All @@ -419,7 +419,7 @@ describe('EntityActions', () => {
status={ProgramStatusEnum.Published}
/>
)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)

const unpublishButton = screen.getByText('Unpublish')
Expand All @@ -434,7 +434,7 @@ describe('EntityActions', () => {
status={ProgramStatusEnum.Published}
/>
)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)

const completedButton = screen.getByText('Mark as Completed')
Expand All @@ -443,7 +443,7 @@ describe('EntityActions', () => {

it('handles undefined status gracefully', () => {
render(<EntityActions type="program" programKey="test-program" />)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)

// Should still show Edit and Add Module
Expand All @@ -461,7 +461,7 @@ describe('EntityActions', () => {
<EntityActions type="program" programKey="test-program" />
</div>
)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)

expect(mockParentClick).not.toHaveBeenCalled()
Expand All @@ -475,7 +475,7 @@ describe('EntityActions', () => {
<EntityActions type="program" programKey="test-program" />
</div>
)
const button = screen.getByTestId('program-actions-button')
const button = screen.getByRole('button', { name: /Program actions menu/ })
fireEvent.click(button)

const editButton = screen.getByText('Edit')
Expand Down
6 changes: 3 additions & 3 deletions frontend/__tests__/unit/components/ProgramCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ describe('ProgramCard', () => {
/>
)

const actionsButton = screen.getByTestId('program-actions-button')
const actionsButton = screen.getByRole('button', { name: /Program actions menu/ })

await act(async () => {
fireEvent.click(actionsButton)
Expand Down Expand Up @@ -416,7 +416,7 @@ describe('ProgramCard', () => {
/>
)

expect(screen.getByTestId('program-actions-button')).toBeInTheDocument()
expect(screen.getByRole('button', { name: /Program actions menu/ })).toBeInTheDocument()
})
})

Expand All @@ -431,7 +431,7 @@ describe('ProgramCard', () => {
/>
)

expect(screen.getByTestId('program-actions-button')).toBeInTheDocument()
expect(screen.getByRole('button', { name: /Program actions menu/ })).toBeInTheDocument()
})

it('handles program with minimal data', () => {
Expand Down
Loading