-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
41 lines (32 loc) · 1.2 KB
/
Copy pathconftest.py
File metadata and controls
41 lines (32 loc) · 1.2 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
import pytest
from playwright.sync_api import sync_playwright, Browser, Page
from config.settings import settings
from utils.api_client import ApiClient
from pages.login_page import LoginPage
@pytest.fixture(scope="session")
def browser():
with sync_playwright() as p:
browser = p.chromium.launch(headless=settings.HEADLESS)
yield browser
browser.close()
@pytest.fixture
def page(browser: Browser) -> Page:
context = browser.new_context(base_url=settings.BASE_URL)
page = context.new_page()
page.set_default_timeout(settings.DEFAULT_TIMEOUT)
yield page
context.close()
@pytest.fixture(autouse=True)
def reset_backend():
"""Runs before every test so each one starts from the same seed data,
regardless of what earlier tests created or deleted."""
ApiClient().reset_state()
yield
@pytest.fixture
def authenticated_page(page: Page) -> Page:
"""Logs in through the UI and lands on /tasks. Use this for tests that
don't care about the login flow itself, only what happens after it."""
login_page = LoginPage(page).open()
login_page.login(settings.TEST_USER_EMAIL, settings.TEST_USER_PASSWORD)
page.wait_for_url("**/tasks")
return page