Skip to content

Commit

Permalink
Add notebook test for CSS loader
Browse files Browse the repository at this point in the history
  • Loading branch information
edan-bainglass committed Aug 30, 2024
1 parent 0d511e2 commit c3880d0
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
3 changes: 3 additions & 0 deletions aiidalab_widgets_base/static/styles/test.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.for-testing-purposes {
color: rgb(255, 0, 0);
}
68 changes: 68 additions & 0 deletions notebooks/test.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as ipw"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from aiida import load_profile\n",
"\n",
"load_profile();"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# DO NOT REMOVE!\n",
"# This triggers required jupyter-notebook specific actions.\n",
"# See `aiidalab_widgets_base.__init__.py` for details\n",
"import aiidalab_widgets_base"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"label = ipw.Label(\"Testing\")\n",
"label.add_class(\"for-testing-purposes\")\n",
"display(label)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
7 changes: 7 additions & 0 deletions tests_notebooks/test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
from selenium.webdriver.common.keys import Keys


def test_load_css_stylesheet(selenium_driver):
"""Test `load_css_stylesheet` function."""
driver = selenium_driver("notebooks/test.ipynb")
element = driver.find_element(By.CLASS_NAME, "for-testing-purposes")
assert element.value_of_css_property("color") == "rgba(255, 0, 0)"


def test_notebook_service_available(notebook_service):
url, token = notebook_service
response = requests.get(f"{url}/?token={token}")
Expand Down

0 comments on commit c3880d0

Please sign in to comment.