|
2 | 2 | /* eslint-disable react/prop-types */ |
3 | 3 | import userEvent from '@testing-library/user-event'; |
4 | 4 |
|
| 5 | +import { mockWaffleFlags } from '@src/data/apiHooks.mock'; |
5 | 6 | import { |
6 | 7 | act, |
7 | 8 | render, |
@@ -319,6 +320,52 @@ describe('<AddComponent />', () => { |
319 | 320 | }); |
320 | 321 | }); |
321 | 322 |
|
| 323 | + it('adds a PDF block from the advanced selection in modal as an mfe-editable block', async () => { |
| 324 | + const user = userEvent.setup(); |
| 325 | + const { getByRole, queryAllByRole } = renderComponent(); |
| 326 | + const advancedBtn = getByRole('button', { |
| 327 | + name: new RegExp(`${messages.buttonText.defaultMessage} Advanced`, 'i'), |
| 328 | + }); |
| 329 | + |
| 330 | + await user.click(advancedBtn); |
| 331 | + |
| 332 | + const dialog = getByRole('dialog'); |
| 333 | + const pdfOption = within(dialog).getByLabelText('PDF'); |
| 334 | + await user.click(pdfOption); |
| 335 | + const confirmation = within(dialog).getByText('Select'); |
| 336 | + await user.click(confirmation); |
| 337 | + await waitFor(() => expect(queryAllByRole('dialog')).toEqual([])); |
| 338 | + expect(handleCreateNewCourseXBlockMock).toHaveBeenCalled(); |
| 339 | + expect(handleCreateNewCourseXBlockMock).toHaveBeenCalledWith({ |
| 340 | + parentLocator: '123', |
| 341 | + type: COMPONENT_TYPES.pdf, |
| 342 | + }, expect.any(Function)); |
| 343 | + }); |
| 344 | + |
| 345 | + it('adds a PDF block from the advanced selection in modal as a traditional block', async () => { |
| 346 | + const user = userEvent.setup(); |
| 347 | + mockWaffleFlags({ useNewPdfEditor: false }); |
| 348 | + const { getByRole, queryAllByRole } = renderComponent(); |
| 349 | + const advancedBtn = getByRole('button', { |
| 350 | + name: new RegExp(`${messages.buttonText.defaultMessage} Advanced`, 'i'), |
| 351 | + }); |
| 352 | + |
| 353 | + await user.click(advancedBtn); |
| 354 | + |
| 355 | + const dialog = getByRole('dialog'); |
| 356 | + const pdfOption = within(dialog).getByLabelText('PDF'); |
| 357 | + await user.click(pdfOption); |
| 358 | + const confirmation = within(dialog).getByText('Select'); |
| 359 | + await user.click(confirmation); |
| 360 | + await waitFor(() => expect(queryAllByRole('dialog')).toEqual([])); |
| 361 | + expect(handleCreateNewCourseXBlockMock).toHaveBeenCalled(); |
| 362 | + expect(handleCreateNewCourseXBlockMock).toHaveBeenCalledWith({ |
| 363 | + parentLocator: '123', |
| 364 | + type: COMPONENT_TYPES.pdf, |
| 365 | + category: COMPONENT_TYPES.pdf, |
| 366 | + }); |
| 367 | + }); |
| 368 | + |
322 | 369 | it('verifies "Text" component selection in modal', async () => { |
323 | 370 | const user = userEvent.setup(); |
324 | 371 | const { getByRole, getByText } = renderComponent(); |
|
0 commit comments