mirror of
https://github.com/velocitatem/PHANTOM.git
synced 2026-05-31 08:33:36 +00:00
feature: simple npm setup
This commit is contained in:
53
tests/e2e/config/pricing.py
Normal file
53
tests/e2e/config/pricing.py
Normal file
@@ -0,0 +1,53 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import Dict, Any
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class SurgePricingConfig:
|
||||
high_threshold: int
|
||||
surge_multiplier: float
|
||||
window_size: int # seconds
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
return {
|
||||
"high_threshold": self.high_threshold,
|
||||
"surge_multiplier": self.surge_multiplier,
|
||||
"window_size": self.window_size,
|
||||
}
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class SessionAwareConfig:
|
||||
velocity_threshold: float
|
||||
view_depth_threshold: int
|
||||
cart_ratio_threshold: float
|
||||
agent_multiplier: float
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
return {
|
||||
"velocity_threshold": self.velocity_threshold,
|
||||
"view_depth_threshold": self.view_depth_threshold,
|
||||
"cart_ratio_threshold": self.cart_ratio_threshold,
|
||||
"agent_multiplier": self.agent_multiplier,
|
||||
}
|
||||
|
||||
|
||||
# Test-optimized configurations for deterministic results
|
||||
AGGRESSIVE_SURGE = SurgePricingConfig(
|
||||
high_threshold=3,
|
||||
surge_multiplier=1.5,
|
||||
window_size=10,
|
||||
)
|
||||
|
||||
MODERATE_SURGE = SurgePricingConfig(
|
||||
high_threshold=5,
|
||||
surge_multiplier=1.3,
|
||||
window_size=15,
|
||||
)
|
||||
|
||||
STRICT_SESSION_AWARE = SessionAwareConfig(
|
||||
velocity_threshold=2.0, # 2 events/sec is agent-like
|
||||
view_depth_threshold=5,
|
||||
cart_ratio_threshold=0.8,
|
||||
agent_multiplier=1.4,
|
||||
)
|
||||
36
tests/e2e/config/settings.py
Normal file
36
tests/e2e/config/settings.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
@dataclass(frozen=True)
|
||||
class ServiceConfig:
|
||||
web_url: str
|
||||
backend_url: str
|
||||
pricing_url: str
|
||||
kafka_host: str
|
||||
kafka_port: int
|
||||
redis_port: int
|
||||
@dataclass(frozen=True)
|
||||
class TestConfig:
|
||||
headless: bool
|
||||
timeout: int
|
||||
poll_interval: float
|
||||
max_retries: int
|
||||
kafka_consumer_timeout: int
|
||||
|
||||
|
||||
def load_service_config() -> ServiceConfig:
|
||||
return ServiceConfig(
|
||||
web_url=os.getenv("WEB_URL", "http://localhost:3000"),
|
||||
backend_url=os.getenv("BACKEND_URL", "http://localhost:5000"),
|
||||
pricing_url=os.getenv("PRICING_PROVIDER_URL", "http://localhost:5001"),
|
||||
kafka_host=os.getenv("KAFKA_HOST", "localhost"),
|
||||
kafka_port=int(os.getenv("KAFKA_PORT", "9092")),
|
||||
redis_port=int(os.getenv("REDIS_PORT", "6377")),
|
||||
)
|
||||
def load_test_config() -> TestConfig:
|
||||
return TestConfig(
|
||||
headless=os.getenv("HEADLESS", "true").lower() == "true",
|
||||
timeout=int(os.getenv("TEST_TIMEOUT", "30000")),
|
||||
poll_interval=float(os.getenv("POLL_INTERVAL", "0.5")),
|
||||
max_retries=int(os.getenv("MAX_RETRIES", "10")),
|
||||
kafka_consumer_timeout=int(os.getenv("KAFKA_TIMEOUT", "15")),
|
||||
)
|
||||
20
tests/e2e/package.json
Normal file
20
tests/e2e/package.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "e2e",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "playwright test",
|
||||
"test:ui": "playwright test --ui",
|
||||
"test:debug": "playwright test --debug"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"description": "",
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.57.0",
|
||||
"@types/node": "^25.0.6",
|
||||
"kafka-node": "^5.0.0",
|
||||
"typescript": "^5.9.3"
|
||||
}
|
||||
}
|
||||
25
tests/e2e/playwright.config.ts
Normal file
25
tests/e2e/playwright.config.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { defineConfig, devices } from '@playwright/test';
|
||||
|
||||
export default defineConfig({
|
||||
testDir: './scenarios',
|
||||
fullyParallel: false,
|
||||
forbidOnly: !!process.env.CI,
|
||||
retries: 0,
|
||||
workers: 1,
|
||||
reporter: 'list',
|
||||
use: {
|
||||
baseURL: process.env.WEB_URL || 'http://localhost:3000',
|
||||
trace: 'retain-on-failure',
|
||||
screenshot: 'only-on-failure',
|
||||
},
|
||||
timeout: 60000,
|
||||
expect: {
|
||||
timeout: 10000,
|
||||
},
|
||||
projects: [
|
||||
{
|
||||
name: 'chromium',
|
||||
use: { ...devices['Desktop Chrome'] },
|
||||
},
|
||||
],
|
||||
});
|
||||
15
tests/e2e/tsconfig.json
Normal file
15
tests/e2e/tsconfig.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "commonjs",
|
||||
"lib": ["ES2022"],
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"types": ["node", "@playwright/test"]
|
||||
},
|
||||
"include": ["**/*.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
Reference in New Issue
Block a user