File size: 2,369 Bytes
af567cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import pytest
from playwright.sync_api import sync_playwright, expect


BASE_URL = "http://localhost:3000"
API_URL = "http://localhost:8000"


class TestE2E:
    @pytest.fixture(autouse=True)
    def setup(self, browser):
        self.context = browser.new_context()
        self.page = self.context.new_page()
        yield
        self.context.close()

    def test_homepage_loads(self):
        """Test that homepage loads successfully"""
        self.page.goto(BASE_URL)
        expect(self.page).to_have_title(/OpenVar/)
        expect(self.page.get_by_text("Clinical Variant Interpretation")).to_be_visible()

    def test_search_variants(self):
        """Test variant search functionality"""
        self.page.goto(BASE_URL)
        
        # Fill in search input
        search_input = self.page.get_by_placeholder("Search variants")
        search_input.fill("chr9-135800978-A-G")
        
        # Click search button
        self.page.get_by_role("button", name="Search").click()
        
        # Wait for results (or no results message)
        self.page.wait_for_timeout(1000)

    def test_genes_page(self):
        """Test genes page loads"""
        self.page.goto(f"{BASE_URL}/genes")
        expect(self.page.get_by_text("Genes")).to_be_visible()

    def test_knowledge_page(self):
        """Test knowledge base page loads"""
        self.page.goto(f"{BASE_URL}/knowledge")
        expect(self.page.get_by_text("Knowledge Base")).to_be_visible()


class TestAPIE2E:
    def test_api_health(self, request):
        """Test API health endpoint"""
        import httpx
        response = httpx.get(f"{API_URL}/health")
        assert response.status_code == 200
        assert response.json()["status"] == "healthy"

    def test_api_genes_list(self):
        """Test API genes list"""
        import httpx
        response = httpx.get(f"{API_URL}/api/genes")
        assert response.status_code == 200
        data = response.json()
        assert isinstance(data, list)
        assert len(data) > 0

    def test_api_auth_login(self):
        """Test API login"""
        import httpx
        response = httpx.post(
            f"{API_URL}/api/auth/login",
            json={"email": "demo@openvar.io", "password": "demo"}
        )
        assert response.status_code == 200
        data = response.json()
        assert "access_token" in data