-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd0554b
commit 19cbbac
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import time | ||
from pathlib import Path | ||
|
||
from selenium.webdriver.common.by import By | ||
from selenium.webdriver.remote.webdriver import WebDriver | ||
|
||
|
||
def test_home_notification(selenium_driver, final_screenshot): | ||
config_dir = Path.home() / ".aiidalab" | ||
warning_file = config_dir / "home_app_warning.md" | ||
|
||
# If the file exists, we are testing locally | ||
# We should make sure not to overwrite or remove the file | ||
testing_locally = warning_file.exists() | ||
|
||
if not testing_locally: | ||
config_dir.mkdir(exist_ok=True) | ||
warning_file.write_text("This is a test warning message.") | ||
|
||
selenium: WebDriver = selenium_driver("start.ipynb") | ||
selenium.set_window_size(1000, 941) | ||
|
||
notifications = selenium.find_elements(By.CLASS_NAME, "home-notification") | ||
assert len(notifications) == 1 | ||
|
||
if not testing_locally: | ||
home_warning = notifications[0] | ||
content_element = home_warning.find_element(By.TAG_NAME, "p") | ||
file_content = warning_file.read_text() | ||
assert file_content in content_element.text | ||
|
||
if not testing_locally: | ||
warning_file.unlink() | ||
selenium.refresh() | ||
time.sleep(10) | ||
notifications = selenium.find_elements(By.CLASS_NAME, "home-notification") | ||
assert len(notifications) == 0 |