async def test_login_get(client): resp = await client.get("/login") assert resp.status == 200 text = await resp.text() assert "Access Your Retoor's Cloud Account" in text assert "Login to your Account" in text async def test_register_get(client): resp = await client.get("/register") assert resp.status == 200 text = await resp.text() assert "Create Your Retoor's Cloud Account" in text assert "Create an Account" in text assert resp.url.path == "/register" async def test_register_post_password_mismatch(client): resp = await client.post( "/register", data={ "full_name": "Test User", "email": "test@example.com", "password": "password", "confirm_password": "wrong_password", }, ) assert resp.status == 200 text = await resp.text() assert "Passwords do not match" in text async def test_register_post_user_exists(client): await client.post( "/register", data={ "full_name": "Test User", "email": "test@example.com", "password": "password", "confirm_password": "password", }, ) resp = await client.post( "/register", data={ "full_name": "Test User 2", "email": "test@example.com", "password": "password", "confirm_password": "password", }, ) assert resp.status == 200 text = await resp.text() assert "User with this email already exists" in text async def test_register_post_invalid_email(client): resp = await client.post( "/register", data={ "full_name": "Test User", "email": "invalid-email", "password": "password", "confirm_password": "password", }, ) assert resp.status == 200 text = await resp.text() assert "value is not a valid email address" in text async def test_register_post_short_password(client): resp = await client.post( "/register", data={ "full_name": "Test User", "email": "test@example.com", "password": "short", "confirm_password": "short", }, ) assert resp.status == 200 text = await resp.text() assert "ensure this value has at least 8 characters" in text async def test_login_post(client): await client.post( "/register", data={ "full_name": "Test User", "email": "test@example.com", "password": "password", "confirm_password": "password", }, ) resp = await client.post( "/login", data={"email": "test@example.com", "password": "password"}, allow_redirects=False ) assert resp.status == 302 assert resp.headers["Location"] == "/dashboard" async def test_login_post_invalid_credentials(client): resp = await client.post( "/login", data={"email": "test@example.com", "password": "wrong_password"} ) assert resp.status == 200 text = await resp.text() assert "Invalid email or password" in text async def test_logout(client): await client.post( "/register", data={ "full_name": "Test User", "email": "test@example.com", "password": "password", "confirm_password": "password", }, ) await client.post( "/login", data={"email": "test@example.com", "password": "password"} ) resp = await client.get("/logout", allow_redirects=False) assert resp.status == 302 assert resp.headers["Location"] == "/"