-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Describe the bug
BaseModal.tsx component adds an explicit role = "dialog" attribute that duplicates the implicit role = "dialog" already provided by react-bootstrap modal, causing the test failures when using getByRole("dialog") in the spec.tsx files.
To Reproduce
Steps to reproduce the behavior:
- Create a test that uses the screen.getByRole("dialog") to find a BaseModal
- Render a component that uses the baseModal
- run the tests
- We see that the test fails with " Found Multiple elements with role dialog " error
Expected behavior
screen.getByRole('dialog') should find exactly one dialog element when BaseModal is rendered, allowing tests to pass without requiring workarounds.
Actual behavior
screen.getByRole('dialog') throws "Found multiple elements with role dialog" error because:
- react-bootstrap Modal automatically provides role="dialog" i.e. Implicit
- BaseModal explicitly adds role="dialog" on line 112 (explicit duplicate)
This issue forces maintainers to use getByTestId workarounds instead of semantic role-based queries in the test files.
Screenshots
Additional details
File : "talawa-admin\src\shared-components\BaseModal\BaseModal.tsx"
Line : 113
Impact : All Components using BaseModal require test workarounds that leads to very large change in the test files of the codebase.
Fix : we remove the role ="dialog" from the file at line 113
This will restore proper semantic testing while maintaining accessibility since the underlying Modal still provides the role.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Status