hotmail-api-mode.test.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. const test = require('node:test');
  2. const assert = require('node:assert/strict');
  3. const fs = require('node:fs');
  4. test('Hotmail API对接界面文案应启用 remote 模式并隐藏禁用态', () => {
  5. const html = fs.readFileSync('sidepanel/sidepanel.html', 'utf8');
  6. assert.match(
  7. html,
  8. /data-hotmail-service-mode="remote"[^>]*>\s*API对接\s*<\/button>/,
  9. 'remote 模式按钮应显示为 API对接'
  10. );
  11. assert.doesNotMatch(
  12. html,
  13. /data-hotmail-service-mode="remote"[^>]*\sdisabled(\s|>)/,
  14. 'API对接按钮不应继续被禁用'
  15. );
  16. assert.match(
  17. html,
  18. /<span class="data-label">API对接<\/span>/,
  19. 'Hotmail 配置行文案应改为 API对接'
  20. );
  21. });
  22. test('Hotmail API对接应接入微软邮箱 helper 而不是旧远程服务占位', () => {
  23. const background = fs.readFileSync('background.js', 'utf8');
  24. assert.match(background, /importScripts\([^)]*microsoft-email\.js[^)]*\)/, 'background 应加载微软邮箱 helper');
  25. assert.match(background, /fetchMicrosoftMailboxMessages/, '账号校验和最新验证码应接入微软邮箱列表 helper');
  26. assert.match(
  27. background,
  28. /fetchMicrosoftMailboxMessages\(\{[\s\S]*mailbox,[\s\S]*top:\s*10,/,
  29. '微软邮箱 helper 应按请求的邮箱夹读取消息'
  30. );
  31. assert.match(
  32. background,
  33. /for \(const mailbox of mailboxes\) \{\s*const result = await requestHotmailRemoteMailbox\(workingAccount, mailbox\);/s,
  34. 'API对接模式不应丢掉 INBOX\/Junk 的逐邮箱夹轮询'
  35. );
  36. assert.match(
  37. background,
  38. /pickVerificationMessageWithTimeFallback\(fetchResult\.messages, \{/,
  39. '步骤 4\/7 应继续复用现有验证码筛选与时间回退逻辑'
  40. );
  41. });