feat: refine forum settings uploads and transitions
This commit is contained in:
1 parent
e85ced7319
commit
f5d173350b
23 files changed
+985
-54
No files matched your search
@@ -117,6 +117,38 @@ test('获取论坛设置', async () => {
|
||||
const { status, data } = await api('/settings');
|
||||
assert.equal(status, 200);
|
||||
assert.equal(data.forum_name, '测试论坛');
|
||||
assert.match(data.version_commit, /^(?:[0-9a-f]{7}|unknown)$/);
|
||||
assert.equal(data.favicon_object, undefined);
|
||||
});
|
||||
|
||||
test('未登录用户不能上传网站图标', async () => {
|
||||
const form = new FormData();
|
||||
form.append('file', new Blob([Buffer.from('not-an-image')]), 'favicon.png');
|
||||
const res = await fetch(BASE + '/api/admin/favicon', { method: 'POST', body: form });
|
||||
assert.equal(res.status, 401);
|
||||
});
|
||||
|
||||
test('管理员上传网站图标', async () => {
|
||||
const png = Buffer.from(
|
||||
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=',
|
||||
'base64'
|
||||
);
|
||||
const form = new FormData();
|
||||
form.append('file', new Blob([png], { type: 'image/png' }), 'favicon.png');
|
||||
const res = await fetch(BASE + '/api/admin/favicon', {
|
||||
method: 'POST',
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
body: form,
|
||||
});
|
||||
const data = await res.json();
|
||||
assert.equal(res.status, 200);
|
||||
assert.match(data.favicon_url, /^\/uploads\/forumlify-favicon-[\w-]+\.png$/);
|
||||
assert.match(data.favicon_version, /^\d+$/);
|
||||
|
||||
const settings = await api('/settings');
|
||||
assert.equal(settings.data.favicon_url, data.favicon_url);
|
||||
assert.equal(settings.data.favicon_version, data.favicon_version);
|
||||
assert.equal(settings.data.favicon_object, undefined);
|
||||
});
|
||||
|
||||
test('添加友情链接', async () => {
|
||||
|
||||
Reference in new issue
Block a user