-
-
Notifications
You must be signed in to change notification settings - Fork 355
Autoinject feedback widget #4483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
638377d
Auto-inject feedback form
antonis db407ce
Temporarily disable sample rotating indicator
antonis 7837b96
Merge branch 'feedback-ui' into antonis/feedback-autoinject
antonis e9f428d
Revert "Temporarily disable sample rotating indicator"
antonis 011fea7
Wrap Modal in a View
antonis a4962b9
Handles Android back button
antonis 2d4abb3
Make modal style configurable
antonis 84108f1
Print an error when the modal is not supported
antonis 587c3fc
Add changelog
antonis f4df57c
Adds tests
antonis 0d466d2
Get major, minor version with deconstruct declaration
antonis caa075b
Remove if condition
antonis 8071e8d
Prettier
antonis d8ab914
Fix test import
antonis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Adds tests
- Loading branch information
commit f4df57c2c52ac2c6709863ad4fab39e0fecaec44
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,53 @@ | ||
| import { logger } from '@sentry/core'; | ||
| import { render } from '@testing-library/react-native'; | ||
| import * as React from 'react'; | ||
| import { Text } from 'react-native'; | ||
|
|
||
| import { FeedbackFormProvider, showFeedbackForm } from '../../src/js/feedback/FeedbackFormManager'; | ||
|
|
||
| jest.mock('../../src/js/feedback/utils', () => ({ | ||
| isModalSupported: jest.fn(), | ||
| })); | ||
|
|
||
| beforeEach(() => { | ||
| logger.error = jest.fn(); | ||
| }); | ||
|
|
||
| describe('FeedbackFormManager', () => { | ||
| it('showFeedbackForm displays the form when FeedbackFormProvider is used', () => { | ||
| require('../../src/js/feedback/utils').isModalSupported.mockReturnValue(true); | ||
| const { getByText, getByTestId } = render( | ||
| <FeedbackFormProvider> | ||
| <Text>App Components</Text> | ||
| </FeedbackFormProvider> | ||
| ); | ||
|
|
||
| showFeedbackForm(); | ||
|
|
||
| expect(getByTestId('feedback-form-modal')).toBeTruthy(); | ||
| expect(getByText('App Components')).toBeTruthy(); | ||
| }); | ||
|
|
||
| it('showFeedbackForm does not display the form when Modal is not available', () => { | ||
| require('../../src/js/feedback/utils').isModalSupported.mockReturnValue(false); | ||
| const { getByText, queryByTestId } = render( | ||
| <FeedbackFormProvider> | ||
| <Text>App Components</Text> | ||
| </FeedbackFormProvider> | ||
| ); | ||
|
|
||
| showFeedbackForm(); | ||
|
|
||
| expect(queryByTestId('feedback-form-modal')).toBeNull(); | ||
| expect(getByText('App Components')).toBeTruthy(); | ||
| expect(logger.error).toHaveBeenLastCalledWith( | ||
| 'FeedbackForm Modal is not supported in React Native < 0.71 with Fabric renderer.', | ||
| ); | ||
| }); | ||
|
|
||
| it('showFeedbackForm does not throw an error when FeedbackFormProvider is not used', () => { | ||
| expect(() => { | ||
| showFeedbackForm(); | ||
| }).not.toThrow(); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l:
import { isModalSupported } from ''../../src/js/feedback/utils'';and then(isModalSupported as jest.MockedFunction<typeof isModalSupported>)should also work and it will be typesafe.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea Krystof 👍
Updated with d8ab914