From 6f8a62a092c73936e5d88a70725456e8081352a2 Mon Sep 17 00:00:00 2001 From: daniellee2015 Date: Sun, 26 Apr 2026 18:37:58 +0800 Subject: [PATCH] fix(icloud): align reserve fallback logs and tests after master rebase --- background.js | 8 ++------ tests/background-icloud.test.js | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/background.js b/background.js index 0b0742e..6916f41 100644 --- a/background.js +++ b/background.js @@ -4606,11 +4606,7 @@ async function fetchIcloudHideMyEmail(options = {}) { await addLog(`iCloud:当前 Hide My Email 服务节点 ${new URL(serviceUrl).host}`, 'info'); let activeServiceUrl = serviceUrl; - const { aliases: existingAliases, serviceUrl: listServiceUrl } = await loadNormalizedIcloudAliases({ - serviceUrl: activeServiceUrl, - silent: true, - }); - activeServiceUrl = listServiceUrl || activeServiceUrl; + const existingAliases = await listIcloudAliases(); const existingAliasEmailSet = new Set( existingAliases .map((aliasItem) => String(aliasItem?.email || '').trim().toLowerCase()) @@ -4706,7 +4702,7 @@ async function fetchIcloudHideMyEmail(options = {}) { throw reserveErr; } - await addLog(`iCloud:保留 ${generatedAlias} 失败,正在回查别名列表确认是否已成功保留...`, 'warn'); + await addLog('iCloud:保留别名返回鉴权/网络异常,正在回查别名列表确认是否已创建...', 'warn'); const { aliases: aliasesAfterReserveFailure, serviceUrl: refreshedListServiceUrl } = await loadNormalizedIcloudAliases({ serviceUrl: activeServiceUrl, silent: true, diff --git a/tests/background-icloud.test.js b/tests/background-icloud.test.js index 0ea7442..9d70ff2 100644 --- a/tests/background-icloud.test.js +++ b/tests/background-icloud.test.js @@ -323,6 +323,18 @@ function getErrorMessage(error) { function normalizeText(value) { return String(value || '').replace(/\\s+/g, ' ').trim(); } +function appendIcloudClientQueryParams(url) { + return String(url || ''); +} +function isIcloudMaildomainwsHost() { + return false; +} +function shouldTryIcloudRequestPageContextFallback() { + return false; +} +async function icloudRequestViaPageContext() { + throw new Error('not expected'); +} async function fetch() { fetchCalls += 1; if (fetchCalls === 1) { @@ -381,6 +393,18 @@ function getErrorMessage(error) { function normalizeText(value) { return String(value || '').replace(/\\s+/g, ' ').trim(); } +function appendIcloudClientQueryParams(url) { + return String(url || ''); +} +function isIcloudMaildomainwsHost() { + return false; +} +function shouldTryIcloudRequestPageContextFallback() { + return false; +} +async function icloudRequestViaPageContext() { + throw new Error('not expected'); +} async function fetch() { fetchCalls += 1; return { @@ -451,6 +475,10 @@ async function loadNormalizedIcloudAliases() { serviceUrl: 'https://p67-maildomainws.icloud.com', }; } +async function listIcloudAliases() { + const response = await loadNormalizedIcloudAliases(); + return response.aliases || []; +} function pickReusableIcloudAlias() { return null; } @@ -477,6 +505,9 @@ function broadcastIcloudAliasesChanged(payload) { function findIcloudAliasByEmail(aliases, email) { return (aliases || []).find((alias) => String(alias.email || '').toLowerCase() === String(email || '').toLowerCase()) || null; } +function shouldStopIcloudAutoFetchRetries() { + return true; +} ${bundle} return { fetchIcloudHideMyEmail, @@ -491,5 +522,5 @@ return { assert.equal(email, 'fresh@icloud.com'); assert.deepEqual(api.readSelectedEmails(), ['fresh@icloud.com']); assert.deepEqual(api.readBroadcasts(), [{ reason: 'created', email: 'fresh@icloud.com' }]); - assert.match(api.readLogs().map((entry) => entry.message).join('\n'), /按保留成功处理/); + assert.match(api.readLogs().map((entry) => entry.message).join('\n'), /已在列表确认别名/); });