Skip to content

Commit 92c4d2d

Browse files
antoniskrystofwoldrichlucas-zimerman
authored
test(e2e): Adds Feedback Widget Maestro E2E tests (#4604)
* Update the client implementation to use the new capture feedback js api * Updates SDK API * Adds new feedback button in the sample * Adds changelog * Removes unused mock * Update CHANGELOG.md Co-authored-by: Krystof Woldrich <[email protected]> * Directly use captureFeedback from sentry/core * Use import from core * Fixes imports order lint issue * Fixes build issue * Adds captureFeedback tests from sentry-javascript * Update CHANGELOG.md * Only deprecate client captureUserFeedback * Add simple form UI * Adds basic form functionality * Update imports * Update imports * Remove useState hook to avoid multiple react instances issues * Move types and styles in different files * Removes attachment button to be added back separately along with the implementation * Add basic field validation * Adds changelog * Updates changelog * Updates changelog * Trim whitespaces from the submitted feedback * Adds tests * Renames FeedbackFormScreen to FeedbackForm * Add beta label * Extract default text to constants * Moves constant to a separate file and aligns naming with JS * Adds input text labels * Close screen before sending the feedback to minimise wait time Co-authored-by: LucasZF <[email protected]> * Rename file for consistency * Flatten configuration hierarchy and clean up * Align required values with JS * Use Sentry user email and name when set * Simplifies email validation * Show success alert message * Aligns naming with JS and unmounts the form by default * Use the minimum config without props in the changelog * Adds development not for unimplemented function * Show email and name conditionally * Adds sentry branding (png logo) * Adds sentry logo resource * Add assets in module exports * Revert "Add assets in module exports" This reverts commit 5292475. * Revert "Adds sentry logo resource" This reverts commit d6e9229. * Revert "Adds sentry branding (png logo)" This reverts commit 8c56753. * Add last event id * Mock lastEventId * Adds beta note in the changelog * Autoinject feedback form * Updates changelog * Align colors with JS * Update CHANGELOG.md Co-authored-by: Krystof Woldrich <[email protected]> * Update CHANGELOG.md Co-authored-by: Krystof Woldrich <[email protected]> * Update CHANGELOG.md Co-authored-by: Krystof Woldrich <[email protected]> * Use regular fonts for both buttons * Handle keyboard properly * Adds an option on whether the email should be validated * Merge properties only once * Loads current user data on form construction * Remove unneeded extra padding * Fix background color issue * Adds feedback button * Updates the changelog * Fixes changelog typo * Updates styles background color Co-authored-by: Krystof Woldrich <[email protected]> * Use defaultProps * Correct defaultProps * Adds test to verify when getUser is called * Use smaller image Co-authored-by: LucasZF <[email protected]> * Add margin next to the icon * Adds bottom spacing in the ErrorScreen so that the feedback button does not hide the scrollview buttons * (2.2) feat: Add Feedback Form UI Branding logo (#4357) * Adds sentry branding logo as a base64 encoded png --------- Co-authored-by: LucasZF <[email protected]> * Autoinject feedback form (#4370) * Align changelog entry * Update changelog * Disable bouncing * Add modal ui appearance * Update snapshot tests * Fix bottom margin * Fix sheet height * Remove extra modal border * Do not expose modal styles * Animate background color * Avoid keyboard in modal * Update changelog * Fix changelog * Updates comment * Extract FeedbackButtonProps * Add public function description to satisfy lint check * Adds tests * Fix tests * Add test ids in feedback widget * Add feedback widget button in test app * WIP: Add feedback test * Update snapshot tests with the added test ids * Android happy path test * Check field validation * Scroll if button is not visible * Adds accessibility labels * Remove extended initial checks due to flakiness * Revert "Remove extended initial checks due to flakiness" This reverts commit fa3bdfc. * Add hardcoded dark and light color themes * Rename theme options * Update snapshot tests * Include in the feedback integration * Fix circular dependency * Add theme integration options * Adds changelog * Add comment note * Align with JS api * Remove unneeded line Co-authored-by: Krystof Woldrich <[email protected]> * Place widget button below the feedback widget shadow * Expose showFeedbackButton/hideFeedbackButton methods * Add dummy integration for tracking usage * Adds button border * Fixes tests * Add accentBackground and accentForeground colors * Extract integration getter in a helper function * Adds dynamic theming support * Add snapshot tests * Show screenshot button UI * Add screenshot button integration * Add screenshot icon * Adds Take a screenshot button in FeedbackWidget * Updates snapshot tests * Fix circularDepCheck * Fix circularDepCheck * Attache captured screenshot * Hide the take screenshot button when there is a screenshot * Convert uint8Array to Base64 on the native side * ref(feedback): Extracts FeedbackWidgetProvider in a separate file * Updates exposed comments * Adds snapshot tests * Disable functionality on the Web * Add screenshot button in the sample expo app * Adds system theme tests * Test dynamically changed theme * Remove showScreenshotButton and hideScreenshotButton from the exposed api * Fix function name typo * Adds enableTakeScreenshot option * Adds happy flow test * Make flow tests more granular * Increate wait time out to fix flakiness on ci * Reset widget state after each test * Fix CI flakiness * Remove flaky test * fix(feedback): Fixes accessibility issue on iOS * Add changelog * Properly wrap root app component * Handle undefined AppRegistryIntegration.onRunApplication gracefully * Fix lint issue * Do not validate all fields for visibility * Take screenshots for debugging * Revert "Take screenshots for debugging" This reverts commit 3e361a1. * Simplify test scenario * Try without hiding the keyboard * Test Feedback button * Test screenshot capture * Show an error if screenshot capture fails * Test error flow * Revert unneeded change * Test with latest Maestro * Revert "Test with latest Maestro" This reverts commit e7c31bf. * Revert "Test screenshot capture" This reverts commit 8913ffc. * Skip for 0.65.3 * Remove version check * Use testId for feedback button * Skip for 0.65.3 * Update snapshots * Cleanup testIds and accessibility labels * Enable for all RN versions * Temp: remove modal supported check * Do not use native driver for backgroundOpacity animation * Revert "Temp: remove modal supported check" This reverts commit e20aff2. * Do not use native driver for backgroundOpacity animation * Use text instead of test ids * Separate iOS and Android tests --------- Co-authored-by: Krystof Woldrich <[email protected]> Co-authored-by: LucasZF <[email protected]>
1 parent f7675d9 commit 92c4d2d

File tree

10 files changed

+192
-4
lines changed

10 files changed

+192
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
appId: ${APP_ID}
2+
jsEngine: graaljs
3+
---
4+
- runFlow: utils/launchTestAppClear.yml
5+
6+
7+
# The following tests are happy path tests for the feedback widget on both iOS and Android.
8+
# They verify that the feedback form can be opened, filled out, and submitted successfully.
9+
# The tests are separate because iOS tests work better with `testID` and Android tests work better with `text`.
10+
11+
- runFlow:
12+
file: feedback/happyFlow-ios.yml
13+
when:
14+
platform: iOS
15+
16+
- runFlow:
17+
file: feedback/happyFlow-android.yml
18+
when:
19+
platform: Android
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# This is a happy path test for the feedback widget on Android.
2+
# It verifies that the feedback form can be opened, filled out, and submitted successfully
3+
appId: ${APP_ID}
4+
jsEngine: graaljs
5+
---
6+
7+
# Show feedback button
8+
- tapOn: 'Feedback'
9+
10+
# Open feedback widget
11+
- tapOn: 'Report a Bug'
12+
13+
# Assert that the feedback form is visible
14+
- extendedWaitUntil:
15+
visible: 'Report a Bug'
16+
timeout: 5_000
17+
18+
# Fill out name field
19+
- tapOn: 'Your Name'
20+
- inputText: 'John Doe'
21+
22+
# Fill out email field
23+
24+
- inputText: '[email protected]'
25+
26+
# Fill out message field
27+
- tapOn: "What's the bug? What did you expect?"
28+
- inputText: 'This is a test feedback message from CI e2e tests'
29+
30+
# Submit feedback
31+
- scrollUntilVisible:
32+
element:
33+
text: 'Send Bug Report'
34+
- tapOn: 'Send Bug Report'
35+
- assertVisible: 'Thank you for your report!'
36+
- tapOn: 'OK'
37+
38+
# Verify feedback form is closed and the home screen is visible
39+
- assertVisible: 'Welcome to React Native'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# This is a happy path test for the feedback widget on iOS.
2+
# It verifies that the feedback form can be opened, filled out, and submitted successfully
3+
appId: ${APP_ID}
4+
jsEngine: graaljs
5+
---
6+
7+
# Show feedback button
8+
- tapOn: 'Feedback'
9+
10+
# Open feedback widget
11+
- tapOn:
12+
id: 'sentry-feedback-button'
13+
14+
# Assert that the feedback form is visible
15+
- extendedWaitUntil:
16+
visible:
17+
id: 'sentry-feedback-form-title'
18+
timeout: 5_000
19+
20+
# Fill out name field
21+
- tapOn:
22+
id: 'sentry-feedback-name-input'
23+
- inputText: 'John Doe'
24+
25+
# Fill out email field
26+
- tapOn:
27+
id: 'sentry-feedback-email-input'
28+
- inputText: '[email protected]'
29+
30+
# Fill out message field
31+
- tapOn:
32+
id: 'sentry-feedback-message-input'
33+
- inputText: 'This is a test feedback message from CI e2e tests'
34+
35+
# Submit feedback
36+
- scrollUntilVisible:
37+
element:
38+
id: 'sentry-feedback-submit-button'
39+
- tapOn:
40+
id: 'sentry-feedback-submit-button'
41+
- assertVisible: 'Thank you for your report!'
42+
- tapOn: 'OK'
43+
44+
# Verify feedback form is closed and the home screen is visible
45+
- assertVisible: 'Welcome to React Native'

dev-packages/e2e-tests/patch-scripts/rn.patch.app.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const e2eComponentPatch = '<EndToEndTestsScreen />';
3939
const lastImportRex = /^([^]*)(import\s+[^;]*?;$)/m;
4040
const patchRex = '@sentry/react-native';
4141
const headerComponentRex = /<ScrollView/gm;
42+
const exportDefaultRex = /export\s+default\s+App;/m;
4243

4344
const jsPath = path.join(args.app, 'App.js');
4445
const tsxPath = path.join(args.app, 'App.tsx');
@@ -50,7 +51,8 @@ const isPatched = app.match(patchRex);
5051
if (!isPatched) {
5152
const patched = app
5253
.replace(lastImportRex, m => m + initPatch)
53-
.replace(headerComponentRex, m => e2eComponentPatch + m);
54+
.replace(headerComponentRex, m => e2eComponentPatch + m)
55+
.replace(exportDefaultRex, 'export default Sentry.wrap(App);');
5456

5557
fs.writeFileSync(appPath, patched);
5658
logger.info('Patched RN App.(js|tsx) successfully!');

dev-packages/e2e-tests/src/EndToEndTests.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ const EndToEndTestsScreen = (): JSX.Element => {
6262
name: 'Unhandled Promise Rejection',
6363
action: async () => await Promise.reject(new Error('Unhandled Promise Rejection')),
6464
},
65+
{
66+
id: 'feedback',
67+
name: 'Feedback',
68+
action: () => Sentry.showFeedbackButton(),
69+
},
6570
{
6671
id: 'close',
6772
name: 'Close',

packages/core/src/js/feedback/FeedbackButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class FeedbackButton extends React.Component<FeedbackButtonProps> {
5959
accessibilityLabel={text.triggerAriaLabel}
6060
>
6161
<Image source={{ uri: feedbackIcon }} style={styles.triggerIcon}/>
62-
<Text style={styles.triggerText}>{text.triggerLabel}</Text>
62+
<Text style={styles.triggerText} testID='sentry-feedback-button'>{text.triggerLabel}</Text>
6363
</TouchableOpacity>
6464
);
6565
}

packages/core/src/js/feedback/FeedbackWidget.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ export class FeedbackWidget extends React.Component<FeedbackWidgetProps, Feedbac
273273
>
274274
<View style={styles.container}>
275275
<View style={styles.titleContainer}>
276-
<Text style={styles.title}>{text.formTitle}</Text>
276+
<Text style={styles.title} testID='sentry-feedback-form-title'>{text.formTitle}</Text>
277277
{config.showBranding && (
278278
<Image
279279
source={{ uri: sentryLogo }}
@@ -291,6 +291,7 @@ export class FeedbackWidget extends React.Component<FeedbackWidgetProps, Feedbac
291291
</Text>
292292
<TextInput
293293
style={styles.input}
294+
testID='sentry-feedback-name-input'
294295
placeholder={text.namePlaceholder}
295296
value={name}
296297
onChangeText={(value) => this.setState({ name: value })}
@@ -306,6 +307,7 @@ export class FeedbackWidget extends React.Component<FeedbackWidgetProps, Feedbac
306307
</Text>
307308
<TextInput
308309
style={styles.input}
310+
testID='sentry-feedback-email-input'
309311
placeholder={text.emailPlaceholder}
310312
keyboardType={'email-address' as KeyboardTypeOptions}
311313
value={email}
@@ -320,6 +322,7 @@ export class FeedbackWidget extends React.Component<FeedbackWidgetProps, Feedbac
320322
</Text>
321323
<TextInput
322324
style={[styles.input, styles.textArea]}
325+
testID='sentry-feedback-message-input'
323326
placeholder={text.messagePlaceholder}
324327
value={description}
325328
onChangeText={(value) => this.setState({ description: value })}
@@ -352,7 +355,7 @@ export class FeedbackWidget extends React.Component<FeedbackWidgetProps, Feedbac
352355
</TouchableOpacity>
353356
)}
354357
<TouchableOpacity style={styles.submitButton} onPress={this.handleFeedbackSubmit}>
355-
<Text style={styles.submitText}>{text.submitButtonLabel}</Text>
358+
<Text style={styles.submitText} testID='sentry-feedback-submit-button'>{text.submitButtonLabel}</Text>
356359
</TouchableOpacity>
357360

358361
<TouchableOpacity style={styles.cancelButton} onPress={onCancel}>

packages/core/test/feedback/__snapshots__/FeedbackButton.test.tsx.snap

+3
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ exports[`FeedbackButton matches the snapshot with custom styles 1`] = `
7878
"fontSize": 18,
7979
}
8080
}
81+
testID="sentry-feedback-button"
8182
>
8283
Report a Bug
8384
</Text>
@@ -162,6 +163,7 @@ exports[`FeedbackButton matches the snapshot with custom texts 1`] = `
162163
"fontSize": 18,
163164
}
164165
}
166+
testID="sentry-feedback-button"
165167
>
166168
Give Feedback
167169
</Text>
@@ -246,6 +248,7 @@ exports[`FeedbackButton matches the snapshot with default configuration 1`] = `
246248
"fontSize": 18,
247249
}
248250
}
251+
testID="sentry-feedback-button"
249252
>
250253
Report a Bug
251254
</Text>

0 commit comments

Comments
 (0)