Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add visual comparison test #137

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,9 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: python-${{ matrix.python-version }}

- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-traces
path: tests/web/snapshots/
33 changes: 14 additions & 19 deletions aiida_workgraph/web/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion aiida_workgraph/web/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"three": "^0.156.1",
"typescript": "^4.9.5",
"vis-timeline": "^7.7.3",
"weas": "^0.1.6",
"weas": "^0.1.11",
"web-vitals": "^2.1.4",
"web-worker": "^1.2.0"
},
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ tests = [
"pytest~=7.0",
"pytest-cov~=2.7,<2.11",
"playwright",
"pytest-playwright-visual",
"httpx",
]

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 13 additions & 16 deletions tests/web/test_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def test_workgraph(page, wg_calcfunction):
# 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()
Expand All @@ -43,23 +42,21 @@ def test_workgraph(page, wg_calcfunction):
assert page.locator("tr").count() >= 2 # Including header row


def test_workgraph_item(page, wg_calcfunction):
def test_workgraph_item(page, wg_calcfunction, assert_snapshot):

wg = wg_calcfunction
wg.submit(wait=True)
page.goto("http://localhost:8000/workgraph/{}".format(wg.pk))
page.wait_for_timeout(8000)

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.goto(
"http://localhost:8000/workgraph/{}".format(wg.pk),
wait_until="domcontentloaded",
)
page.wait_for_timeout(3000)
page.get_by_role("button", name="Arrange").click()
page.wait_for_timeout(8000)
# Capture a screenshot
screenshot = page.screenshot()
page.wait_for_timeout(5000)

# compare the screenshot
assert_snapshot(page.screenshot())

# Save the screenshot to a file
with open("screenshot.png", "wb") as f:
f.write(screenshot)
# page.get_by_text("sumdiff2").click()
# page.wait_for_timeout(3000)
# assert_snapshot(page.screenshot(), name='test_workgraph_item_sumdiff2.png')
Loading