feat: surface the Plotly page console in the Console dock
A plotly failure inside the WebEngine page was invisible from Python - the react promise just rejected and the canvas looked frozen with no evidence. PlotlyCanvas now installs a QWebEnginePage that forwards javaScriptConsoleMessage into the Console dock with the right severity (error/warning/info), so the next silent failure is diagnosable.
This commit is contained in:
parent
0611153555
commit
7cf323df23
3 changed files with 73 additions and 2 deletions
|
|
@ -99,3 +99,25 @@ def test_style_change_keeps_the_view_but_updates_the_layout(qtbot) -> None: # t
|
|||
payload, preserve = _parse_call(calls[-1])
|
||||
assert preserve is True, "colour changes must not re-frame the view"
|
||||
assert payload["layout"]["scene"]["xaxis"]["showgrid"] is True # layout applied
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
def test_js_console_messages_reach_the_log(qtbot) -> None: # type: ignore[no-untyped-def]
|
||||
"""A plotly failure inside the page must not be invisible from Python."""
|
||||
from PySide6.QtWebEngineCore import QWebEnginePage
|
||||
|
||||
from otko.views.canvas_plotly.plotly_canvas import _LoggingPage
|
||||
|
||||
messages: list[tuple[str, str]] = []
|
||||
page = _LoggingPage(lambda msg, severity="info": messages.append((severity, msg)))
|
||||
|
||||
levels = QWebEnginePage.JavaScriptConsoleMessageLevel
|
||||
page.javaScriptConsoleMessage(levels.ErrorMessageLevel, "boom", 7, "file:///tmp/plot.html")
|
||||
page.javaScriptConsoleMessage(levels.WarningMessageLevel, "careful", 8, "file:///tmp/plot.html")
|
||||
page.javaScriptConsoleMessage(levels.InfoMessageLevel, "hello", 9, "")
|
||||
|
||||
assert messages == [
|
||||
("error", "[web] plot.html:7 boom"),
|
||||
("warning", "[web] plot.html:8 careful"),
|
||||
("info", "[web] plotly:9 hello"),
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in a new issue