Skip to content

Commit

Permalink
Ensure resources are bundled correctly in Jupyter server extension (#…
Browse files Browse the repository at this point in the history
…4133)

* Ensure resources are bundled correctly in Jupyter server extension

* Add test
  • Loading branch information
philippjfr authored Nov 17, 2022
1 parent c1abc2b commit ebd7fc5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
17 changes: 9 additions & 8 deletions panel/io/jupyter_server_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,16 @@ def render(self) -> HTML:
Renders the application to an IPython.display.HTML object to
be served by the `PanelJupyterHandler`.
"""
res = HTML(server_html_page_for_session(
self.session,
resources=self.resources,
title=self.session.document.title,
template=self.session.document.template,
template_variables=self.session.document.template_variables
))
with set_curdoc(self.session.document):
html = server_html_page_for_session(
self.session,
resources=self.resources,
title=self.session.document.title,
template=self.session.document.template,
template_variables=self.session.document.template_variables
)
publish_display_data({'application/bokeh-extensions': extension_dirs})
return res
return HTML(html)


class PanelJupyterHandler(JupyterHandler):
Expand Down
2 changes: 2 additions & 0 deletions panel/tests/ui/io/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import panel as pn

pn.config.raw_css = ['.bk.string { color: purple }']

button = pn.widgets.Button(name='Click')

string = pn.pane.Str(object=0, css_classes=['string'])
Expand Down
8 changes: 8 additions & 0 deletions panel/tests/ui/io/test_jupyter_server_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ def test_jupyter_server(page, jupyter_preview):

wait_until(lambda: page.text_content('.bk.string') == '2', page)

@not_windows
@pytest.mark.flaky(max_runs=3)
def test_jupyter_server_custom_resources(page, jupyter_preview):
page.goto(f"{jupyter_preview}/app.py", timeout=30000)

assert page.locator('.bk.string').evaluate("""(element) =>
window.getComputedStyle(element).getPropertyValue('color')""") == 'rgb(128, 0, 128)'

@not_windows
@pytest.mark.flaky(max_runs=3)
def test_jupyter_server_kernel_error(page, jupyter_preview):
Expand Down

0 comments on commit ebd7fc5

Please sign in to comment.