test
This commit is contained in:
@@ -48,6 +48,63 @@ cat <<'EOF'
|
||||
openIMRenderApi: typeof window.openIMRenderApi,
|
||||
});
|
||||
window.__deployTestProbeCounts = counts;
|
||||
window.__deployTestReadLocalForage = async (key) => {
|
||||
const tryRead = (dbName, storeName) => new Promise((resolve, reject) => {
|
||||
const req = indexedDB.open(dbName);
|
||||
req.onerror = () => reject(req.error);
|
||||
req.onsuccess = () => {
|
||||
const db = req.result;
|
||||
if (!Array.from(db.objectStoreNames || []).includes(storeName)) {
|
||||
db.close();
|
||||
resolve(undefined);
|
||||
return;
|
||||
}
|
||||
const tx = db.transaction(storeName, "readonly");
|
||||
const store = tx.objectStore(storeName);
|
||||
const getReq = store.get(key);
|
||||
getReq.onerror = () => reject(getReq.error);
|
||||
getReq.onsuccess = () => {
|
||||
db.close();
|
||||
resolve(getReq.result);
|
||||
};
|
||||
};
|
||||
});
|
||||
for (const dbName of ["localforage", "OpenCorp-Base"]) {
|
||||
for (const storeName of ["keyvaluepairs", "local-forage-detect-blob-support"]) {
|
||||
try {
|
||||
const value = await tryRead(dbName, storeName);
|
||||
if (value) return value;
|
||||
} catch (err) {
|
||||
console.warn(`[probe] read ${dbName}/${storeName}/${key} failed`, err);
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
window.__deployTestManualLogin = async ({ userID, token, apiAddr, wsAddr } = {}) => {
|
||||
userID = userID || await window.__deployTestReadLocalForage("IM_USERID");
|
||||
token = token || await window.__deployTestReadLocalForage("IM_TOKEN");
|
||||
const operationID = `deploy-test-${Date.now()}`;
|
||||
const config = {
|
||||
platformID: 5,
|
||||
apiAddr: apiAddr || "http://54.116.29.247/api/im",
|
||||
wsAddr: wsAddr || "ws://54.116.29.247/msg_gateway",
|
||||
dataDir: "./",
|
||||
logLevel: 5,
|
||||
isLogStandardOutput: true,
|
||||
logFilePath: "./",
|
||||
isExternalExtensions: false,
|
||||
};
|
||||
console.log(`[probe ${stamp()}] manual initSDK`, { operationID, config });
|
||||
window.initSDK(operationID, JSON.stringify(config));
|
||||
console.log(`[probe ${stamp()}] manual login start`, { operationID, userID, hasToken: Boolean(token) });
|
||||
const timeout = new Promise((_, reject) => {
|
||||
setTimeout(() => reject(new Error("manual window.login timeout after 15000ms")), 15000);
|
||||
});
|
||||
const result = await Promise.race([window.login(operationID, String(userID || ""), String(token || "")), timeout]);
|
||||
console.log(`[probe ${stamp()}] manual login result`, result);
|
||||
return result;
|
||||
};
|
||||
clearInterval(window.__deployTestProbeTimer);
|
||||
window.__deployTestProbeTimer = setInterval(() => {
|
||||
console.log(`[probe ${stamp()}] counts`, { ...counts });
|
||||
@@ -59,4 +116,15 @@ cat <<'EOF'
|
||||
- login called / returned
|
||||
- window error / unhandledrejection
|
||||
- counts 里的 initSDK/login 是否从 0 变成 1
|
||||
|
||||
如果点登录后 counts 仍为 0,可用当前登录 token 手动测:
|
||||
|
||||
window.__deployTestManualLogin()
|
||||
|
||||
如果自动读取 token 失败,再手动传入:
|
||||
|
||||
window.__deployTestManualLogin({
|
||||
userID: "6087132211",
|
||||
token: "把 console 里 SDK login args 的 token 粘到这里"
|
||||
})
|
||||
EOF
|
||||
|
||||
Reference in New Issue
Block a user