journalRecord.api-smoke.js
2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* dailyReport 接口冒烟测试
* 用法: npm run api:smoke:journal
*/
const { createLoggedInClient } = require("../src/libs/rop/ropClient");
async function main() {
const client = await createLoggedInClient();
console.log("axios.baseURL:", client.config.baseURL);
console.log("axios.appkey:", client.config.appkey);
console.log("env:", client.config.env);
const merchantData = await client.callSmartcarlife("dailyReport.merchant.list", {
currentPage: 1,
pageSize: 10,
});
console.log(" merchant.list total:", merchantData?.total, "listLen:", merchantData?.list?.length);
const reportDate = new Date().toISOString().slice(0, 10);
const tabs = [
["staffDaily", 1],
["storeDaily", 2],
["negotiation", 3],
];
let fallbackMerchantId = merchantData?.list?.[0]?.merchantId;
for (const [tabKey, templateType] of tabs) {
const overviewData = await client.callSmartcarlife("dailyReport.overview.page", {
currentPage: 1,
pageSize: 10,
templateType,
reportDate,
});
console.log(`[OK] dailyReport.overview.page (${tabKey}) total:`, overviewData?.total);
if (!fallbackMerchantId && overviewData?.list?.[0]?.merchantId) {
fallbackMerchantId = overviewData.list[0].merchantId;
}
const firstId = overviewData?.list?.[0]?.id;
if (firstId) {
const detailData = await client.callSmartcarlife("dailyReport.detail.select", { id: firstId });
console.log(` detail ${tabKey} id=${firstId} jsonContent=`, !!detailData?.jsonContent);
}
}
if (fallbackMerchantId) {
const staffData = await client.callSmartcarlife("merchant.staff.list", {
merchantId: fallbackMerchantId,
});
const staffLen = Array.isArray(staffData) ? staffData.length : staffData?.list?.length;
console.log(`[OK] merchant.staff.list merchantId=${fallbackMerchantId} len=`, staffLen);
} else {
console.log("[SKIP] merchant.staff.list: 无可用 merchantId");
}
console.log("\nAll dailyReport smoke tests passed.");
}
main().catch((error) => {
console.error("\nSmoke test failed:", error.message);
process.exit(1);
});