Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Chat Mentions #156

Merged
merged 4 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion server/tests/live/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ async def test_auth_with_client_id(world, announcement, inactive_announcement):
"user.config",
"chat.channels",
"chat.read_pointers",
"chat.notification_counts",
"exhibition",
"announcements",
}
Expand Down Expand Up @@ -140,6 +141,7 @@ async def test_auth_with_jwt_token(index, world):
"user.config",
"chat.channels",
"chat.read_pointers",
"chat.notification_counts",
"exhibition",
"announcements",
}
Expand Down Expand Up @@ -180,6 +182,7 @@ async def test_update_user():
"user.config",
"chat.channels",
"chat.read_pointers",
"chat.notification_counts",
"exhibition",
"announcements",
}
Expand Down Expand Up @@ -224,6 +227,7 @@ async def test_update_user():
"user.config",
"chat.channels",
"chat.read_pointers",
"chat.notification_counts",
"exhibition",
"announcements",
}
Expand All @@ -236,6 +240,7 @@ async def test_update_user():
@pytest.mark.asyncio
@pytest.mark.django_db
async def test_wrong_user_command():

async with world_communicator() as c:
await c.send_json_to(["authenticate", {"client_id": 4}])
response = await c.receive_json_from()
Expand Down Expand Up @@ -271,6 +276,7 @@ async def test_auth_with_jwt_token_update_traits(world):
"user.config",
"chat.channels",
"chat.read_pointers",
"chat.notification_counts",
"exhibition",
"announcements",
}
Expand All @@ -289,6 +295,7 @@ async def test_auth_with_jwt_token_update_traits(world):
"user.config",
"chat.channels",
"chat.read_pointers",
"chat.notification_counts",
"exhibition",
"announcements",
}
Expand Down Expand Up @@ -321,6 +328,7 @@ async def test_auth_with_jwt_token_twice(world):
"user.config",
"chat.channels",
"chat.read_pointers",
"chat.notification_counts",
"exhibition",
"announcements",
}
Expand All @@ -339,6 +347,7 @@ async def test_auth_with_jwt_token_twice(world):
"user.config",
"chat.channels",
"chat.read_pointers",
"chat.notification_counts",
"exhibition",
"announcements",
}
Expand All @@ -362,6 +371,7 @@ async def test_fetch_user():
"user.config",
"chat.channels",
"chat.read_pointers",
"chat.notification_counts",
"exhibition",
"announcements",
}
Expand Down Expand Up @@ -457,6 +467,7 @@ async def test_auth_with_jwt_token_and_permission_traits(world):
"user.config",
"chat.channels",
"chat.read_pointers",
"chat.notification_counts",
"exhibition",
"announcements",
}
Expand Down Expand Up @@ -1061,4 +1072,4 @@ async def test_anonymous_invite(client, world, stream_room, bbb_room):
"room:question.ask",
"room:poll.vote",
"room:poll.read",
}
}
48 changes: 24 additions & 24 deletions server/tests/live/test_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ async def test_join_leave(chat_room):
await c.send_json_to(["chat.join", 123, {"channel": str(chat_room.channel.id)}])
response = await c.receive_json_from()
response[2]["next_event_id"] = -1
response[2]["notification_pointer"] = -1
response[2]["unread_pointer"] = -1
assert response == [
"success",
123,
{
"state": None,
"next_event_id": -1,
"notification_pointer": -1,
"unread_pointer": -1,
"members": [],
},
]
Expand Down Expand Up @@ -150,7 +150,7 @@ async def test_join_volatile_based_on_room_config(volatile_chat_room, chat_room,
"chat.channels",
{
"channels": [
{"id": str(chat_room.channel.id), "notification_pointer": 0}
{"id": str(chat_room.channel.id), "unread_pointer": 0}
]
},
]
Expand Down Expand Up @@ -243,7 +243,7 @@ async def test_subscribe_without_name(chat_room):
{
"state": None,
"next_event_id": -1,
"notification_pointer": 0,
"unread_pointer": 0,
"members": [],
},
]
Expand Down Expand Up @@ -275,29 +275,29 @@ async def test_subscribe_join_leave(chat_room):
)
response = await c.receive_json_from()
response[2]["next_event_id"] = -1
response[2]["notification_pointer"] = -1
response[2]["unread_pointer"] = -1
assert response == [
"success",
123,
{
"state": None,
"next_event_id": -1,
"members": [],
"notification_pointer": -1,
"unread_pointer": -1,
},
]
await c.send_json_to(["chat.join", 123, {"channel": str(chat_room.channel.id)}])
response = await c.receive_json_from()
response[2]["next_event_id"] = -1
response[2]["notification_pointer"] = -1
response[2]["unread_pointer"] = -1
assert response == [
"success",
123,
{
"state": None,
"next_event_id": -1,
"members": [],
"notification_pointer": -1,
"unread_pointer": -1,
},
]
response = await c.receive_json_from()
Expand Down Expand Up @@ -340,15 +340,15 @@ async def test_bogus_command(chat_room):
await c.send_json_to(["chat.join", 123, {"channel": str(chat_room.channel.id)}])
response = await c.receive_json_from()
response[2]["next_event_id"] = -1
response[2]["notification_pointer"] = -1
response[2]["unread_pointer"] = -1
assert response == [
"success",
123,
{
"state": None,
"next_event_id": -1,
"members": [],
"notification_pointer": -1,
"unread_pointer": -1,
},
]
await c.receive_json_from() # join notification
Expand Down Expand Up @@ -555,15 +555,15 @@ async def test_fetch_messages_after_join(chat_room):
)
response = await c1.receive_json_from()
response[2]["next_event_id"] = -1
response[2]["notification_pointer"] = -1
response[2]["unread_pointer"] = -1
assert response == [
"success",
123,
{
"state": None,
"next_event_id": -1,
"members": [],
"notification_pointer": -1,
"unread_pointer": -1,
},
]
await c1.receive_json_from() # join notification c1
Expand Down Expand Up @@ -670,14 +670,14 @@ async def test_send_message_to_other_client(chat_room):
)
response = await c1.receive_json_from()
response[2]["next_event_id"] = -1
response[2]["notification_pointer"] = -1
response[2]["unread_pointer"] = -1
assert response == [
"success",
123,
{
"state": None,
"next_event_id": -1,
"notification_pointer": -1,
"unread_pointer": -1,
"members": [],
},
]
Expand Down Expand Up @@ -765,14 +765,14 @@ async def test_no_messages_after_leave(chat_room):
)
response = await c1.receive_json_from()
response[2]["next_event_id"] = -1
response[2]["notification_pointer"] = -1
response[2]["unread_pointer"] = -1
assert response == [
"success",
123,
{
"state": None,
"next_event_id": -1,
"notification_pointer": -1,
"unread_pointer": -1,
"members": [],
},
]
Expand Down Expand Up @@ -855,7 +855,7 @@ async def test_no_message_after_unsubscribe(chat_room):
{
"state": None,
"next_event_id": -1,
"notification_pointer": 0,
"unread_pointer": 0,
"members": [],
},
]
Expand Down Expand Up @@ -916,7 +916,7 @@ async def test_no_message_after_unsubscribe(chat_room):
]

response = await c2.receive_json_from()
assert response[0] == "chat.notification_pointers"
assert response[0] == "chat.unread_pointer"

with pytest.raises(asyncio.TimeoutError):
await c2.receive_json_from()
Expand All @@ -939,7 +939,7 @@ async def test_disconnect_is_no_leave(chat_room):
"state": None,
"members": [],
"next_event_id": 1,
"notification_pointer": 0,
"unread_pointer": 0,
},
]
await c2.send_json_to(
Expand Down Expand Up @@ -982,7 +982,7 @@ async def test_last_disconnect_is_leave_in_volatile_channel(world, volatile_chat
"state": None,
"members": [],
"next_event_id": 1,
"notification_pointer": 0,
"unread_pointer": 0,
},
]

Expand Down Expand Up @@ -1163,7 +1163,7 @@ async def test_unread_channels(world, chat_room):

# c2 gets a notification pointer
response = await c2.receive_json_from() # receives notification pointer
assert response[0] == "chat.notification_pointers"
assert response[0] == "chat.unread_pointer"
assert channel_id in response[1]

# c1 sends a message
Expand Down Expand Up @@ -1214,7 +1214,7 @@ async def test_unread_channels(world, chat_room):

# c2 gets a notification pointer
response = await c2.receive_json_from() # receives notification pointer
assert response[0] == "chat.notification_pointers"
assert response[0] == "chat.unread_pointer"
assert response[1] == {channel_id: event_id + 1}

with pytest.raises(asyncio.TimeoutError):
Expand Down Expand Up @@ -1280,7 +1280,7 @@ async def test_broadcast_read_channels(world, chat_room):
assert c3.context["chat.channels"] == [
{
"id": channel_id,
"notification_pointer": event_id,
"unread_pointer": event_id,
}
]
assert c3.context["chat.read_pointers"] == {channel_id: event_id}
Expand Down Expand Up @@ -1323,4 +1323,4 @@ async def test_force_join_after_login(world, chat_room):
# Some asyncio test weirdness, I don't get why
r = await c2.receive_json_from()
assert r[0] == "chat.channels"
assert channel_id in [c["id"] for c in r[1]["channels"]]
assert channel_id in [c["id"] for c in r[1]["channels"]]
Loading
Loading