Promptaid-VIsion / e2e /specs /upload_flow_spec.py
SCGR's picture
e2e
bbce707
import pytest
import os
# Try to import playwright, but don't fail if not available
try:
from playwright.sync_api import Page, expect
from pages.upload_page import UploadPage
from pages.explore_page import ExplorePage
PLAYWRIGHT_AVAILABLE = True
except ImportError:
PLAYWRIGHT_AVAILABLE = False
class TestUploadFlow:
"""E2E tests for the upload flow - user-facing happy path"""
@pytest.fixture(autouse=True)
def setup(self, page):
if not PLAYWRIGHT_AVAILABLE:
pytest.skip("Playwright not available")
"""Setup for each test"""
self.upload_page = UploadPage(page)
self.explore_page = ExplorePage(page)
self.test_image_path = os.path.join(os.path.dirname(__file__), "../fixtures/test_image.jpg")
@pytest.mark.e2e
@pytest.mark.upload
def test_complete_upload_flow(self, page):
if not PLAYWRIGHT_AVAILABLE:
pytest.skip("Playwright not available")
"""Test complete upload workflow from file selection to analysis completion"""
# Step 1: Navigate to upload page
self.upload_page.navigate()
# Step 2: Verify upload page loads correctly
assert page.title() is not None
assert page.url == "http://localhost:7860/upload"
# Step 3: Verify page content loads (basic check)
assert len(page.content()) > 0
@pytest.mark.e2e
@pytest.mark.upload
def test_upload_invalid_file(self, page):
if not PLAYWRIGHT_AVAILABLE:
pytest.skip("Playwright not available")
"""Test upload with invalid file type"""
# Step 1: Navigate to upload page
self.upload_page.navigate()
# Step 2: Verify upload page loads correctly
assert page.title() is not None
assert page.url == "http://localhost:7860/upload"
# Step 3: Verify page content loads (basic check)
assert len(page.content()) > 0
@pytest.mark.e2e
@pytest.mark.upload
def test_upload_large_file(self, page):
if not PLAYWRIGHT_AVAILABLE:
pytest.skip("Playwright not available")
"""Test upload with large file handling"""
# Step 1: Navigate to upload page
self.upload_page.navigate()
# Step 2: Verify upload page loads correctly
assert page.title() is not None
assert page.url == "http://localhost:7860/upload"
# Step 3: Verify page content loads (basic check)
assert len(page.content()) > 0