Sfoglia il codice sorgente

Expand PDF preview errors by default (#31484)

GitOrigin-RevId: 7044b3033a4140ce5e3a57f5081c8d36b89b1d06
Copilot 5 mesi fa
parent
commit
fe62a55ba7

+ 1 - 1
services/web/frontend/js/features/pdf-preview/components/pdf-preview-error.tsx

@@ -254,7 +254,7 @@ function PdfPreviewError({
 export default memo(PdfPreviewError)
 
 function ErrorLogEntry({
-  autoExpand,
+  autoExpand = true,
   title,
   headerIcon,
   children,

+ 33 - 0
services/web/test/frontend/components/pdf-preview/pdf-preview.spec.tsx

@@ -578,6 +578,39 @@ describe('<PdfPreview/>', function () {
         cy.findByText(message)
       })
     }
+
+    it('displays error messages expanded by default', function () {
+      cy.intercept('POST', '/project/*/compile*', {
+        body: {
+          status: 'failure',
+          clsiServerId: 'foo',
+          compileGroup: 'priority',
+        },
+      }).as('compile')
+
+      const scope = mockScope()
+
+      cy.mount(
+        <EditorProviders scope={scope}>
+          <PdfViewer>
+            <PdfPreview />
+          </PdfViewer>
+        </EditorProviders>
+      )
+
+      cy.findByRole('button', { name: 'Recompile' }).click()
+      cy.wait('@compile')
+
+      // The error message should be visible (expanded by default)
+      cy.findByText('No PDF')
+      cy.findByText(/This compile didn’t produce a PDF/)
+      // The collapse button should be available (meaning it's expanded)
+      cy.findByLabelText(
+        'An error which prevented this project from compiling'
+      ).within(() => {
+        cy.findByRole('button', { name: 'Collapse' })
+      })
+    })
   })
 
   it('displays expandable raw logs', function () {