|
| 1 | +import { streamStatus } from '@linode/api-v4'; |
1 | 2 | import { |
2 | 3 | screen, |
3 | 4 | waitFor, |
@@ -241,47 +242,63 @@ describe('StreamEdit', () => { |
241 | 242 | }); |
242 | 243 | }); |
243 | 244 |
|
244 | | - describe('and stream has status: provisioning', () => { |
245 | | - it('should have disabled Edit Stream button and show info tooltip', async () => { |
246 | | - server.use( |
247 | | - http.get('*/monitor/streams/destinations', () => { |
248 | | - return HttpResponse.json(makeResourcePage(mockDestinations)); |
249 | | - }), |
250 | | - http.get(`*/monitor/streams/${streamId}`, () => { |
251 | | - return HttpResponse.json({ |
252 | | - ...mockStream, |
253 | | - status: 'provisioning', |
254 | | - }); |
255 | | - }) |
256 | | - ); |
257 | | - |
258 | | - renderWithThemeAndHookFormContext({ |
259 | | - component: <StreamEdit />, |
| 245 | + const blockingStatuses = [ |
| 246 | + streamStatus.Deactivating, |
| 247 | + streamStatus.Failed, |
| 248 | + streamStatus.Provisioning, |
| 249 | + ]; |
| 250 | + |
| 251 | + describe.each(blockingStatuses)( |
| 252 | + 'and stream has status: %status', |
| 253 | + (status) => { |
| 254 | + it('should have disabled Edit Stream button and show info tooltip', async () => { |
| 255 | + server.use( |
| 256 | + http.get('*/monitor/streams/destinations', () => { |
| 257 | + return HttpResponse.json( |
| 258 | + makeResourcePage(mockDestinations) |
| 259 | + ); |
| 260 | + }), |
| 261 | + http.get(`*/monitor/streams/${streamId}`, () => { |
| 262 | + return HttpResponse.json({ |
| 263 | + ...mockStream, |
| 264 | + status, |
| 265 | + }); |
| 266 | + }) |
| 267 | + ); |
| 268 | + |
| 269 | + renderWithThemeAndHookFormContext({ |
| 270 | + component: <StreamEdit />, |
| 271 | + }); |
| 272 | + const loadingElement = screen.queryByTestId(loadingTestId); |
| 273 | + await waitForElementToBeRemoved(loadingElement); |
| 274 | + |
| 275 | + const editStreamButton = screen.getByRole('button', { |
| 276 | + name: saveStreamButtonText, |
| 277 | + }); |
| 278 | + |
| 279 | + // Edit stream button should be disabled |
| 280 | + expect(editStreamButton).toBeDisabled(); |
| 281 | + |
| 282 | + // Edit stream |
| 283 | + await userEvent.hover(editStreamButton); |
| 284 | + await screen.findByRole('tooltip'); |
| 285 | + |
| 286 | + screen.getByText((content) => |
| 287 | + content.includes( |
| 288 | + `You cannot save changes while the stream status is ${status}` |
| 289 | + ) |
| 290 | + ); |
| 291 | + |
| 292 | + const disabledButtonTooltip = screen.getByText((content) => |
| 293 | + content.includes( |
| 294 | + `You cannot save changes while the stream status is ${status}` |
| 295 | + ) |
| 296 | + ); |
| 297 | + |
| 298 | + expect(disabledButtonTooltip).toBeInTheDocument(); |
260 | 299 | }); |
261 | | - const loadingElement = screen.queryByTestId(loadingTestId); |
262 | | - await waitForElementToBeRemoved(loadingElement); |
263 | | - |
264 | | - const editStreamButton = screen.getByRole('button', { |
265 | | - name: saveStreamButtonText, |
266 | | - }); |
267 | | - |
268 | | - // Edit stream button should be disabled |
269 | | - expect(editStreamButton).toBeDisabled(); |
270 | | - |
271 | | - // Edit stream |
272 | | - await userEvent.hover(editStreamButton); |
273 | | - |
274 | | - await waitFor(() => { |
275 | | - expect(screen.getByRole('tooltip')).toBeInTheDocument(); |
276 | | - }); |
277 | | - |
278 | | - const disabledButtonTooltip = screen.getByText( |
279 | | - 'You cannot save changes while the stream is provisioning.' |
280 | | - ); |
281 | | - |
282 | | - expect(disabledButtonTooltip).toBeInTheDocument(); |
283 | | - }); |
284 | | - }); |
| 300 | + } |
| 301 | + ); |
285 | 302 | }); |
286 | 303 | }); |
287 | 304 |
|
|
0 commit comments