Skip to content

Commit 19a5cca

Browse files
Add selenium test
1 parent cd0554b commit 19a5cca

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests_notebooks/test_notification.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import time
2+
from pathlib import Path
3+
4+
from selenium.webdriver.common.by import By
5+
from selenium.webdriver.remote.webdriver import WebDriver
6+
7+
8+
def test_home_notification(selenium_driver, final_screenshot):
9+
selenium: WebDriver = selenium_driver("start.ipynb")
10+
selenium.set_window_size(1000, 941)
11+
12+
config_dir = Path.home() / ".aiidalab"
13+
warning_file = config_dir / "home_app_warning.md"
14+
15+
# If the file exists, we are testing locally
16+
# We should make sure not to overwrite or remove the file
17+
testing_locally = warning_file.exists()
18+
19+
if not testing_locally:
20+
config_dir.mkdir(exist_ok=True)
21+
warning_file.write_text("This is a test warning message.")
22+
selenium.refresh()
23+
time.sleep(2)
24+
25+
notifications = selenium.find_elements(By.CLASS_NAME, "home-notification")
26+
assert len(notifications) == 1
27+
28+
home_warning = notifications[0]
29+
content = warning_file.read_text()
30+
assert content in home_warning.text
31+
32+
if not testing_locally:
33+
warning_file.unlink()

0 commit comments

Comments
 (0)