@@ -153,6 +153,41 @@ describe('ImportSRP', () => {
153
153
expect ( mockClearClipboard ) . toHaveBeenCalled ( ) ;
154
154
} ) ;
155
155
156
+ it ( 'clears the SRP input fields and error message when Clear button is clicked' , async ( ) => {
157
+ const onActionComplete = jest . fn ( ) ;
158
+ const render = renderWithProvider (
159
+ < ImportSrp onActionComplete = { onActionComplete } /> ,
160
+ store ,
161
+ ) ;
162
+ const { getByText, queryByTestId, getByTestId } = render ;
163
+
164
+ // Input an invalid SRP to trigger error
165
+ const invalidSRP = VALID_SECRET_RECOVERY_PHRASE . replace ( 'input' , 'inptu' ) ;
166
+ pasteSrpIntoFirstInput ( render , invalidSRP ) ;
167
+
168
+ // Verify error message is shown
169
+ const bannerAlert = await waitFor ( ( ) => getByTestId ( 'bannerAlert' ) ) ;
170
+ expect ( bannerAlert ) . toBeInTheDocument ( ) ;
171
+
172
+ // Click Clear button
173
+ const clearButton = getByText ( 'Clear' ) ;
174
+ fireEvent . click ( clearButton ) ;
175
+
176
+ // Verify error message is cleared
177
+ expect ( queryByTestId ( 'bannerAlert' ) ) . not . toBeInTheDocument ( ) ;
178
+
179
+ // Verify all input fields are cleared
180
+ for ( let i = 0 ; i < 12 ; i ++ ) {
181
+ const input = getByTestId ( `import-srp__srp-word-${ i } ` ) . querySelector (
182
+ 'input' ,
183
+ ) ;
184
+ expect ( input ) . toHaveValue ( '' ) ;
185
+ }
186
+
187
+ // Verify Import wallet button is disabled
188
+ expect ( getByText ( 'Import wallet' ) ) . not . toBeEnabled ( ) ;
189
+ } ) ;
190
+
156
191
it ( 'logs an error and not call onActionComplete on import failure' , async ( ) => {
157
192
( actions . importMnemonicToVault as jest . Mock ) . mockImplementation ( ( ) =>
158
193
jest . fn ( ) . mockRejectedValue ( new Error ( 'error' ) ) ,
0 commit comments