-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfrontend_e2e_test.py
More file actions
149 lines (127 loc) · 5.63 KB
/
frontend_e2e_test.py
File metadata and controls
149 lines (127 loc) · 5.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import os
import sys
os.environ.setdefault("PLAYWRIGHT_DISABLE_HEADLESS_SHELL", "1")
def run_tests():
from playwright.sync_api import sync_playwright, expect
results = []
def record(name, ok, detail=""):
results.append((name, ok, detail))
with sync_playwright() as p:
chromium_path = p.chromium.executable_path
if not os.path.exists(chromium_path):
chromium_path = chromium_path.replace("chrome-mac-arm64", "chrome-mac-x64")
browser = p.chromium.launch(
executable_path=chromium_path,
headless=True,
args=[
"--headless=new",
"--disable-gpu",
"--no-sandbox",
"--disable-dev-shm-usage",
],
)
page = browser.new_page()
page.set_default_timeout(8000)
frontend_url = os.environ.get("FRONTEND_URL", "http://localhost:5173/")
print(f"Navigating to {frontend_url}", flush=True)
page.goto(frontend_url, wait_until="domcontentloaded")
page.wait_for_timeout(1500)
try:
print("Checking header", flush=True)
expect(page.get_by_text("CSEMInsight")).to_be_visible()
record("App header visible", True)
except Exception as exc:
record("App header visible", False, str(exc))
try:
print("Checking Input panel", flush=True)
expect(page.locator("fieldset", has_text="Input")).to_be_visible()
record("Input panel visible", True)
except Exception as exc:
record("Input panel visible", False, str(exc))
try:
print("Checking Datasets panel", flush=True)
datasets_fieldset = page.locator("fieldset", has_text="Datasets")
expect(datasets_fieldset).to_be_visible()
record("Datasets panel visible", True)
except Exception as exc:
record("Datasets panel visible", False, str(exc))
try:
print("Switching to Side-by-Side", flush=True)
datasets_fieldset = page.locator("fieldset", has_text="Datasets")
combo = datasets_fieldset.locator("button[role='combobox']").first
combo.click()
page.get_by_role("option", name="Side-by-Side").click()
record("Comparison mode switch to Side-by-Side", True)
except Exception as exc:
record("Comparison mode switch to Side-by-Side", False, str(exc))
try:
print("Checking side-by-side empty state", flush=True)
expect(page.get_by_text("No datasets selected for side-by-side comparison.")).to_be_visible()
record("Side-by-side empty state visible", True)
except Exception as exc:
record("Side-by-side empty state visible", False, str(exc))
try:
print("Loading sample datasets", flush=True)
page.get_by_role("button", name="Spatial offset comparison").click()
page.wait_for_timeout(5000)
record("Sample data load action triggered", True)
except Exception as exc:
record("Sample data load action triggered", False, str(exc))
try:
print("Checking dataset presence", flush=True)
expect(page.locator("label", has_text="EMAGE_LINE2_s4IC_m_ef3.data").first).to_be_visible(timeout=10000)
record("Sample data load success", True)
except Exception as exc:
record("Sample data load success", False, str(exc))
try:
ok_button = page.get_by_role("button", name="OK")
if ok_button.is_visible():
ok_button.click()
page.wait_for_timeout(500)
except Exception:
pass
overlay_switch_error = None
try:
print("Switching to Overlay", flush=True)
datasets_fieldset = page.locator("fieldset", has_text="Datasets")
combo = datasets_fieldset.locator("button[role='combobox']").first
combo.click()
page.get_by_role("option", name="Overlay").click(force=True)
record("Comparison mode switch to Overlay", True)
except Exception as exc:
overlay_switch_error = exc
try:
print("Checking loaded datasets list", flush=True)
expect(page.get_by_text("Loaded datasets")).to_be_visible()
record("Loaded datasets list visible", True)
except Exception as exc:
record("Loaded datasets list visible", False, str(exc))
try:
print("Checking overlay charts", flush=True)
expect(page.locator("#amp-chart")).to_be_visible()
expect(page.locator("#phi-chart")).to_be_visible()
record("Overlay charts visible", True)
if overlay_switch_error:
record(
"Comparison mode switch to Overlay",
True,
"Overlay charts visible despite selection timeout",
)
except Exception as exc:
record("Overlay charts visible", False, str(exc))
if overlay_switch_error:
record("Comparison mode switch to Overlay", False, str(overlay_switch_error))
page.screenshot(path="/tmp/cseminight_frontend.png", full_page=True)
browser.close()
failures = [entry for entry in results if not entry[1]]
print("\nFrontend test results:")
for name, ok, detail in results:
status = "PASS" if ok else "FAIL"
print(f"{status}: {name}")
if detail:
print(f" {detail}")
if failures:
raise SystemExit(1)
if __name__ == "__main__":
sys.exit(0)
run_tests()