@@ -53,7 +53,7 @@ jest.mock('@mui/material', () => {
5353} ) ;
5454
5555const transferDefaultData : TransferModalData [ 'transfer' ] = {
56- transferFrom : 'transferFrom ' ,
56+ transferFrom : 'Staff Account ' ,
5757 transferTo : '' ,
5858 amount : 0 ,
5959 schedule : ScheduleEnum . OneTime ,
@@ -152,11 +152,8 @@ describe('TransferModal', () => {
152152 userEvent . type ( amountField , '-100' ) ;
153153 userEvent . tab ( ) ;
154154
155- const fromAccount = getByRole ( 'combobox' , { name : / f r o m a c c o u n t / i } ) ;
156155 const toAccount = getByRole ( 'combobox' , { name : / t o a c c o u n t / i } ) ;
157156
158- userEvent . click ( fromAccount ) ;
159- userEvent . click ( getByRole ( 'option' , { name : / s t a f f a c c o u n t / i } ) ) ;
160157 userEvent . click ( toAccount ) ;
161158 userEvent . click ( getByRole ( 'option' , { name : / s t a f f s a v i n g s / i } ) ) ;
162159
@@ -199,13 +196,9 @@ describe('TransferModal', () => {
199196 it ( 'should submit form with valid data' , async ( ) => {
200197 const { getByRole } = render ( < Components /> ) ;
201198
202- const fromAccount = getByRole ( 'combobox' , { name : / f r o m a c c o u n t / i } ) ;
203199 const toAccount = getByRole ( 'combobox' , { name : / t o a c c o u n t / i } ) ;
204200 const amountField = getByRole ( 'spinbutton' , { name : / a m o u n t / i } ) ;
205201
206- userEvent . click ( fromAccount ) ;
207- userEvent . click ( getByRole ( 'option' , { name : / s t a f f a c c o u n t / i } ) ) ;
208-
209202 userEvent . click ( toAccount ) ;
210203 userEvent . click ( getByRole ( 'option' , { name : / s t a f f s a v i n g s / i } ) ) ;
211204
@@ -227,14 +220,10 @@ describe('TransferModal', () => {
227220 it ( 'should handle form submission successfully' , async ( ) => {
228221 const { getByRole } = render ( < Components /> ) ;
229222
230- const fromAccount = getByRole ( 'combobox' , { name : / f r o m a c c o u n t / i } ) ;
231223 const toAccount = getByRole ( 'combobox' , { name : / t o a c c o u n t / i } ) ;
232224 const amountField = getByRole ( 'spinbutton' , { name : / a m o u n t / i } ) ;
233225 const submitButton = getByRole ( 'button' , { name : / s u b m i t / i } ) ;
234226
235- userEvent . click ( fromAccount ) ;
236- userEvent . click ( getByRole ( 'option' , { name : / s t a f f a c c o u n t / i } ) ) ;
237-
238227 userEvent . click ( toAccount ) ;
239228 userEvent . click ( getByRole ( 'option' , { name : / s t a f f s a v i n g s / i } ) ) ;
240229
@@ -274,55 +263,25 @@ describe('TransferModal', () => {
274263 expect ( getByLabelText ( / e n d d a t e / i) ) . toHaveValue ( '' ) ;
275264 } ) ;
276265
277- it ( 'should validate that from and to accounts are different ' , async ( ) => {
278- const { getByRole, queryByRole, getAllByRole } = render ( < Components /> ) ;
266+ it ( 'locks the From Account to the launching card and excludes it from To Account options ' , async ( ) => {
267+ const { getByRole, queryByRole } = render ( < Components /> ) ;
279268
280- const [ fromAccount , toAccount ] = getAllByRole ( 'combobox' ) ;
269+ const fromAccount = getByRole ( 'combobox' , { name : / f r o m a c c o u n t / i } ) ;
270+ expect ( fromAccount ) . toHaveTextContent ( 'Staff Account' ) ;
281271
282272 userEvent . click ( fromAccount ) ;
283- expect (
284- getByRole ( 'option' , { name : / s t a f f a c c o u n t / i } ) ,
285- ) . toBeInTheDocument ( ) ;
286- userEvent . click ( getByRole ( 'option' , { name : / s t a f f a c c o u n t / i } ) ) ;
273+ expect ( queryByRole ( 'listbox' ) ) . not . toBeInTheDocument ( ) ;
274+
275+ userEvent . click ( getByRole ( 'combobox' , { name : / t o a c c o u n t / i } ) ) ;
287276
288- userEvent . click ( toAccount ) ;
289277 await waitFor ( ( ) =>
290278 expect (
291279 queryByRole ( 'option' , { name : / s t a f f a c c o u n t / i } ) ,
292280 ) . not . toBeInTheDocument ( ) ,
293281 ) ;
294-
295- userEvent . click ( getByRole ( 'option' , { name : / s t a f f s a v i n g s / i } ) ) ;
296- userEvent . click ( getByRole ( 'button' , { name : / s u b m i t / i } ) ) ;
297- } ) ;
298-
299- it ( 'should swap accounts when swap button is clicked' , async ( ) => {
300- const { getByRole, getByTestId } = render ( < Components /> ) ;
301-
302- const icon = getByTestId ( 'SwapHorizIcon' ) ;
303- const swapButton = icon . closest ( 'button' ) ;
304-
305- expect ( swapButton ) . toBeDisabled ( ) ;
306-
307- const fromAccount = getByRole ( 'combobox' , { name : / f r o m a c c o u n t / i } ) ;
308- const toAccount = getByRole ( 'combobox' , { name : / t o a c c o u n t / i } ) ;
309-
310- userEvent . click ( fromAccount ) ;
311- userEvent . click ( getByRole ( 'option' , { name : / s t a f f a c c o u n t / i } ) ) ;
312-
313- userEvent . click ( toAccount ) ;
314- userEvent . click ( getByRole ( 'option' , { name : / s t a f f s a v i n g s / i } ) ) ;
315-
316- await waitFor ( ( ) => {
317- expect ( swapButton ) . not . toBeDisabled ( ) ;
318- } ) ;
319-
320- userEvent . click ( swapButton as HTMLButtonElement ) ;
321-
322- await waitFor ( ( ) => {
323- expect ( fromAccount ) . toHaveTextContent ( 'Staff Savings' ) ;
324- expect ( toAccount ) . toHaveTextContent ( 'Staff Account' ) ;
325- } ) ;
282+ expect (
283+ getByRole ( 'option' , { name : / s t a f f s a v i n g s / i } ) ,
284+ ) . toBeInTheDocument ( ) ;
326285 } ) ;
327286
328287 it ( 'should show/hide end date based on schedule selection' , async ( ) => {
@@ -393,12 +352,8 @@ describe('TransferModal', () => {
393352 it ( 'should show information box when amount exceeds limit' , async ( ) => {
394353 const { getByRole, findByRole } = render ( < Components /> ) ;
395354
396- const fromAccount = getByRole ( 'combobox' , { name : / f r o m a c c o u n t / i } ) ;
397355 const toAccount = getByRole ( 'combobox' , { name : / t o a c c o u n t / i } ) ;
398356
399- userEvent . click ( fromAccount ) ;
400- userEvent . click ( getByRole ( 'option' , { name : / s t a f f a c c o u n t / i } ) ) ;
401-
402357 userEvent . click ( toAccount ) ;
403358 userEvent . click ( getByRole ( 'option' , { name : / s t a f f s a v i n g s / i } ) ) ;
404359
@@ -441,9 +396,6 @@ describe('TransferModal', () => {
441396
442397 const amountField = getByRole ( 'spinbutton' , { name : / a m o u n t / i } ) ;
443398
444- userEvent . click ( getByRole ( 'combobox' , { name : / f r o m a c c o u n t / i } ) ) ;
445- userEvent . click ( getByRole ( 'option' , { name : / s t a f f a c c o u n t / i } ) ) ;
446-
447399 userEvent . click ( getByRole ( 'combobox' , { name : / t o a c c o u n t / i } ) ) ;
448400 userEvent . click ( getByRole ( 'option' , { name : / s t a f f s a v i n g s / i } ) ) ;
449401
@@ -474,9 +426,6 @@ describe('TransferModal', () => {
474426
475427 const amountField = getByRole ( 'spinbutton' , { name : / a m o u n t / i } ) ;
476428
477- userEvent . click ( getByRole ( 'combobox' , { name : / f r o m a c c o u n t / i } ) ) ;
478- userEvent . click ( getByRole ( 'option' , { name : / s t a f f a c c o u n t / i } ) ) ;
479-
480429 userEvent . click ( getByRole ( 'combobox' , { name : / t o a c c o u n t / i } ) ) ;
481430 userEvent . click ( getByRole ( 'option' , { name : / s t a f f s a v i n g s / i } ) ) ;
482431
0 commit comments