|
1 | 1 | import ProcessManagedTickets from "components/views/GetStartedPage/SetupWallet/ProcessManagedTickets"; |
2 | 2 | import { render } from "test-utils.js"; |
3 | | -import { screen, wait } from "@testing-library/react"; |
4 | | -import user from "@testing-library/user-event"; |
| 3 | +import { screen, waitFor } from "@testing-library/react"; |
5 | 4 | import * as sel from "selectors"; |
6 | 5 | import * as wal from "wallet"; |
7 | 6 | import * as arrs from "../../../../../../app/helpers/arrays"; |
@@ -108,37 +107,40 @@ const initialState = { |
108 | 107 | } |
109 | 108 | }; |
110 | 109 |
|
111 | | -test("skip ProcessManagedTickets and show error", () => { |
112 | | - render( |
| 110 | +test("skip ProcessManagedTickets and show error", async () => { |
| 111 | + const { user } = render( |
113 | 112 | <ProcessManagedTickets |
114 | 113 | send={mockSend} |
115 | 114 | cancel={mockCancel} |
116 | 115 | error={testError} |
117 | 116 | /> |
118 | 117 | ); |
119 | | - user.click(getSkipButton()); |
| 118 | + await user.click(getSkipButton()); |
120 | 119 | expect(screen.getByText(testError)).toBeInTheDocument(); |
121 | 120 | expect(mockCancel).toHaveBeenCalled(); |
122 | 121 | }); |
123 | 122 |
|
124 | 123 | test("do ProcessManagedTickets - in a private wallet", async () => { |
125 | 124 | mockUnlockLockAndGetAccountsAttempt(); |
126 | | - render(<ProcessManagedTickets send={mockSend} cancel={mockCancel} />, { |
127 | | - initialState |
128 | | - }); |
| 125 | + const { user } = render( |
| 126 | + <ProcessManagedTickets send={mockSend} cancel={mockCancel} />, |
| 127 | + { |
| 128 | + initialState |
| 129 | + } |
| 130 | + ); |
129 | 131 | const continueButton = getContinueButton(); |
130 | | - user.click(continueButton); |
| 132 | + await user.click(continueButton); |
131 | 133 |
|
132 | 134 | expect(screen.getByText("Passphrase")).toBeInTheDocument(); |
133 | 135 |
|
134 | 136 | // cancel first |
135 | | - user.click(getCancelButton()); |
| 137 | + await user.click(getCancelButton()); |
136 | 138 |
|
137 | | - user.click(continueButton); |
138 | | - user.type(screen.getByLabelText("Private Passphrase"), testPassphrase); |
139 | | - user.click(getModalContinueButton()); |
| 139 | + await user.click(continueButton); |
| 140 | + await user.type(screen.getByLabelText("Private Passphrase"), testPassphrase); |
| 141 | + await user.click(getModalContinueButton()); |
140 | 142 |
|
141 | | - await wait(() => expect(mockSend).toHaveBeenCalled()); |
| 143 | + await waitFor(() => expect(mockSend).toHaveBeenCalled()); |
142 | 144 |
|
143 | 145 | expect(mockProcessManagedTickets).toHaveBeenNthCalledWith( |
144 | 146 | 1, |
@@ -201,22 +203,25 @@ test("do ProcessManagedTickets - in a default wallet, available vps pubkeys have |
201 | 203 | selectors.getMixedAccount = jest.fn(() => null); |
202 | 204 | selectors.getChangeAccount = jest.fn(() => null); |
203 | 205 | mockUnlockLockAndGetAccountsAttempt(); |
204 | | - render(<ProcessManagedTickets send={mockSend} cancel={mockCancel} />, { |
205 | | - initialState |
206 | | - }); |
| 206 | + const { user } = render( |
| 207 | + <ProcessManagedTickets send={mockSend} cancel={mockCancel} />, |
| 208 | + { |
| 209 | + initialState |
| 210 | + } |
| 211 | + ); |
207 | 212 | const continueButton = getContinueButton(); |
208 | | - user.click(continueButton); |
| 213 | + await user.click(continueButton); |
209 | 214 |
|
210 | 215 | expect(screen.getByText("Passphrase")).toBeInTheDocument(); |
211 | 216 |
|
212 | 217 | // cancel first |
213 | | - user.click(getCancelButton()); |
| 218 | + await user.click(getCancelButton()); |
214 | 219 |
|
215 | | - user.click(continueButton); |
216 | | - user.type(screen.getByLabelText("Private Passphrase"), testPassphrase); |
217 | | - user.click(getModalContinueButton()); |
| 220 | + await user.click(continueButton); |
| 221 | + await user.type(screen.getByLabelText("Private Passphrase"), testPassphrase); |
| 222 | + await user.click(getModalContinueButton()); |
218 | 223 |
|
219 | | - await wait(() => expect(mockSend).toHaveBeenCalled()); |
| 224 | + await waitFor(() => expect(mockSend).toHaveBeenCalled()); |
220 | 225 |
|
221 | 226 | expect(mockProcessManagedTickets).toHaveBeenNthCalledWith( |
222 | 227 | 1, |
@@ -279,22 +284,25 @@ test("do ProcessManagedTickets - in a default wallet, available vps pubkeys have |
279 | 284 | selectors.getMixedAccount = jest.fn(() => null); |
280 | 285 | selectors.getChangeAccount = jest.fn(() => null); |
281 | 286 | mockUnlockLockAndGetAccountsAttempt(); |
282 | | - render(<ProcessManagedTickets send={mockSend} cancel={mockCancel} />, { |
283 | | - initialState |
284 | | - }); |
| 287 | + const { user } = render( |
| 288 | + <ProcessManagedTickets send={mockSend} cancel={mockCancel} />, |
| 289 | + { |
| 290 | + initialState |
| 291 | + } |
| 292 | + ); |
285 | 293 | const continueButton = getContinueButton(); |
286 | | - user.click(continueButton); |
| 294 | + await user.click(continueButton); |
287 | 295 |
|
288 | 296 | expect(screen.getByText("Passphrase")).toBeInTheDocument(); |
289 | 297 |
|
290 | 298 | // cancel first |
291 | | - user.click(getCancelButton()); |
| 299 | + await user.click(getCancelButton()); |
292 | 300 |
|
293 | | - user.click(continueButton); |
294 | | - user.type(screen.getByLabelText("Private Passphrase"), testPassphrase); |
295 | | - user.click(getModalContinueButton()); |
| 301 | + await user.click(continueButton); |
| 302 | + await user.type(screen.getByLabelText("Private Passphrase"), testPassphrase); |
| 303 | + await user.click(getModalContinueButton()); |
296 | 304 |
|
297 | | - await wait(() => expect(mockSend).toHaveBeenCalled()); |
| 305 | + await waitFor(() => expect(mockSend).toHaveBeenCalled()); |
298 | 306 |
|
299 | 307 | expect(mockProcessManagedTickets).toHaveBeenNthCalledWith( |
300 | 308 | 1, |
@@ -355,16 +363,19 @@ test("do ProcessManagedTickets - failed to fetch vsps", async () => { |
355 | 363 | mockGetAllVSPs = wallet.getAllVSPs = jest.fn(() => { |
356 | 364 | throw testError; |
357 | 365 | }); |
358 | | - render(<ProcessManagedTickets send={mockSend} cancel={mockCancel} />, { |
359 | | - initialState |
360 | | - }); |
| 366 | + const { user } = render( |
| 367 | + <ProcessManagedTickets send={mockSend} cancel={mockCancel} />, |
| 368 | + { |
| 369 | + initialState |
| 370 | + } |
| 371 | + ); |
361 | 372 | const continueButton = getContinueButton(); |
362 | | - user.click(continueButton); |
| 373 | + await user.click(continueButton); |
363 | 374 |
|
364 | | - user.type(screen.getByLabelText("Private Passphrase"), testPassphrase); |
365 | | - user.click(getModalContinueButton()); |
| 375 | + await user.type(screen.getByLabelText("Private Passphrase"), testPassphrase); |
| 376 | + await user.click(getModalContinueButton()); |
366 | 377 |
|
367 | | - await wait(() => expect(mockSend).toHaveBeenCalled()); |
| 378 | + await waitFor(() => expect(mockSend).toHaveBeenCalled()); |
368 | 379 |
|
369 | 380 | expect(mockGetAllVSPs).toHaveBeenCalled(); |
370 | 381 | expect(mockProcessManagedTickets).not.toHaveBeenCalled(); |
|
0 commit comments