-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(feedback): Trigger button aria label configuration (#13008)
Adds `triggerAriaLabel` to configure the aria label of the trigger button. The aria label is set to the first value that's non-empty: 1. `triggerAriaLabel` 2. `triggerLabel` 3. TRIGGER_LABEL ("Report a Bug") Closes #12505
- Loading branch information
Showing
4 changed files
with
77 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { TRIGGER_LABEL } from '../../constants'; | ||
import { getFeedback } from '../getFeedback'; | ||
import { buildFeedbackIntegration } from '../integration'; | ||
import { mockSdk } from '../mockSdk'; | ||
|
||
describe('Actor', () => { | ||
it('renders the actor button', () => { | ||
const feedbackIntegration = buildFeedbackIntegration({ | ||
lazyLoadIntegration: jest.fn(), | ||
}); | ||
|
||
const configuredIntegration = feedbackIntegration({}); | ||
mockSdk({ | ||
sentryOptions: { | ||
integrations: [configuredIntegration], | ||
}, | ||
}); | ||
|
||
const feedback = getFeedback(); | ||
expect(feedback).toBeDefined(); | ||
|
||
const actorComponent = feedback!.createWidget(); | ||
|
||
expect(actorComponent.el).toBeInstanceOf(HTMLButtonElement); | ||
expect(actorComponent.el?.textContent).toBe(TRIGGER_LABEL); | ||
}); | ||
|
||
it('renders the correct aria label for the button', () => { | ||
const feedbackIntegration = buildFeedbackIntegration({ | ||
lazyLoadIntegration: jest.fn(), | ||
}); | ||
|
||
const configuredIntegration = feedbackIntegration({}); | ||
mockSdk({ | ||
sentryOptions: { | ||
integrations: [configuredIntegration], | ||
}, | ||
}); | ||
|
||
const feedback = getFeedback(); | ||
expect(feedback).toBeDefined(); | ||
|
||
// aria label is the same as trigger label when the trigger label isn't empty | ||
const actorDefault = feedback!.createWidget({ triggerLabel: 'Button' }); | ||
|
||
expect(actorDefault.el?.textContent).toBe('Button'); | ||
expect(actorDefault.el?.ariaLabel).toBe('Button'); | ||
|
||
// aria label is default text when trigger label is empty and aria isn't configured | ||
const actorIcon = feedback!.createWidget({ triggerLabel: '' }); | ||
|
||
expect(actorIcon.el?.textContent).toBe(''); | ||
expect(actorIcon.el?.ariaLabel).toBe(TRIGGER_LABEL); | ||
|
||
// aria label is the triggerAriaLabel if it's configured | ||
const actorAria = feedback!.createWidget({ triggerLabel: 'Button', triggerAriaLabel: 'Aria' }); | ||
|
||
expect(actorAria.el?.textContent).toBe('Button'); | ||
expect(actorAria.el?.ariaLabel).toBe('Aria'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters