Browse Source

Update pdf-preview.test.js (#5656)

Since the original test iterates over a number of fixtures, it makes more sense to express it as parameterized test, running each scenario separately, each using the default timeout.

GitOrigin-RevId: 6b87adbeb01975db1308b5241f6eccbcdb33f9de
Miguel Serrano 4 years ago
parent
commit
bd8c6608c0

+ 11 - 9
services/web/test/frontend/features/pdf-preview/components/pdf-preview.test.js

@@ -289,7 +289,7 @@ describe('<PdfPreview/>', function () {
     expect(fetchMock.calls()).to.have.length(3)
   })
 
-  it('displays an error message if there was a compile error', async function () {
+  describe('displays error messages', function () {
     const compileErrorStatuses = {
       'clear-cache':
         'Sorry, something went wrong and your project could not be compiled. Please try again in a few moments.',
@@ -313,17 +313,19 @@ describe('<PdfPreview/>', function () {
     }
 
     for (const [status, message] of Object.entries(compileErrorStatuses)) {
-      cleanup()
-      fetchMock.restore()
-      mockCompileError(status)
+      it(`displays error message for '${status}' status`, async function () {
+        cleanup()
+        fetchMock.restore()
+        mockCompileError(status)
 
-      renderWithEditorContext(<PdfPreview />, { scope })
+        renderWithEditorContext(<PdfPreview />, { scope })
 
-      // wait for "compile on load" to finish
-      await screen.findByRole('button', { name: 'Compiling…' })
-      await screen.findByRole('button', { name: 'Recompile' })
+        // wait for "compile on load" to finish
+        await screen.findByRole('button', { name: 'Compiling…' })
+        await screen.findByRole('button', { name: 'Recompile' })
 
-      screen.getByText(message)
+        screen.getByText(message)
+      })
     }
   })