-
-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Sentry user email and name when set
- Loading branch information
Showing
4 changed files
with
36 additions
and
3 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,12 @@ jest.spyOn(Alert, 'alert'); | |
|
||
jest.mock('@sentry/core', () => ({ | ||
captureFeedback: jest.fn(), | ||
getCurrentScope: jest.fn(() => ({ | ||
getUser: jest.fn(() => ({ | ||
email: '[email protected]', | ||
name: 'Test User', | ||
})), | ||
})), | ||
})); | ||
|
||
const defaultProps: FeedbackFormProps = { | ||
|
@@ -50,6 +56,16 @@ describe('FeedbackForm', () => { | |
expect(getByText(defaultProps.cancelButtonLabel)).toBeTruthy(); | ||
}); | ||
|
||
it('name and email are prefilled when sentry user is set', () => { | ||
const { getByPlaceholderText } = render(<FeedbackForm {...defaultProps} />); | ||
|
||
const nameInput = getByPlaceholderText(defaultProps.namePlaceholder); | ||
const emailInput = getByPlaceholderText(defaultProps.emailPlaceholder); | ||
|
||
expect(nameInput.props.value).toBe('Test User'); | ||
expect(emailInput.props.value).toBe('[email protected]'); | ||
}); | ||
|
||
it('shows an error message if required fields are empty', async () => { | ||
const { getByText } = render(<FeedbackForm {...defaultProps} />); | ||
|
||
|