@@ -50,11 +50,8 @@ describe("Event Builder", () => {
5050 const { wrapped } = withProviders ( < Sut /> , { isLoggedIn : false } )
5151 const { findByLabelText, findByTestId } = renderer . render ( wrapped )
5252
53- await React . act ( async ( ) => {
54- // Choose the second view in the list
55- const clientToggle = await findByTestId ( "use firebase" )
56- clientToggle . click ( )
57- } )
53+ const clientToggle = await findByTestId ( "use firebase" )
54+ userEvent . click ( clientToggle )
5855
5956 await findByLabelText ( Label . APISecret , { exact : false } )
6057
@@ -95,45 +92,49 @@ describe("Event Builder", () => {
9592 exact : false ,
9693 } )
9794
98- await React . act ( async ( ) => {
99- await userEvent . type ( apiSecret , "my_secret" , { delay : 1 } )
100- await userEvent . type ( firebaseAppId , "my_firebase_app_id" , {
101- delay : 1 ,
102- } )
103- await userEvent . type ( appInstanceId , "my_instance_id" , { delay : 1 } )
104- await userEvent . type ( userId , "my_user_id" , { delay : 1 } )
105-
106- // TODO - I'm pretty unhappy with this, but I'm having a lot of
107- // trouble testing the Autocomplete component without doing this.
108- // This test is somewhat likely to break if we add/remove events &
109- // event categories so if it's broken, it's probably fine to just
110- // change the expected values.
111- const ecInput = within ( eventCategory ) . getByRole ( "combobox" )
112- eventCategory . focus ( )
113- renderer . fireEvent . change ( ecInput , { target : { value : "All apps" } } )
114-
115- const enInput = within ( eventName ) . getByRole ( "combobox" )
116- eventCategory . focus ( )
117- renderer . fireEvent . change ( enInput , { target : { value : "select_content" } } )
95+ userEvent . type ( apiSecret , "my_secret" )
96+ userEvent . type ( firebaseAppId , "my_firebase_app_id" )
97+ userEvent . type ( appInstanceId , "my_instance_id" )
98+ userEvent . type ( userId , "my_user_id" )
99+
100+ // TODO - I'm pretty unhappy with this, but I'm having a lot of
101+ // trouble testing the Autocomplete component without doing this.
102+ // This test is somewhat likely to break if we add/remove events &
103+ // event categories so if it's broken, it's probably fine to just
104+ // change the expected values.
105+ const ecInput = within ( eventCategory ) . getByRole ( "combobox" )
106+ eventCategory . focus ( )
107+ renderer . fireEvent . change ( ecInput , {
108+ target : { value : "All apps" } ,
109+ } )
118110
119- await userEvent . type ( timestampMicros , "1234" , { delay : 1 } )
120- nonPersonalizedAds . click ( )
111+ const enInput = within ( eventName ) . getByRole ( "combobox" )
112+ eventCategory . focus ( )
113+ renderer . fireEvent . change ( enInput , {
114+ target : { value : "select_content" } ,
121115 } )
122116
117+ userEvent . type ( timestampMicros , "1234" )
118+ userEvent . click ( nonPersonalizedAds )
119+
123120 const validatePaper = await findByTestId ( "validate and send" )
124- expect ( validatePaper ) . toHaveTextContent ( / a p i _ s e c r e t = m y _ s e c r e t / )
125- expect ( validatePaper ) . toHaveTextContent (
126- / f i r e b a s e _ a p p _ i d = m y _ f i r e b a s e _ a p p _ i d /
127- )
121+ await renderer . waitFor ( ( ) => {
122+ expect ( validatePaper ) . toHaveTextContent ( / a p i _ s e c r e t = m y _ s e c r e t / )
123+ expect ( validatePaper ) . toHaveTextContent (
124+ / f i r e b a s e _ a p p _ i d = m y _ f i r e b a s e _ a p p _ i d /
125+ )
126+ } )
128127
129128 const payload = await findByTestId ( "payload" )
130- expect ( payload ) . toHaveTextContent (
131- / " a p p _ i n s t a n c e _ i d " : " m y _ i n s t a n c e _ i d " /
132- )
133- expect ( payload ) . toHaveTextContent ( / " u s e r _ i d " : " m y _ u s e r _ i d " / )
134- expect ( payload ) . toHaveTextContent ( / " t i m e s t a m p _ m i c r o s " : 1 2 3 4 / )
135- expect ( payload ) . toHaveTextContent ( / " n o n _ p e r s o n a l i z e d _ a d s " : t r u e / )
136- expect ( payload ) . toHaveTextContent ( / " n a m e " : " s e l e c t _ c o n t e n t " / )
129+ await renderer . waitFor ( ( ) => {
130+ expect ( payload ) . toHaveTextContent (
131+ / " a p p _ i n s t a n c e _ i d " : " m y _ i n s t a n c e _ i d " /
132+ )
133+ expect ( payload ) . toHaveTextContent ( / " u s e r _ i d " : " m y _ u s e r _ i d " / )
134+ expect ( payload ) . toHaveTextContent ( / " t i m e s t a m p _ m i c r o s " : 1 2 3 4 / )
135+ expect ( payload ) . toHaveTextContent ( / " n o n _ p e r s o n a l i z e d _ a d s " : t r u e / )
136+ expect ( payload ) . toHaveTextContent ( / " n a m e " : " s e l e c t _ c o n t e n t " / )
137+ } )
137138 } )
138139 } )
139140 describe ( "for gtag switch" , ( ) => {
@@ -146,11 +147,8 @@ describe("Event Builder", () => {
146147 wrapped
147148 )
148149
149- await React . act ( async ( ) => {
150- // Choose the second view in the list
151- const clientToggle = await findByTestId ( "use firebase" )
152- clientToggle . click ( )
153- } )
150+ const clientToggle = await findByTestId ( "use firebase" )
151+ userEvent . click ( clientToggle )
154152
155153 const apiSecret = await find ( Label . APISecret , { exact : false } )
156154 const measurementId = await find ( Label . MeasurementID , {
@@ -167,49 +165,47 @@ describe("Event Builder", () => {
167165 exact : false ,
168166 } )
169167
170- await React . act ( async ( ) => {
171- await userEvent . type ( apiSecret , "my_secret" , { delay : 1 } )
172- await userEvent . type ( measurementId , "my_measurement_id" , {
173- delay : 1 ,
174- } )
175- await userEvent . type ( clientId , "my_client_id" , { delay : 1 } )
176- await userEvent . type ( userId , "{selectall}{backspace}my_user_id" , {
177- delay : 1 ,
178- } )
179-
180- // TODO - I'm pretty unhappy with this, but I'm having a lot of
181- // trouble testing the Autocomplete component without doing this.
182- // This test is somewhat likely to break if we add/remove events &
183- // event categories so if it's broken, it's probably fine to just
184- // change the expected values.
185- const ecInput = within ( eventCategory ) . getByRole ( "combobox" )
186- //eventCategory.focus()
187- renderer . fireEvent . change ( ecInput , { target : { value : "All apps" } } )
188-
189- const enInput = within ( eventName ) . getByRole ( "combobox" )
190- //eventCategory.focus()
191- renderer . fireEvent . change ( enInput , { target : { value : "campaign_details" } } )
192-
193- await userEvent . type (
194- timestampMicros ,
195- "{selectall}{backspace}1234" ,
196- { delay : 1 }
197- )
198- nonPersonalizedAds . click ( )
168+ userEvent . type ( apiSecret , "my_secret" )
169+ userEvent . type ( measurementId , "my_measurement_id" )
170+ userEvent . type ( clientId , "my_client_id" )
171+ userEvent . type ( userId , "{selectall}{backspace}my_user_id" )
172+
173+ // TODO - I'm pretty unhappy with this, but I'm having a lot of
174+ // trouble testing the Autocomplete component without doing this.
175+ // This test is somewhat likely to break if we add/remove events &
176+ // event categories so if it's broken, it's probably fine to just
177+ // change the expected values.
178+ const ecInput = within ( eventCategory ) . getByRole ( "combobox" )
179+ //eventCategory.focus()
180+ renderer . fireEvent . change ( ecInput , {
181+ target : { value : "All apps" } ,
199182 } )
200183
184+ const enInput = within ( eventName ) . getByRole ( "combobox" )
185+ //eventCategory.focus()
186+ renderer . fireEvent . change ( enInput , {
187+ target : { value : "campaign_details" } ,
188+ } )
189+
190+ userEvent . type ( timestampMicros , "{selectall}{backspace}1234" )
191+ userEvent . click ( nonPersonalizedAds )
192+
201193 const validatePaper = await findByTestId ( "validate and send" )
202- expect ( validatePaper ) . toHaveTextContent ( / a p i _ s e c r e t = m y _ s e c r e t / )
203- expect ( validatePaper ) . toHaveTextContent (
204- / m e a s u r e m e n t _ i d = m y _ m e a s u r e m e n t _ i d /
205- )
194+ await renderer . waitFor ( ( ) => {
195+ expect ( validatePaper ) . toHaveTextContent ( / a p i _ s e c r e t = m y _ s e c r e t / )
196+ expect ( validatePaper ) . toHaveTextContent (
197+ / m e a s u r e m e n t _ i d = m y _ m e a s u r e m e n t _ i d /
198+ )
199+ } )
206200
207201 const payload = await findByTestId ( "payload" )
208- expect ( payload ) . toHaveTextContent ( / " c l i e n t _ i d " : " m y _ c l i e n t _ i d " / )
209- expect ( payload ) . toHaveTextContent ( / " u s e r _ i d " : " m y _ u s e r _ i d " / )
210- expect ( payload ) . toHaveTextContent ( / " t i m e s t a m p _ m i c r o s " : 1 2 3 4 / )
211- expect ( payload ) . toHaveTextContent ( / " n o n _ p e r s o n a l i z e d _ a d s " : t r u e / )
212- expect ( payload ) . toHaveTextContent ( / " n a m e " : " c a m p a i g n _ d e t a i l s " / )
202+ await renderer . waitFor ( ( ) => {
203+ expect ( payload ) . toHaveTextContent ( / " c l i e n t _ i d " : " m y _ c l i e n t _ i d " / )
204+ expect ( payload ) . toHaveTextContent ( / " u s e r _ i d " : " m y _ u s e r _ i d " / )
205+ expect ( payload ) . toHaveTextContent ( / " t i m e s t a m p _ m i c r o s " : 1 2 3 4 / )
206+ expect ( payload ) . toHaveTextContent ( / " n o n _ p e r s o n a l i z e d _ a d s " : t r u e / )
207+ expect ( payload ) . toHaveTextContent ( / " n a m e " : " c a m p a i g n _ d e t a i l s " / )
208+ } )
213209 } )
214210 } )
215211 } )
@@ -219,10 +215,8 @@ describe("Event Builder", () => {
219215 const { wrapped } = withProviders ( < Sut /> , { isLoggedIn : false } )
220216 const { findByTestId } = renderer . render ( wrapped )
221217
222- await React . act ( async ( ) => {
223- const clientToggle = await findByTestId ( "use firebase" )
224- clientToggle . click ( )
225- } )
218+ const clientToggle = await findByTestId ( "use firebase" )
219+ userEvent . click ( clientToggle )
226220
227221 const eventName = await findByTestId ( Label . EventName )
228222 const enInput = within ( eventName ) . getByRole ( "combobox" )
0 commit comments