-
Notifications
You must be signed in to change notification settings - Fork 8
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
420692d
commit d23ab57
Showing
5 changed files
with
114 additions
and
3 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
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ msprime | |
panel | ||
pre-commit | ||
pytest | ||
pytest-playwright | ||
selenium | ||
tskit | ||
tszip |
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,30 @@ | ||
import panel as pn | ||
import pytest | ||
|
||
PORT = [6000] | ||
|
||
|
||
@pytest.fixture | ||
def port(): | ||
PORT[0] += 1 | ||
return PORT[0] | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def server_cleanup(): | ||
""" | ||
Clean up server state after each test. | ||
""" | ||
try: | ||
yield | ||
finally: | ||
pn.state.reset() | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption( | ||
"--save-screenshots", | ||
action="store_true", | ||
default=False, | ||
help="Save screenshots during tests", | ||
) |
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,71 @@ | ||
import time | ||
|
||
import msprime | ||
import panel as pn | ||
import pytest | ||
from playwright.sync_api import expect | ||
|
||
from tsbrowse import app | ||
from tsbrowse import model | ||
from tsbrowse import preprocess | ||
|
||
|
||
@pytest.fixture | ||
def save_screenshots(request): | ||
return request.config.getoption("--save-screenshots") | ||
|
||
|
||
def test_component(page, port, tmpdir, save_screenshots): | ||
ts = msprime.sim_ancestry( | ||
10, sequence_length=1000, recombination_rate=1e-2, random_seed=1 | ||
) | ||
ts = msprime.sim_mutations(ts, rate=1e-2, random_seed=1) | ||
ts.dump(tmpdir / "test.trees") | ||
preprocess.preprocess(tmpdir / "test.trees", tmpdir / "test.tsbrowse") | ||
|
||
tsm = model.TSModel(tmpdir / "test.tsbrowse") | ||
component = app.App(tsm) | ||
|
||
url = f"http://localhost:{port}" | ||
server = pn.serve(component.view(), port=port, threaded=True, show=False) | ||
time.sleep(1) | ||
page.goto(url) | ||
page.set_viewport_size({"width": 1920, "height": 1080}) | ||
expect(page.get_by_role("link", name="Tree Sequence")).to_be_visible() | ||
expect(page.get_by_role("cell", name="Provenance Timestamp")).to_be_visible() | ||
if save_screenshots: | ||
page.screenshot(path="overview.png") | ||
|
||
page.get_by_role("button", name="Tables").click() | ||
expect(page.get_by_label("Select Table")).to_be_visible() | ||
expect(page.get_by_placeholder("Enter query expression (e.g")).to_be_visible() | ||
page.get_by_label("Select Table").select_option("trees") | ||
expect(page.get_by_text("total_branch_length")).to_be_visible() | ||
if save_screenshots: | ||
page.screenshot(path="tables.png") | ||
|
||
page.get_by_role("button", name="Mutations").click() | ||
expect(page.get_by_text("Log y-axis")).to_be_visible() | ||
expect(page.get_by_title("Reset").locator("div")).to_be_visible() | ||
if save_screenshots: | ||
page.screenshot(path="mutations.png") | ||
|
||
page.get_by_role("button", name="Edges").click() | ||
expect(page.get_by_text("Parent node")).to_be_visible() | ||
expect(page.get_by_title("Reset").locator("div")).to_be_visible() | ||
if save_screenshots: | ||
page.screenshot(path="edges.png") | ||
|
||
page.get_by_role("button", name="Trees").click() | ||
expect(page.get_by_text("log y-axis")).to_be_visible() | ||
expect(page.locator(".bk-Canvas > div:nth-child(12)").first).to_be_visible() | ||
if save_screenshots: | ||
page.screenshot(path="trees.png") | ||
|
||
page.get_by_role("button", name="Nodes").click() | ||
expect(page.get_by_role("heading", name="Node Flags")).to_be_visible() | ||
expect(page.get_by_title("Reset").locator("div")).to_be_visible() | ||
if save_screenshots: | ||
page.screenshot(path="nodes.png") | ||
|
||
server.stop() |