修复部署与反代初始化回归测试
Some checks are pending
Security Checks / security (push) Waiting to run

This commit is contained in:
smail 2026-10-03 05:02:42 +08:00
parent 3ee4593e9f
commit 4d3d46c96e
2 changed files with 26 additions and 5 deletions

View File

@ -83,7 +83,8 @@ test('部署和启动必须完整构建、验证产物且不覆盖运行配置',
const start = await read('deploy/start-dev.ps1')
assert.ok(deploy.indexOf("'build.ps1'") < deploy.indexOf('Copy-Item'))
assert.match(deploy, /verify --deployed/)
assert.match(deploy, /deployment-history/)
assert.doesNotMatch(deploy, /deployment-history/)
assert.match(deploy, /Remove-Item -LiteralPath \$item\.FullName -Recurse -Force/)
assert.doesNotMatch(deploy, /Copy-Item[^\n]*(config|data|ssl)/)
assert.doesNotMatch(start, /SkipBuild|SkipFrontend/)
assert.match(start, /\$env:SMAIL_ROOT = \$runtime/)

View File

@ -16,19 +16,38 @@ const createPage = compileFunction(
function fixture(tlsMode, type = '2') {
const requests = []
const messages = []
const window = { location: { href: 'https://mail.example.test/setup' } }
let scheduledTimer = null
const window = {
location: { href: 'https://mail.example.test/setup' },
setTimeout: callback => {
scheduledTimer = callback
return 1
},
clearTimeout: () => {
scheduledTimer = null
}
}
const page = createPage(computed, () => {}, reactive, ref,
{ error: message => messages.push(message) }, {}, {}, {}, {
post: async (path, payload) => {
requests.push({ path, payload })
return { errorNo: 0, data: { tlsMode, type, port: 8080 } }
}
}, () => 'https://mail.example.test/', () => assert.fail('外部证书不应探测签发状态'), window)
return { page, requests, messages, window }
}, () => 'https://mail.example.test/', () => true, window)
return {
page,
requests,
messages,
window,
runScheduledTimer: async () => {
scheduledTimer = null
await page.checkStatus()
}
}
}
test('反代初始化强制导入外部证书,即使旧配置仍是自动 DNS 类型', async () => {
const { page, requests, messages, window } = fixture('proxy')
const { page, requests, messages, window, runScheduledTimer } = fixture('proxy')
await page.getSSLConfig()
assert.equal(page.proxyHTTPS.value, true)
assert.equal(page.sslSettings.type, '1')
@ -51,6 +70,7 @@ test('反代初始化强制导入外部证书,即使旧配置仍是自动 DNS
}
})
assert.equal(requests.length, 2)
await runScheduledTimer()
assert.equal(window.location.href, 'https://mail.example.test/')
assert.deepEqual(messages, [])
})