From e3a1bce11343d5f502d84a13914f600e0421ed47 Mon Sep 17 00:00:00 2001 From: Domagoj Kriskovic Date: Wed, 22 Apr 2026 13:30:31 +0200 Subject: [PATCH] Add tests for stderr output handling and execution interruption in PythonOutputPane GitOrigin-RevId: d383e90dffbabbb597a9cf793a6fabeeff9d6b1a --- .../components/python-output-pane.spec.tsx | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/services/web/test/frontend/features/ide-react/components/python-output-pane.spec.tsx b/services/web/test/frontend/features/ide-react/components/python-output-pane.spec.tsx index 6d53882a00..3bf2b3bd2e 100644 --- a/services/web/test/frontend/features/ide-react/components/python-output-pane.spec.tsx +++ b/services/web/test/frontend/features/ide-react/components/python-output-pane.spec.tsx @@ -214,4 +214,88 @@ describe('', function () { cy.findByText('Sushi,Japanese').should('exist') cy.findByText('Tacos,Mexican').should('exist') }) + + it('renders stderr output with the stderr line class', function () { + const executablePythonFileContents = [ + 'import sys', + "print('hello!')", + "sys.stderr.write('boom\\n')", + ].join('\n') + const projectFiles = { + [pythonExecutableScript.filename]: executablePythonFileContents, + } + const ProjectProvider = makeProjectProvider(projectFiles) + + cy.mount( + executablePythonFileContents, + }, + currentDocumentId: pythonExecutableScript.file_id, + openDocName: pythonExecutableScript.filename, + }, + }} + providers={{ FileTreePathProvider, ProjectProvider }} + > + + + + + ) + + cy.findByRole('button', { name: 'Run Python code' }) + .should('not.be.disabled') + .click() + + cy.findByText('hello!') + .should('have.class', 'ide-redesign-python-output-pane-line-stdout') + .and('not.have.class', 'ide-redesign-python-output-pane-line-stderr') + cy.findByText('boom').should( + 'have.class', + 'ide-redesign-python-output-pane-line-stderr' + ) + }) + + it('renders the interrupt message as an info line', function () { + const executablePythonFileContents = 'while True:\n pass\n' + const projectFiles = { + [pythonExecutableScript.filename]: executablePythonFileContents, + } + const ProjectProvider = makeProjectProvider(projectFiles) + + cy.mount( + executablePythonFileContents, + }, + currentDocumentId: pythonExecutableScript.file_id, + openDocName: pythonExecutableScript.filename, + }, + }} + providers={{ FileTreePathProvider, ProjectProvider }} + > + + + + + ) + + cy.findByRole('button', { name: 'Run Python code' }) + .should('not.be.disabled') + .click() + cy.findByRole('button', { name: 'Stop Python execution' }) + .should('not.be.disabled') + .click() + + cy.findByText('Execution interrupted').should( + 'have.class', + 'ide-redesign-python-output-pane-line-info' + ) + }) })