Skip to content

Commit ff246a1

Browse files
authored
test: fix scheduled test (#1658)
## Goal This PR attempts to fix the scheduled test by adding the build step. **Changes:** - Import from the built bundle instead of trying to access internal utils - Created a simple UUID function for testing purposes
1 parent aadb0f2 commit ff246a1

File tree

17 files changed

+335
-262
lines changed

17 files changed

+335
-262
lines changed

.github/workflows/scheduled_test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ jobs:
1414

1515
- uses: ./.github/actions/setup-node
1616

17+
- name: Build project
18+
run: yarn build
19+
1720
- name: Run test
1821
env:
1922
API_KEY: ${{ secrets.TS_TEST_API_KEY }}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@
9797
"eslint-fix": "yarn run eslint --fix",
9898
"test": "yarn test-unit",
9999
"testwatch": "NODE_ENV=test nodemon ./node_modules/.bin/mocha --timeout 20000 --require test-entry.js test/test.js",
100-
"test-types": "node test/typescript/index.js && tsc --esModuleInterop true --noEmit true --strictNullChecks true --noImplicitAny true --strict true test/typescript/*.ts",
100+
"test-types": "yarn run-test-types && yarn run-types-gen",
101+
"run-test-types": "node test/typescript/index.js",
102+
"run-types-gen": "tsc --esModuleInterop true --noEmit true --strictNullChecks true --noImplicitAny true --strict true test/typescript/*.ts",
101103
"test-unit": "vitest",
102104
"test-coverage": "vitest run --coverage",
103105
"fix-staged": "lint-staged --config .lintstagedrc.fix.json --concurrent 1",

src/client.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ import type {
220220
UpdatePollOptionAPIResponse,
221221
UpdateReminderOptions,
222222
UpdateSegmentData,
223+
UpdateUsersAPIResponse,
223224
UpsertPushPreferencesResponse,
224225
UserCustomEvent,
225226
UserFilters,
@@ -2396,11 +2397,9 @@ export class StreamChat {
23962397
userMap[userObject.id] = userObject;
23972398
}
23982399

2399-
return await this.post<
2400-
APIResponse & {
2401-
users: { [key: string]: UserResponse };
2402-
}
2403-
>(this.baseURL + '/users', { users: userMap });
2400+
return await this.post<UpdateUsersAPIResponse>(this.baseURL + '/users', {
2401+
users: userMap,
2402+
});
24042403
}
24052404

24062405
/**
@@ -2448,11 +2447,7 @@ export class StreamChat {
24482447
}
24492448
}
24502449

2451-
return await this.patch<
2452-
APIResponse & {
2453-
users: { [key: string]: UserResponse };
2454-
}
2455-
>(this.baseURL + '/users', { users });
2450+
return await this.patch<UpdateUsersAPIResponse>(this.baseURL + '/users', { users });
24562451
}
24572452

24582453
async deleteUser(

src/types.ts

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export type Unpacked<T> = T extends (infer U)[]
7171

7272
export type APIResponse = {
7373
duration: string;
74+
blocklist?: BlockListResponse;
7475
};
7576

7677
export type TranslateResponse = {
@@ -80,6 +81,8 @@ export type TranslateResponse = {
8081

8182
export type AppSettingsAPIResponse = APIResponse & {
8283
app?: {
84+
id?: string | number;
85+
allow_multi_user_devices?: boolean;
8386
// TODO
8487
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8588
call_types: any;
@@ -108,6 +111,9 @@ export type AppSettingsAPIResponse = APIResponse & {
108111
read_events?: boolean;
109112
replies?: boolean;
110113
search?: boolean;
114+
shared_locations?: boolean;
115+
skip_last_msg_update_for_system_msgs?: boolean;
116+
count_messages?: boolean;
111117
typing_events?: boolean;
112118
updated_at?: string;
113119
uploads?: boolean;
@@ -140,12 +146,28 @@ export type AppSettingsAPIResponse = APIResponse & {
140146
type: string;
141147
}>;
142148
grants?: Record<string, string[]>;
149+
guest_user_creation_disabled?: boolean;
143150
image_moderation_enabled?: boolean;
151+
image_moderation_labels?: string[];
144152
image_upload_config?: FileUploadConfig;
153+
allowed_flag_reasons?: string[];
154+
max_aggregated_activities_length?: number;
155+
moderation_bulk_submit_action_enabled?: boolean;
156+
moderation_dashboard_preferences?: Record<string, unknown> | null;
157+
moderation_enabled?: boolean;
158+
moderation_llm_configurability_enabled?: boolean;
159+
moderation_multitenant_blocklist_enabled?: boolean;
160+
moderation_webhook_url?: string;
145161
multi_tenant_enabled?: boolean;
146162
name?: string;
147163
organization?: string;
148164
permission_version?: string;
165+
/**
166+
* The placement of the app in the form of `${region}.${shard}`.
167+
* Examples: "us-east.c1", "dublin.c3", "singapore.c2"
168+
* Note: The backend may add/remove regions or shards occasionally.
169+
*/
170+
placement?: string;
149171
policies?: Record<string, Policy[]>;
150172
poll_enabled?: boolean;
151173
push_notifications?: {
@@ -167,6 +189,8 @@ export type AppSettingsAPIResponse = APIResponse & {
167189
sqs_url?: string;
168190
suspended?: boolean;
169191
suspended_explanation?: string;
192+
use_hook_v2?: boolean;
193+
user_response_time_enabled?: boolean;
170194
user_search_disallowed_roles?: string[] | null;
171195
video_provider?: string;
172196
webhook_events?: Array<string>;
@@ -788,6 +812,7 @@ export type OwnUserBase = {
788812
privacy_settings?: PrivacySettings;
789813
push_preferences?: PushPreference;
790814
roles?: string[];
815+
total_unread_count_by_team?: Record<string, number> | null;
791816
};
792817

793818
export type OwnUserResponse = UserResponse & OwnUserBase;
@@ -884,10 +909,12 @@ export type UpdateMessageAPIResponse = APIResponse & {
884909

885910
export type UsersAPIResponse = APIResponse & {
886911
users: Array<UserResponse>;
912+
membership_deletion_task_id?: string;
887913
};
888914

889915
export type UpdateUsersAPIResponse = APIResponse & {
890916
users: { [key: string]: UserResponse };
917+
membership_deletion_task_id?: string;
891918
};
892919

893920
export type UserResponse = CustomUserData & {
@@ -910,7 +937,7 @@ export type UserResponse = CustomUserData & {
910937
role?: string;
911938
shadow_banned?: boolean;
912939
teams?: string[];
913-
teams_role?: TeamsRole;
940+
teams_role?: TeamsRole | null;
914941
updated_at?: string;
915942
username?: string;
916943
avg_response_time?: number;
@@ -1034,11 +1061,13 @@ export type CreateChannelOptions = {
10341061
reminders?: boolean;
10351062
replies?: boolean;
10361063
search?: boolean;
1064+
shared_locations?: boolean;
10371065
skip_last_msg_update_for_system_msgs?: boolean;
10381066
typing_events?: boolean;
10391067
uploads?: boolean;
10401068
url_enrichment?: boolean;
10411069
user_message_reminders?: boolean;
1070+
count_messages?: boolean;
10421071
};
10431072

10441073
export type CreateCommandOptions = {
@@ -1066,9 +1095,8 @@ export type DeactivateUsersOptions = {
10661095
export type NewMemberPayload = CustomMemberData &
10671096
Pick<ChannelMemberResponse, 'user_id' | 'channel_role'>;
10681097

1069-
export type Thresholds = Record<
1070-
'explicit' | 'spam' | 'toxic',
1071-
Partial<{ block: number; flag: number }>
1098+
export type Thresholds = Partial<
1099+
Record<'explicit' | 'spam' | 'toxic', Partial<{ block: number; flag: number }>>
10721100
>;
10731101

10741102
export type BlockListOptions = {
@@ -1172,6 +1200,7 @@ export type UpdateChannelTypeResponse = {
11721200
reminders: boolean;
11731201
replies: boolean;
11741202
search: boolean;
1203+
shared_locations: boolean;
11751204
skip_last_msg_update_for_system_msgs: boolean;
11761205
typing_events: boolean;
11771206
updated_at: string;
@@ -1182,9 +1211,11 @@ export type UpdateChannelTypeResponse = {
11821211
blocklist?: string;
11831212
blocklist_behavior?: BlocklistBehavior;
11841213
blocklists?: BlockListOptions[];
1214+
message_retention?: string;
11851215
partition_size?: number;
11861216
partition_ttl?: string;
11871217
count_messages?: boolean;
1218+
user_message_reminders?: boolean;
11881219
};
11891220

11901221
export type GetChannelTypeResponse = {
@@ -1210,6 +1241,7 @@ export type GetChannelTypeResponse = {
12101241
reminders: boolean;
12111242
replies: boolean;
12121243
search: boolean;
1244+
shared_locations: boolean;
12131245
skip_last_msg_update_for_system_msgs: boolean;
12141246
typing_events: boolean;
12151247
updated_at: string;
@@ -1220,9 +1252,11 @@ export type GetChannelTypeResponse = {
12201252
blocklist?: string;
12211253
blocklist_behavior?: BlocklistBehavior;
12221254
blocklists?: BlockListOptions[];
1255+
message_retention?: string;
12231256
partition_size?: number;
12241257
partition_ttl?: string;
12251258
count_messages?: boolean;
1259+
user_message_reminders?: boolean;
12261260
};
12271261

12281262
export type UpdateChannelOptions = Partial<{
@@ -2049,7 +2083,7 @@ export type UserFilters = QueryFilters<
20492083
}
20502084
>;
20512085

2052-
export type InviteStatus = 'pending' | 'accepted' | 'rejected';
2086+
export type InviteStatus = 'pending' | 'accepted' | 'rejected' | 'member';
20532087

20542088
// https://getstream.io/chat/docs/react/channel_member/#update-channel-members
20552089
export type MemberFilters = QueryFilters<
@@ -2373,6 +2407,8 @@ export type BlockList = {
23732407
team?: string;
23742408
type?: string;
23752409
validate?: boolean;
2410+
is_leet_check_enabled?: boolean;
2411+
is_plural_check_enabled?: boolean;
23762412
};
23772413

23782414
export type ChannelConfig = ChannelConfigFields &

src/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export function isOwnUserBaseProperty(property: string) {
104104
privacy_settings: true,
105105
roles: true,
106106
push_preferences: true,
107+
total_unread_count_by_team: true,
107108
};
108109

109110
return ownUserBaseProperties[property as keyof OwnUserBase];

0 commit comments

Comments
 (0)