Skip to content

Commit 90f477b

Browse files
Refined testcases
1 parent 1e3c2d5 commit 90f477b

1 file changed

Lines changed: 8 additions & 16 deletions

File tree

  • contentcuration/contentcuration/frontend/channelEdit/views/trash/__tests__

contentcuration/contentcuration/frontend/channelEdit/views/trash/__tests__/trashModal.spec.js

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ describe('TrashModal', () => {
114114
expect(screen.getByTestId('delete')).toBeDisabled();
115115
expect(screen.getByTestId('restore')).toBeDisabled();
116116

117-
const checkboxes = screen.getAllByRole('checkbox');
118-
await user.click(checkboxes[1]);
117+
await user.click(screen.getAllByRole('checkbox')[1]);
119118

120119
await waitFor(() => {
121120
expect(screen.getByTestId('delete')).toBeEnabled();
@@ -125,8 +124,7 @@ describe('TrashModal', () => {
125124

126125
it('checking the select-all checkbox checks all items', async () => {
127126
const { user } = await makeWrapper();
128-
const [selectAll] = screen.getAllByRole('checkbox');
129-
await user.click(selectAll);
127+
await user.click(screen.getByTestId('selectall'));
130128

131129
await waitFor(() => {
132130
screen
@@ -162,17 +160,15 @@ describe('TrashModal', () => {
162160

163161
it('clicking Delete opens a confirmation dialog', async () => {
164162
const { user } = await makeWrapper();
165-
const [selectAll] = screen.getAllByRole('checkbox');
166-
await user.click(selectAll);
163+
await user.click(screen.getByTestId('selectall'));
167164
await user.click(screen.getByTestId('delete'));
168165

169166
expect(await screen.findByText(/You cannot undo this action/i)).toBeInTheDocument();
170167
});
171168

172169
it('clicking Cancel in the confirmation dialog closes it', async () => {
173170
const { user } = await makeWrapper();
174-
const [selectAll] = screen.getAllByRole('checkbox');
175-
await user.click(selectAll);
171+
await user.click(screen.getByTestId('selectall'));
176172
await user.click(screen.getByTestId('delete'));
177173
await screen.findByText(/You cannot undo this action/i);
178174

@@ -190,8 +186,7 @@ describe('TrashModal', () => {
190186

191187
const { user } = await makeWrapper();
192188

193-
const [selectAll] = screen.getAllByRole('checkbox');
194-
await user.click(selectAll);
189+
await user.click(screen.getByTestId('selectall'));
195190
await user.click(screen.getByTestId('delete'));
196191
await user.click(await screen.findByRole('button', { name: /Delete permanently/i }));
197192

@@ -205,8 +200,7 @@ describe('TrashModal', () => {
205200
const dispatchSpy = jest.spyOn(store, 'dispatch').mockImplementation(() => Promise.resolve());
206201

207202
const { user, loadNodesSpy } = await makeWrapper();
208-
const [selectAll] = screen.getAllByRole('checkbox');
209-
await user.click(selectAll);
203+
await user.click(screen.getByTestId('selectall'));
210204
await user.click(screen.getByTestId('delete'));
211205
await user.click(await screen.findByRole('button', { name: /Delete permanently/i }));
212206

@@ -227,8 +221,7 @@ describe('TrashModal', () => {
227221

228222
it('clicking Restore opens the MoveModal', async () => {
229223
const { user } = await makeWrapper();
230-
const [selectAll] = screen.getAllByRole('checkbox');
231-
await user.click(selectAll);
224+
await user.click(screen.getByTestId('selectall'));
232225
await user.click(screen.getByTestId('restore'));
233226
expect(await screen.findByRole('button', { name: /Move here/i })).toBeInTheDocument();
234227
});
@@ -240,8 +233,7 @@ describe('TrashModal', () => {
240233

241234
expect(screen.queryByText(/items selected/i)).not.toBeInTheDocument();
242235

243-
const [selectAll] = screen.getAllByRole('checkbox');
244-
await user.click(selectAll);
236+
await user.click(screen.getByTestId('selectall'));
245237

246238
expect(await screen.findByText(`${testChildren.length} items selected`)).toBeInTheDocument();
247239
});

0 commit comments

Comments
 (0)