File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22[pytest]
33markers =
44 sample: quick setup verification test
5+ bootstrap: one-time signup & session save
6+ addopts = -m " not bootstrap"
Original file line number Diff line number Diff line change 11# tests/test_signup_and_save_session.py
22import os
3- import time
43from pathlib import Path
4+ import time
55import pytest
66from playwright .sync_api import Page , BrowserContext
77from pages .signup_page import SignupPage
88
99STORAGE_PATH = os .getenv ("STORAGE_STATE" , "auth/storage_state.json" )
1010
11- @pytest .mark .sample
11+ @pytest .mark .bootstrap
1212def test_signup_and_save_session (page : Page , context : BrowserContext ):
13+ # If storage already exists, don't run the bootstrap again
14+ if Path (STORAGE_PATH ).exists ():
15+ pytest .skip (f"Storage state already exists at { STORAGE_PATH } ; bootstrap not needed." )
16+
1317 sp = SignupPage (page )
1418 sp .goto ()
1519
1620 epoch = int (time .time ())
17- full_name = f"Test User { epoch } "
21+ username = f"TestUser { epoch } "
1822 email = f"playwright_user_{ epoch } @example.com"
1923 password = f"P@ssw0rd{ epoch } !"
2024
21- sp .sign_up (full_name , email , password )
25+ sp .sign_up (username , email , password )
26+
2227 Path ("auth" ).mkdir (parents = True , exist_ok = True )
2328 context .storage_state (path = STORAGE_PATH )
24-
2529 assert Path (STORAGE_PATH ).exists (), f"Expected storage state at { STORAGE_PATH } "
You can’t perform that action at this time.
0 commit comments