1- import { render , screen , waitFor } from '@testing-library/vue' ;
1+ import { render , screen } from '@testing-library/vue' ;
22import userEvent from '@testing-library/user-event' ;
33import { createLocalVue } from '@vue/test-utils' ;
44import Vuex from 'vuex' ;
@@ -65,9 +65,6 @@ const renderComponent = (props = {}) => {
6565 store,
6666 props : defaultProps ,
6767 routes : new VueRouter ( ) ,
68- stubs : {
69- transition : true ,
70- } ,
7168 } ) ;
7269} ;
7370
@@ -87,14 +84,11 @@ describe('EmailUsersDialog', () => {
8784 expect ( screen . getByText ( '[email protected] ' ) ) . toBeInTheDocument ( ) ; 8885 } ) ;
8986
90- it ( 'displays individual user chips when initialRecipients are provided' , async ( ) => {
87+ it ( 'displays individual user chips when initialRecipients are provided' , ( ) => {
9188 renderComponent ( { initialRecipients : [ userId , userId2 ] } ) ;
9289
93- // Use waitFor to handle async rendering
94- await waitFor ( ( ) => {
95- expect ( screen . getByText ( 'Testy User' ) ) . toBeInTheDocument ( ) ;
96- } ) ;
97-
90+ // Should work immediately now with proper data initialization
91+ expect ( screen . getByText ( 'Testy User' ) ) . toBeInTheDocument ( ) ;
9892 expect ( screen . getByText ( 'Testier User' ) ) . toBeInTheDocument ( ) ;
9993 } ) ;
10094
@@ -176,10 +170,9 @@ describe('EmailUsersDialog', () => {
176170 const user = userEvent . setup ( ) ;
177171 renderComponent ( { initialRecipients : [ userId , userId2 ] } ) ;
178172
179- // Wait for recipients to be loaded
180- await waitFor ( ( ) => {
181- expect ( screen . getByText ( 'Testy User' ) ) . toBeInTheDocument ( ) ;
182- } ) ;
173+ // No need to wait - users should be immediately available
174+ expect ( screen . getByText ( 'Testy User' ) ) . toBeInTheDocument ( ) ;
175+ expect ( screen . getByText ( 'Testier User' ) ) . toBeInTheDocument ( ) ;
183176
184177 await user . type ( screen . getByLabelText ( / s u b j e c t l i n e / i) , 'Test Subject' ) ;
185178 await user . type ( screen . getByLabelText ( / e m a i l b o d y / i) , 'Test Message' ) ;
@@ -198,20 +191,13 @@ describe('EmailUsersDialog', () => {
198191 const user = userEvent . setup ( ) ;
199192 renderComponent ( { initialRecipients : [ userId , userId2 ] } ) ;
200193
201- // Wait for chips to render
202- await waitFor ( ( ) => {
203- expect ( screen . getByText ( 'Testy User' ) ) . toBeInTheDocument ( ) ;
204- } ) ;
205-
206- // Use getAllByTestId with the correct test ID
207- const removeButtons = screen . getAllByTestId ( 'remove' ) ;
208- await user . click ( removeButtons [ 0 ] ) ;
194+ expect ( screen . getByText ( 'Testy User' ) ) . toBeInTheDocument ( ) ;
195+ expect ( screen . getByText ( 'Testier User' ) ) . toBeInTheDocument ( ) ;
209196
210- // Wait for the removal to take effect
211- await waitFor ( ( ) => {
212- expect ( screen . queryByText ( 'Testy User' ) ) . not . toBeInTheDocument ( ) ;
213- } ) ;
197+ const removeButton = screen . getByRole ( 'button' , { name : 'Remove Testy User' } ) ;
198+ await user . click ( removeButton ) ;
214199
200+ expect ( screen . queryByText ( 'Testy User' ) ) . not . toBeInTheDocument ( ) ;
215201 expect ( screen . getByText ( 'Testier User' ) ) . toBeInTheDocument ( ) ;
216202 } ) ;
217203 } ) ;
0 commit comments