@@ -2,7 +2,7 @@ import { getClient, logger, setCurrentClient } from '@sentry/core';
22import { render } from '@testing-library/react-native' ;
33import * as React from 'react' ;
44import { Text } from 'react-native' ;
5-
5+ import { Appearance } from 'react-native' ;
66import { defaultConfiguration } from '../../src/js/feedback/defaults' ;
77import { FeedbackWidgetProvider , hideFeedbackButton , resetFeedbackButtonManager , resetFeedbackWidgetManager , showFeedbackButton , showFeedbackWidget } from '../../src/js/feedback/FeedbackWidgetManager' ;
88import { feedbackIntegration } from '../../src/js/feedback/integration' ;
@@ -205,14 +205,31 @@ describe('FeedbackButtonManager', () => {
205205 expect ( getClient ( ) . getIntegrationByName ( AUTO_INJECT_FEEDBACK_BUTTON_INTEGRATION_NAME ) ) . toBeDefined ( ) ;
206206 } ) ;
207207
208- it ( 'the Feedback Widget matches the snapshot with default configuration' , ( ) => {
208+ it ( 'the Feedback Widget matches the snapshot with default configuration and system light theme ' , ( ) => {
209209 mockedIsModalSupported . mockReturnValue ( true ) ;
210210 const { toJSON } = render (
211211 < FeedbackWidgetProvider >
212212 < Text > App Components</ Text >
213213 </ FeedbackWidgetProvider >
214214 ) ;
215215
216+ jest . spyOn ( Appearance , 'getColorScheme' ) . mockReturnValue ( 'light' ) ;
217+
218+ showFeedbackWidget ( ) ;
219+
220+ expect ( toJSON ( ) ) . toMatchSnapshot ( ) ;
221+ } ) ;
222+
223+ it ( 'the Feedback Widget matches the snapshot with default configuration and system dark theme' , ( ) => {
224+ mockedIsModalSupported . mockReturnValue ( true ) ;
225+ const { toJSON } = render (
226+ < FeedbackWidgetProvider >
227+ < Text > App Components</ Text >
228+ </ FeedbackWidgetProvider >
229+ ) ;
230+
231+ jest . spyOn ( Appearance , 'getColorScheme' ) . mockReturnValue ( 'dark' ) ;
232+
216233 showFeedbackWidget ( ) ;
217234
218235 expect ( toJSON ( ) ) . toMatchSnapshot ( ) ;
@@ -262,14 +279,79 @@ describe('FeedbackButtonManager', () => {
262279 expect ( toJSON ( ) ) . toMatchSnapshot ( ) ;
263280 } ) ;
264281
265- it ( 'the Feedback Button matches the snapshot with default configuration' , ( ) => {
282+ it ( 'the Feedback Widget matches the snapshot with system light custom theme' , ( ) => {
283+ mockedIsModalSupported . mockReturnValue ( true ) ;
284+ const { toJSON } = render (
285+ < FeedbackWidgetProvider >
286+ < Text > App Components</ Text >
287+ </ FeedbackWidgetProvider >
288+ ) ;
289+
290+ const integration = feedbackIntegration ( {
291+ colorScheme : 'system' ,
292+ themeLight : {
293+ foreground : '#ff0000' ,
294+ background : '#00ff00' ,
295+ } ,
296+ } ) ;
297+ getClient ( ) ?. addIntegration ( integration ) ;
298+
299+ jest . spyOn ( Appearance , 'getColorScheme' ) . mockReturnValue ( 'light' ) ;
300+
301+ showFeedbackWidget ( ) ;
302+
303+ expect ( toJSON ( ) ) . toMatchSnapshot ( ) ;
304+ } ) ;
305+
306+ it ( 'the Feedback Widget matches the snapshot with system dark custom theme' , ( ) => {
307+ mockedIsModalSupported . mockReturnValue ( true ) ;
308+ const { toJSON } = render (
309+ < FeedbackWidgetProvider >
310+ < Text > App Components</ Text >
311+ </ FeedbackWidgetProvider >
312+ ) ;
313+
314+ const integration = feedbackIntegration ( {
315+ colorScheme : 'system' ,
316+ themeDark : {
317+ foreground : '#00ff00' ,
318+ background : '#ff0000' ,
319+ } ,
320+ } ) ;
321+ getClient ( ) ?. addIntegration ( integration ) ;
322+
323+ jest . spyOn ( Appearance , 'getColorScheme' ) . mockReturnValue ( 'dark' ) ;
324+
325+ showFeedbackWidget ( ) ;
326+
327+ expect ( toJSON ( ) ) . toMatchSnapshot ( ) ;
328+ } ) ;
329+
330+ it ( 'the Feedback Button matches the snapshot with default configuration and system light theme' , ( ) => {
266331 mockedIsModalSupported . mockReturnValue ( true ) ;
267332 const { toJSON } = render (
268333 < FeedbackWidgetProvider >
269334 < Text > App Components</ Text >
270335 </ FeedbackWidgetProvider >
271336 ) ;
272337
338+ jest . spyOn ( Appearance , 'getColorScheme' ) . mockReturnValue ( 'light' ) ;
339+
340+ showFeedbackButton ( ) ;
341+
342+ expect ( toJSON ( ) ) . toMatchSnapshot ( ) ;
343+ } ) ;
344+
345+ it ( 'the Feedback Button matches the snapshot with default configuration and system dark theme' , ( ) => {
346+ mockedIsModalSupported . mockReturnValue ( true ) ;
347+ const { toJSON } = render (
348+ < FeedbackWidgetProvider >
349+ < Text > App Components</ Text >
350+ </ FeedbackWidgetProvider >
351+ ) ;
352+
353+ jest . spyOn ( Appearance , 'getColorScheme' ) . mockReturnValue ( 'dark' ) ;
354+
273355 showFeedbackButton ( ) ;
274356
275357 expect ( toJSON ( ) ) . toMatchSnapshot ( ) ;
@@ -318,4 +400,52 @@ describe('FeedbackButtonManager', () => {
318400
319401 expect ( toJSON ( ) ) . toMatchSnapshot ( ) ;
320402 } ) ;
403+
404+ it ( 'the Feedback Button matches the snapshot with system light custom theme' , ( ) => {
405+ mockedIsModalSupported . mockReturnValue ( true ) ;
406+ const { toJSON } = render (
407+ < FeedbackWidgetProvider >
408+ < Text > App Components</ Text >
409+ </ FeedbackWidgetProvider >
410+ ) ;
411+
412+ const integration = feedbackIntegration ( {
413+ colorScheme : 'system' ,
414+ themeLight : {
415+ foreground : '#ff0000' ,
416+ background : '#00ff00' ,
417+ } ,
418+ } ) ;
419+ getClient ( ) ?. addIntegration ( integration ) ;
420+
421+ jest . spyOn ( Appearance , 'getColorScheme' ) . mockReturnValue ( 'light' ) ;
422+
423+ showFeedbackButton ( ) ;
424+
425+ expect ( toJSON ( ) ) . toMatchSnapshot ( ) ;
426+ } ) ;
427+
428+ it ( 'the Feedback Button matches the snapshot with system dark custom theme' , ( ) => {
429+ mockedIsModalSupported . mockReturnValue ( true ) ;
430+ const { toJSON } = render (
431+ < FeedbackWidgetProvider >
432+ < Text > App Components</ Text >
433+ </ FeedbackWidgetProvider >
434+ ) ;
435+
436+ const integration = feedbackIntegration ( {
437+ colorScheme : 'system' ,
438+ themeDark : {
439+ foreground : '#00ff00' ,
440+ background : '#ff0000' ,
441+ } ,
442+ } ) ;
443+ getClient ( ) ?. addIntegration ( integration ) ;
444+
445+ jest . spyOn ( Appearance , 'getColorScheme' ) . mockReturnValue ( 'dark' ) ;
446+
447+ showFeedbackButton ( ) ;
448+
449+ expect ( toJSON ( ) ) . toMatchSnapshot ( ) ;
450+ } ) ;
321451} ) ;
0 commit comments