Skip to content

Commit

Permalink
Feature/add chat member count in title bar (#381)
Browse files Browse the repository at this point in the history
* fix spacing in TitleBar

* fix linter

* member count is now displayed when it finished loading, basicGroup member count is now correct

* ui test for chat member count

* test all chats in lists

* Removed the need for shrinkWrap by manually implementing the same thing

* Removed Vivide from baseline

* Updating screenshot test hash

* fixed merge

* Removing cellGap for Squeak 5.2

* hide after addMorphFront to stay compatible with 5.2

* fix formatting, remove unused code

* fix MockData and tests

* remove TCTMockCore

* merge user count

* manually fix some squeak auto merging errors

* fix linter and add extended linter failure info

* Adding newline for linter

Co-authored-by: Paul Ermler <[email protected]>
Co-authored-by: Jannis Berndt <[email protected]>
Co-authored-by: rsommerfeld <[email protected]>
  • Loading branch information
4 people authored May 31, 2021
1 parent 89884b0 commit a167fe3
Show file tree
Hide file tree
Showing 62 changed files with 214 additions and 88 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
initialization
isNotPrivate

^ self isPrivate not
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
memberCount: aNumber

memberCount := aNumber
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
memberCount

^ memberCount
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"class" : {
"newFromChatEvent:" : "pk 5/13/2021 12:46" },
"newFromChatEvent:" : "TR 5/19/2021 13:42" },
"instance" : {
"addNewestMessage:" : "js 8/2/2020 12:58",
"addOldestMessage:" : "js 8/2/2020 12:58",
Expand All @@ -10,10 +10,13 @@
"id" : "rs 6/7/2020 22:20",
"id:" : "5/11/2021 10:09:15",
"ifNotWaitingForUpdate:" : "js 8/2/2020 13:17",
"initialize" : "pk 5/12/2021 12:47",
"initialize" : "per 5/26/2021 14:02",
"isNotPrivate" : "TR 5/21/2021 15:36",
"isPrivate" : "per 5/13/2021 08:48",
"lastMessage" : "rs 6/19/2020 17:33",
"lastMessage:" : "5/11/2021 10:09:15",
"memberCount" : "TR 5/21/2021 15:53",
"memberCount:" : "TR 5/21/2021 15:53",
"messages" : "R.S 6/1/2020 15:37",
"messages:" : "5/11/2021 10:09:15",
"numberOfMessages" : "js 8/1/2020 18:04",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"waitingForUpdate",
"numberOfRequestedMessages",
"type",
"canSendMessages" ],
"canSendMessages",
"memberCount" ],
"name" : "TCCChat",
"pools" : [
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
events
addChat: aChatEvent

| chat |
chat := TCCChat newFromChatEvent: aChatEvent.
(chat type = 'chatTypeSupergroup') ifTrue: [
self loadSuperGroupChatMemberCountFor: chat with: (((aChatEvent at: 'chat') at: 'type') at: 'supergroup_id').
].
(chat type = 'chatTypeBasicGroup') ifTrue: [
self loadBasicGroupChatMemberCountFor: chat with: (((aChatEvent at: 'chat') at: 'type') at: 'basic_group_id').
].

self app chats
add: (TCCChat newFromChatEvent: aChatEvent);
add: chat;
notify.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
events
loadBasicGroupChatMemberCountFor: aChat with: aBasicGroupId

self client send: (TCCRequest
newWithType: 'getBasicGroupFullInfo'
from: {
'basic_group_id'->aBasicGroupId.
'@extra'->aBasicGroupId}).
self app pendingRequests at: aBasicGroupId put: [:aBasicGroupFullInfoEvent |
aChat memberCount: ((aBasicGroupFullInfoEvent at: 'members') size).]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
events
loadSuperGroupChatMemberCountFor: aChat with: aSupergroupId

self client send: (TCCRequest
newWithType: 'getSupergroupFullInfo'
from: {
'supergroup_id'->aSupergroupId.
'@extra'->aSupergroupId}).
self app pendingRequests at: aSupergroupId put: [:aSupergroupFullInfoEvent |
aChat memberCount: (aSupergroupFullInfoEvent at: 'member_count').].
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
"class" : {
},
"instance" : {
"addChat:" : "per 5/15/2021 12:28",
"addNewMessage:from:" : "pk 5/21/2021 09:23",
"addChat:" : "TR 5/30/2021 13:15",
"addNewMessage:from:" : "pk 5/17/2021 19:10",
"app" : "5/11/2021 10:09:15",
"app:" : "pk 5/17/2021 19:11",
"chatHistoryReceived:" : "pk 5/12/2021 12:35",
"client" : "js 6/1/2020 14:44",
"defaultMessageLimit" : "js 8/1/2020 18:24",
"getChatHistoryFrom:with:limit:" : "js 8/2/2020 13:17",
"getChats" : "js 7/31/2020 22:50",
"handleNewMessage:from:" : "pk 5/21/2021 09:23",
"handleNewMessage:from:" : "pk 5/17/2021 18:28",
"loadBasicGroupChatMemberCountFor:with:" : "per 5/26/2021 14:03",
"loadSuperGroupChatMemberCountFor:with:" : "per 5/26/2021 14:03",
"openNewChat:" : "pk 5/13/2021 12:45",
"remainingMessages" : "5/11/2021 10:09:15",
"remainingMessages:" : "js 8/1/2020 16:50",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ handleEvent: anEvent
['updateChatLastMessage'] -> [self chatsHandler updateLastMessage: anEvent].
['messages'] -> [self chatsHandler chatHistoryReceived: anEvent].
['updateNewMessage'] -> [self handleMessageEvent: anEvent].
['user'] -> [self handleUserEvent: anEvent].
['user'] -> [self handlePendingEvent: anEvent].
['supergroupFullInfo'] -> [self handlePendingEvent: anEvent].
['basicGroupFullInfo'] -> [self handlePendingEvent: anEvent].
['chat'] -> [self chatsHandler openNewChat: anEvent]}
otherwise: [].
update isSymbol ifTrue: [self triggerEvent: update].
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
events
handleUserEvent: anEvent

event handling
handlePendingEvent: anEvent
| extra |
extra := (anEvent at: '@extra') asString.
(self pendingRequests at: extra) value: anEvent.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
"client:" : "js 6/13/2020 19:10",
"getChatHistoryFrom:" : "js 8/1/2020 18:19",
"getOwnProfile" : "pk 5/13/2021 09:44",
"handleEvent:" : "RK 5/19/2021 09:57",
"handleMessageEvent:" : "pk 5/30/2021 13:16",
"handleUserEvent:" : "pk 5/21/2021 10:14",
"initialize" : "pk 5/21/2021 09:13",
"handleEvent:" : "per 5/26/2021 14:04",
"handleMessageEvent:" : "pk 5/19/2021 11:29",
"handlePendingEvent:" : "per 5/26/2021 14:03",
"initialize" : "pk 5/13/2021 09:33",
"initializeHandlers" : "js 8/1/2020 18:09",
"isClientAlive" : "js 5/28/2020 17:18",
"loggedInUserID" : "rs 7/5/2020 14:48",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
app: aMorph

app := aMorph
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
app

^ app

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
running
setUp

self core: TCTTestCore new.
20 seconds wait.
self core authHandler isAuthorizationStateReady ifFalse: [
self core loginWithTestData.
20 seconds wait].
self core: TCTNoTDLibCore new.
self core chats: TCTMocks mockChats.
self app: (TCUMain newWithCore: self core).
self wantsToTest: self app.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
running
tearDown

super tearDown.
self core client specificClient isNil ifFalse: [self core client free].
super tearDown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ testing
testCanCloseChatInfoPage

| titleBar |
self wantsToTest: (TCUMain newWithCore: self core).
self slowTestBy: 1000.

(self subject findByClass: TCUChatListItem) click.
titleBar := (self subject findByClass: TCUChatWindow) morphs collect: [:chatWindow | chatWindow titleBar].
(self subject createWrapperFor: titleBar) click.
titleBar := (self subject findByClass: TCUChatWindow) titleBar.
(self subject createWrapperFor: { titleBar } ) click.
self assert: (self subject findByClass: TCUChatInfoPage) visible.

(self subject findByName: 'infoBackButton') click.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ testing
testCanOpenChatInfoPage

| titleBar |
self wantsToTest: (TCUMain newWithCore: self core).
self slowTestBy: 1000.

(self subject findByClass: TCUChatListItem) click.
titleBar := (self subject findByClass: TCUChatWindow) morphs collect: [:chatWindow | chatWindow titleBar].
(self subject createWrapperFor: titleBar) click.
titleBar := (self subject findByClass: TCUChatWindow) titleBar.
(self subject createWrapperFor: { titleBar }) click.

self assert: (self subject findByClass: TCUChatInfoPage) visible.
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
testing
testChatInfoPageIsHidden

self wantsToTest: (TCUMain newWithCore: self core).
self slowTestBy: 1000.

(self subject findByClass: TCUChatListItem) click.
self assert: (self subject findByClass: TCUChatInfoPage) visible not.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
testing
testChatMemberCount

((self subject findByClass: TCUChatListItem)morphs) do: [
:chatListItem | | chatWindowWrapper |
chatWindowWrapper := self subject createWrapperFor: {self app chatWindow}.
(MTFMorphWrapper newWith: {chatListItem}) click.
chatListItem chat isPrivate
ifTrue: [
self assertNotReading: 'Members: ' in: chatWindowWrapper.
] ifFalse: [
self assertReading: ('Members: ', chatListItem chat memberCount asString) in: chatWindowWrapper.
]
]
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
testing
testMessageAuthors

| message user notification overrideCore |
"Fake core because some other tests need a working one"
overrideCore := TCTNoTDLibCore new.
overrideCore chats add: (TCCChat new id: TCTMocks mockChatID).
overrideCore when: #newMessageReceived send: #newMessageReceived: to: self.
| message user notification |
self core when: #newMessageReceived send: #newMessageReceived: to: self.

self receivedMessage: nil.
message := TCTMocks mockMessageEventFrom: TCTMocks mockChatID.

overrideCore handleEvent: message.
self core handleEvent: message.
2 seconds wait.
user := TCTMocks mockUserEvent.
overrideCore handleEvent: user.
self core handleEvent: user.
1 second wait.
notification := TCUNotification newWithMessage: self receivedMessage.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@
"class" : {
},
"instance" : {
"app" : "RS 5/31/2021 07:52",
"app:" : "RS 5/31/2021 07:52",
"core" : "pk 5/17/2021 15:28",
"core:" : "pk 5/30/2021 20:40",
"defaultTimeout" : "RS 5/27/2021 21:13",
"expectedFailures" : "RS 5/31/2021 07:36",
"newMessageReceived:" : "pk 5/17/2021 19:20",
"receivedMessage" : "pk 5/17/2021 19:15",
"receivedMessage:" : "pk 5/17/2021 19:32",
"setUp" : "RS 5/27/2021 21:13",
"tearDown" : "JB 5/24/2021 18:22",
"testCanCloseChatInfoPage" : "RS 5/28/2021 10:55",
"testCanOpenChatInfoPage" : "RS 5/28/2021 10:50",
"testChatInfoPageIsHidden" : "RS 5/28/2021 10:51",
"testMessageAuthors" : "pk 5/30/2021 21:08" } }
"setUp" : "RS 5/31/2021 08:01",
"tearDown" : "RS 5/31/2021 07:33",
"testCanCloseChatInfoPage" : "RS 5/31/2021 07:39",
"testCanOpenChatInfoPage" : "RS 5/31/2021 07:39",
"testChatInfoPageIsHidden" : "RS 5/31/2021 07:34",
"testChatMemberCount" : "RS 5/31/2021 07:35",
"testMessageAuthors" : "RS 5/31/2021 07:41",
"testMessageUI" : "RS 5/31/2021 07:36",
"testNotificationContainsMessage" : "RS 5/31/2021 07:36" } }
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
"commentStamp" : "pk 5/17/2021 19:32",
"instvars" : [
"core",
"app",
"receivedMessage" ],
"name" : "TCTAcceptanceTests",
"pools" : [
],
"super" : "TCTUITest",
"super" : "TCTUITestCase",
"type" : "normal" }
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
private
arbitraryCodeRule: aRule plugIn: aPlugIn

| failures result |
| failures failingTestObjects result |

failures := ((SLTestRunner new
environment: (self environmentFor: aPlugIn withRule: aRule))
runOnTests: {aRule} andTestObjects: self classTestObjects)
select: [:testObject |
result := (testObject resultOf: aRule).
result isSummary
ifTrue: [result > 0]
ifFalse: [result isNegative]].

self assert: failures isEmpty description: 'Failures in: ', failures asString.
failingTestObjects := OrderedCollection new.
failures := ((SLTestRunner new environment: (self environmentFor: aPlugIn withRule: aRule))
runOnTests: {aRule}
andTestObjects: self classTestObjects) select: [:testObject |
result := testObject resultOf: aRule.
result isSummary
ifTrue: [
failingTestObjects addAll: (testObject methods select: [:each | result summarizingCondition value: (each resultOf: result summarizedTest)]).
result > 0]
ifFalse: [result isNegative]].
self assert: failures isEmpty description: 'Failures in: ', failures asString
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
},
"instance" : {
"arbitraryCodeRule:" : "js 6/13/2020 18:04",
"arbitraryCodeRule:plugIn:" : "js 6/13/2020 18:04",
"arbitraryCodeRule:plugIn:" : "JB 5/31/2021 08:57",
"classTestObjects" : "js 6/13/2020 13:28",
"classTestObjects:" : "js 6/13/2020 13:28",
"classes" : "js 6/13/2020 11:38",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
chat
mockBasicGroupChat

^ TCCChat new
id: 2;
title: 'GroupMockChat';
type: 'chatTypeBasicGroup';
lastMessage: 'lastBasicGroupMessage';
canSendMessages: true;
memberCount: 5
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
chat
mockChats

|chats|
chats := TCCChats newWithDefaultSorting.
chats
add: self mockBasicGroupChat;
add: self mockPrivateChat;
add: self mockSupergroupChat.
^chats
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
chat
mockPrivateChat

^ TCCChat new
id: 1;
title: 'PrivateMockChat';
type: 'chatTypePrivate';
lastMessage: 'lastPrivateMessage';
canSendMessages: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
chat
mockSupergroupChat

^ TCCChat new
id: 3;
title: 'SupergroupMockChat';
type: 'chatTypeSupergroup';
lastMessage: 'lastSupergroupMessage';
canSendMessages: true;
memberCount: 8972981
Loading

0 comments on commit a167fe3

Please sign in to comment.