Files
customerTicket/tests/e2e/test_external_environment_smoke.py
T
2026-09-10 11:34:19 +03:30

52 lines
2.3 KiB
Python

import os
import pytest
from playwright.sync_api import expect
pytestmark = [pytest.mark.e2e, pytest.mark.external_e2e, pytest.mark.django_db(transaction=True)]
def require_setting(name):
value = os.getenv(name)
if not value:
pytest.skip(f"{name} is not configured for external E2E")
return value
def test_external_customer_login_and_public_routing_are_usable(
browser_page, application_base_url, e2e_settings
):
if not e2e_settings.base_url:
pytest.skip("E2E_BASE_URL/BASE_URL is not configured; external environment was not run")
mobile = require_setting("E2E_CUSTOMER_MOBILE")
password = require_setting("E2E_CUSTOMER_PASSWORD")
with browser_page() as page:
page.goto(f"{application_base_url}/login/password/", wait_until="domcontentloaded")
page.locator('input[name="mobile"]').fill(mobile)
page.locator('input[name="password"]').fill(password)
page.get_by_role("button", name="ورود به حساب").click()
expect(page).to_have_url(f"{application_base_url}/tickets/")
page.goto(f"{application_base_url}/tickets/new/", wait_until="domcontentloaded")
expect(page.locator("[data-ticket-unit]")).to_be_visible()
expect(page.locator("[data-ticket-category]")).to_be_visible()
expect(page.locator("[data-expert-picker]")).to_be_visible()
def test_external_staff_login_and_navigation_are_usable(
browser_page, application_base_url, e2e_settings
):
if not e2e_settings.base_url:
pytest.skip("E2E_BASE_URL/BASE_URL is not configured; external environment was not run")
username = require_setting("E2E_STAFF_USERNAME")
password = require_setting("E2E_STAFF_PASSWORD")
with browser_page() as page:
page.goto(f"{application_base_url}/staff/login/", wait_until="domcontentloaded")
page.locator('input[name="username"]').fill(username)
page.locator('input[name="password"]').fill(password)
page.get_by_role("button", name="ورود به میز کار").click()
expect(page).to_have_url(f"{application_base_url}/staff/tickets/")
response = page.goto(f"{application_base_url}/staff/tickets/new/", wait_until="domcontentloaded")
assert response.status == 200
expect(page.locator("[data-staff-unit]")).to_be_visible()