Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

test(api): escape bad response bodies, drop unused helpers

Hampus0292aa200962
diff --git a/fluxer_api/src/api/channel/tests/ChannelTestUtils.ts b/fluxer_api/src/api/channel/tests/ChannelTestUtils.ts
index 459f80fde..c7770fb8e 100644
--- a/fluxer_api/src/api/channel/tests/ChannelTestUtils.ts
+++ b/fluxer_api/src/api/channel/tests/ChannelTestUtils.ts
@@ -207,34 +207,6 @@ export async function removeRecipientFromGroupDm(
await createBuilder(harness, token).delete(`/channels/${channelId}/recipients/${userId}`).expect(204).execute();
}
-interface SeedPrivateChannelsResult {
- group_dms: Array<{
- channel_id: string;
- last_message_id: string;
- }>;
- dms: Array<{
- channel_id: string;
- last_message_id: string;
- }>;
-}
-
-export async function seedPrivateChannels(
- harness: ApiTestHarness,
- _token: string,
- userId: string,
- params: {
- group_dm_count?: number;
- dm_count?: number;
- recipients?: Array<string>;
- clear_existing?: boolean;
- },
-): Promise<SeedPrivateChannelsResult> {
- return createBuilder<SeedPrivateChannelsResult>(harness, '')
- .post(`/test/users/${userId}/private-channels`)
- .body(params)
- .execute();
-}
-
export {
acceptInvite,
addMemberRole,
diff --git a/fluxer_api/src/api/message/tests/MessageTestUtils.ts b/fluxer_api/src/api/message/tests/MessageTestUtils.ts
index c0607b97d..31801de79 100644
--- a/fluxer_api/src/api/message/tests/MessageTestUtils.ts
+++ b/fluxer_api/src/api/message/tests/MessageTestUtils.ts
@@ -46,18 +46,6 @@ export async function deleteMessage(
.expect(204)
.execute();
}
-export async function pinMessage(
- harness: ApiTestHarness,
- token: string,
- channelId: string,
- messageId: string,
-): Promise<void> {
- await createBuilder<void>(harness, token)
- .put(`/channels/${channelId}/pins/${messageId}`)
- .body(null)
- .expect(204)
- .execute();
-}
export async function createGuild(harness: ApiTestHarness, token: string, name: string): Promise<GuildResponse> {
const guild = await createBuilder<GuildResponse>(harness, token)
.post('/guilds')
diff --git a/fluxer_api/src/api/test/TestRequestBuilder.ts b/fluxer_api/src/api/test/TestRequestBuilder.ts
index 11b082f08..a384113f8 100644
--- a/fluxer_api/src/api/test/TestRequestBuilder.ts
+++ b/fluxer_api/src/api/test/TestRequestBuilder.ts
@@ -87,7 +87,7 @@ export class TestRequestBuilder<TResponse = unknown> {
try {
json = JSON.parse(text) as TResponse;
} catch {
- throw new Error(`Failed to parse response as JSON: ${text}`);
+ throw new Error(`Failed to parse response as JSON: ${JSON.stringify(text)}`);
}
if (this.expectedErrorCode !== null) {
const actualCode = (
@@ -129,7 +129,7 @@ export class TestRequestBuilder<TResponse = unknown> {
try {
json = JSON.parse(text) as TResponse;
} catch {
- throw new Error(`Failed to parse response as JSON: ${text}`);
+ throw new Error(`Failed to parse response as JSON: ${JSON.stringify(text)}`);
}
}
return {response, json};