From 4d3d46c96e12d7c16849dee37fed660602d0cdb4 Mon Sep 17 00:00:00 2001 From: smail Date: Sat, 3 Oct 2026 05:02:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E7=BD=B2=E4=B8=8E?= =?UTF-8?q?=E5=8F=8D=E4=BB=A3=E5=88=9D=E5=A7=8B=E5=8C=96=E5=9B=9E=E5=BD=92?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/frontend/runtime-deployment.test.mjs | 3 ++- test/frontend/setup-ssl-proxy.test.mjs | 28 +++++++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/test/frontend/runtime-deployment.test.mjs b/test/frontend/runtime-deployment.test.mjs index 36ca4c4..eee8b72 100644 --- a/test/frontend/runtime-deployment.test.mjs +++ b/test/frontend/runtime-deployment.test.mjs @@ -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/) diff --git a/test/frontend/setup-ssl-proxy.test.mjs b/test/frontend/setup-ssl-proxy.test.mjs index 7bfab99..ce00743 100644 --- a/test/frontend/setup-ssl-proxy.test.mjs +++ b/test/frontend/setup-ssl-proxy.test.mjs @@ -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, []) })