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 a88a81d commit 20e3826
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests_notebooks/static/styles/test.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.red-text {
color: rgb(255, 0, 0);
}
67 changes: 67 additions & 0 deletions tests_notebooks/test_notebook.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"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": [
"from aiidalab_widgets_base.utils.loaders import load_css\n",
"\n",
"load_css(css_path=\"static/styles/test.css\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"label = ipw.Label(\"Testing\")\n",
"label.add_class(\"red-text\")\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
}
9 changes: 9 additions & 0 deletions tests_notebooks/test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
from selenium.webdriver.common.keys import Keys


def test_loaded_css(selenium_driver):
driver = selenium_driver("tests_notebooks/test_notebook.ipynb")
element = driver.find_element(By.CLASS_NAME, "red-text")
assert element.value_of_css_property("color") in (
"rgba(255, 0, 0, 1)", # Chrome
"rgb(255, 0, 0)", # Firefox
)


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

0 comments on commit 20e3826

Please sign in to comment.