chore(repo): 移除重复版权文件头并纳入共享单测
集中保留原版权声明,移除文件头检查和全局测试忽略规则。验证:全量单测、受影响用例复测及静态检查通过。
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import React from 'react';
|
||||
import * as Ant from 'antd';
|
||||
import { loadFrontendModule } from './helpers/frontendModule.js';
|
||||
import {
|
||||
overlayMask,
|
||||
overlayMaskClosable,
|
||||
} from '../../src/components/ui/overlayPolicy.js';
|
||||
|
||||
test('personal routes allow mask dismissal even when a shared caller disables it', () => {
|
||||
for (const path of [
|
||||
'/market',
|
||||
'/market/',
|
||||
'/skill-market',
|
||||
'/skill-market/',
|
||||
'/user-center',
|
||||
'/user-center/dashboard',
|
||||
'/user-center/key-management',
|
||||
'/user-center/settings/security',
|
||||
]) {
|
||||
for (const configured of [undefined, false, true]) {
|
||||
assert.equal(overlayMaskClosable(configured, path), true, path);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('other routes retain their existing mask policy', () => {
|
||||
for (const path of [
|
||||
'',
|
||||
'/console/token',
|
||||
'/org/settings',
|
||||
'/login',
|
||||
'/marketplace',
|
||||
'/skill-market-admin',
|
||||
'/user-center-admin',
|
||||
]) {
|
||||
for (const configured of [undefined, false, true]) {
|
||||
assert.equal(overlayMaskClosable(configured, path), configured, path);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('modal, drawer and imperative APIs apply the policy and preserve callbacks', async () => {
|
||||
let pathname = '/user-center/settings';
|
||||
const calls = [];
|
||||
const methods = ['confirm', 'info', 'success', 'warning', 'error'];
|
||||
const Modal = Object.assign(
|
||||
() => null,
|
||||
Object.fromEntries(
|
||||
methods.map((name) => [name, (props) => calls.push(props)]),
|
||||
),
|
||||
);
|
||||
const ui = await loadFrontendModule(
|
||||
new URL('../../src/components/ui/index.jsx', import.meta.url),
|
||||
{
|
||||
react: React,
|
||||
antd: { ...Ant, Modal },
|
||||
'./controls': {},
|
||||
'./pagination': {},
|
||||
'./pagination.css': {},
|
||||
'../../hooks/common/useIsMobile': { useIsMobile: () => false },
|
||||
'./form': {},
|
||||
'./chat': {},
|
||||
'../console/ConsoleContext': { useConsolePage: () => null },
|
||||
'./CenterActionTable': Ant.Table,
|
||||
'../console/ConsolePrimitives': {},
|
||||
'../console/consoleTableAdapter': {},
|
||||
'./overlayPolicy': {
|
||||
overlayMask: (mask, closable) => overlayMask(mask, closable, pathname),
|
||||
overlayMaskClosable: (configured) =>
|
||||
overlayMaskClosable(configured, pathname),
|
||||
},
|
||||
},
|
||||
);
|
||||
const onCancel = () => {};
|
||||
const onOk = () => {};
|
||||
for (const path of ['/market', '/skill-market', '/user-center/settings']) {
|
||||
pathname = path;
|
||||
const props = { visible: true, maskClosable: false, onCancel, onOk };
|
||||
const modal = ui.Modal(props);
|
||||
const drawer = ui.SideSheet(props);
|
||||
assert.equal(modal.props.mask.closable, true);
|
||||
assert.equal(modal.props.onCancel, onCancel);
|
||||
assert.equal(modal.props.onOk, onOk);
|
||||
assert.equal(drawer.props.mask.closable, true);
|
||||
assert.equal(drawer.props.onClose, onCancel);
|
||||
for (const method of methods) {
|
||||
ui.Modal[method](props);
|
||||
const config = calls.at(-1);
|
||||
assert.equal(config.mask.closable, true);
|
||||
assert.equal(config.onCancel, onCancel);
|
||||
assert.equal(config.onOk, onOk);
|
||||
}
|
||||
}
|
||||
pathname = '/console/token';
|
||||
assert.equal(ui.Modal({ maskClosable: false }).props.mask.closable, false);
|
||||
assert.equal(
|
||||
ui.SideSheet({ maskClosable: false }).props.mask.closable,
|
||||
false,
|
||||
);
|
||||
ui.Modal.confirm({ maskClosable: false });
|
||||
assert.equal(calls.at(-1).mask.closable, false);
|
||||
});
|
||||
Reference in New Issue
Block a user