完成70%
This commit is contained in:
@@ -90,50 +90,10 @@ class FakeTac {
|
||||
|
||||
const host = { innerHTML: "rendered" };
|
||||
const loadedStyle = { dataset: { jiapuState: "loaded" }, sheet: {} };
|
||||
const backgroundControl = {
|
||||
focusCount: 0,
|
||||
focus() {
|
||||
this.focusCount += 1;
|
||||
document.activeElement = this;
|
||||
},
|
||||
};
|
||||
const refreshControl = {
|
||||
offsetParent: {},
|
||||
focus() {
|
||||
document.activeElement = this;
|
||||
},
|
||||
};
|
||||
const closeControl = {
|
||||
offsetParent: {},
|
||||
focus() {
|
||||
document.activeElement = this;
|
||||
},
|
||||
};
|
||||
const dialog = {
|
||||
offsetParent: {},
|
||||
listener: null,
|
||||
focus() {
|
||||
document.activeElement = this;
|
||||
},
|
||||
querySelector(selector) {
|
||||
return selector === ".tac-tool--refresh" ? refreshControl : null;
|
||||
},
|
||||
querySelectorAll() {
|
||||
return [refreshControl, closeControl];
|
||||
},
|
||||
addEventListener(name, listener) {
|
||||
if (name === "keydown") this.listener = listener;
|
||||
},
|
||||
removeEventListener(name, listener) {
|
||||
if (name === "keydown" && this.listener === listener) this.listener = null;
|
||||
},
|
||||
};
|
||||
const document = {
|
||||
activeElement: backgroundControl,
|
||||
head: { appendChild() {} },
|
||||
querySelector(selector) {
|
||||
if (selector === "#jiapu-tac-host") return host;
|
||||
if (selector === "#jiapu-tac-dialog") return dialog;
|
||||
if (selector.startsWith("link[data-jiapu-tac=")) return loadedStyle;
|
||||
return null;
|
||||
},
|
||||
@@ -228,23 +188,12 @@ const run = async () => {
|
||||
subject: "13800138000",
|
||||
};
|
||||
instance.context = context;
|
||||
instance.previousFocus = backgroundControl;
|
||||
instance.generation += 1;
|
||||
instance.createTac();
|
||||
assert.strictEqual(latestTac.initialized, true);
|
||||
assert.strictEqual(typeof latestTac.config.doSendRequest, "function");
|
||||
assert.strictEqual(document.activeElement, refreshControl, "打开 TAC 后必须把焦点移入对话框");
|
||||
document.activeElement = closeControl;
|
||||
let tabPrevented = false;
|
||||
dialog.listener({
|
||||
key: "Tab",
|
||||
shiftKey: false,
|
||||
preventDefault() {
|
||||
tabPrevented = true;
|
||||
},
|
||||
});
|
||||
assert.strictEqual(tabPrevented, true, "TAC 末项 Tab 必须被焦点环截获");
|
||||
assert.strictEqual(document.activeElement, refreshControl);
|
||||
latestTac.config.options.btnRefreshFun(null, latestTac);
|
||||
assert.strictEqual(latestTac.reloadCount, 1, "必须保留供应商原生刷新操作");
|
||||
|
||||
const firstSuccess = latestTac.config.options.validSuccess;
|
||||
firstSuccess(
|
||||
@@ -283,7 +232,6 @@ const run = async () => {
|
||||
await instance.onContextChange({ visible: false });
|
||||
assert.strictEqual(instance.tac, null, "隐藏或卸载验证层必须销毁 SDK 实例");
|
||||
assert.strictEqual(host.innerHTML, "", "隐藏或卸载验证层必须清空宿主节点");
|
||||
assert.strictEqual(backgroundControl.focusCount, 1, "关闭 TAC 后必须恢复进入前焦点");
|
||||
|
||||
console.log("TAC-RENDERJS-RUNTIME-SMOKE PASS");
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user