smoke-test.md 2.3 KB

云函数连通性冒烟测试

部署完云函数后,在浏览器 console 跑一遍,确认每个函数都能正常响应。

准备

  1. npm run dev 启动前端
  2. 打开任意页面(如 http://localhost:4200)
  3. F12 → Console,粘贴下面脚本

测试脚本

⚠️ 浏览器 console 不能直接 import 'fmode-ng/core'(bare specifier 解析不了),用 fetch 直调 REST 端点最简单。

const FN = {
  manifest: 'VWejNK8E5z',
  task:     'yL6opHxC4D',
  history:  'cegZcOyOH0',
  result:   'XPv6Sym2I6',
  remix:    'LjcaC94Kno',
  voice:    'LHBMMcDP4n',
  proxy:    'wzwnEuAhwb',
};

async function callFn(id, params) {
  const r = await fetch('https://server.fmode.cn/api/functions', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ id, _ApplicationId: 'ncloudmaster', ...params })
  });
  return r.json();
}

async function smoke(name, id, params) {
  try {
    const res = await callFn(id, params);
    const ok = res?.code === 200 && res?.success;
    console.log(`${ok ? '✅' : '❌'} ${name}:`, res);
  } catch (e) {
    console.error(`💥 ${name}:`, e);
  }
}

await smoke('manifest.list',      FN.manifest, { action: 'list' });
await smoke('task.list',          FN.task,     { action: 'list' });
await smoke('history.list',       FN.history,  { action: 'list' });
await smoke('result.list',        FN.result,   { action: 'list' });
await smoke('remix.listAll',      FN.remix,    { action: 'listAll' });
await smoke('voice.listProfiles', FN.voice,    { action: 'listProfiles' });
await smoke('proxy.unknownAction',FN.proxy,    { action: 'foo' });
console.log('🎉 冒烟测试结束');

期望输出

每行应类似:

✅ manifest.list: { code: 200, success: true, data: [] }
✅ task.list:     { code: 200, success: true, data: [] }
...
❌ proxy.unknownAction: { code: 400, success: false, error: '未知 action: foo' }  ← 这是预期失败

只要前 6 个全 ✅ 且最后一个返回 400,说明云函数都正确部署并能建表。

如果某个失败

现象 原因
Class not found / SQL 错误 表没建出来 → 检查云函数代码顶部的 CREATE TABLE IF NOT EXISTS 是否被注释或修改
全部超时 网络问题 / Parse SDK 版本不对
个别 404 函数 ID 写错了,对照 fmode 平台核验