-
Notifications
You must be signed in to change notification settings - Fork 5
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
7aa929f
commit 922b3aa
Showing
9 changed files
with
113 additions
and
8 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
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 |
---|---|---|
|
@@ -131,3 +131,4 @@ dmypy.json | |
# | ||
tests/work | ||
/tests/**/*.png |
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
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 |
---|---|---|
|
@@ -58,6 +58,7 @@ pre-commit = [ | |
tests = [ | ||
"pytest~=7.0", | ||
"pytest-cov~=2.7,<2.11", | ||
"playwright", | ||
] | ||
|
||
[project.scripts] | ||
|
Empty file.
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,8 @@ | ||
|
||
## Requirements | ||
|
||
In order to run the test for the web frontend, one need to install | ||
|
||
```console | ||
playwright install | ||
``` |
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,27 @@ | ||
import pytest | ||
from fastapi.testclient import TestClient | ||
from aiida_worktree.web.backend.app.api import app | ||
from playwright.sync_api import sync_playwright | ||
|
||
|
||
# Define a fixture for the FastAPI app client | ||
@pytest.fixture(scope="module") | ||
def client(): | ||
return TestClient(app) | ||
|
||
|
||
# Define a fixture for the browser | ||
@pytest.fixture(scope="module") | ||
def browser(): | ||
with sync_playwright() as p: | ||
browser = p.chromium.launch() | ||
yield browser | ||
browser.close() | ||
|
||
|
||
# Define a fixture for the page | ||
@pytest.fixture(scope="module") | ||
def page(browser): | ||
with browser.new_page() as page: | ||
yield page | ||
page.close() |
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,9 @@ | ||
# Sample test case for the root route | ||
def test_root_route(client): | ||
response = client.get("/api") | ||
assert response.status_code == 200 | ||
assert response.json() == {"message": "Welcome to AiiDA-WorkTree."} | ||
|
||
|
||
# Add more test cases for your other routes and features | ||
# For example, testing authentication, database interactions, etc. |
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,63 @@ | ||
import pytest | ||
|
||
|
||
def test_homepage(page): | ||
page.goto("http://localhost:3000") | ||
|
||
assert page.title() == "AiiDA-WorkTree App" | ||
|
||
# Check for the existence of a specific element on the page | ||
# Attempt to locate the element | ||
element = page.locator("a[href='/worktree']") | ||
|
||
# Check if the element is found | ||
if not element.is_visible(): | ||
pytest.fail("Element 'a[href='/wortre']' not found on the page") | ||
|
||
|
||
def test_worktree(page): | ||
page.goto("http://localhost:3000/worktree") | ||
|
||
# Check for the existence of a specific element on the page | ||
|
||
# Verify the presence of the WorkTreeTable heading | ||
assert page.locator("h2").inner_text() == "WorkTree" | ||
|
||
# Verify the presence of the search input | ||
assert page.locator(".search-input").is_visible() | ||
|
||
# Verify the presence of the table header columns | ||
# Verify the presence of the table header columns | ||
assert page.locator("th:has-text('PK')").is_visible() | ||
assert page.locator("th:has-text('Created')").is_visible() | ||
assert page.locator("th:has-text('Process Label')").is_visible() | ||
assert page.locator("th:has-text('State')").is_visible() | ||
assert page.locator("th:has-text('Actions')").is_visible() | ||
|
||
# Verify the presence of pagination controls | ||
assert page.locator(".pagination").is_visible() | ||
|
||
# Verify the presence of at least one row in the table | ||
assert page.locator("tr").count() >= 2 # Including header row | ||
|
||
|
||
def test_worktree_item(page, wt_calcfunction): | ||
|
||
wt = wt_calcfunction | ||
wt.submit(wait=True) | ||
page.goto("http://localhost:3000/worktree/{}".format(wt.pk)) | ||
page.wait_for_timeout(3000) | ||
|
||
page.get_by_text("sumdiff3").is_visible() | ||
|
||
# Simulate user interaction (e.g., clicking a button) | ||
# Replace the selector with the actual selector of the button you want to click | ||
# You should identify the button that triggers an action in your component | ||
page.get_by_role("button", name="Arrange").click() | ||
page.wait_for_timeout(3000) | ||
# Capture a screenshot | ||
screenshot = page.screenshot() | ||
|
||
# Save the screenshot to a file | ||
with open("screenshot.png", "wb") as f: | ||
f.write(screenshot) |