mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-07-01 20:51:34 +08:00
feat(update): integrate official site update flow
This commit is contained in:
@@ -6,6 +6,7 @@ import path from 'node:path'
|
||||
|
||||
import {
|
||||
buildOpenclawPathConflictRecords,
|
||||
resolveOpenclawCliInput,
|
||||
quarantineOpenclawPathForWeb,
|
||||
readJsonFileRelaxed,
|
||||
} from '../scripts/dev-api.js'
|
||||
@@ -93,3 +94,22 @@ test('Web API CLI 隔离拒绝非 openclaw 文件', () => {
|
||||
fs.rmSync(tmp, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
|
||||
test('Web API Windows CLI 解析不会绑定无扩展名 openclaw shim', (t) => {
|
||||
if (process.platform !== 'win32') {
|
||||
t.skip('Windows only')
|
||||
return
|
||||
}
|
||||
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'clawpanel-cli-shim-'))
|
||||
try {
|
||||
const bare = path.join(tmp, 'openclaw')
|
||||
fs.writeFileSync(bare, '#!/bin/sh\n')
|
||||
assert.equal(resolveOpenclawCliInput(bare), null)
|
||||
|
||||
const cmd = path.join(tmp, 'openclaw.cmd')
|
||||
fs.writeFileSync(cmd, '@echo off\r\n')
|
||||
assert.equal(resolveOpenclawCliInput(bare), cmd)
|
||||
} finally {
|
||||
fs.rmSync(tmp, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
|
||||
42
tests/site-message-center.test.js
Normal file
42
tests/site-message-center.test.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
|
||||
import { normalizeSiteMessagePayload } from '../src/components/site-message-center.js'
|
||||
|
||||
test('官网公告接口按 displayType 分流并过滤非客户端 surface', () => {
|
||||
const normalized = normalizeSiteMessagePayload({
|
||||
announcements: [
|
||||
{
|
||||
id: 1,
|
||||
displayType: 'notification',
|
||||
targetSurface: 'client',
|
||||
level: 'success',
|
||||
title: '客户端通知',
|
||||
body: '通知正文',
|
||||
dismissKey: 'client-notification',
|
||||
updatedAt: '2026-06-06T03:21:10Z',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
displayType: 'announcement',
|
||||
targetSurface: 'all',
|
||||
level: 'warning',
|
||||
title: '系统公告',
|
||||
body: '公告正文',
|
||||
dismissKey: 'system-announcement',
|
||||
updatedAt: '2026-06-06T03:22:10Z',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
displayType: 'notification',
|
||||
targetSurface: 'home',
|
||||
title: '官网首页通知',
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
assert.equal(normalized.notifications.length, 1)
|
||||
assert.equal(normalized.announcements.length, 1)
|
||||
assert.equal(normalized.notifications[0].title, '客户端通知')
|
||||
assert.equal(normalized.announcements[0].title, '系统公告')
|
||||
})
|
||||
Reference in New Issue
Block a user