계정 아이콘 등록과 목록 내리기 제한을 조정한다

This commit is contained in:
2026-09-24 15:46:11 +00:00
parent 4bf812b601
commit 8823434610
9 changed files with 138 additions and 153 deletions
@@ -156,7 +156,7 @@ integration('account icon daily PostgreSQL CAS', () => {
});
});
it('serializes the five-slot library and preserves retired rows', async () => {
it('serializes the five-slot library without an upload cooldown and preserves retired rows', async () => {
const users = createPostgresUserRepository(db);
const start = new Date('2026-08-03T00:00:00.000Z');
await db.userIcon.deleteMany({ where: { userId } });
@@ -166,35 +166,29 @@ integration('account icon daily PostgreSQL CAS', () => {
});
for (let index = 0; index < 5; index += 1) {
const now = new Date(start.getTime() + index * 86_400_000);
const now = new Date(start.getTime() + index);
await expect(
users.addIconForWindow(
userId,
`postgres-library-${index}.png`,
1,
now,
new Date(now.getTime() - 86_400_000),
5
)
users.addIconForWindow(userId, `postgres-library-${index}.png`, 1, now, 5)
).resolves.toMatchObject({ ok: true });
}
await expect(
users.addIconForWindow(
userId,
'postgres-library-sixth.png',
1,
new Date(start.getTime() + 5 * 86_400_000),
new Date(start.getTime() + 4 * 86_400_000),
5
)
users.addIconForWindow(userId, 'postgres-library-sixth.png', 1, new Date(start.getTime() + 5), 5)
).resolves.toEqual({ ok: false, reason: 'LIMIT' });
const icons = await users.listIcons(userId);
const retiredAt = new Date(start.getTime() + 6 * 86_400_000);
const retiredAt = new Date(start.getTime() + 6);
await expect(
users.retireIconForWindow(userId, icons[0]!.id, retiredAt, new Date(retiredAt.getTime() - 7 * 86_400_000))
users.retireIconForWindow(userId, icons[0]!.id, retiredAt, new Date(retiredAt.getTime() - 86_400_000))
).resolves.toMatchObject({ ok: true });
await expect(users.listIcons(userId)).resolves.toHaveLength(4);
const tooSoon = new Date(retiredAt.getTime() + 86_400_000 - 1);
await expect(
users.retireIconForWindow(userId, icons[1]!.id, tooSoon, new Date(tooSoon.getTime() - 86_400_000))
).resolves.toEqual({ ok: false, reason: 'COOLDOWN' });
const allowedAt = new Date(retiredAt.getTime() + 86_400_000);
await expect(
users.retireIconForWindow(userId, icons[1]!.id, allowedAt, new Date(allowedAt.getTime() - 86_400_000))
).resolves.toMatchObject({ ok: true });
await expect(users.listIcons(userId)).resolves.toHaveLength(3);
await expect(users.listIcons(userId, true)).resolves.toContainEqual(
expect.objectContaining({ picture: 'postgres-library-0.png', retiredAt: retiredAt.toISOString() })
);