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 21, 2024
1 parent e7f5bdf commit 36545e0
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
3 changes: 3 additions & 0 deletions aiidalab_widgets_base/static/styles/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.for-testing-purposes {
color: red;
}
56 changes: 56 additions & 0 deletions notebooks/test.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"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": [
"label = ipw.Label(\"Testing\")\n",
"label.add_class(\"for-testing-purposes\")\n",
"display(label)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"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
}
11 changes: 11 additions & 0 deletions tests_notebooks/test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys

from aiidalab_widgets_base.utils.loaders import load_css_stylesheet


def test_load_css_stylesheet(selenium_driver):
"""Test `load_css_stylesheet` function."""
driver = selenium_driver("notebooks/test.ipynb")
package = "aiidalab_widgets_base.static.styles"
load_css_stylesheet(package=package, filename="global.css")
element = driver.find_element(By.CLASS_NAME, "for-testing-purposes")
assert element.value_of_css_property("color") == "red"


def test_notebook_service_available(notebook_service):
url, token = notebook_service
Expand Down

0 comments on commit 36545e0

Please sign in to comment.