Skip to content

Commit af83d95

Browse files
Updated failing tests
1 parent c8096e0 commit af83d95

File tree

1 file changed

+12
-26
lines changed

1 file changed

+12
-26
lines changed

contentcuration/contentcuration/frontend/administration/pages/Users/__tests__/emailUsersDialog.spec.js

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { render, screen, waitFor } from '@testing-library/vue';
1+
import { render, screen } from '@testing-library/vue';
22
import userEvent from '@testing-library/user-event';
33
import { createLocalVue } from '@vue/test-utils';
44
import 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(/subject line/i), 'Test Subject');
185178
await user.type(screen.getByLabelText(/email body/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

Comments
 (0)