File size: 1,305 Bytes
75ba54e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
"""
Test script for the new nickname and @pseudo features
"""

import requests
import time

BASE_URL = "http://127.0.0.1:5000"


def test_nickname_api():
    """Test the nickname API"""
    print("Testing nickname API...")

    # Test set nickname
    response = requests.post(
        f"{BASE_URL}/api/set-nickname", json={"nickname": "TestUser123"}
    )
    print(f"Set nickname response: {response.status_code}")
    data = response.json()
    print(f"Response: {data}")

    # Test get current user
    response = requests.get(f"{BASE_URL}/api/me")
    print(f"Get user response: {response.status_code}")
    data = response.json()
    print(f"Current user: {data}")


def test_board_page():
    """Test accessing a board page"""
    print("\nTesting board page...")
    response = requests.get(f"{BASE_URL}/g/")
    print(f"Board page response: {response.status_code}")
    if "nickname-modal" in response.text:
        print("✅ Nickname modal found on board page")
    else:
        print("❌ Nickname modal not found")


if __name__ == "__main__":
    # Wait for server to start
    time.sleep(2)

    try:
        test_nickname_api()
        test_board_page()
        print("\n✅ All tests completed!")
    except Exception as e:
        print(f"❌ Test failed: {e}")