From 973a8e92fec619f7862be76fcbc5b2e36d709006 Mon Sep 17 00:00:00 2001 From: Rohit Bansal <40559587+Rohit3523@users.noreply.github.com> Date: Sat, 1 Nov 2025 02:07:27 +0530 Subject: [PATCH 1/8] Added test id in badge, added e2e test for badge --- .maestro/tests/room/mark-as-unread.yaml | 2 +- .maestro/tests/room/unread-badge.yaml | 62 +++++++++++++++++++ .../__snapshots__/HeaderButtons.test.tsx.snap | 6 ++ .../__snapshots__/RoomItem.test.tsx.snap | 18 ++++++ .../__snapshots__/UnreadBadge.test.tsx.snap | 30 +++++++++ app/containers/UnreadBadge/index.tsx | 11 +++- 6 files changed, 127 insertions(+), 2 deletions(-) create mode 100644 .maestro/tests/room/unread-badge.yaml diff --git a/.maestro/tests/room/mark-as-unread.yaml b/.maestro/tests/room/mark-as-unread.yaml index 7507549c2fc..dbceb3d4c66 100644 --- a/.maestro/tests/room/mark-as-unread.yaml +++ b/.maestro/tests/room/mark-as-unread.yaml @@ -53,7 +53,7 @@ tags: timeout: 60000 - extendedWaitUntil: visible: - text: '.*1.*' + id: 'unread-badge-1' childOf: id: 'rooms-list-view-item-${output.otherUser.username}' timeout: 60000 diff --git a/.maestro/tests/room/unread-badge.yaml b/.maestro/tests/room/unread-badge.yaml new file mode 100644 index 00000000000..604b494a1a0 --- /dev/null +++ b/.maestro/tests/room/unread-badge.yaml @@ -0,0 +1,62 @@ +appId: chat.rocket.reactnative +name: Unread badge +onFlowStart: + - runFlow: '../../helpers/setup.yaml' +tags: + - test-13 + +--- +- evalScript: ${output.user = output.utils.createUser()} +- evalScript: ${output.otherUser = output.utils.createUser()} + +- runFlow: + file: '../../helpers/login-with-deeplink.yaml' + env: + USERNAME: ${output.user.username} + PASSWORD: ${output.user.password} + +# Should have normal unread indicator on normal message +- evalScript: ${output.message = output.utils.sendMessage(output.otherUser.username, output.otherUser.password, '@' + output.user.username, 'message-mark-as-unread')} +- extendedWaitUntil: + visible: + id: 'rooms-list-view-item-${output.otherUser.username}' + timeout: 60000 +- extendedWaitUntil: + visible: + id: 'unread-badge-1' + childOf: + id: 'rooms-list-view-item-${output.otherUser.username}' + timeout: 60000 +- tapOn: + id: 'rooms-list-view-item-${output.otherUser.username}' +- tapOn: + id: header-back +- extendedWaitUntil: + notVisible: + id: 'unread-badge-1' + childOf: + id: 'rooms-list-view-item-${output.otherUser.username}' + timeout: 60000 + +# Should have mention unread indicator on mentioned message +- evalScript: ${output.message = output.utils.sendMessage(output.otherUser.username, output.otherUser.password, '@' + output.user.username, '@' + output.user.username)} +- extendedWaitUntil: + visible: + id: 'rooms-list-view-item-${output.otherUser.username}' + timeout: 60000 +- extendedWaitUntil: + visible: + id: 'mention-badge-1' + childOf: + id: 'rooms-list-view-item-${output.otherUser.username}' + timeout: 60000 +- tapOn: + id: 'rooms-list-view-item-${output.otherUser.username}' +- tapOn: + id: header-back +- extendedWaitUntil: + notVisible: + id: 'mention-badge-1' + childOf: + id: 'rooms-list-view-item-${output.otherUser.username}' + timeout: 60000 diff --git a/app/containers/Header/components/HeaderButton/__snapshots__/HeaderButtons.test.tsx.snap b/app/containers/Header/components/HeaderButton/__snapshots__/HeaderButtons.test.tsx.snap index ec296cc2f6e..cf862f237ac 100644 --- a/app/containers/Header/components/HeaderButton/__snapshots__/HeaderButtons.test.tsx.snap +++ b/app/containers/Header/components/HeaderButton/__snapshots__/HeaderButtons.test.tsx.snap @@ -204,6 +204,7 @@ exports[`Story Snapshots: Badge should match snapshot 1`] = ` }, ] } + testID="badge-1" > + ]} + testID={testId}> {text} From 1af4db1339e8549799683e3c60bace04c21af3b2 Mon Sep 17 00:00:00 2001 From: Rohit Bansal <40559587+Rohit3523@users.noreply.github.com> Date: Sat, 1 Nov 2025 02:14:27 +0530 Subject: [PATCH 2/8] Improve testId case --- app/containers/UnreadBadge/index.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/containers/UnreadBadge/index.tsx b/app/containers/UnreadBadge/index.tsx index 389a6543c34..fb1aa806ed0 100644 --- a/app/containers/UnreadBadge/index.tsx +++ b/app/containers/UnreadBadge/index.tsx @@ -99,9 +99,7 @@ const UnreadBadge = React.memo( ? `mention-badge-${text}` : groupMentions ? `group-mention-badge-${text}` - : unread - ? `unread-badge-${text}` - : `badge-${text}`; + : `unread-badge-${text}`; return ( Date: Sat, 1 Nov 2025 02:15:08 +0530 Subject: [PATCH 3/8] Added 2 more test case --- .maestro/tests/room/unread-badge.yaml | 48 +++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/.maestro/tests/room/unread-badge.yaml b/.maestro/tests/room/unread-badge.yaml index 604b494a1a0..b095ade4440 100644 --- a/.maestro/tests/room/unread-badge.yaml +++ b/.maestro/tests/room/unread-badge.yaml @@ -60,3 +60,51 @@ tags: childOf: id: 'rooms-list-view-item-${output.otherUser.username}' timeout: 60000 + +# send normal message first and mention in next message and it should show mentioned unread indicator +- evalScript: ${output.message = output.utils.sendMessage(output.otherUser.username, output.otherUser.password, '@' + output.user.username, 'message-mark-as-unread')} +- evalScript: ${output.message = output.utils.sendMessage(output.otherUser.username, output.otherUser.password, '@' + output.user.username, '@' + output.user.username)} +- extendedWaitUntil: + visible: + id: 'rooms-list-view-item-${output.otherUser.username}' + timeout: 60000 +- extendedWaitUntil: + visible: + id: 'mention-badge-2' + childOf: + id: 'rooms-list-view-item-${output.otherUser.username}' + timeout: 60000 +- tapOn: + id: 'rooms-list-view-item-${output.otherUser.username}' +- tapOn: + id: header-back +- extendedWaitUntil: + notVisible: + id: 'mention-badge-2' + childOf: + id: 'rooms-list-view-item-${output.otherUser.username}' + timeout: 60000 + +# send mention message first and normal message in next message and it should show mentioned unread indicator +- evalScript: ${output.message = output.utils.sendMessage(output.otherUser.username, output.otherUser.password, '@' + output.user.username, '@' + output.user.username)} +- evalScript: ${output.message = output.utils.sendMessage(output.otherUser.username, output.otherUser.password, '@' + output.user.username, 'message-mark-as-unread')} +- extendedWaitUntil: + visible: + id: 'rooms-list-view-item-${output.otherUser.username}' + timeout: 60000 +- extendedWaitUntil: + visible: + id: 'mention-badge-2' + childOf: + id: 'rooms-list-view-item-${output.otherUser.username}' + timeout: 60000 +- tapOn: + id: 'rooms-list-view-item-${output.otherUser.username}' +- tapOn: + id: header-back +- extendedWaitUntil: + notVisible: + id: 'mention-badge-2' + childOf: + id: 'rooms-list-view-item-${output.otherUser.username}' + timeout: 60000 From cd71eabc281e5ae78e487d025df6a2b4f1d3bde0 Mon Sep 17 00:00:00 2001 From: Rohit Bansal <40559587+Rohit3523@users.noreply.github.com> Date: Sat, 1 Nov 2025 02:19:09 +0530 Subject: [PATCH 4/8] lint fix --- app/containers/UnreadBadge/index.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/containers/UnreadBadge/index.tsx b/app/containers/UnreadBadge/index.tsx index fb1aa806ed0..0dd317cace9 100644 --- a/app/containers/UnreadBadge/index.tsx +++ b/app/containers/UnreadBadge/index.tsx @@ -39,6 +39,16 @@ export interface IUnreadBadge { hideMentionStatus?: boolean; } +function getTestId(userMentions: number | undefined, groupMentions: number | undefined, unread: number | undefined) { + if (userMentions) { + return `mention-badge-${unread}`; + } + if (groupMentions) { + return `group-mention-badge-${unread}`; + } + return `unread-badge-${unread}`; +} + const UnreadBadge = React.memo( ({ unread, @@ -95,11 +105,7 @@ const UnreadBadge = React.memo( minWidth = 11 + text.length * 5; } const borderRadius = 10.5 * fontScale; - const testId = userMentions - ? `mention-badge-${text}` - : groupMentions - ? `group-mention-badge-${text}` - : `unread-badge-${text}`; + const testId = getTestId(userMentions, groupMentions, unread); return ( Date: Sat, 1 Nov 2025 02:30:04 +0530 Subject: [PATCH 5/8] Some more changes --- .../__snapshots__/HeaderButtons.test.tsx.snap | 12 ++++++------ .../__snapshots__/RoomItem.test.tsx.snap | 16 ++++++++-------- .../__snapshots__/UnreadBadge.test.tsx.snap | 6 +++--- app/containers/UnreadBadge/index.tsx | 7 +++++-- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/app/containers/Header/components/HeaderButton/__snapshots__/HeaderButtons.test.tsx.snap b/app/containers/Header/components/HeaderButton/__snapshots__/HeaderButtons.test.tsx.snap index cf862f237ac..938b20fc972 100644 --- a/app/containers/Header/components/HeaderButton/__snapshots__/HeaderButtons.test.tsx.snap +++ b/app/containers/Header/components/HeaderButton/__snapshots__/HeaderButtons.test.tsx.snap @@ -204,7 +204,7 @@ exports[`Story Snapshots: Badge should match snapshot 1`] = ` }, ] } - testID="badge-1" + testID="unread-badge-1" > Date: Fri, 31 Oct 2025 21:01:51 +0000 Subject: [PATCH 6/8] chore: format code and fix lint issues [skip ci] --- app/containers/UnreadBadge/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/containers/UnreadBadge/index.tsx b/app/containers/UnreadBadge/index.tsx index ab70d329015..b2c1d96554c 100644 --- a/app/containers/UnreadBadge/index.tsx +++ b/app/containers/UnreadBadge/index.tsx @@ -46,10 +46,10 @@ function getTestId(userMentions: number | undefined, groupMentions: number | und if (groupMentions) { return `group-mention-badge-${unread}`; } - if(unread){ - return `unread-badge-${unread}`; - } - return ''; + if (unread) { + return `unread-badge-${unread}`; + } + return ''; } const UnreadBadge = React.memo( From 105a8372db0f65307f52e11180932ad66d529f2b Mon Sep 17 00:00:00 2001 From: Rohit Bansal <40559587+Rohit3523@users.noreply.github.com> Date: Sat, 1 Nov 2025 02:34:10 +0530 Subject: [PATCH 7/8] ci rerun --- app/containers/UnreadBadge/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/containers/UnreadBadge/index.tsx b/app/containers/UnreadBadge/index.tsx index b2c1d96554c..70ba5b89a70 100644 --- a/app/containers/UnreadBadge/index.tsx +++ b/app/containers/UnreadBadge/index.tsx @@ -126,4 +126,4 @@ const UnreadBadge = React.memo( } ); -export default UnreadBadge; +export default UnreadBadge; From 8e3a77806b9d11c80b4399126cf674a9294d2e1b Mon Sep 17 00:00:00 2001 From: Rohit Bansal <40559587+Rohit3523@users.noreply.github.com> Date: Sat, 1 Nov 2025 02:34:18 +0530 Subject: [PATCH 8/8] revert --- app/containers/UnreadBadge/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/containers/UnreadBadge/index.tsx b/app/containers/UnreadBadge/index.tsx index 70ba5b89a70..b2c1d96554c 100644 --- a/app/containers/UnreadBadge/index.tsx +++ b/app/containers/UnreadBadge/index.tsx @@ -126,4 +126,4 @@ const UnreadBadge = React.memo( } ); -export default UnreadBadge; +export default UnreadBadge;