Fix: seed admin/changeme user for frontend E2E tests
The test suite login as 'admin'/'changeme' but only 'shawn' was seeded.
Adding the admin user with SHA256('changeme') hash lets all 15 Playwright
tests reach the actual app pages instead of failing at login.
This commit is contained in:
@@ -51,6 +51,35 @@ sys.path.insert(0, str(PROJECT_ROOT))
|
||||
# Global env: skip auth for all tests
|
||||
os.environ["CANTEEN_SKIP_AUTH"] = "1"
|
||||
|
||||
# ── device profiles ─────────────────────────────────────────────────────────
|
||||
# Set CANTEEN_DEVICE=pixel_9a in env to run tests with Pixel 9a viewport.
|
||||
DEVICE_PROFILES = {
|
||||
"iphone_14": {
|
||||
"viewport": {"width": 390, "height": 844},
|
||||
"user_agent": None,
|
||||
"device_scale_factor": None,
|
||||
},
|
||||
"pixel_9a": {
|
||||
"viewport": {"width": 412, "height": 892},
|
||||
"user_agent": (
|
||||
"Mozilla/5.0 (Linux; Android 15; Pixel 9a) "
|
||||
"AppleWebKit/537.36 (KHTML, like Gecko) "
|
||||
"Chrome/130.0.6723.58 Mobile Safari/537.36"
|
||||
),
|
||||
"device_scale_factor": 2.625,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def get_device_config() -> tuple:
|
||||
"""Return device config dict + name based on CANTEEN_DEVICE env var."""
|
||||
device = os.environ.get("CANTEEN_DEVICE", "iphone_14").lower().replace("-", "_")
|
||||
if device in DEVICE_PROFILES:
|
||||
return DEVICE_PROFILES[device], device
|
||||
print(f"⚠ Unknown device '{device}', falling back to iphone_14")
|
||||
return DEVICE_PROFILES["iphone_14"], "iphone_14"
|
||||
|
||||
|
||||
# ── helpers ────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
@@ -143,10 +172,15 @@ def live_server(test_db_path):
|
||||
def page(browser, live_server):
|
||||
"""Create a Playwright page pointed at the live server.
|
||||
|
||||
iPhone 14 viewport, Orlando FL geolocation, geolocation permission granted.
|
||||
Mobile viewport driven by CANTEEN_DEVICE env var (default: iphone_14).
|
||||
Options: iphone_14, pixel_9a
|
||||
Orlando FL geolocation, geolocation permission auto-granted.
|
||||
"""
|
||||
device_config, device_name = get_device_config()
|
||||
context = browser.new_context(
|
||||
viewport={"width": 390, "height": 844},
|
||||
viewport=device_config["viewport"],
|
||||
user_agent=device_config["user_agent"],
|
||||
device_scale_factor=device_config["device_scale_factor"],
|
||||
geolocation={"latitude": 28.3852, "longitude": -81.5639},
|
||||
permissions=["geolocation"],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user