Commit 59a5ce6f authored by Tim Kinnane's avatar Tim Kinnane
Browse files

test(driver): Add regression for private group ID

- Related #21
- Requires PR #11703 merge on core
- Next SDK release will be blocked by that PR
parent 69de295e
......@@ -36,20 +36,20 @@ FN:218,(anonymous_42)
FN:218,(anonymous_43)
FNF:34
FNH:16
FNDA:44,loggedIn
FNDA:35,getQueryString
FNDA:49,(anonymous_9)
FNDA:45,loggedIn
FNDA:36,getQueryString
FNDA:51,(anonymous_9)
FNDA:8,setAuth
FNDA:56,getHeaders
FNDA:57,getHeaders
FNDA:11,clearHeaders
FNDA:58,success
FNDA:59,success
FNDA:21,post
FNDA:21,(anonymous_16)
FNDA:21,(anonymous_17)
FNDA:0,(anonymous_18)
FNDA:32,get
FNDA:32,(anonymous_21)
FNDA:32,(anonymous_22)
FNDA:33,get
FNDA:33,(anonymous_21)
FNDA:33,(anonymous_22)
FNDA:0,(anonymous_23)
FNDA:20,login
FNDA:21,logout
......@@ -75,30 +75,30 @@ DA:2,1
DA:3,1
DA:17,1
DA:25,1
DA:26,44
DA:26,45
DA:30,1
DA:31,1
DA:37,1
DA:42,1
DA:43,35
DA:44,25
DA:45,49
DA:48,49
DA:43,36
DA:44,26
DA:45,51
DA:48,51
DA:53,1
DA:54,1
DA:57,1
DA:58,8
DA:59,8
DA:63,1
DA:64,56
DA:65,46
DA:64,57
DA:65,47
DA:70,1
DA:72,45
DA:72,46
DA:76,1
DA:77,11
DA:78,11
DA:82,1
DA:83,58
DA:83,59
DA:104,1
DA:110,21
DA:111,21
......@@ -115,19 +115,19 @@ DA:122,21
DA:124,0
DA:125,0
DA:136,1
DA:142,32
DA:143,32
DA:144,32
DA:145,32
DA:146,32
DA:147,32
DA:148,32
DA:149,32
DA:150,32
DA:151,32
DA:142,33
DA:143,33
DA:144,33
DA:145,33
DA:146,33
DA:147,33
DA:148,33
DA:149,33
DA:150,33
DA:151,33
DA:152,0
DA:154,32
DA:155,32
DA:154,33
DA:155,33
DA:157,0
DA:166,1
DA:170,20
......@@ -164,30 +164,30 @@ LH:77
BRDA:38,0,0,0
BRDA:38,0,1,1
BRDA:43,1,0,10
BRDA:43,1,1,25
BRDA:43,2,0,35
BRDA:43,2,1,27
BRDA:43,2,2,27
BRDA:46,3,0,2
BRDA:46,3,1,47
BRDA:43,1,1,26
BRDA:43,2,0,36
BRDA:43,2,1,28
BRDA:43,2,2,28
BRDA:46,3,0,3
BRDA:46,3,1,48
BRDA:63,4,0,1
BRDA:64,5,0,10
BRDA:64,5,1,46
BRDA:64,5,1,47
BRDA:65,6,0,1
BRDA:65,6,1,45
BRDA:66,7,0,46
BRDA:66,7,1,45
BRDA:66,7,2,45
BRDA:66,7,3,45
BRDA:92,8,0,56
BRDA:65,6,1,46
BRDA:66,7,0,47
BRDA:66,7,1,46
BRDA:66,7,2,46
BRDA:66,7,3,46
BRDA:92,8,0,57
BRDA:92,8,1,2
BRDA:85,9,0,58
BRDA:85,9,1,58
BRDA:85,9,2,40
BRDA:85,9,3,57
BRDA:85,9,0,59
BRDA:85,9,1,59
BRDA:85,9,2,41
BRDA:85,9,3,58
BRDA:85,9,4,18
BRDA:85,9,5,40
BRDA:85,9,6,38
BRDA:85,9,5,41
BRDA:85,9,6,39
BRDA:85,9,7,2
BRDA:85,9,8,0
BRDA:85,9,9,0
......@@ -202,13 +202,13 @@ BRDA:117,14,0,0
BRDA:117,14,1,21
BRDA:139,15,0,14
BRDA:144,16,0,1
BRDA:144,16,1,31
BRDA:144,17,0,32
BRDA:144,17,1,31
BRDA:144,16,1,32
BRDA:144,17,0,33
BRDA:144,17,1,32
BRDA:149,18,0,0
BRDA:149,18,1,32
BRDA:149,18,1,33
BRDA:150,19,0,0
BRDA:150,19,1,32
BRDA:150,19,1,33
BRDA:166,20,0,6
BRDA:171,21,0,13
BRDA:171,21,1,7
......@@ -285,24 +285,24 @@ FN:594,setReaction
FNF:54
FNH:46
FNDA:0,useLog
FNDA:31,connect
FNDA:31,(anonymous_10)
FNDA:27,(anonymous_11)
FNDA:34,connect
FNDA:34,(anonymous_10)
FNDA:30,(anonymous_11)
FNDA:0,(anonymous_12)
FNDA:4,(anonymous_13)
FNDA:27,(anonymous_14)
FNDA:30,(anonymous_14)
FNDA:1,disconnect
FNDA:1,(anonymous_16)
FNDA:31,setupMethodCache
FNDA:34,setupMethodCache
FNDA:22,asyncCall
FNDA:0,(anonymous_19)
FNDA:22,(anonymous_20)
FNDA:1,callMethod
FNDA:10,cacheCall
FNDA:13,cacheCall
FNDA:0,(anonymous_23)
FNDA:10,(anonymous_24)
FNDA:22,login
FNDA:22,(anonymous_26)
FNDA:13,(anonymous_24)
FNDA:25,login
FNDA:25,(anonymous_26)
FNDA:0,(anonymous_27)
FNDA:2,logout
FNDA:0,(anonymous_29)
......@@ -320,8 +320,8 @@ FNDA:7,respondToMessages
FNDA:0,(anonymous_41)
FNDA:13,(anonymous_42)
FNDA:13,(anonymous_43)
FNDA:6,getRoomId
FNDA:2,getRoomName
FNDA:8,getRoomId
FNDA:3,getRoomName
FNDA:2,getDirectMessageRoomId
FNDA:2,(anonymous_47)
FNDA:4,joinRoom
......@@ -353,34 +353,34 @@ DA:73,1
DA:83,1
DA:84,0
DA:104,1
DA:105,31
DA:106,31
DA:107,31
DA:108,31
DA:109,31
DA:117,31
DA:118,31
DA:119,31
DA:120,31
DA:121,31
DA:105,34
DA:106,34
DA:107,34
DA:108,34
DA:109,34
DA:117,34
DA:118,34
DA:119,34
DA:120,34
DA:121,34
DA:122,4
DA:123,4
DA:124,4
DA:125,4
DA:126,4
DA:131,31
DA:132,31
DA:133,27
DA:135,27
DA:136,27
DA:137,27
DA:131,34
DA:132,34
DA:133,30
DA:135,30
DA:136,30
DA:137,30
DA:146,1
DA:147,1
DA:148,1
DA:149,1
DA:160,31
DA:161,31
DA:169,31
DA:160,34
DA:161,34
DA:169,34
DA:180,1
DA:181,22
DA:182,22
......@@ -392,20 +392,20 @@ DA:192,22
DA:203,1
DA:204,1
DA:214,1
DA:215,10
DA:215,13
DA:217,0
DA:218,0
DA:221,10
DA:224,10
DA:221,13
DA:224,13
DA:232,1
DA:238,22
DA:238,25
DA:239,0
DA:240,0
DA:246,22
DA:247,22
DA:252,22
DA:254,22
DA:255,22
DA:246,25
DA:247,25
DA:252,25
DA:254,25
DA:255,25
DA:258,0
DA:259,0
DA:264,1
......@@ -439,9 +439,9 @@ DA:358,86
DA:359,86
DA:360,86
DA:361,86
DA:362,48
DA:363,48
DA:365,38
DA:362,46
DA:363,46
DA:365,40
DA:368,0
DA:382,1
DA:383,7
......@@ -471,9 +471,9 @@ DA:437,3
DA:449,3
DA:451,7
DA:479,1
DA:480,6
DA:480,8
DA:484,1
DA:485,2
DA:485,3
DA:493,1
DA:494,2
DA:498,1
......@@ -513,13 +513,13 @@ DA:594,1
DA:595,2
LF:173
LH:151
BRDA:104,0,0,24
BRDA:104,0,0,27
BRDA:126,1,0,3
BRDA:126,1,1,1
BRDA:131,2,0,31
BRDA:131,2,0,34
BRDA:131,2,1,0
BRDA:136,3,0,2
BRDA:136,3,1,25
BRDA:136,3,1,28
BRDA:181,4,0,20
BRDA:181,4,1,2
BRDA:190,5,0,15
......@@ -528,25 +528,25 @@ BRDA:205,6,0,1
BRDA:205,6,1,0
BRDA:204,7,0,1
BRDA:204,7,1,1
BRDA:222,8,0,9
BRDA:222,8,0,12
BRDA:222,8,1,1
BRDA:232,9,0,22
BRDA:232,9,0,25
BRDA:238,10,0,0
BRDA:238,10,1,22
BRDA:238,10,1,25
BRDA:241,11,0,0
BRDA:241,11,1,0
BRDA:243,12,0,0
BRDA:243,12,1,0
BRDA:248,13,0,22
BRDA:248,13,1,22
BRDA:248,13,0,25
BRDA:248,13,1,25
BRDA:305,14,0,0
BRDA:305,14,1,6
BRDA:359,15,0,86
BRDA:359,15,1,0
BRDA:359,16,0,86
BRDA:359,16,1,86
BRDA:361,17,0,48
BRDA:361,17,1,38
BRDA:361,17,0,46
BRDA:361,17,1,40
BRDA:382,18,0,1
BRDA:388,19,0,1
BRDA:388,19,1,6
......@@ -615,8 +615,8 @@ FNDA:0,(anonymous_3)
FNDA:0,(anonymous_4)
FNDA:2,replaceLog
FNDA:2,silence
FNDA:235,(anonymous_7)
FNDA:236,(anonymous_8)
FNDA:245,(anonymous_7)
FNDA:243,(anonymous_8)
FNDA:0,(anonymous_9)
FNDA:0,(anonymous_10)
FNDA:0,(anonymous_11)
......@@ -628,8 +628,8 @@ DA:18,0
DA:22,1
DA:25,2
DA:29,2
DA:30,235
DA:31,236
DA:30,245
DA:31,243
DA:32,0
DA:33,0
DA:34,0
......@@ -674,9 +674,9 @@ FN:88,resetAll
FN:89,(anonymous_8)
FNF:8
FNH:8
FNDA:47,use
FNDA:100,create
FNDA:33,call
FNDA:50,use
FNDA:109,create
FNDA:36,call
FNDA:4,has
FNDA:4,get
FNDA:3,reset
......@@ -687,21 +687,21 @@ DA:2,1
DA:6,1
DA:7,1
DA:16,1
DA:17,47
DA:17,50
DA:26,1
DA:27,100
DA:28,100
DA:29,100
DA:27,109
DA:28,109
DA:29,109
DA:37,1
DA:38,33
DA:39,33
DA:42,33
DA:38,36
DA:39,36
DA:42,36
DA:43,3
DA:45,3
DA:48,30
DA:49,30
DA:50,28
DA:52,31
DA:48,33
DA:49,33
DA:50,31
DA:52,34
DA:60,1
DA:61,4
DA:69,1
......@@ -716,9 +716,9 @@ LF:30
LH:30
BRDA:26,0,0,5
BRDA:38,1,0,3
BRDA:38,1,1,30
BRDA:38,1,1,33
BRDA:42,2,0,3
BRDA:42,2,1,30
BRDA:42,2,1,33
BRDA:70,3,0,4
BRDA:70,3,1,0
BRDA:79,4,0,3
......
......@@ -121,6 +121,21 @@ export interface IChannelAPI {
username: string;
};
ts: string;
default: boolean;
}
/** Group result schema */
export interface IGroupAPI {
_id: string;
name: string;
usernames: string[];
t: 'c' | 'p' | 'l';
msgs: number;
u: {
_id: string;
username: string;
};
ts: string;
default: boolean;
}
/** Result structure for room creation (e.g. DM) */
export interface IRoomResultAPI {
......@@ -132,3 +147,8 @@ export interface IChannelResultAPI {
channel: IChannelAPI;
success: boolean;
}
/** Result structure for group creation */
export interface IGroupResultAPI {
group: IGroupAPI;
success: boolean;
}
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/utils/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["/** Payload structure for `chat.postMessage` endpoint */\nexport interface IMessageAPI {\n roomId: string // The room id of where the message is to be sent\n channel?: string // The channel name with the prefix in front of it\n text?: string // The text of the message to send, is optional because of attachments\n alias?: string // This will cause the messenger name to appear as the given alias, but username will still display\n emoji?: string // If provided, this will make the avatar on this message be an emoji\n avatar?: string // If provided, this will make the avatar use the provided image url\n attachments?: IAttachmentAPI[] // See attachment interface below\n}\n\n/** Payload structure for `chat.update` endpoint */\nexport interface IMessageUpdateAPI {\n roomId: string // The room id of where the message is\n msgId: string // The message id to update\n text: string // Updated text for the message\n}\n\n/** Message receipt returned after send (not the same as sent object) */\nexport interface IMessageReceiptAPI {\n _id: string // ID of sent message\n rid: string // Room ID of sent message\n alias: string // ?\n msg: string // Content of message\n parseUrls: boolean // URL parsing enabled on message hooks\n groupable: boolean // Grouping message enabled\n ts: string // Timestamp of message creation\n u: { // User details of sender\n _id: string\n username: string\n }\n _updatedAt: string // Time message last updated\n editedAt?: string // Time updated by edit\n editedBy?: { // User details for the updater\n _id: string\n username: string\n }\n}\n\n/** Payload structure for message attachments */\nexport interface IAttachmentAPI {\n color?: string // The color you want the order on the left side to be, any value background-css supports\n text?: string // The text to display for this attachment, it is different than the message text\n ts?: string // ISO timestamp, displays the time next to the text portion\n thumb_url?: string // An image that displays to the left of the text, looks better when this is relatively small\n message_link?: string // Only applicable if the ts is provided, as it makes the time clickable to this link\n collapsed?: boolean // Causes the image, audio, and video sections to be hiding when collapsed is true\n author_name?: string // Name of the author\n author_link?: string // Providing this makes the author name clickable and points to this link\n author_icon?: string // Displays a tiny icon to the left of the author's name\n title?: string // Title to display for this attachment, displays under the author\n title_link?: string // Providing this makes the title clickable, pointing to this link\n title_link_download_true?: string // When this is true, a download icon appears and clicking this saves the link to file\n image_url?: string // The image to display, will be “big” and easy to see\n audio_url?: string // Audio file to play, only supports what html audio does\n video_url?: string // Video file to play, only supports what html video does\n fields?: IAttachmentFieldAPI[] // An array of Attachment Field Objects\n}\n\n/**\n * Payload structure for attachment field object\n * The field property of the attachments allows for “tables” or “columns” to be displayed on messages\n */\nexport interface IAttachmentFieldAPI {\n short?: boolean // Whether this field should be a short field\n title: string // The title of this field\n value: string // The value of this field, displayed underneath the title value\n}\n\n/** Result structure for message endpoints */\nexport interface IMessageResultAPI {\n ts: number // Seconds since unix epoch\n channel: string // Name of channel without prefix\n message: IMessageReceiptAPI // Sent message\n success: boolean // Send status\n}\n\n/** User object structure for creation endpoints */\nexport interface INewUserAPI {\n email?: string // Email address\n name?: string // Full name\n password: string // User pass\n username: string // Username\n active?: true // Subscription is active\n roles?: string[] // Role IDs\n joinDefaultChannels?: boolean // Auto join channels marked as default\n requirePasswordChange?: boolean // Direct to password form on next login\n sendWelcomeEmail?: boolean // Send new credentials in email\n verified?: true // Email address verification status\n}\n\n/** User object structure for queries (not including admin access level) */\nexport interface IUserAPI {\n _id: string // MongoDB user doc ID\n type: string // user / bot ?\n status: string // online | offline\n active: boolean // Subscription is active\n name: string // Full name\n utcOffset: number // Hours off UTC/GMT\n username: string // Username\n}\n\n/** Result structure for user data request (by non-admin) */\nexport interface IUserResultAPI {\n user: IUserAPI // The requested user\n success: boolean // Status of request\n}\n\n/** Room object structure */\nexport interface IRoomAPI {\n _id: string // Room ID\n _updatedAt: string // ISO timestamp\n t: 'c' | 'p' | 'd' | 'l' // Room type (channel, private, direct, livechat)\n msgs: number // Count of messages in room\n ts: string // ISO timestamp (current time in room?)\n meta: {\n revision: number // ??\n created: number // Unix ms>epoch time\n version: number // ??\n }\n}\n\n/** Channel result schema */\nexport interface IChannelAPI {\n _id: string // Channel ID\n name: string // Channel name\n t: 'c' | 'p' | 'l' // Channel type (channel, private, livechat)\n msgs: number // Count of messages in room\n u: {\n _id: string // Owner user ID\n username: string // Owner username\n }\n ts: string // ISO timestamp (current time in room?)\n}\n\n/** Result structure for room creation (e.g. DM) */\nexport interface IRoomResultAPI {\n room: IRoomAPI\n success: boolean\n}\n\n/** Result structure for channel creation */\nexport interface IChannelResultAPI {\n channel: IChannelAPI\n success: boolean\n}\n"]}
\ No newline at end of file
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/utils/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["/** Payload structure for `chat.postMessage` endpoint */\nexport interface IMessageAPI {\n roomId: string // The room id of where the message is to be sent\n channel?: string // The channel name with the prefix in front of it\n text?: string // The text of the message to send, is optional because of attachments\n alias?: string // This will cause the messenger name to appear as the given alias, but username will still display\n emoji?: string // If provided, this will make the avatar on this message be an emoji\n avatar?: string // If provided, this will make the avatar use the provided image url\n attachments?: IAttachmentAPI[] // See attachment interface below\n}\n\n/** Payload structure for `chat.update` endpoint */\nexport interface IMessageUpdateAPI {\n roomId: string // The room id of where the message is\n msgId: string // The message id to update\n text: string // Updated text for the message\n}\n\n/** Message receipt returned after send (not the same as sent object) */\nexport interface IMessageReceiptAPI {\n _id: string // ID of sent message\n rid: string // Room ID of sent message\n alias: string // ?\n msg: string // Content of message\n parseUrls: boolean // URL parsing enabled on message hooks\n groupable: boolean // Grouping message enabled\n ts: string // Timestamp of message creation\n u: { // User details of sender\n _id: string\n username: string\n }\n _updatedAt: string // Time message last updated\n editedAt?: string // Time updated by edit\n editedBy?: { // User details for the updater\n _id: string\n username: string\n }\n}\n\n/** Payload structure for message attachments */\nexport interface IAttachmentAPI {\n color?: string // The color you want the order on the left side to be, any value background-css supports\n text?: string // The text to display for this attachment, it is different than the message text\n ts?: string // ISO timestamp, displays the time next to the text portion\n thumb_url?: string // An image that displays to the left of the text, looks better when this is relatively small\n message_link?: string // Only applicable if the ts is provided, as it makes the time clickable to this link\n collapsed?: boolean // Causes the image, audio, and video sections to be hiding when collapsed is true\n author_name?: string // Name of the author\n author_link?: string // Providing this makes the author name clickable and points to this link\n author_icon?: string // Displays a tiny icon to the left of the author's name\n title?: string // Title to display for this attachment, displays under the author\n title_link?: string // Providing this makes the title clickable, pointing to this link\n title_link_download_true?: string // When this is true, a download icon appears and clicking this saves the link to file\n image_url?: string // The image to display, will be “big” and easy to see\n audio_url?: string // Audio file to play, only supports what html audio does\n video_url?: string // Video file to play, only supports what html video does\n fields?: IAttachmentFieldAPI[] // An array of Attachment Field Objects\n}\n\n/**\n * Payload structure for attachment field object\n * The field property of the attachments allows for “tables” or “columns” to be displayed on messages\n */\nexport interface IAttachmentFieldAPI {\n short?: boolean // Whether this field should be a short field\n title: string // The title of this field\n value: string // The value of this field, displayed underneath the title value\n}\n\n/** Result structure for message endpoints */\nexport interface IMessageResultAPI {\n ts: number // Seconds since unix epoch\n channel: string // Name of channel without prefix\n message: IMessageReceiptAPI // Sent message\n success: boolean // Send status\n}\n\n/** User object structure for creation endpoints */\nexport interface INewUserAPI {\n email?: string // Email address\n name?: string // Full name\n password: string // User pass\n username: string // Username\n active?: true // Subscription is active\n roles?: string[] // Role IDs\n joinDefaultChannels?: boolean // Auto join channels marked as default\n requirePasswordChange?: boolean // Direct to password form on next login\n sendWelcomeEmail?: boolean // Send new credentials in email\n verified?: true // Email address verification status\n}\n\n/** User object structure for queries (not including admin access level) */\nexport interface IUserAPI {\n _id: string // MongoDB user doc ID\n type: string // user / bot ?\n status: string // online | offline\n active: boolean // Subscription is active\n name: string // Full name\n utcOffset: number // Hours off UTC/GMT\n username: string // Username\n}\n\n/** Result structure for user data request (by non-admin) */\nexport interface IUserResultAPI {\n user: IUserAPI // The requested user\n success: boolean // Status of request\n}\n\n/** Room object structure */\nexport interface IRoomAPI {\n _id: string // Room ID\n _updatedAt: string // ISO timestamp\n t: 'c' | 'p' | 'd' | 'l' // Room type (channel, private, direct, livechat)\n msgs: number // Count of messages in room\n ts: string // ISO timestamp (current time in room?)\n meta: {\n revision: number // ??\n created: number // Unix ms>epoch time\n version: number // ??\n }\n}\n\n/** Channel result schema */\nexport interface IChannelAPI {\n _id: string // Channel ID\n name: string // Channel name\n t: 'c' | 'p' | 'l' // Channel type (channel always c)\n msgs: number // Count of messages in room\n u: {\n _id: string // Owner user ID\n username: string // Owner username\n }\n ts: string // ISO timestamp (current time in room?)\n default: boolean // Is default channel\n}\n\n/** Group result schema */\nexport interface IGroupAPI {\n _id: string // Group ID\n name: string // Group name\n usernames: string[] // Users in group\n t: 'c' | 'p' | 'l' // Group type (private always p)\n msgs: number // Count of messages in room\n u: {\n _id: string // Owner user ID\n username: string // Owner username\n }\n ts: string // ISO timestamp (current time in room?)\n default: boolean // Is default channel (would be false)\n}\n\n/** Result structure for room creation (e.g. DM) */\nexport interface IRoomResultAPI {\n room: IRoomAPI\n success: boolean\n}\n\n/** Result structure for channel creation */\nexport interface IChannelResultAPI {\n channel: IChannelAPI\n success: boolean\n}\n\n/** Result structure for group creation */\nexport interface IGroupResultAPI {\n group: IGroupAPI\n success: boolean\n}\n"]}
\ No newline at end of file
import { IMessageUpdateAPI, IMessageResultAPI, INewUserAPI, IUserResultAPI, IRoomResultAPI, IChannelResultAPI } from './interfaces';
import { IMessageUpdateAPI, IMessageResultAPI, INewUserAPI, IUserResultAPI, IRoomResultAPI, IChannelResultAPI, IGroupResultAPI } from './interfaces';
import { IMessage } from '../config/messageInterfaces';
/** Define common attributes for DRY tests */
export declare const testChannelName = "tests";
export declare const testPrivateName = "p-tests";
/** Get information about a user */
export declare function userInfo(username: string): Promise<IUserResultAPI>;
/** Create a user and catch the error if they exist already */
......@@ -11,10 +12,17 @@ export declare function channelInfo(query: {
roomName?: string;
roomId?: string;
}): Promise<IChannelResultAPI>;
/** Get information about a private group */
export declare function privateInfo(query: {
roomName?: string;
roomId?: string;
}): Promise<IGroupResultAPI>;
/** Get the last messages sent to a channel (in last 10 minutes) */
export declare function lastMessages(roomId: string, count?: number): Promise<IMessage[]>;
/** Create a room for tests and catch the error if it exists already */
export declare function createChannel(name: string, members?: string[], readOnly?: boolean): Promise<IChannelResultAPI>;
/** Create a private group / room and catch if exists already */
export declare function createPrivate(name: string, members?: string[], readOnly?: boolean): Promise<IChannelResultAPI>;
/** Send message from mock user to channel for tests to listen and respond */
/** @todo Sometimes the post request completes before the change event emits
* the message to the streamer. That's why the interval is used for proof
......
......@@ -12,6 +12,7 @@ const api_1 = require("../lib/api");
const config_1 = require("./config");
/** Define common attributes for DRY tests */
exports.testChannelName = 'tests';
exports.testPrivateName = 'p-tests';
/** Get information about a user */
function userInfo(username) {
return __awaiter(this, void 0, void 0, function* () {
......@@ -33,6 +34,13 @@ function channelInfo(query) {
});
}
exports.channelInfo = channelInfo;
/** Get information about a private group */
function privateInfo(query) {
return __awaiter(this, void 0, void 0, function* () {
return api_1.get('groups.info', query, true);
});
}
exports.privateInfo = privateInfo;
/** Get the last messages sent to a channel (in last 10 minutes) */
function lastMessages(roomId, count = 1) {
return __awaiter(this, void 0, void 0, function* () {
......@@ -50,6 +58,13 @@ function createChannel(name, members = [], readOnly = false) {
});
}
exports.createChannel = createChannel;
/** Create a private group / room and catch if exists already */
function createPrivate(name, members = [], readOnly = false) {
return __awaiter(this, void 0, void 0, function* () {
return api_1.post('groups.create', { name, members, readOnly }, true);
});
}
exports.createPrivate = createPrivate;
/** Send message from mock user to channel for tests to listen and respond */
/** @todo Sometimes the post request completes before the change event emits
* the message to the streamer. That's why the interval is used for proof
......@@ -122,7 +137,7 @@ function setup() {
}
// Verify or create user for bot
let botInfo = yield userInfo(config_1.botUser.username);
if (!botInfo.success) {
if (!botInfo || !botInfo.success) {
console.log(`Bot user (${config_1.botUser.username}) not found`);
botInfo = yield createUser(config_1.botUser);
if (!botInfo.success) {
......@@ -137,7 +152,7 @@ function setup() {
}
// Verify or create mock user for talking to bot
let mockInfo = yield userInfo(config_1.mockUser.username);
if (!mockInfo.success) {
if (!mockInfo || !mockInfo.success) {
console.log(`Mock user (${config_1.mockUser.username}) not found`);
mockInfo = yield createUser(config_1.mockUser);
if (!mockInfo.success) {
......@@ -152,7 +167,7 @@ function setup() {
}
// Verify or create channel for tests
let testChannelInfo = yield channelInfo({ roomName: exports.testChannelName });
if (!testChannelInfo.success) {
if (!testChannelInfo || !testChannelInfo.success) {
console.log(`Test channel (${exports.testChannelName}) not found`);
testChannelInfo = yield createChannel(exports.testChannelName);
if (!testChannelInfo.success) {
......@@ -165,6 +180,23 @@ function setup() {
else {
console.log(`Test channel (${exports.testChannelName}) exists`);
}
// Verify or create private room for tests
let testPrivateInfo = yield channelInfo({ roomName: exports.testPrivateName });
if (!testPrivateInfo || !testPrivateInfo.success) {
console.log(`Test private room (${exports.testPrivateName}) not found`);
testPrivateInfo = yield createPrivate(exports.testPrivateName, [
config_1.apiUser.username, config_1.botUser.username, config_1.mockUser.username
]);
if (!testPrivateInfo.success) {
throw new Error(`Test private room (${exports.testPrivateName}) could not be created`);
}
else {
console.log(`Test private room (${exports.testPrivateName}) created`);
}
}
else {
console.log(`Test private room (${exports.testPrivateName}) exists`);
}
yield api_1.logout();
}
catch (e) {
......
This diff is collapsed.
......@@ -10,8 +10,10 @@ import * as methodCache from './methodCache'
const delay = (ms) => new Promise((resolve, reject) => setTimeout(resolve, ms))
let clock
let tId // test channel ID populated before tests start
let tName = utils.testChannelName // test channel name always the same
let tId
let pId
const tName = utils.testChannelName
const pName = utils.testPrivateName
silence() // suppress log during tests (disable this while developing tests)
......@@ -19,6 +21,8 @@ describe('driver', () => {
before(async () => {
const testChannel = await utils.channelInfo({ roomName: tName })
tId = testChannel.channel._id
const testPrivate = await utils.privateInfo({ roomName: pName })
pId = testPrivate.group._id
})
after(async () => {
await api.logout()
......@@ -367,6 +371,20 @@ describe('driver', () => {
// expect(callback.firstCall.args[2].roomName).to.equal(undefined)
// })
})
describe('.getRoomId', () => {
beforeEach(async () => {
await driver.connect()
await driver.login()
})
it('returns the ID for a channel by ID', async () => {
const room = await driver.getRoomId(tName)
expect(room).to.equal(tId)
})
it('returns the ID for a private room name', async () => {
const room = await driver.getRoomId(pName)
expect(room).to.equal(pId)
})
})
describe('.getRoomName', () => {
beforeEach(async () => {
await driver.connect()
......@@ -376,6 +394,10 @@ describe('driver', () => {
const room = await driver.getRoomName(tId)
expect(room).to.equal(tName)
})
it('returns the name for a private group by ID', async () => {
const room = await driver.getRoomName(pId)
expect(room).to.equal(pName)