feat(web): support group avatar updates
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import { canEditGroupAvatar, groupAvatarError, privateChatOption, privateChatOptions } from '../src/features/groups/group-settings.ts';
|
||||
|
||||
test('member private chat labels keep the existing boolean mapping', () => {
|
||||
assert.deepEqual(privateChatOptions, [
|
||||
{ value: 'all', label: '全员' },
|
||||
{ value: 'friends', label: '好友添加' },
|
||||
]);
|
||||
assert.equal(privateChatOption(true), 'all');
|
||||
assert.equal(privateChatOption(false), 'friends');
|
||||
});
|
||||
|
||||
test('server profile permission overrides role, with role fallback only when absent', () => {
|
||||
assert.equal(canEditGroupAvatar(true, 'member'), true);
|
||||
assert.equal(canEditGroupAvatar(false, 'owner'), false);
|
||||
assert.equal(canEditGroupAvatar(false, 'admin'), false);
|
||||
assert.equal(canEditGroupAvatar(undefined, 'owner'), true);
|
||||
assert.equal(canEditGroupAvatar(undefined, 'admin'), true);
|
||||
assert.equal(canEditGroupAvatar(undefined, 'member'), false);
|
||||
});
|
||||
|
||||
test('group avatar accepts images up to 5MB and rejects other files', () => {
|
||||
assert.equal(groupAvatarError({ type: 'image/png', size: 5 * 1024 * 1024 }), null);
|
||||
assert.equal(groupAvatarError({ type: 'text/plain', size: 10 }), '请选择图片文件');
|
||||
assert.equal(groupAvatarError({ type: 'image/jpeg', size: 5 * 1024 * 1024 + 1 }), '图片大小不能超过 5MB');
|
||||
});
|
||||
Reference in New Issue
Block a user