From 157d6eb1bd075b8ab04ff89cd2a2598799ce0c2d Mon Sep 17 00:00:00 2001 From: Yevheniia Berdnyk Date: Wed, 12 Feb 2025 19:31:35 +0200 Subject: [PATCH] test_: activity center notifications (#6337) * test_: activity center notifications * test_: small fix * test_: changes according to review --- .../wakuext_acceptActivityCenterNotifications | 284 ++++++++++++ .../wakuext_activityCenterNotifications | 379 +++++++++++++++- .../wakuext_activityCenterNotificationsCount | 68 +++ .../wakuext_deleteActivityCenterNotifications | 20 + ...wakuext_dismissActivityCenterNotifications | 20 + .../schemas/wakuext_getActivityCenterState | 32 ++ ...kuext_hasUnseenActivityCenterNotifications | 20 + ...akuext_markActivityCenterNotificationsRead | 371 ++++++++++++++++ ...uext_markActivityCenterNotificationsUnread | 276 ++++++++++++ ...ext_markAllActivityCenterNotificationsRead | 415 ++++++++++++++++++ ...uext_markAsSeenActivityCenterNotifications | 48 ++ .../test_activity_center_notifications.py | 186 ++++++++ tests-functional/tests/test_cases.py | 21 +- tests-functional/tests/test_waku_rpc.py | 4 - 14 files changed, 2117 insertions(+), 27 deletions(-) create mode 100644 tests-functional/schemas/wakuext_acceptActivityCenterNotifications create mode 100644 tests-functional/schemas/wakuext_activityCenterNotificationsCount create mode 100644 tests-functional/schemas/wakuext_deleteActivityCenterNotifications create mode 100644 tests-functional/schemas/wakuext_dismissActivityCenterNotifications create mode 100644 tests-functional/schemas/wakuext_getActivityCenterState create mode 100644 tests-functional/schemas/wakuext_hasUnseenActivityCenterNotifications create mode 100644 tests-functional/schemas/wakuext_markActivityCenterNotificationsRead create mode 100644 tests-functional/schemas/wakuext_markActivityCenterNotificationsUnread create mode 100644 tests-functional/schemas/wakuext_markAllActivityCenterNotificationsRead create mode 100644 tests-functional/schemas/wakuext_markAsSeenActivityCenterNotifications create mode 100644 tests-functional/tests/test_activity_center_notifications.py diff --git a/tests-functional/schemas/wakuext_acceptActivityCenterNotifications b/tests-functional/schemas/wakuext_acceptActivityCenterNotifications new file mode 100644 index 000000000..ad2e2eddf --- /dev/null +++ b/tests-functional/schemas/wakuext_acceptActivityCenterNotifications @@ -0,0 +1,284 @@ +{ + "$schema": "http://json-schema.org/schema#", + "properties": { + "id": { + "type": "integer" + }, + "jsonrpc": { + "type": "string" + }, + "result": { + "properties": { + "activityCenterState": { + "properties": { + "hasSeen": { + "type": "boolean" + }, + "updatedAt": { + "type": "integer" + } + }, + "required": [ + "hasSeen", + "updatedAt" + ], + "type": "object" + }, + "chats": { + "items": { + "properties": { + "ReadMessagesAtClockValue": { + "type": "integer" + }, + "active": { + "type": "boolean" + }, + "alias": { + "type": "string" + }, + "chatType": { + "type": "integer" + }, + "color": { + "type": "string" + }, + "deletedAtClockValue": { + "type": "integer" + }, + "description": { + "type": "string" + }, + "emoji": { + "type": "string" + }, + "highlight": { + "type": "boolean" + }, + "id": { + "type": "string" + }, + "identicon": { + "type": "string" + }, + "joined": { + "type": "integer" + }, + "lastClockValue": { + "type": "integer" + }, + "lastMessage": { + "properties": { + "alias": { + "type": "string" + }, + "chatId": { + "type": "string" + }, + "clock": { + "type": "integer" + }, + "compressedKey": { + "type": "string" + }, + "contactRequestState": { + "type": "integer" + }, + "contentType": { + "type": "integer" + }, + "displayName": { + "type": "string" + }, + "emojiHash": { + "items": { + "type": "string" + }, + "type": "array" + }, + "ensName": { + "type": "string" + }, + "from": { + "type": "string" + }, + "id": { + "type": "string" + }, + "identicon": { + "type": "string" + }, + "lineCount": { + "type": "integer" + }, + "localChatId": { + "type": "string" + }, + "messageType": { + "type": "integer" + }, + "new": { + "type": "boolean" + }, + "parsedText": { + "items": { + "properties": { + "children": { + "items": { + "properties": { + "literal": { + "type": "string" + } + }, + "required": [ + "literal" + ], + "type": "object" + }, + "type": "array" + }, + "type": { + "type": "string" + } + }, + "required": [ + "children", + "type" + ], + "type": "object" + }, + "type": "array" + }, + "quotedMessage": { + "type": "null" + }, + "replace": { + "type": "string" + }, + "responseTo": { + "type": "string" + }, + "rtl": { + "type": "boolean" + }, + "seen": { + "type": "boolean" + }, + "text": { + "type": "string" + }, + "timestamp": { + "type": "integer" + }, + "whisperTimestamp": { + "type": "integer" + } + }, + "required": [ + "alias", + "chatId", + "clock", + "compressedKey", + "contactRequestState", + "contentType", + "displayName", + "emojiHash", + "ensName", + "from", + "id", + "identicon", + "lineCount", + "localChatId", + "messageType", + "new", + "parsedText", + "quotedMessage", + "replace", + "responseTo", + "rtl", + "seen", + "text", + "timestamp", + "whisperTimestamp" + ], + "type": "object" + }, + "members": { + "type": "null" + }, + "membershipUpdateEvents": { + "type": "null" + }, + "muteTill": { + "type": "string" + }, + "muted": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "timestamp": { + "type": "integer" + }, + "unviewedMentionsCount": { + "type": "integer" + }, + "unviewedMessagesCount": { + "type": "integer" + }, + "viewersCanPostReactions": { + "type": "boolean" + } + }, + "required": [ + "ReadMessagesAtClockValue", + "active", + "alias", + "chatType", + "color", + "deletedAtClockValue", + "description", + "emoji", + "highlight", + "id", + "identicon", + "joined", + "lastClockValue", + "lastMessage", + "members", + "membershipUpdateEvents", + "muteTill", + "muted", + "name", + "timestamp", + "unviewedMentionsCount", + "unviewedMessagesCount", + "viewersCanPostReactions" + ], + "type": "object" + }, + "type": "array" + }, + "discordOldestMessageTimestamp": { + "type": "integer" + }, + "notifications": { + "type": "null" + } + }, + "required": [ + "activityCenterState", + "chats", + "discordOldestMessageTimestamp", + "notifications" + ], + "type": "object" + } + }, + "required": [ + "id", + "jsonrpc", + "result" + ], + "type": "object" +} \ No newline at end of file diff --git a/tests-functional/schemas/wakuext_activityCenterNotifications b/tests-functional/schemas/wakuext_activityCenterNotifications index 455e7a93d..5567b0080 100644 --- a/tests-functional/schemas/wakuext_activityCenterNotifications +++ b/tests-functional/schemas/wakuext_activityCenterNotifications @@ -1,33 +1,378 @@ { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "http://example.com/example.json", - "type": "object", - "required": [ - "id", - "jsonrpc", - "result" - ], + "$schema": "http://json-schema.org/schema#", "properties": { "id": { - "type": "string" + "type": "integer" }, "jsonrpc": { "type": "string" }, "result": { - "type": "object", - "required": [ - "cursor", - "notifications" - ], "properties": { "cursor": { "type": "string" }, "notifications": { - "type": "null" + "items": { + "properties": { + "accepted": { + "type": "boolean" + }, + "albumMessages": { + "type": "null" + }, + "author": { + "type": "string" + }, + "chatId": { + "type": "string" + }, + "communityId": { + "type": "string" + }, + "contactVerificationStatus": { + "type": "integer" + }, + "deleted": { + "type": "boolean" + }, + "dismissed": { + "type": "boolean" + }, + "id": { + "type": "string" + }, + "installationId": { + "type": "string" + }, + "lastMessage": { + "properties": { + "alias": { + "type": "string" + }, + "chatId": { + "type": "string" + }, + "clock": { + "type": "integer" + }, + "compressedKey": { + "type": "string" + }, + "contactRequestState": { + "type": "integer" + }, + "contentType": { + "type": "integer" + }, + "displayName": { + "type": "string" + }, + "emojiHash": { + "items": { + "type": "string" + }, + "type": "array" + }, + "ensName": { + "type": "string" + }, + "from": { + "type": "string" + }, + "id": { + "type": "string" + }, + "identicon": { + "type": "string" + }, + "lineCount": { + "type": "integer" + }, + "localChatId": { + "type": "string" + }, + "messageType": { + "type": "integer" + }, + "new": { + "type": "boolean" + }, + "parsedText": { + "items": { + "properties": { + "children": { + "items": { + "properties": { + "literal": { + "type": "string" + } + }, + "required": [ + "literal" + ], + "type": "object" + }, + "type": "array" + }, + "type": { + "type": "string" + } + }, + "required": [ + "children", + "type" + ], + "type": "object" + }, + "type": "array" + }, + "quotedMessage": { + "type": "null" + }, + "replace": { + "type": "string" + }, + "responseTo": { + "type": "string" + }, + "rtl": { + "type": "boolean" + }, + "seen": { + "type": "boolean" + }, + "text": { + "type": "string" + }, + "timestamp": { + "type": "integer" + }, + "whisperTimestamp": { + "type": "integer" + } + }, + "required": [ + "alias", + "chatId", + "clock", + "compressedKey", + "contentType", + "displayName", + "emojiHash", + "ensName", + "from", + "id", + "identicon", + "lineCount", + "localChatId", + "messageType", + "quotedMessage", + "replace", + "responseTo", + "rtl", + "seen", + "text", + "timestamp", + "whisperTimestamp" + ], + "type": "object" + }, + "membershipStatus": { + "type": "integer" + }, + "message": { + "properties": { + "alias": { + "type": "string" + }, + "chatId": { + "type": "string" + }, + "clock": { + "type": "integer" + }, + "compressedKey": { + "type": "string" + }, + "contactRequestState": { + "type": "integer" + }, + "contentType": { + "type": "integer" + }, + "displayName": { + "type": "string" + }, + "emojiHash": { + "items": { + "type": "string" + }, + "type": "array" + }, + "ensName": { + "type": "string" + }, + "from": { + "type": "string" + }, + "id": { + "type": "string" + }, + "identicon": { + "type": "string" + }, + "lineCount": { + "type": "integer" + }, + "localChatId": { + "type": "string" + }, + "messageType": { + "type": "integer" + }, + "parsedText": { + "items": { + "properties": { + "children": { + "items": { + "properties": { + "literal": { + "type": "string" + } + }, + "required": [ + "literal" + ], + "type": "object" + }, + "type": "array" + }, + "type": { + "type": "string" + } + }, + "required": [ + "children", + "type" + ], + "type": "object" + }, + "type": "array" + }, + "quotedMessage": { + "type": "null" + }, + "replace": { + "type": "string" + }, + "responseTo": { + "type": "string" + }, + "rtl": { + "type": "boolean" + }, + "seen": { + "type": "boolean" + }, + "text": { + "type": "string" + }, + "timestamp": { + "type": "integer" + }, + "whisperTimestamp": { + "type": "integer" + } + }, + "required": [ + "alias", + "chatId", + "clock", + "compressedKey", + "contactRequestState", + "contentType", + "displayName", + "emojiHash", + "ensName", + "from", + "id", + "identicon", + "lineCount", + "localChatId", + "messageType", + "parsedText", + "quotedMessage", + "replace", + "responseTo", + "rtl", + "seen", + "text", + "timestamp", + "whisperTimestamp" + ], + "type": "object" + }, + "name": { + "type": "string" + }, + "read": { + "type": "boolean" + }, + "replyMessage": { + "type": "null" + }, + "timestamp": { + "type": "integer" + }, + "tokenData": { + "type": "null" + }, + "type": { + "type": "integer" + }, + "updatedAt": { + "type": "integer" + } + }, + "required": [ + "accepted", + "albumMessages", + "author", + "chatId", + "communityId", + "contactVerificationStatus", + "deleted", + "dismissed", + "id", + "installationId", + "lastMessage", + "membershipStatus", + "message", + "name", + "read", + "replyMessage", + "timestamp", + "tokenData", + "type", + "updatedAt" + ], + "type": "object" + }, + "type": "array" } - } + }, + "required": [ + "cursor", + "notifications" + ], + "type": "object" } - } + }, + "required": [ + "id", + "jsonrpc", + "result" + ], + "type": "object" } \ No newline at end of file diff --git a/tests-functional/schemas/wakuext_activityCenterNotificationsCount b/tests-functional/schemas/wakuext_activityCenterNotificationsCount new file mode 100644 index 000000000..ef1f7f4cb --- /dev/null +++ b/tests-functional/schemas/wakuext_activityCenterNotificationsCount @@ -0,0 +1,68 @@ +{ + "$schema": "http://json-schema.org/schema#", + "properties": { + "id": { + "type": "integer" + }, + "jsonrpc": { + "type": "string" + }, + "result": { + "properties": { + "1": { + "type": "integer" + }, + "10": { + "type": "integer" + }, + "2": { + "type": "integer" + }, + "23": { + "type": "integer" + }, + "24": { + "type": "integer" + }, + "3": { + "type": "integer" + }, + "4": { + "type": "integer" + }, + "5": { + "type": "integer" + }, + "7": { + "type": "integer" + }, + "8": { + "type": "integer" + }, + "9": { + "type": "integer" + } + }, + "required": [ + "1", + "10", + "2", + "23", + "24", + "3", + "4", + "5", + "7", + "8", + "9" + ], + "type": "object" + } + }, + "required": [ + "id", + "jsonrpc", + "result" + ], + "type": "object" +} \ No newline at end of file diff --git a/tests-functional/schemas/wakuext_deleteActivityCenterNotifications b/tests-functional/schemas/wakuext_deleteActivityCenterNotifications new file mode 100644 index 000000000..f30225692 --- /dev/null +++ b/tests-functional/schemas/wakuext_deleteActivityCenterNotifications @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/schema#", + "properties": { + "id": { + "type": "integer" + }, + "jsonrpc": { + "type": "string" + }, + "result": { + "type": "null" + } + }, + "required": [ + "id", + "jsonrpc", + "result" + ], + "type": "object" +} \ No newline at end of file diff --git a/tests-functional/schemas/wakuext_dismissActivityCenterNotifications b/tests-functional/schemas/wakuext_dismissActivityCenterNotifications new file mode 100644 index 000000000..f30225692 --- /dev/null +++ b/tests-functional/schemas/wakuext_dismissActivityCenterNotifications @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/schema#", + "properties": { + "id": { + "type": "integer" + }, + "jsonrpc": { + "type": "string" + }, + "result": { + "type": "null" + } + }, + "required": [ + "id", + "jsonrpc", + "result" + ], + "type": "object" +} \ No newline at end of file diff --git a/tests-functional/schemas/wakuext_getActivityCenterState b/tests-functional/schemas/wakuext_getActivityCenterState new file mode 100644 index 000000000..3eaa50c53 --- /dev/null +++ b/tests-functional/schemas/wakuext_getActivityCenterState @@ -0,0 +1,32 @@ +{ + "$schema": "http://json-schema.org/schema#", + "properties": { + "id": { + "type": "integer" + }, + "jsonrpc": { + "type": "string" + }, + "result": { + "properties": { + "hasSeen": { + "type": "boolean" + }, + "updatedAt": { + "type": "integer" + } + }, + "required": [ + "hasSeen", + "updatedAt" + ], + "type": "object" + } + }, + "required": [ + "id", + "jsonrpc", + "result" + ], + "type": "object" +} \ No newline at end of file diff --git a/tests-functional/schemas/wakuext_hasUnseenActivityCenterNotifications b/tests-functional/schemas/wakuext_hasUnseenActivityCenterNotifications new file mode 100644 index 000000000..5e090f4c8 --- /dev/null +++ b/tests-functional/schemas/wakuext_hasUnseenActivityCenterNotifications @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/schema#", + "properties": { + "id": { + "type": "integer" + }, + "jsonrpc": { + "type": "string" + }, + "result": { + "type": "boolean" + } + }, + "required": [ + "id", + "jsonrpc", + "result" + ], + "type": "object" +} \ No newline at end of file diff --git a/tests-functional/schemas/wakuext_markActivityCenterNotificationsRead b/tests-functional/schemas/wakuext_markActivityCenterNotificationsRead new file mode 100644 index 000000000..7a51cf99c --- /dev/null +++ b/tests-functional/schemas/wakuext_markActivityCenterNotificationsRead @@ -0,0 +1,371 @@ +{ + "$schema": "http://json-schema.org/schema#", + "properties": { + "id": { + "type": "integer" + }, + "jsonrpc": { + "type": "string" + }, + "result": { + "properties": { + "activityCenterNotifications": { + "items": { + "properties": { + "accepted": { + "type": "boolean" + }, + "albumMessages": { + "type": "null" + }, + "author": { + "type": "string" + }, + "chatId": { + "type": "string" + }, + "communityId": { + "type": "string" + }, + "contactVerificationStatus": { + "type": "integer" + }, + "deleted": { + "type": "boolean" + }, + "dismissed": { + "type": "boolean" + }, + "id": { + "type": "string" + }, + "installationId": { + "type": "string" + }, + "lastMessage": { + "properties": { + "alias": { + "type": "string" + }, + "chatId": { + "type": "string" + }, + "clock": { + "type": "integer" + }, + "compressedKey": { + "type": "string" + }, + "contentType": { + "type": "integer" + }, + "displayName": { + "type": "string" + }, + "emojiHash": { + "items": { + "type": "string" + }, + "type": "array" + }, + "ensName": { + "type": "string" + }, + "from": { + "type": "string" + }, + "id": { + "type": "string" + }, + "identicon": { + "type": "string" + }, + "lineCount": { + "type": "integer" + }, + "localChatId": { + "type": "string" + }, + "messageType": { + "type": "integer" + }, + "quotedMessage": { + "type": "null" + }, + "replace": { + "type": "string" + }, + "responseTo": { + "type": "string" + }, + "rtl": { + "type": "boolean" + }, + "seen": { + "type": "boolean" + }, + "text": { + "type": "string" + }, + "timestamp": { + "type": "integer" + }, + "whisperTimestamp": { + "type": "integer" + } + }, + "required": [ + "alias", + "chatId", + "clock", + "compressedKey", + "contentType", + "displayName", + "emojiHash", + "ensName", + "from", + "id", + "identicon", + "lineCount", + "localChatId", + "messageType", + "quotedMessage", + "replace", + "responseTo", + "rtl", + "seen", + "text", + "timestamp", + "whisperTimestamp" + ], + "type": "object" + }, + "membershipStatus": { + "type": "integer" + }, + "message": { + "properties": { + "alias": { + "type": "string" + }, + "chatId": { + "type": "string" + }, + "clock": { + "type": "integer" + }, + "compressedKey": { + "type": "string" + }, + "contactRequestState": { + "type": "integer" + }, + "contentType": { + "type": "integer" + }, + "displayName": { + "type": "string" + }, + "emojiHash": { + "items": { + "type": "string" + }, + "type": "array" + }, + "ensName": { + "type": "string" + }, + "from": { + "type": "string" + }, + "gapParameters": { + "type": "object" + }, + "id": { + "type": "string" + }, + "identicon": { + "type": "string" + }, + "lineCount": { + "type": "integer" + }, + "localChatId": { + "type": "string" + }, + "messageType": { + "type": "integer" + }, + "outgoingStatus": { + "type": "string" + }, + "parsedText": { + "items": { + "properties": { + "children": { + "items": { + "properties": { + "literal": { + "type": "string" + } + }, + "required": [ + "literal" + ], + "type": "object" + }, + "type": "array" + }, + "type": { + "type": "string" + } + }, + "required": [ + "children", + "type" + ], + "type": "object" + }, + "type": "array" + }, + "quotedMessage": { + "type": "null" + }, + "replace": { + "type": "string" + }, + "responseTo": { + "type": "string" + }, + "rtl": { + "type": "boolean" + }, + "seen": { + "type": "boolean" + }, + "text": { + "type": "string" + }, + "timestamp": { + "type": "integer" + }, + "whisperTimestamp": { + "type": "integer" + } + }, + "required": [ + "alias", + "chatId", + "clock", + "compressedKey", + "contactRequestState", + "contentType", + "displayName", + "emojiHash", + "ensName", + "from", + "gapParameters", + "id", + "identicon", + "lineCount", + "localChatId", + "messageType", + "outgoingStatus", + "parsedText", + "quotedMessage", + "replace", + "responseTo", + "rtl", + "seen", + "text", + "timestamp", + "whisperTimestamp" + ], + "type": "object" + }, + "name": { + "type": "string" + }, + "read": { + "type": "boolean" + }, + "replyMessage": { + "type": "null" + }, + "timestamp": { + "type": "integer" + }, + "tokenData": { + "type": "null" + }, + "type": { + "type": "integer" + }, + "updatedAt": { + "type": "integer" + } + }, + "required": [ + "accepted", + "albumMessages", + "author", + "chatId", + "communityId", + "contactVerificationStatus", + "deleted", + "dismissed", + "id", + "installationId", + "lastMessage", + "membershipStatus", + "message", + "name", + "read", + "replyMessage", + "timestamp", + "tokenData", + "type", + "updatedAt" + ], + "type": "object" + }, + "type": "array" + }, + "activityCenterState": { + "properties": { + "hasSeen": { + "type": "boolean" + }, + "updatedAt": { + "type": "integer" + } + }, + "required": [ + "hasSeen", + "updatedAt" + ], + "type": "object" + }, + "discordOldestMessageTimestamp": { + "type": "integer" + }, + "notifications": { + "type": "null" + } + }, + "required": [ + "activityCenterNotifications", + "activityCenterState", + "discordOldestMessageTimestamp", + "notifications" + ], + "type": "object" + } + }, + "required": [ + "id", + "jsonrpc", + "result" + ], + "type": "object" +} \ No newline at end of file diff --git a/tests-functional/schemas/wakuext_markActivityCenterNotificationsUnread b/tests-functional/schemas/wakuext_markActivityCenterNotificationsUnread new file mode 100644 index 000000000..4ee922737 --- /dev/null +++ b/tests-functional/schemas/wakuext_markActivityCenterNotificationsUnread @@ -0,0 +1,276 @@ +{ + "$schema": "http://json-schema.org/schema#", + "properties": { + "id": { + "type": "integer" + }, + "jsonrpc": { + "type": "string" + }, + "result": { + "properties": { + "activityCenterNotifications": { + "items": { + "properties": { + "accepted": { + "type": "boolean" + }, + "albumMessages": { + "type": "null" + }, + "author": { + "type": "string" + }, + "chatId": { + "type": "string" + }, + "communityId": { + "type": "string" + }, + "contactVerificationStatus": { + "type": "integer" + }, + "deleted": { + "type": "boolean" + }, + "dismissed": { + "type": "boolean" + }, + "id": { + "type": "string" + }, + "installationId": { + "type": "string" + }, + "lastMessage": { + "type": "null" + }, + "membershipStatus": { + "type": "integer" + }, + "message": { + "properties": { + "alias": { + "type": "string" + }, + "chatId": { + "type": "string" + }, + "clock": { + "type": "integer" + }, + "compressedKey": { + "type": "string" + }, + "contactRequestState": { + "type": "integer" + }, + "contentType": { + "type": "integer" + }, + "displayName": { + "type": "string" + }, + "emojiHash": { + "items": { + "type": "string" + }, + "type": "array" + }, + "ensName": { + "type": "string" + }, + "from": { + "type": "string" + }, + "gapParameters": { + "type": "object" + }, + "id": { + "type": "string" + }, + "identicon": { + "type": "string" + }, + "lineCount": { + "type": "integer" + }, + "localChatId": { + "type": "string" + }, + "messageType": { + "type": "integer" + }, + "outgoingStatus": { + "type": "string" + }, + "parsedText": { + "items": { + "properties": { + "children": { + "items": { + "properties": { + "literal": { + "type": "string" + } + }, + "required": [ + "literal" + ], + "type": "object" + }, + "type": "array" + }, + "type": { + "type": "string" + } + }, + "required": [ + "children", + "type" + ], + "type": "object" + }, + "type": "array" + }, + "quotedMessage": { + "type": "null" + }, + "replace": { + "type": "string" + }, + "responseTo": { + "type": "string" + }, + "rtl": { + "type": "boolean" + }, + "seen": { + "type": "boolean" + }, + "text": { + "type": "string" + }, + "timestamp": { + "type": "integer" + }, + "whisperTimestamp": { + "type": "integer" + } + }, + "required": [ + "alias", + "chatId", + "clock", + "compressedKey", + "contactRequestState", + "contentType", + "displayName", + "emojiHash", + "ensName", + "from", + "gapParameters", + "id", + "identicon", + "lineCount", + "localChatId", + "messageType", + "outgoingStatus", + "parsedText", + "quotedMessage", + "replace", + "responseTo", + "rtl", + "seen", + "text", + "timestamp", + "whisperTimestamp" + ], + "type": "object" + }, + "name": { + "type": "string" + }, + "read": { + "type": "boolean" + }, + "replyMessage": { + "type": "null" + }, + "timestamp": { + "type": "integer" + }, + "tokenData": { + "type": "null" + }, + "type": { + "type": "integer" + }, + "updatedAt": { + "type": "integer" + } + }, + "required": [ + "accepted", + "albumMessages", + "author", + "chatId", + "communityId", + "contactVerificationStatus", + "deleted", + "dismissed", + "id", + "installationId", + "lastMessage", + "membershipStatus", + "message", + "name", + "read", + "replyMessage", + "timestamp", + "tokenData", + "type", + "updatedAt" + ], + "type": "object" + }, + "type": "array" + }, + "activityCenterState": { + "properties": { + "hasSeen": { + "type": "boolean" + }, + "updatedAt": { + "type": "integer" + } + }, + "required": [ + "hasSeen", + "updatedAt" + ], + "type": "object" + }, + "discordOldestMessageTimestamp": { + "type": "integer" + }, + "notifications": { + "type": "null" + } + }, + "required": [ + "activityCenterNotifications", + "activityCenterState", + "discordOldestMessageTimestamp", + "notifications" + ], + "type": "object" + } + }, + "required": [ + "id", + "jsonrpc", + "result" + ], + "type": "object" +} \ No newline at end of file diff --git a/tests-functional/schemas/wakuext_markAllActivityCenterNotificationsRead b/tests-functional/schemas/wakuext_markAllActivityCenterNotificationsRead new file mode 100644 index 000000000..a11fa32f7 --- /dev/null +++ b/tests-functional/schemas/wakuext_markAllActivityCenterNotificationsRead @@ -0,0 +1,415 @@ +{ + "$schema": "http://json-schema.org/schema#", + "properties": { + "id": { + "type": "integer" + }, + "jsonrpc": { + "type": "string" + }, + "result": { + "properties": { + "activityCenterNotifications": { + "items": { + "properties": { + "accepted": { + "type": "boolean" + }, + "albumMessages": { + "type": "null" + }, + "author": { + "type": "string" + }, + "chatId": { + "type": "string" + }, + "communityId": { + "type": "string" + }, + "contactVerificationStatus": { + "type": "integer" + }, + "deleted": { + "type": "boolean" + }, + "dismissed": { + "type": "boolean" + }, + "id": { + "type": "string" + }, + "installationId": { + "type": "string" + }, + "lastMessage": { + "anyOf": [ + { + "type": "null" + }, + { + "properties": { + "alias": { + "type": "string" + }, + "chatId": { + "type": "string" + }, + "clock": { + "type": "integer" + }, + "compressedKey": { + "type": "string" + }, + "contactRequestState": { + "type": "integer" + }, + "contentType": { + "type": "integer" + }, + "displayName": { + "type": "string" + }, + "emojiHash": { + "items": { + "type": "string" + }, + "type": "array" + }, + "ensName": { + "type": "string" + }, + "from": { + "type": "string" + }, + "id": { + "type": "string" + }, + "identicon": { + "type": "string" + }, + "lineCount": { + "type": "integer" + }, + "localChatId": { + "type": "string" + }, + "messageType": { + "type": "integer" + }, + "new": { + "type": "boolean" + }, + "parsedText": { + "items": { + "properties": { + "children": { + "items": { + "properties": { + "literal": { + "type": "string" + } + }, + "required": [ + "literal" + ], + "type": "object" + }, + "type": "array" + }, + "type": { + "type": "string" + } + }, + "required": [ + "children", + "type" + ], + "type": "object" + }, + "type": "array" + }, + "quotedMessage": { + "type": "null" + }, + "replace": { + "type": "string" + }, + "responseTo": { + "type": "string" + }, + "rtl": { + "type": "boolean" + }, + "seen": { + "type": "boolean" + }, + "text": { + "type": "string" + }, + "timestamp": { + "type": "integer" + }, + "whisperTimestamp": { + "type": "integer" + } + }, + "required": [ + "alias", + "chatId", + "clock", + "compressedKey", + "contactRequestState", + "contentType", + "displayName", + "emojiHash", + "ensName", + "from", + "id", + "identicon", + "lineCount", + "localChatId", + "messageType", + "new", + "parsedText", + "quotedMessage", + "replace", + "responseTo", + "rtl", + "seen", + "text", + "timestamp", + "whisperTimestamp" + ], + "type": "object" + } + ] + }, + "membershipStatus": { + "type": "integer" + }, + "message": { + "anyOf": [ + { + "type": "null" + }, + { + "properties": { + "alias": { + "type": "string" + }, + "chatId": { + "type": "string" + }, + "clock": { + "type": "integer" + }, + "compressedKey": { + "type": "string" + }, + "contactRequestState": { + "type": "integer" + }, + "contentType": { + "type": "integer" + }, + "displayName": { + "type": "string" + }, + "emojiHash": { + "items": { + "type": "string" + }, + "type": "array" + }, + "ensName": { + "type": "string" + }, + "from": { + "type": "string" + }, + "id": { + "type": "string" + }, + "identicon": { + "type": "string" + }, + "lineCount": { + "type": "integer" + }, + "localChatId": { + "type": "string" + }, + "messageType": { + "type": "integer" + }, + "parsedText": { + "items": { + "properties": { + "children": { + "items": { + "properties": { + "literal": { + "type": "string" + } + }, + "required": [ + "literal" + ], + "type": "object" + }, + "type": "array" + }, + "type": { + "type": "string" + } + }, + "required": [ + "children", + "type" + ], + "type": "object" + }, + "type": "array" + }, + "quotedMessage": { + "type": "null" + }, + "replace": { + "type": "string" + }, + "responseTo": { + "type": "string" + }, + "rtl": { + "type": "boolean" + }, + "seen": { + "type": "boolean" + }, + "text": { + "type": "string" + }, + "timestamp": { + "type": "integer" + }, + "whisperTimestamp": { + "type": "integer" + } + }, + "required": [ + "alias", + "chatId", + "clock", + "compressedKey", + "contactRequestState", + "contentType", + "displayName", + "emojiHash", + "ensName", + "from", + "id", + "identicon", + "lineCount", + "localChatId", + "messageType", + "parsedText", + "quotedMessage", + "replace", + "responseTo", + "rtl", + "seen", + "text", + "timestamp", + "whisperTimestamp" + ], + "type": "object" + } + ] + }, + "name": { + "type": "string" + }, + "read": { + "type": "boolean" + }, + "replyMessage": { + "type": "null" + }, + "timestamp": { + "type": "integer" + }, + "tokenData": { + "type": "null" + }, + "type": { + "type": "integer" + }, + "updatedAt": { + "type": "integer" + } + }, + "required": [ + "accepted", + "albumMessages", + "author", + "chatId", + "communityId", + "contactVerificationStatus", + "deleted", + "dismissed", + "id", + "installationId", + "lastMessage", + "membershipStatus", + "message", + "name", + "read", + "replyMessage", + "timestamp", + "tokenData", + "type", + "updatedAt" + ], + "type": "object" + }, + "type": "array" + }, + "activityCenterState": { + "properties": { + "hasSeen": { + "type": "boolean" + }, + "updatedAt": { + "type": "integer" + } + }, + "required": [ + "hasSeen", + "updatedAt" + ], + "type": "object" + }, + "discordOldestMessageTimestamp": { + "type": "integer" + }, + "notifications": { + "type": "null" + } + }, + "required": [ + "activityCenterNotifications", + "activityCenterState", + "discordOldestMessageTimestamp", + "notifications" + ], + "type": "object" + } + }, + "required": [ + "id", + "jsonrpc", + "result" + ], + "type": "object" +} \ No newline at end of file diff --git a/tests-functional/schemas/wakuext_markAsSeenActivityCenterNotifications b/tests-functional/schemas/wakuext_markAsSeenActivityCenterNotifications new file mode 100644 index 000000000..3c91cd1a1 --- /dev/null +++ b/tests-functional/schemas/wakuext_markAsSeenActivityCenterNotifications @@ -0,0 +1,48 @@ +{ + "$schema": "http://json-schema.org/schema#", + "properties": { + "id": { + "type": "integer" + }, + "jsonrpc": { + "type": "string" + }, + "result": { + "properties": { + "activityCenterState": { + "properties": { + "hasSeen": { + "type": "boolean" + }, + "updatedAt": { + "type": "integer" + } + }, + "required": [ + "hasSeen", + "updatedAt" + ], + "type": "object" + }, + "discordOldestMessageTimestamp": { + "type": "integer" + }, + "notifications": { + "type": "null" + } + }, + "required": [ + "activityCenterState", + "discordOldestMessageTimestamp", + "notifications" + ], + "type": "object" + } + }, + "required": [ + "id", + "jsonrpc", + "result" + ], + "type": "object" +} \ No newline at end of file diff --git a/tests-functional/tests/test_activity_center_notifications.py b/tests-functional/tests/test_activity_center_notifications.py new file mode 100644 index 000000000..17912dc1a --- /dev/null +++ b/tests-functional/tests/test_activity_center_notifications.py @@ -0,0 +1,186 @@ +from typing import Union + +import pytest + +from clients.status_backend import StatusBackend +from tests.test_cases import MessengerTestCase + + +def _get_activity_center_notifications( + backend_instance: StatusBackend, activity_types: list = [1, 2, 3, 4, 5, 7, 8, 9, 10, 23, 24], read_type: Union[int, None] = None +): + params = {"cursor": "", "limit": 20, "activityTypes": activity_types} + if read_type: + params["readType"] = read_type + return backend_instance.wakuext_service.rpc_request(method="activityCenterNotifications", params=[params]).json() + + +@pytest.mark.usefixtures("setup_two_unprivileged_nodes") +@pytest.mark.rpc +class TestActivityCenterNotifications(MessengerTestCase): + + def test_activity_center_notifications(self): + message_id = self.send_contact_request_and_wait_for_signal_to_be_received() + response = _get_activity_center_notifications(backend_instance=self.receiver, activity_types=[5], read_type=2) + self.receiver.verify_json_schema(response, method="wakuext_activityCenterNotifications") + notification = response["result"]["notifications"][0] + assert all( + ( + notification["accepted"] is False, + notification["author"] == self.sender.public_key, + notification["chatId"] == self.sender.public_key, + notification["id"] == message_id, + notification["read"] is False, + notification["lastMessage"]["contactRequestState"] == 1, + ) + ) + + self.accept_contact_request_and_wait_for_signal_to_be_received(message_id) + response = _get_activity_center_notifications(backend_instance=self.sender) + self.sender.verify_json_schema(response, method="wakuext_activityCenterNotifications") + notification = response["result"]["notifications"][0] + assert all( + ( + notification["accepted"] is True, + notification["author"] == self.sender.public_key, + notification["chatId"] == self.receiver.public_key, + notification["id"] == message_id, + notification["read"] is True, + notification["message"]["contactRequestState"] == 2, + notification["lastMessage"]["text"] == f"@{self.receiver.public_key} accepted your contact request", + ) + ) + + def test_activity_center_notifications_count(self): + self.send_contact_request_and_wait_for_signal_to_be_received() + response = self.receiver.wakuext_service.rpc_request( + method="activityCenterNotificationsCount", params=[{"activityTypes": [1, 2, 3, 4, 5, 7, 8, 9, 10, 23, 24], "readType": 2}] + ).json() + self.receiver.verify_json_schema(response, method="wakuext_activityCenterNotificationsCount") + assert response["result"]["5"] == 1 + + def test_seen_unseen_activity_center_notifications(self): + self.send_contact_request_and_wait_for_signal_to_be_received() + response = self.receiver.wakuext_service.rpc_request(method="hasUnseenActivityCenterNotifications").json() + self.receiver.verify_json_schema(response, method="wakuext_hasUnseenActivityCenterNotifications") + assert response["result"] is True + + response = self.receiver.wakuext_service.rpc_request(method="markAsSeenActivityCenterNotifications").json() + self.receiver.verify_json_schema(response, method="wakuext_markAsSeenActivityCenterNotifications") + + response = self.receiver.wakuext_service.rpc_request(method="hasUnseenActivityCenterNotifications").json() + self.receiver.verify_json_schema(response, method="wakuext_hasUnseenActivityCenterNotifications") + assert response["result"] is False + + def test_get_activity_center_state(self): + self.send_contact_request_and_wait_for_signal_to_be_received() + response = self.receiver.wakuext_service.rpc_request(method="getActivityCenterState").json() + self.receiver.verify_json_schema(response, method="wakuext_getActivityCenterState") + assert response["result"]["hasSeen"] is False + + self.receiver.wakuext_service.rpc_request(method="markAsSeenActivityCenterNotifications").json() + + response = self.receiver.wakuext_service.rpc_request(method="getActivityCenterState").json() + assert response["result"]["hasSeen"] is True + + def test_mark_all_activity_center_notifications_read(self): + message_id = self.send_contact_request_and_wait_for_signal_to_be_received() + response = self.receiver.wakuext_service.rpc_request(method="markAllActivityCenterNotificationsRead").json() + self.receiver.verify_json_schema(response, method="wakuext_markAllActivityCenterNotificationsRead") + assert all( + ( + response["result"]["activityCenterState"]["hasSeen"] is True, + response["result"]["activityCenterNotifications"][0]["id"] == message_id, + response["result"]["activityCenterNotifications"][0]["read"] is True, + ) + ) + + response = self.receiver.wakuext_service.rpc_request(method="hasUnseenActivityCenterNotifications").json() + assert response["result"] is False + + def test_mark_activity_center_notifications_read_unread(self): + message_id = self.make_contacts() + response = self.sender.wakuext_service.rpc_request( + method="markActivityCenterNotificationsRead", + params=[ + [ + message_id, + ], + ], + ).json() + self.sender.verify_json_schema(response, method="wakuext_markActivityCenterNotificationsRead") + assert all( + ( + response["result"]["activityCenterNotifications"][0]["id"] == message_id, + response["result"]["activityCenterNotifications"][0]["read"] is True, + ) + ) + + result = _get_activity_center_notifications(backend_instance=self.sender, activity_types=[5])["result"] + assert result["notifications"][0]["read"] is True + + response = self.sender.wakuext_service.rpc_request( + method="markActivityCenterNotificationsUnread", + params=[ + [ + message_id, + ], + ], + ).json() + self.sender.verify_json_schema(response, method="wakuext_markActivityCenterNotificationsUnread") + assert all( + ( + response["result"]["activityCenterState"]["hasSeen"] is False, + response["result"]["activityCenterNotifications"][0]["id"] == message_id, + response["result"]["activityCenterNotifications"][0]["read"] is False, + ) + ) + + result = _get_activity_center_notifications(backend_instance=self.sender, activity_types=[5])["result"] + assert result["notifications"][0]["read"] is False + + def test_accept_activity_center_notifications(self): + message_id = self.send_contact_request_and_wait_for_signal_to_be_received() + response = self.receiver.wakuext_service.rpc_request( + method="acceptActivityCenterNotifications", + params=[ + [ + message_id, + ], + ], + ).json() + self.receiver.verify_json_schema(response, method="wakuext_acceptActivityCenterNotifications") + + result = _get_activity_center_notifications(backend_instance=self.receiver)["result"] + assert all((result["notifications"][0]["accepted"] is True, result["notifications"][0]["id"] == message_id)) + + def test_dismiss_activity_center_notifications(self): + message_id = self.send_contact_request_and_wait_for_signal_to_be_received() + response = self.receiver.wakuext_service.rpc_request( + method="dismissActivityCenterNotifications", + params=[ + [ + message_id, + ], + ], + ).json() + self.receiver.verify_json_schema(response, method="wakuext_dismissActivityCenterNotifications") + + result = _get_activity_center_notifications(backend_instance=self.receiver)["result"] + assert all((result["notifications"][0]["dismissed"] is True, result["notifications"][0]["id"] == message_id)) + + def test_delete_activity_center_notifications(self): + message_id = self.make_contacts() + result = _get_activity_center_notifications(backend_instance=self.sender)["result"] + assert len(result["notifications"]) == 1 + response = self.sender.wakuext_service.rpc_request( + method="deleteActivityCenterNotifications", + params=[ + [ + message_id, + ], + ], + ).json() + self.sender.verify_json_schema(response, method="wakuext_deleteActivityCenterNotifications") + result = _get_activity_center_notifications(backend_instance=self.sender)["result"] + assert not result["notifications"] diff --git a/tests-functional/tests/test_cases.py b/tests-functional/tests/test_cases.py index 972ba8101..2468b9e9f 100644 --- a/tests-functional/tests/test_cases.py +++ b/tests-functional/tests/test_cases.py @@ -227,18 +227,27 @@ class MessengerTestCase(NetworkConditionTestCase): backend.wakuext_service.start_messenger() return backend + def send_contact_request_and_wait_for_signal_to_be_received(self): + response = self.sender.wakuext_service.send_contact_request(self.receiver.public_key, "contact_request") + expected_message = self.get_message_by_content_type(response, content_type=MessageContentType.CONTACT_REQUEST.value)[0] + message_id = expected_message.get("id") + self.receiver.find_signal_containing_pattern(SignalType.MESSAGES_NEW.value, event_pattern=message_id) + return message_id + + def accept_contact_request_and_wait_for_signal_to_be_received(self, message_id): + self.receiver.wakuext_service.accept_contact_request(message_id) + accepted_signal = f"@{self.receiver.public_key} accepted your contact request" + self.sender.find_signal_containing_pattern(SignalType.MESSAGES_NEW.value, event_pattern=accepted_signal) + def make_contacts(self): existing_contacts = self.receiver.wakuext_service.get_contacts() if self.sender.public_key in str(existing_contacts): return - response = self.sender.wakuext_service.send_contact_request(self.receiver.public_key, "contact_request") - expected_message = self.get_message_by_content_type(response, content_type=MessageContentType.CONTACT_REQUEST.value)[0] - self.receiver.find_signal_containing_pattern(SignalType.MESSAGES_NEW.value, event_pattern=expected_message.get("id")) - self.receiver.wakuext_service.accept_contact_request(expected_message.get("id")) - accepted_signal = f"@{self.receiver.public_key} accepted your contact request" - self.sender.find_signal_containing_pattern(SignalType.MESSAGES_NEW.value, event_pattern=accepted_signal) + message_id = self.send_contact_request_and_wait_for_signal_to_be_received() + self.accept_contact_request_and_wait_for_signal_to_be_received(message_id) + return message_id def validate_signal_event_against_response(self, signal_event, fields_to_validate, expected_message): expected_message_id = expected_message.get("id") diff --git a/tests-functional/tests/test_waku_rpc.py b/tests-functional/tests/test_waku_rpc.py index 3a6d9857d..9ec2a9ac5 100644 --- a/tests-functional/tests/test_waku_rpc.py +++ b/tests-functional/tests/test_waku_rpc.py @@ -9,10 +9,6 @@ class TestRpc(StatusBackendTestCase): "method, params", [ ("wakuext_peers", []), - ( - "wakuext_activityCenterNotifications", - [{"cursor": "", "limit": 20, "activityTypes": [5], "readType": 2}], - ), ], ) def test_(self, method, params):