chore(repo): remove dead code and useless tests (#3375)

This commit is contained in:
Hampus authored and GitHub committed 2026-10-10 21:43:29 +02:00
1 parent 7e177a1c90
commit 1cd62eb661
1391 files changed
+783 -120415

No files matched your search

@@ -10,7 +10,6 @@ import {
import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness';
import {HTTP_STATUS} from '@app/api/test/TestConstants';
import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder';
import {getExpiryBucket} from '@app/api/utils/AttachmentDecay';
import {MessageReferenceTypes} from '@fluxer/constants/src/ChannelConstants';
import {afterEach, beforeEach, describe, expect, test} from 'vitest';
@@ -25,12 +24,6 @@ interface AttachmentDecayRow {
status: string | null;
}
interface AttachmentDecayQueryResponse {
rows: Array<AttachmentDecayRow>;
has_more: boolean;
count: number;
}
describe('Attachment Decay', () => {
let harness: ApiTestHarness;
beforeEach(async () => {
@@ -107,99 +100,6 @@ describe('Attachment Decay', () => {
expect(decayResponse.row?.message_id).toBe(json.id);
}
});
test('should seed attachment decay rows via test endpoint', async () => {
const account = await createTestAccount(harness);
const guild = await createGuild(harness, account.token, 'Seed Test Guild');
const channelId = guild.system_channel_id!;
const futureExpiryDate = new Date(Date.now() + 30 * 24 * 60 * 60 * 1000);
const futureExpiry = futureExpiryDate.toISOString();
const bucket = getExpiryBucket(futureExpiryDate);
await createBuilderWithoutAuth(harness)
.post('/test/attachment-decay/rows')
.body({
rows: [
{
attachment_id: '123456789012345678',
channel_id: channelId,
message_id: '234567890123456789',
filename: 'seeded.png',
size_bytes: '1024',
expires_at: futureExpiry,
},
],
})
.execute();
const queryTimeAfterExpiry = new Date(futureExpiryDate.getTime() + 1000).toISOString();
const queryResponse = await createBuilderWithoutAuth<AttachmentDecayQueryResponse>(harness)
.post('/test/attachment-decay/query')
.body({
bucket,
limit: 100,
current_time: queryTimeAfterExpiry,
})
.execute();
expect(queryResponse.rows.some((r) => r.attachment_id === '123456789012345678')).toBe(true);
});
test('should clear attachment decay data', async () => {
const account = await createTestAccount(harness);
const guild = await createGuild(harness, account.token, 'Clear Test Guild');
const channelId = guild.system_channel_id!;
const expiry = new Date(Date.now() + 1000).toISOString();
await createBuilderWithoutAuth(harness)
.post('/test/attachment-decay/rows')
.body({
rows: [
{
attachment_id: '111111111111111111',
channel_id: channelId,
message_id: '222222222222222222',
filename: 'clear-test.png',
size_bytes: '512',
expires_at: expiry,
},
],
})
.execute();
await createBuilderWithoutAuth(harness).post('/test/attachment-decay/clear').body({}).execute();
const checkResponse = await createBuilderWithoutAuth<{
row: AttachmentDecayRow | null;
}>(harness)
.get('/test/attachment-decay/111111111111111111')
.execute();
expect(checkResponse.row).toBeNull();
});
test('should include decay metadata in message response', async () => {
const account = await createTestAccount(harness);
const guild = await createGuild(harness, account.token, 'Metadata Test Guild');
const channel = await createChannel(harness, account.token, guild.id, 'test-channel');
const channelId = guild.system_channel_id ?? channel.id;
const fileData = loadFixture('yeah.png');
const {response, json} = await sendMessageWithAttachments(
harness,
account.token,
channelId,
{
content: 'Decay metadata test',
attachments: [{id: 0, filename: 'metadata.png'}],
},
[{index: 0, filename: 'metadata.png', data: fileData}],
);
expect(response.status).toBe(HTTP_STATUS.OK);
const messageResponse = await createBuilder<{
id: string;
attachments: Array<{
id: string;
filename: string;
url: string;
}>;
}>(harness, account.token)
.get(`/channels/${channelId}/messages/${json.id}`)
.execute();
expect(messageResponse.attachments).toBeDefined();
expect(messageResponse.attachments).not.toBeNull();
expect(messageResponse.attachments!.length).toBe(1);
expect(messageResponse.attachments![0].url).toBeTruthy();
});
test('should configure decay metadata for forwarded snapshot attachments', async () => {
const account = await createTestAccount(harness);
const guild = await createGuild(harness, account.token, 'Forwarded Decay Test Guild');
@@ -252,74 +152,4 @@ describe('Attachment Decay', () => {
expect(decayResponse.row?.channel_id).toBe(destinationChannel.id);
expect(decayResponse.row?.message_id).toBe(forwardedMessage.id);
});
test('should handle attachment with different sizes', async () => {
const account = await createTestAccount(harness);
const guild = await createGuild(harness, account.token, 'Size Test Guild');
const channel = await createChannel(harness, account.token, guild.id, 'test-channel');
const channelId = guild.system_channel_id ?? channel.id;
const smallFile = loadFixture('yeah.png');
const largeFile = loadFixture('animated.gif');
const smallResult = await sendMessageWithAttachments(
harness,
account.token,
channelId,
{
content: 'Small file',
attachments: [{id: 0, filename: 'small.png'}],
},
[{index: 0, filename: 'small.png', data: smallFile}],
);
const largeResult = await sendMessageWithAttachments(
harness,
account.token,
channelId,
{
content: 'Large file',
attachments: [{id: 0, filename: 'large.gif'}],
},
[{index: 0, filename: 'large.gif', data: largeFile}],
);
expect(smallResult.response.status).toBe(HTTP_STATUS.OK);
expect(largeResult.response.status).toBe(HTTP_STATUS.OK);
const smallDecay = await createBuilderWithoutAuth<{
row: AttachmentDecayRow | null;
}>(harness)
.get(`/test/attachment-decay/${smallResult.json.attachments![0].id}`)
.execute();
const largeDecay = await createBuilderWithoutAuth<{
row: AttachmentDecayRow | null;
}>(harness)
.get(`/test/attachment-decay/${largeResult.json.attachments![0].id}`)
.execute();
expect(smallDecay.row).not.toBeNull();
expect(largeDecay.row).not.toBeNull();
const smallSize = BigInt(smallDecay.row?.size_bytes ?? '0');
const largeSize = BigInt(largeDecay.row?.size_bytes ?? '0');
expect(largeSize).toBeGreaterThan(smallSize);
});
test('should track filename in decay metadata', async () => {
const account = await createTestAccount(harness);
const guild = await createGuild(harness, account.token, 'Filename Test Guild');
const channel = await createChannel(harness, account.token, guild.id, 'test-channel');
const channelId = guild.system_channel_id ?? channel.id;
const fileData = loadFixture('yeah.png');
const {response, json} = await sendMessageWithAttachments(
harness,
account.token,
channelId,
{
content: 'Filename tracking test',
attachments: [{id: 0, filename: 'unique-filename-test.png'}],
},
[{index: 0, filename: 'unique-filename-test.png', data: fileData}],
);
expect(response.status).toBe(HTTP_STATUS.OK);
const decayResponse = await createBuilderWithoutAuth<{
row: AttachmentDecayRow | null;
}>(harness)
.get(`/test/attachment-decay/${json.attachments![0].id}`)
.execute();
expect(decayResponse.row).not.toBeNull();
expect(decayResponse.row?.filename).toBe('unique-filename-test.png');
});
});