chore: remove pre-locust test stubs and add daily topic, follow router, password reset, image upload, and badge awarding features

This commit is contained in:
2026-05-10 22:41:41 +00:00
parent f4343c3d05
commit d8ef8ebef2
31 changed files with 598 additions and 473 deletions
+19 -10
View File
@@ -47,12 +47,16 @@ def app_server(test_db_path):
env = os.environ.copy()
env["DEVPLACE_DATABASE_URL"] = f"sqlite:///{test_db_path}"
env["SECRET_KEY"] = "test-secret-key"
proc = subprocess.Popen(
[sys.executable, "-m", "uvicorn", "devplacepy.main:app",
"--host", "127.0.0.1", "--port", "10501"],
cwd=str(PROJECT_ROOT), env=env,
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
)
err_path = Path("/tmp/devplace_test_server_err.log")
with open(err_path, "w") as err_f:
proc = subprocess.Popen(
[sys.executable, "-m", "uvicorn", "devplacepy.main:app",
"--host", "127.0.0.1", "--port", "10501"],
cwd=str(PROJECT_ROOT),
env=env,
stdout=subprocess.DEVNULL,
stderr=err_f,
)
deadline = time.time() + 20
while time.time() < deadline:
try:
@@ -83,7 +87,7 @@ def browser(playwright_instance):
yield b
b.close()
@pytest.fixture
@pytest.fixture(scope="module")
def browser_context(browser):
ctx = browser.new_context(viewport={"width": 1400, "height": 900})
yield ctx
@@ -92,6 +96,7 @@ def browser_context(browser):
@pytest.fixture
def page(browser_context):
browser_context.clear_cookies()
p = browser_context.new_page()
p.set_default_timeout(10000)
p.bring_to_front()
@@ -100,7 +105,7 @@ def page(browser_context):
def signup_user(page, user):
page.bring_to_front()
page.goto(f"{BASE_URL}/auth/signup")
page.goto(f"{BASE_URL}/auth/signup", wait_until="domcontentloaded")
page.fill("#username", user["username"])
page.fill("#email", user["email"])
page.fill("#password", user["password"])
@@ -111,11 +116,15 @@ def signup_user(page, user):
def login_user(page, user):
page.bring_to_front()
page.goto(f"{BASE_URL}/auth/login")
page.goto(f"{BASE_URL}/auth/login", wait_until="domcontentloaded")
page.fill("#email", user["email"])
page.fill("#password", user["password"])
page.click("button:has-text('Sign in')")
page.wait_for_url("**/feed", timeout=10000)
try:
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
except Exception as e:
print(f"\n[LOGIN FAIL] URL: {page.url}, title: {page.title()}, err: {e}")
raise
@pytest.fixture(scope="session")
+37 -37
View File
@@ -2,7 +2,7 @@ from tests.conftest import BASE_URL
def test_signup_page_loads(page, app_server):
page.goto(f"{BASE_URL}/auth/signup")
page.goto(f"{BASE_URL}/auth/signup", wait_until="domcontentloaded")
assert page.is_visible("h2:has-text('Join the Community')")
assert page.is_visible("#username")
assert page.is_visible("#email")
@@ -11,27 +11,27 @@ def test_signup_page_loads(page, app_server):
def test_signup_success(page, app_server):
page.goto(f"{BASE_URL}/auth/signup")
page.goto(f"{BASE_URL}/auth/signup", wait_until="domcontentloaded")
page.fill("#username", "fresh_user")
page.fill("#email", "fresh@test.devplace")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
page.click("button:has-text('Create account')")
page.wait_for_url("**/feed", timeout=10000)
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
assert page.is_visible("text=fresh_user")
def test_signup_existing_username(page, app_server):
page.goto(f"{BASE_URL}/auth/signup")
page.goto(f"{BASE_URL}/auth/signup", wait_until="domcontentloaded")
page.fill("#username", "dup_user")
page.fill("#email", "dup1@test.devplace")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
page.click("button:has-text('Create account')")
page.wait_for_url("**/feed", timeout=10000)
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
page.context.clear_cookies()
page.goto(f"{BASE_URL}/auth/signup")
page.goto(f"{BASE_URL}/auth/signup", wait_until="domcontentloaded")
page.fill("#username", "dup_user")
page.fill("#email", "dup2@test.devplace")
page.fill("#password", "secret123")
@@ -42,16 +42,16 @@ def test_signup_existing_username(page, app_server):
def test_signup_existing_email(page, app_server):
page.goto(f"{BASE_URL}/auth/signup")
page.goto(f"{BASE_URL}/auth/signup", wait_until="domcontentloaded")
page.fill("#username", "email_dup1")
page.fill("#email", "sameemail@test.devplace")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
page.click("button:has-text('Create account')")
page.wait_for_url("**/feed", timeout=10000)
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
page.context.clear_cookies()
page.goto(f"{BASE_URL}/auth/signup")
page.goto(f"{BASE_URL}/auth/signup", wait_until="domcontentloaded")
page.fill("#username", "email_dup2")
page.fill("#email", "sameemail@test.devplace")
page.fill("#password", "secret123")
@@ -62,7 +62,7 @@ def test_signup_existing_email(page, app_server):
def test_signup_password_mismatch(page, app_server):
page.goto(f"{BASE_URL}/auth/signup")
page.goto(f"{BASE_URL}/auth/signup", wait_until="domcontentloaded")
page.fill("#username", "mismatch_user")
page.fill("#email", "mismatch@test.devplace")
page.fill("#password", "secret123")
@@ -73,7 +73,7 @@ def test_signup_password_mismatch(page, app_server):
def test_signup_short_password(page, app_server):
page.goto(f"{BASE_URL}/auth/signup")
page.goto(f"{BASE_URL}/auth/signup", wait_until="domcontentloaded")
page.fill("#username", "shortpw_user")
page.fill("#email", "shortpw@test.devplace")
page.fill("#password", "ab")
@@ -84,7 +84,7 @@ def test_signup_short_password(page, app_server):
def test_signup_invalid_username(page, app_server):
page.goto(f"{BASE_URL}/auth/signup")
page.goto(f"{BASE_URL}/auth/signup", wait_until="domcontentloaded")
page.fill("#username", "ab")
page.fill("#email", "shortname@test.devplace")
page.fill("#password", "secret123")
@@ -95,7 +95,7 @@ def test_signup_invalid_username(page, app_server):
def test_login_page_loads(page, app_server):
page.goto(f"{BASE_URL}/auth/login")
page.goto(f"{BASE_URL}/auth/login", wait_until="domcontentloaded")
assert page.is_visible("h2:has-text('Welcome Back')")
assert page.is_visible("#email")
assert page.is_visible("#password")
@@ -103,36 +103,36 @@ def test_login_page_loads(page, app_server):
def test_login_success(page, app_server):
page.goto(f"{BASE_URL}/auth/signup")
page.goto(f"{BASE_URL}/auth/signup", wait_until="domcontentloaded")
page.fill("#username", "login_user")
page.fill("#email", "login@test.devplace")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
page.click("button:has-text('Create account')")
page.wait_for_url("**/feed", timeout=10000)
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
page.goto(f"{BASE_URL}/auth/logout")
page.goto(f"{BASE_URL}/auth/logout", wait_until="domcontentloaded")
page.goto(f"{BASE_URL}/auth/login")
page.goto(f"{BASE_URL}/auth/login", wait_until="domcontentloaded")
page.fill("#email", "login@test.devplace")
page.fill("#password", "secret123")
page.click("button:has-text('Sign in')")
page.wait_for_url("**/feed", timeout=10000)
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
assert page.is_visible("text=login_user")
def test_login_wrong_password(page, app_server):
page.goto(f"{BASE_URL}/auth/signup")
page.goto(f"{BASE_URL}/auth/signup", wait_until="domcontentloaded")
page.fill("#username", "wrongpw_user")
page.fill("#email", "wrongpw@test.devplace")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
page.click("button:has-text('Create account')")
page.wait_for_url("**/feed", timeout=10000)
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
page.goto(f"{BASE_URL}/auth/logout")
page.goto(f"{BASE_URL}/auth/logout", wait_until="domcontentloaded")
page.goto(f"{BASE_URL}/auth/login")
page.goto(f"{BASE_URL}/auth/login", wait_until="domcontentloaded")
page.fill("#email", "wrongpw@test.devplace")
page.fill("#password", "badpassword")
page.click("button:has-text('Sign in')")
@@ -141,7 +141,7 @@ def test_login_wrong_password(page, app_server):
def test_login_nonexistent_email(page, app_server):
page.goto(f"{BASE_URL}/auth/login")
page.goto(f"{BASE_URL}/auth/login", wait_until="domcontentloaded")
page.fill("#email", "nobody@nowhere.devplace")
page.fill("#password", "secret123")
page.click("button:has-text('Sign in')")
@@ -150,53 +150,53 @@ def test_login_nonexistent_email(page, app_server):
def test_login_remember_me(page, app_server):
page.goto(f"{BASE_URL}/auth/signup")
page.goto(f"{BASE_URL}/auth/signup", wait_until="domcontentloaded")
page.fill("#username", "remember_user")
page.fill("#email", "remember@test.devplace")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
page.click("button:has-text('Create account')")
page.wait_for_url("**/feed", timeout=10000)
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
page.goto(f"{BASE_URL}/auth/logout")
page.goto(f"{BASE_URL}/auth/logout", wait_until="domcontentloaded")
page.goto(f"{BASE_URL}/auth/login")
page.goto(f"{BASE_URL}/auth/login", wait_until="domcontentloaded")
page.fill("#email", "remember@test.devplace")
page.fill("#password", "secret123")
page.check("input[name='remember_me']")
page.click("button:has-text('Sign in')")
page.wait_for_url("**/feed", timeout=10000)
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
assert page.is_visible("text=remember_user")
def test_logout(page, app_server):
page.goto(f"{BASE_URL}/auth/signup")
page.goto(f"{BASE_URL}/auth/signup", wait_until="domcontentloaded")
page.fill("#username", "logout_user")
page.fill("#email", "logout@test.devplace")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
page.click("button:has-text('Create account')")
page.wait_for_url("**/feed", timeout=10000)
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
page.goto(f"{BASE_URL}/auth/logout")
page.wait_for_url("**/")
page.goto(f"{BASE_URL}/auth/logout", wait_until="domcontentloaded")
page.wait_for_url("**/", wait_until="domcontentloaded")
assert page.is_visible("text=Join DevPlace Free")
def test_signup_link_from_login(page, app_server):
page.goto(f"{BASE_URL}/auth/login")
page.goto(f"{BASE_URL}/auth/login", wait_until="domcontentloaded")
page.click("a:has-text('Create new account')")
page.wait_for_url("**/auth/signup")
page.wait_for_url("**/auth/signup", wait_until="domcontentloaded")
def test_login_link_from_signup(page, app_server):
page.goto(f"{BASE_URL}/auth/signup")
page.goto(f"{BASE_URL}/auth/signup", wait_until="domcontentloaded")
page.click("a:has-text('Sign in instead')")
page.wait_for_url("**/auth/login")
page.wait_for_url("**/auth/login", wait_until="domcontentloaded")
def test_password_toggle(page, app_server):
page.goto(f"{BASE_URL}/auth/signup")
page.goto(f"{BASE_URL}/auth/signup", wait_until="domcontentloaded")
pw_input = page.locator("#password")
toggle = page.locator(".auth-toggle-pw").first
assert pw_input.get_attribute("type") == "password"
+13 -12
View File
@@ -4,13 +4,14 @@ from tests.conftest import BASE_URL
def create_post(page, content, topic="random", title=None):
page.goto(f"{BASE_URL}/feed")
page.locator(".feed-fab").click()
page.locator(".feed-fab").first.wait_for(state="visible", timeout=10000)
page.locator(".feed-fab").first.click()
page.check(f"input[value='{topic}']")
page.fill("#post-content", content)
if title:
page.fill("#post-title", title)
page.click("button:has-text('Post')")
page.wait_for_url("**/posts/*", timeout=10000)
page.wait_for_url("**/posts/*", timeout=10000, wait_until="domcontentloaded")
def signup(page, username, email, password):
@@ -20,7 +21,7 @@ def signup(page, username, email, password):
page.fill("#password", password)
page.fill("#confirm_password", password)
page.click("button:has-text('Create account')")
page.wait_for_url("**/feed", timeout=10000)
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
def test_full_user_journey(browser, app_server):
@@ -45,7 +46,7 @@ def test_full_user_journey(browser, app_server):
# Navigate to signup via link
pa.click("a:has-text('Sign Up')", no_wait_after=True)
pa.wait_for_url("**/auth/signup", timeout=10000)
pa.wait_for_url("**/auth/signup", timeout=10000, wait_until="domcontentloaded")
# ═══════════════════════════════════════════════
# ACT 2 — TWO USERS SIGN UP
@@ -67,16 +68,16 @@ def test_full_user_journey(browser, app_server):
# Switch all feed tabs
for tab in ("Trending", "Recent"):
pa.click(f"a:has-text('{tab}')")
pa.wait_for_url(f"**/feed?tab={tab.lower()}")
pa.wait_for_url(f"**/feed?tab={tab.lower()}", wait_until="domcontentloaded")
pa.click("a.feed-nav-btn:has-text('All')")
pa.wait_for_url("**/feed**", timeout=10000)
pa.wait_for_url("**/feed**", timeout=10000, wait_until="domcontentloaded")
# Switch all topic filters
for topic in ("showcase", "question", "rant", "fun"):
pa.click(f"a:has-text('{topic.capitalize()}')")
pa.wait_for_url(f"**/feed?topic={topic}")
pa.wait_for_url(f"**/feed?topic={topic}", wait_until="domcontentloaded")
pa.click("a:has-text('All')")
pa.wait_for_url("**/feed**", timeout=10000)
pa.wait_for_url("**/feed**", timeout=10000, wait_until="domcontentloaded")
# ═══════════════════════════════════════════════
# ACT 4 — ALICE CREATES 4 POSTS (ALL TOPICS)
@@ -243,21 +244,21 @@ def test_full_user_journey(browser, app_server):
# ACT 12 — LOGOUT, LOGIN AGAIN
# ═══════════════════════════════════════════════
pa.goto(f"{BASE_URL}/auth/logout")
pa.wait_for_url("**/")
pa.wait_for_url("**/", wait_until="domcontentloaded")
# Log back in
pa.click("text=Log In")
pa.wait_for_url("**/auth/login")
pa.wait_for_url("**/auth/login", wait_until="domcontentloaded")
assert pa.is_visible("h2:has-text('Welcome Back')")
pa.fill("#email", "alice_demo@test.dev")
pa.fill("#password", "alice_pass_1")
pa.click("button:has-text('Sign in')")
pa.wait_for_url("**/feed", timeout=10000)
pa.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
assert pa.is_visible("text=alice_demo")
# Bob logs out
pb.goto(f"{BASE_URL}/auth/logout")
pb.wait_for_url("**/")
pb.wait_for_url("**/", wait_until="domcontentloaded")
# ═══════════════════════════════════════════════
# ACT 13 — FINAL VERIFICATION
+24 -24
View File
@@ -3,7 +3,7 @@ from tests.conftest import BASE_URL
def test_feed_page_loads(alice):
page, user = alice
page.goto(f"{BASE_URL}/feed")
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
assert page.is_visible("text=Topics")
assert page.is_visible("text=All")
assert page.is_visible("text=Devlog")
@@ -12,7 +12,7 @@ def test_feed_page_loads(alice):
def test_feed_nav_tabs(alice):
page, user = alice
page.goto(f"{BASE_URL}/feed")
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
assert page.is_visible("a:has-text('All')")
assert page.is_visible("a:has-text('Trending')")
assert page.is_visible("a:has-text('Recent')")
@@ -21,16 +21,16 @@ def test_feed_nav_tabs(alice):
def test_feed_tab_switching(alice):
page, user = alice
page.goto(f"{BASE_URL}/feed")
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
page.click("a:has-text('Trending')")
page.wait_for_url(f"{BASE_URL}/feed?tab=trending")
page.wait_for_url(f"{BASE_URL}/feed?tab=trending", wait_until="domcontentloaded")
page.click("a:has-text('Recent')")
page.wait_for_url(f"{BASE_URL}/feed?tab=recent")
page.wait_for_url(f"{BASE_URL}/feed?tab=recent", wait_until="domcontentloaded")
def test_feed_topic_filter_sidebar(alice):
page, user = alice
page.goto(f"{BASE_URL}/feed")
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
topics = ["Devlog", "Showcase", "Question", "Rant", "Fun"]
for topic in topics:
link = page.locator(f"a:has-text('{topic}')").first
@@ -39,14 +39,14 @@ def test_feed_topic_filter_sidebar(alice):
def test_feed_topic_filter_navigation(alice):
page, user = alice
page.goto(f"{BASE_URL}/feed")
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
page.click("a:has-text('Devlog')")
page.wait_for_url(f"{BASE_URL}/feed?topic=devlog")
page.wait_for_url(f"{BASE_URL}/feed?topic=devlog", wait_until="domcontentloaded")
def test_feed_community_stats(alice):
page, user = alice
page.goto(f"{BASE_URL}/feed")
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
assert page.is_visible("text=Total Members")
assert page.is_visible("text=Posts Today")
assert page.is_visible("text=Total Projects")
@@ -54,19 +54,19 @@ def test_feed_community_stats(alice):
def test_feed_top_authors(alice):
page, user = alice
page.goto(f"{BASE_URL}/feed")
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
assert page.is_visible("text=Top Authors")
def test_feed_daily_topic(alice):
page, user = alice
page.goto(f"{BASE_URL}/feed")
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
assert page.is_visible("text=Daily Topic")
def test_create_post_fab(alice):
page, user = alice
page.goto(f"{BASE_URL}/feed")
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
fab = page.locator(".feed-fab")
assert fab.is_visible()
fab.click()
@@ -77,63 +77,63 @@ def test_create_post_fab(alice):
def test_create_post_devlog(alice):
page, _ = alice
page.goto(f"{BASE_URL}/feed")
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
page.locator(".feed-fab").click()
page.check("input[value='devlog']")
page.fill("#post-content", "This is a test devlog post created by Playwright")
page.fill("#post-title", "Test Devlog Title")
page.click("button:has-text('Post')")
page.wait_for_url(f"{BASE_URL}/posts/*")
page.wait_for_url(f"{BASE_URL}/posts/*", wait_until="domcontentloaded")
assert page.is_visible("text=Test Devlog Title")
assert page.is_visible("text=This is a test devlog post created by Playwright")
def test_create_post_showcase(alice):
page, _ = alice
page.goto(f"{BASE_URL}/feed")
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
page.locator(".feed-fab").click()
page.check("input[value='showcase']")
page.fill("#post-content", "Check out my new project showcase")
page.click("button:has-text('Post')")
page.wait_for_url(f"{BASE_URL}/posts/*")
page.wait_for_url(f"{BASE_URL}/posts/*", wait_until="domcontentloaded")
def test_create_post_without_title(alice):
page, _ = alice
page.goto(f"{BASE_URL}/feed")
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
page.locator(".feed-fab").click()
page.check("input[value='rant']")
page.fill("#post-content", "Rant without a title")
page.click("button:has-text('Post')")
page.wait_for_url(f"{BASE_URL}/posts/*")
page.wait_for_url(f"{BASE_URL}/posts/*", wait_until="domcontentloaded")
assert page.is_visible("text=Rant without a title")
def test_feed_topnav_navigation(alice):
page, user = alice
page.goto(f"{BASE_URL}/feed")
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
page.click("a:has-text('Projects')")
page.wait_for_url(f"{BASE_URL}/projects")
page.wait_for_url(f"{BASE_URL}/projects", wait_until="domcontentloaded")
page.click("a:has-text('Home')")
page.wait_for_url(f"{BASE_URL}/feed")
page.wait_for_url(f"{BASE_URL}/feed", wait_until="domcontentloaded")
def test_topnav_notification_bell(alice):
page, _ = alice
page.goto(f"{BASE_URL}/feed")
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
bell = page.locator(".topnav-icon").first
assert bell.is_visible()
def test_topnav_user_menu(alice):
page, user = alice
page.goto(f"{BASE_URL}/feed")
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
assert page.is_visible(f"text={user['username']}")
def test_create_post_cancel_modal(alice):
page, _ = alice
page.goto(f"{BASE_URL}/feed")
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
page.locator(".feed-fab").click()
cancel = page.locator("button:has-text('Cancel')").first
cancel.click()
+16 -16
View File
@@ -2,27 +2,27 @@ from tests.conftest import BASE_URL
def test_landing_page_loads(page, app_server):
page.goto(f"{BASE_URL}/")
page.goto(f"{BASE_URL}/", wait_until="domcontentloaded")
assert "DevPlace" in page.title()
assert page.is_visible("text=Devplace.net")
assert page.is_visible("text=The Developer Social Network")
def test_landing_tagline(page, app_server):
page.goto(f"{BASE_URL}/")
page.goto(f"{BASE_URL}/", wait_until="domcontentloaded")
tagline = page.text_content("p")
assert "Track industry shifts" in tagline
def test_landing_join_button(page, app_server):
page.goto(f"{BASE_URL}/")
page.goto(f"{BASE_URL}/", wait_until="domcontentloaded")
btn = page.locator("text=Join DevPlace Free")
assert btn.is_visible()
assert btn.get_attribute("href") == "/auth/signup"
def test_landing_features(page, app_server):
page.goto(f"{BASE_URL}/")
page.goto(f"{BASE_URL}/", wait_until="domcontentloaded")
features = [
"100% Free Forever",
"Zero Ads",
@@ -34,14 +34,14 @@ def test_landing_features(page, app_server):
def test_landing_daily_topic(page, app_server):
page.goto(f"{BASE_URL}/")
page.goto(f"{BASE_URL}/", wait_until="domcontentloaded")
assert page.is_visible("text=Daily Topic")
assert page.is_visible("text=Read More")
assert page.is_visible("text=Source")
def test_landing_nav_links(page, app_server):
page.goto(f"{BASE_URL}/")
page.goto(f"{BASE_URL}/", wait_until="domcontentloaded")
assert page.is_visible("a:has-text('Home')")
assert page.is_visible("a:has-text('Projects')")
assert page.is_visible("a:has-text('Login')")
@@ -49,34 +49,34 @@ def test_landing_nav_links(page, app_server):
def test_landing_nav_to_login(page, app_server):
page.goto(f"{BASE_URL}/")
page.goto(f"{BASE_URL}/", wait_until="domcontentloaded")
page.click("a:has-text('Login')")
page.wait_for_url(f"{BASE_URL}/auth/login")
page.wait_for_url(f"{BASE_URL}/auth/login", wait_until="domcontentloaded")
assert page.is_visible("h2:has-text('Welcome Back')")
def test_landing_nav_to_signup(page, app_server):
page.goto(f"{BASE_URL}/")
page.goto(f"{BASE_URL}/", wait_until="domcontentloaded")
page.click("a:has-text('Sign Up')")
page.wait_for_url(f"{BASE_URL}/auth/signup")
page.wait_for_url(f"{BASE_URL}/auth/signup", wait_until="domcontentloaded")
assert page.is_visible("h2:has-text('Join the Community')")
def test_landing_log_in_link(page, app_server):
page.goto(f"{BASE_URL}/")
page.goto(f"{BASE_URL}/", wait_until="domcontentloaded")
page.click("text=Log In")
page.wait_for_url(f"{BASE_URL}/auth/login")
page.wait_for_url(f"{BASE_URL}/auth/login", wait_until="domcontentloaded")
def test_landing_authenticated_redirects_to_feed(page, app_server):
page.goto(f"{BASE_URL}/auth/signup")
page.goto(f"{BASE_URL}/auth/signup", wait_until="domcontentloaded")
page.fill("#username", "redirect_user")
page.fill("#email", "redirect@test.devplace")
page.fill("#password", "secret123")
page.fill("#confirm_password", "secret123")
with page.expect_navigation(timeout=10000):
page.click("button:has-text('Create account')")
page.wait_for_url("**/feed", timeout=10000)
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
page.goto(f"{BASE_URL}/")
page.wait_for_url("**/feed", timeout=10000)
page.goto(f"{BASE_URL}/", wait_until="domcontentloaded")
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
+4 -4
View File
@@ -3,13 +3,13 @@ from tests.conftest import BASE_URL
def test_messages_page_loads(alice):
page, _ = alice
page.goto(f"{BASE_URL}/messages")
page.goto(f"{BASE_URL}/messages", wait_until="domcontentloaded")
assert page.is_visible(".messages-layout")
def test_messages_search_input(alice):
page, _ = alice
page.goto(f"{BASE_URL}/messages")
page.goto(f"{BASE_URL}/messages", wait_until="domcontentloaded")
search = page.locator("#message-search")
assert search.is_visible()
assert search.get_attribute("placeholder") == "Search conversations..."
@@ -17,7 +17,7 @@ def test_messages_search_input(alice):
def test_messages_empty_state(alice):
page, _ = alice
page.goto(f"{BASE_URL}/messages")
page.goto(f"{BASE_URL}/messages", wait_until="domcontentloaded")
empty = page.locator("text=No conversations yet")
if empty.is_visible():
pass
@@ -27,7 +27,7 @@ def test_messages_empty_state(alice):
def test_messages_search_for_bob(alice):
page, _ = alice
page.goto(f"{BASE_URL}/messages")
page.goto(f"{BASE_URL}/messages", wait_until="domcontentloaded")
page.fill("#message-search", "bob_test")
page.locator("#message-search").press("Enter")
page.wait_for_timeout(500)
+5 -5
View File
@@ -3,13 +3,13 @@ from tests.conftest import BASE_URL
def test_notifications_page_loads(alice):
page, _ = alice
page.goto(f"{BASE_URL}/notifications")
page.goto(f"{BASE_URL}/notifications", wait_until="domcontentloaded")
assert page.is_visible("h2:has-text('Notifications')")
def test_mark_all_read(alice):
page, _ = alice
page.goto(f"{BASE_URL}/notifications")
page.goto(f"{BASE_URL}/notifications", wait_until="domcontentloaded")
mark_all = page.locator("button:has-text('Mark all read')")
if mark_all.is_visible():
mark_all.click()
@@ -18,13 +18,13 @@ def test_mark_all_read(alice):
def test_notifications_navigation(alice):
page, _ = alice
page.goto(f"{BASE_URL}/feed")
page.goto(f"{BASE_URL}/notifications")
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
page.goto(f"{BASE_URL}/notifications", wait_until="domcontentloaded")
assert page.is_visible("h2:has-text('Notifications')")
def test_notifications_bell_visible(alice):
page, _ = alice
page.goto(f"{BASE_URL}/feed")
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
bell = page.locator(".topnav-icon").first
assert bell.is_visible()
+13 -4
View File
@@ -2,14 +2,23 @@ from tests.conftest import BASE_URL
def create_post(page, topic="random", content="Test post content", title=None):
page.goto(f"{BASE_URL}/feed")
page.locator(".feed-fab").click()
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
fab_count = page.locator(".feed-fab").count()
if fab_count == 0:
title = page.title()
has_fab = page.evaluate("document.body.innerHTML.includes('feed-fab')")
body_start = page.evaluate("document.body.innerHTML.substring(0, 500)")
print(f"\n[CREATE_POST] No FAB! URL={page.url} Title={title} has_fab={has_fab}")
print(f"[CREATE_POST] Body start: {body_start[:300]}")
page.wait_for_timeout(2000)
page.locator(".feed-fab").first.wait_for(state="visible", timeout=10000)
page.locator(".feed-fab").first.click()
page.check(f"input[value='{topic}']")
page.fill("#post-content", content)
if title:
page.fill("#post-title", title)
page.click("button:has-text('Post')")
page.wait_for_url(f"{BASE_URL}/posts/*")
page.wait_for_url(f"{BASE_URL}/posts/*", wait_until="domcontentloaded")
def test_post_detail_page(alice):
@@ -112,7 +121,7 @@ def test_back_to_feed_link(alice):
back = page.locator("a:has-text('Back to Feed')")
assert back.is_visible()
back.click()
page.wait_for_url(f"{BASE_URL}/feed")
page.wait_for_url(f"{BASE_URL}/feed", wait_until="domcontentloaded")
def test_multiple_comments_on_post(alice):
+18 -18
View File
@@ -3,13 +3,13 @@ from tests.conftest import BASE_URL
def test_profile_page_loads(alice):
page, user = alice
page.goto(f"{BASE_URL}/profile/{user['username']}")
page.goto(f"{BASE_URL}/profile/{user['username']}", wait_until="domcontentloaded")
assert page.is_visible(f"text={user['username']}")
def test_profile_stats(alice):
page, user = alice
page.goto(f"{BASE_URL}/profile/{user['username']}")
page.goto(f"{BASE_URL}/profile/{user['username']}", wait_until="domcontentloaded")
assert page.is_visible("text=Posts")
assert page.is_visible("text=Level")
assert page.is_visible("text=Stars")
@@ -17,7 +17,7 @@ def test_profile_stats(alice):
def test_profile_level_bar(alice):
page, user = alice
page.goto(f"{BASE_URL}/profile/{user['username']}")
page.goto(f"{BASE_URL}/profile/{user['username']}", wait_until="domcontentloaded")
assert page.is_visible("text=Progress to next level")
level_bar = page.locator(".bar")
assert level_bar.is_visible()
@@ -25,14 +25,14 @@ def test_profile_level_bar(alice):
def test_profile_badges(alice):
page, user = alice
page.goto(f"{BASE_URL}/profile/{user['username']}")
page.goto(f"{BASE_URL}/profile/{user['username']}", wait_until="domcontentloaded")
badges = page.locator(".profile-badge")
assert badges.count() >= 1
def test_profile_tabs(alice):
page, user = alice
page.goto(f"{BASE_URL}/profile/{user['username']}")
page.goto(f"{BASE_URL}/profile/{user['username']}", wait_until="domcontentloaded")
tabs = ["Posts", "Projects", "Activity"]
for tab in tabs:
assert page.is_visible(f"a:has-text('{tab}')")
@@ -40,55 +40,55 @@ def test_profile_tabs(alice):
def test_profile_posts_tab(alice):
page, user = alice
page.goto(f"{BASE_URL}/profile/{user['username']}?tab=posts")
page.goto(f"{BASE_URL}/profile/{user['username']}?tab=posts", wait_until="domcontentloaded")
def test_profile_projects_tab_content(alice):
page, user = alice
page.goto(f"{BASE_URL}/profile/{user['username']}?tab=projects")
page.goto(f"{BASE_URL}/profile/{user['username']}?tab=projects", wait_until="domcontentloaded")
def test_profile_info_section(alice):
page, user = alice
page.goto(f"{BASE_URL}/profile/{user['username']}")
page.goto(f"{BASE_URL}/profile/{user['username']}", wait_until="domcontentloaded")
assert page.is_visible("text=Bio")
assert page.is_visible("text=Location")
def test_profile_back_link(alice):
page, user = alice
page.goto(f"{BASE_URL}/profile/{user['username']}")
page.goto(f"{BASE_URL}/profile/{user['username']}", wait_until="domcontentloaded")
back = page.locator("a:has-text('Back')").first
assert back.is_visible()
back.click()
page.wait_for_url(f"{BASE_URL}/feed")
page.wait_for_url(f"{BASE_URL}/feed", wait_until="domcontentloaded")
def test_profile_role_display(alice):
page, user = alice
page.goto(f"{BASE_URL}/profile/{user['username']}")
page.goto(f"{BASE_URL}/profile/{user['username']}", wait_until="domcontentloaded")
assert page.is_visible("text=Member")
def test_profile_avatar(alice):
page, user = alice
page.goto(f"{BASE_URL}/profile/{user['username']}")
page.goto(f"{BASE_URL}/profile/{user['username']}", wait_until="domcontentloaded")
avatar = page.locator(".avatar-lg")
assert avatar.is_visible()
def test_profile_nav_from_topbar(alice):
page, user = alice
page.goto(f"{BASE_URL}/feed")
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
page.locator(".topnav-user").click()
page.wait_for_timeout(300)
page.goto(f"{BASE_URL}/profile/{user['username']}")
page.goto(f"{BASE_URL}/profile/{user['username']}", wait_until="domcontentloaded")
assert page.is_visible(f"text={user['username']}")
def test_profile_edit_bio(alice):
page, user = alice
page.goto(f"{BASE_URL}/profile/{user['username']}")
page.goto(f"{BASE_URL}/profile/{user['username']}", wait_until="domcontentloaded")
page.evaluate("""
document.querySelector('textarea[name="bio"]').value = 'Test bio for testing';
document.querySelector('form[action="/profile/update"]').submit();
@@ -99,7 +99,7 @@ def test_profile_edit_bio(alice):
def test_profile_edit_location(alice):
page, user = alice
page.goto(f"{BASE_URL}/profile/{user['username']}")
page.goto(f"{BASE_URL}/profile/{user['username']}", wait_until="domcontentloaded")
page.evaluate("""
document.querySelector('input[name="location"]').value = 'Amsterdam';
document.querySelector('form[action="/profile/update"]').submit();
@@ -110,7 +110,7 @@ def test_profile_edit_location(alice):
def test_profile_edit_all_fields(alice):
page, user = alice
page.goto(f"{BASE_URL}/profile/{user['username']}")
page.goto(f"{BASE_URL}/profile/{user['username']}", wait_until="domcontentloaded")
page.evaluate("""
document.querySelector('textarea[name="bio"]').value = 'Full stack dev';
document.querySelector('input[name="location"]').value = 'London, UK';
@@ -133,5 +133,5 @@ def test_profile_viewing_other_user(bob, alice):
def test_profile_activity_tab(alice):
page, user = alice
page.goto(f"{BASE_URL}/profile/{user['username']}?tab=activity")
page.goto(f"{BASE_URL}/profile/{user['username']}?tab=activity", wait_until="domcontentloaded")
page.wait_for_timeout(300)
+14 -14
View File
@@ -3,21 +3,21 @@ from tests.conftest import BASE_URL
def test_projects_page_loads(alice):
page, _ = alice
page.goto(f"{BASE_URL}/projects")
page.goto(f"{BASE_URL}/projects", wait_until="domcontentloaded")
assert page.is_visible("h2:has-text('Projects')")
assert page.is_visible("text=Discover amazing projects")
def test_projects_search_bar(alice):
page, _ = alice
page.goto(f"{BASE_URL}/projects")
page.goto(f"{BASE_URL}/projects", wait_until="domcontentloaded")
search = page.locator("input[placeholder='Search projects...']")
assert search.is_visible()
def test_projects_tabs(alice):
page, _ = alice
page.goto(f"{BASE_URL}/projects")
page.goto(f"{BASE_URL}/projects", wait_until="domcontentloaded")
tabs = ["Recently Released", "Most Popular", "New This Week"]
for tab in tabs:
assert page.is_visible(f"text={tab}")
@@ -25,16 +25,16 @@ def test_projects_tabs(alice):
def test_projects_tab_switch(alice):
page, _ = alice
page.goto(f"{BASE_URL}/projects")
page.goto(f"{BASE_URL}/projects", wait_until="domcontentloaded")
page.click("a:has-text('Most Popular')")
page.wait_for_url(f"{BASE_URL}/projects?tab=popular")
page.wait_for_url(f"{BASE_URL}/projects?tab=popular", wait_until="domcontentloaded")
page.click("a:has-text('New This Week')")
page.wait_for_url(f"{BASE_URL}/projects?tab=new")
page.wait_for_url(f"{BASE_URL}/projects?tab=new", wait_until="domcontentloaded")
def test_create_project_button(alice):
page, _ = alice
page.goto(f"{BASE_URL}/projects")
page.goto(f"{BASE_URL}/projects", wait_until="domcontentloaded")
fab = page.locator("#create-project-btn")
assert fab.is_visible()
fab.click()
@@ -43,7 +43,7 @@ def test_create_project_button(alice):
def test_create_project_full(alice):
page, _ = alice
page.goto(f"{BASE_URL}/projects")
page.goto(f"{BASE_URL}/projects", wait_until="domcontentloaded")
page.locator("#create-project-btn").click()
page.fill("#title", "Playwright Test Game")
page.fill("#description", "A game created by Playwright integration tests")
@@ -58,7 +58,7 @@ def test_create_project_full(alice):
def test_create_project_software(alice):
page, _ = alice
page.goto(f"{BASE_URL}/projects")
page.goto(f"{BASE_URL}/projects", wait_until="domcontentloaded")
page.locator("#create-project-btn").click()
page.fill("#title", "CLI Tool")
page.fill("#description", "A command line tool")
@@ -71,7 +71,7 @@ def test_create_project_software(alice):
def test_create_project_mobile_app(alice):
page, _ = alice
page.goto(f"{BASE_URL}/projects")
page.goto(f"{BASE_URL}/projects", wait_until="domcontentloaded")
page.locator("#create-project-btn").click()
page.fill("#title", "Mobile Messenger")
page.fill("#description", "A cross-platform messaging app")
@@ -87,7 +87,7 @@ def test_create_project_mobile_app(alice):
def test_project_search(alice):
page, _ = alice
page.goto(f"{BASE_URL}/projects")
page.goto(f"{BASE_URL}/projects", wait_until="domcontentloaded")
page.locator("#create-project-btn").click()
page.fill("#title", "SearchableProject")
page.fill("#description", "Find me via search")
@@ -101,7 +101,7 @@ def test_project_search(alice):
def test_project_cancel_modal(alice):
page, _ = alice
page.goto(f"{BASE_URL}/projects")
page.goto(f"{BASE_URL}/projects", wait_until="domcontentloaded")
page.locator("#create-project-btn").click()
cancel = page.locator("button:has-text('Cancel')").first
cancel.click()
@@ -111,7 +111,7 @@ def test_project_cancel_modal(alice):
def test_project_platform_presets(alice):
page, _ = alice
page.goto(f"{BASE_URL}/projects")
page.goto(f"{BASE_URL}/projects", wait_until="domcontentloaded")
page.locator("#create-project-btn").click()
presets = page.locator(".platform-preset")
assert presets.count() >= 5
@@ -122,7 +122,7 @@ def test_project_platform_presets(alice):
def test_projects_count(alice):
page, _ = alice
page.goto(f"{BASE_URL}/projects")
page.goto(f"{BASE_URL}/projects", wait_until="domcontentloaded")
count_text = page.text_content(".projects-count")
assert "Showing" in count_text
assert "projects" in count_text