账号管理改顶栏入口+弹框交互; 停用/启用带确认; 冒烟支持已有实例(SMOKE_USER)
This commit is contained in:
+14
-6
@@ -22,12 +22,16 @@ const sleep = (ms) => new Promise(r => setTimeout(r, ms));
|
||||
ok('详情弹窗隐藏', await p.evaluate(() => getComputedStyle(document.getElementById('detailModal')).display === 'none'));
|
||||
await p.screenshot({ path: '/tmp/smoke-shots/01-init.png' });
|
||||
|
||||
console.log('== 2. 注册超管并自动登录 ==');
|
||||
await $('#f_user').fill('testsuper');
|
||||
await $('#f_pass').fill('test123456');
|
||||
console.log('== 2. 登录(新实例注册超管/已有实例用测试账号) ==');
|
||||
const boot = await p.evaluate(async () => (await (await fetch('/api/bootstrap')).json()));
|
||||
const SU = process.env.SMOKE_USER || 'testsuper';
|
||||
const SP = process.env.SMOKE_PASS || 'test123456';
|
||||
await $('#f_user').fill(SU);
|
||||
await $('#f_pass').fill(SP);
|
||||
await $('#loginBtn').click();
|
||||
await p.waitForNavigation({ waitUntil: 'networkidle', timeout: 8000 }).catch(() => {});
|
||||
await sleep(800);
|
||||
ok(boot.needsInit ? '注册超管成功' : '测试账号登录成功', await $('#main').isVisible());
|
||||
ok('进入主界面', await $('#main').isVisible());
|
||||
ok('身份=超管', (await $('#whoami').textContent()).includes('超管'));
|
||||
await p.screenshot({ path: '/tmp/smoke-shots/02-dashboard.png' });
|
||||
@@ -64,13 +68,17 @@ const sleep = (ms) => new Promise(r => setTimeout(r, ms));
|
||||
});
|
||||
ok('CSV表头正确', csv.includes('姓名') && csv.includes('门槛备注'));
|
||||
|
||||
console.log('== 7. 超管建HR账号 ==');
|
||||
ok('账号管理面板可见', await $('#userPanel').isVisible());
|
||||
console.log('== 7. 顶栏入口+弹框建HR账号 ==');
|
||||
ok('顶栏账号管理入口可见', await $('#userMgrBtn').isVisible());
|
||||
await p.evaluate(() => openUserModal()); await sleep(600);
|
||||
ok('账号管理弹框打开', await $('#userModal').isVisible());
|
||||
await $('#nu_user').fill('hr01'); await $('#nu_pass').fill('hr123456');
|
||||
await $('button:has-text("创建HR账号")').click(); await sleep(700);
|
||||
const uText = await $('#utable').innerText();
|
||||
ok('用户列表含hr01', uText.includes('hr01'));
|
||||
ok('停用/启用按钮存在', uText.includes('停用'));
|
||||
await p.screenshot({ path: '/tmp/smoke-shots/04-users.png' });
|
||||
await p.evaluate(() => document.getElementById('userModal').classList.add('hidden'));
|
||||
|
||||
console.log('== 8. 退出 → HR登录 ==');
|
||||
await p.evaluate(() => logout()); await sleep(800);
|
||||
@@ -78,7 +86,7 @@ const sleep = (ms) => new Promise(r => setTimeout(r, ms));
|
||||
await $('#f_user').fill('hr01'); await $('#f_pass').fill('hr123456');
|
||||
await $('#loginBtn').click(); await sleep(900);
|
||||
ok('HR进入主界面', await $('#main').isVisible());
|
||||
ok('HR看不到账号管理', await p.evaluate(() => !document.getElementById('userPanel') || document.getElementById('userPanel').classList.contains('hidden')));
|
||||
ok('HR看不到账号管理入口', await p.evaluate(() => getComputedStyle(document.getElementById('userMgrBtn')).display === 'none'));
|
||||
const forbidden = await p.evaluate(async () => {
|
||||
const r = await fetch('/api/users'); return r.status;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user