锁定微信九宫切图失败提示
微信九宫切图失败不再向页面透出原生错误细节 微信九宫切图测试覆盖原生下载失败稳定提示 native shell 总门禁反查微信九宫切图失败边界
This commit is contained in:
@@ -1988,6 +1988,49 @@ function assertWechatAuthFailureBoundaries() {
|
||||
}
|
||||
}
|
||||
|
||||
function assertWechatShareGridFailureBoundaries() {
|
||||
const shareGridSource = fs.readFileSync(
|
||||
'miniprogram/shell/shareGrid.js',
|
||||
'utf8',
|
||||
);
|
||||
const shareGridTestSource = fs.readFileSync(
|
||||
'miniprogram/shell/shareGrid.test.js',
|
||||
'utf8',
|
||||
);
|
||||
|
||||
for (const snippet of [
|
||||
"WECHAT_SHARE_GRID_SAVE_UNAVAILABLE_MESSAGE = '九宫切图保存失败。'",
|
||||
"console.error(`[share-grid] ${label}`, error)",
|
||||
'reject(new Error(WECHAT_SHARE_GRID_SAVE_UNAVAILABLE_MESSAGE))',
|
||||
'errorMessage: WECHAT_SHARE_GRID_SAVE_UNAVAILABLE_MESSAGE',
|
||||
]) {
|
||||
if (!shareGridSource.includes(snippet)) {
|
||||
throw new Error(`wechat share-grid shell must include ${snippet}`);
|
||||
}
|
||||
}
|
||||
for (const forbiddenSnippet of [
|
||||
"reject(new Error(error.errMsg || '封面下载失败'))",
|
||||
"reject(new Error(error.errMsg || '读取封面失败'))",
|
||||
"reject(new Error(error.errMsg || '导出切图失败'))",
|
||||
"reject(new Error(error.errMsg || '保存到相册失败'))",
|
||||
"error && error.message ? error.message : '九宫切图保存失败。'",
|
||||
]) {
|
||||
if (shareGridSource.includes(forbiddenSnippet)) {
|
||||
throw new Error(`wechat share-grid shell must not expose native failure detail via ${forbiddenSnippet}`);
|
||||
}
|
||||
}
|
||||
for (const snippet of [
|
||||
'hides downloadFile native failure details from the page',
|
||||
"expect(page.data.errorMessage).toBe('九宫切图保存失败。')",
|
||||
"expect(page.data.errorMessage).not.toContain('private native download detail')",
|
||||
"expect(consoleError).toHaveBeenCalledWith(",
|
||||
]) {
|
||||
if (!shareGridTestSource.includes(snippet)) {
|
||||
throw new Error(`wechat share-grid boundary test must include ${snippet}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function assertHostBridgeLayerLayout() {
|
||||
assertSameList(
|
||||
readDirectoryFileList(
|
||||
@@ -2224,6 +2267,9 @@ assertWechatSubscribeResultBoundaries();
|
||||
console.log('[check:native-shells] wechat-auth-failure-boundaries');
|
||||
assertWechatAuthFailureBoundaries();
|
||||
|
||||
console.log('[check:native-shells] wechat-share-grid-failure-boundaries');
|
||||
assertWechatShareGridFailureBoundaries();
|
||||
|
||||
console.log('[check:native-shells] h5-host-bridge-event-subscription-gates');
|
||||
assertH5HostBridgeEventSubscriptionGates();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user