feat: simplify DSH tool navigation and remove account onboarding

This commit is contained in:
阿白叔 committed 2026-10-30 11:47:20 +08:00
1 parent 96227eed2e
commit f437df2a83
10 files changed
+109 -50

No files matched your search

+15 -17
View File
@@ -1,4 +1,4 @@
"""Click the real task-center menus, then test its embedded official page."""
"""Click the real task-center navigation, then test its embedded official page."""
from __future__ import annotations
import argparse
@@ -44,17 +44,14 @@ def main():
window = TrialTaskCenterWindow(service)
window.resize(1380, 860)
def click_menu(action):
def click_navigation(action):
window.activateWindow()
bar = window.menuBar()
top = bar.actions()[0]
menu = top.menu()
QTest.mouseClick(bar, Qt.MouseButton.LeftButton, pos=bar.actionGeometry(top).center())
QApplication.processEvents()
if not menu.isVisible():
raise AssertionError('The tool menu did not open after mouse click')
QTest.mouseClick(menu, Qt.MouseButton.LeftButton, pos=menu.actionGeometry(action).center())
button = window.dsh_navigation if action is window.dsh_action else window.task_center_navigation
assert button.isVisible() and button.defaultAction() is action
assert window.task_center_navigation.geometry().right() < window.dsh_navigation.geometry().left()
QTest.mouseClick(button, Qt.MouseButton.LeftButton)
QApplication.processEvents()
assert button.isChecked()
def failed(error):
report.update(status='failed', error=type(error).__name__ + ': ' + str(error))
@@ -80,9 +77,10 @@ def main():
pos=window.task_list.list.visualItemRect(item).center())
state['phase'] = 'menu'
elif state['phase'] == 'menu' and window._context is not None and not window._loading:
click_menu(window.dsh_action)
window.grab().save(str(output / 'task-center.png'))
click_navigation(window.dsh_action)
assert window.content_stack.currentWidget() is window._dsh_view
report['checks'].append('clicked task row and Tools > DSH assistant in the real main window')
report['checks'].append('clicked task row and opened DSH with one click on the right navigation item')
state['phase'] = 'ready'
elif state['phase'] == 'ready' and window._dsh_view._started:
command = ['node', str(REPO / 'tools/verify_dsh_native_ui.mjs'), str(output), str(args.port), '--confirm-cancel']
@@ -96,17 +94,17 @@ def main():
if state['child'].returncode:
raise RuntimeError(stderr.decode('utf8', 'replace'))
report['web'] = json.loads((output / 'report.json').read_text(encoding='utf8'))
click_menu(window.task_center_action)
click_navigation(window.task_center_action)
assert window.content_stack.currentIndex() == 0
click_menu(window.dsh_action)
click_navigation(window.dsh_action)
assert window.content_stack.currentWidget() is window._dsh_view
report['checks'].append('clicked back to task center and returned to the same native page')
report['checks'].append('clicked left navigation for task center and right navigation for the same native page')
state['phase'] = 'check-preserved'
def preserved(text):
if '请分析当前任务' not in (text or ''):
failed(AssertionError('Composer draft was lost when switching tool menus'))
failed(AssertionError('Composer draft was lost when switching navigation items'))
return
report['checks'].append('native composer draft survived tool-menu navigation')
report['checks'].append('native composer draft survived direct navigation')
window.grab().save(str(output / 'dsh-in-tool.png'))
report['status'] = 'passed'
(output / 'desktop-report.json').write_text(json.dumps(report, ensure_ascii=False, indent=2), encoding='utf8')
+13 -17
View File
@@ -14,25 +14,8 @@ async function wait(expression,timeout=15000) {
while(Date.now()<end){if(await c.evaluate(expression))return;await new Promise(r=>setTimeout(r,100));}
throw Error('UI condition timed out: '+expression);
}
async function dismissOnboarding() {
const end=Date.now()+12000;
let quiet=Date.now();
while(Date.now()<end) {
const modal=await c.evaluate(`({preview:!![...document.querySelectorAll('button')].find(e=>e.textContent.trim()==='继续'),start:document.body.innerText.includes('开始使用')})`);
if(modal.preview) {
await c.click(`[...document.querySelectorAll('button')].find(e=>e.textContent.trim()==='继续')`);
quiet=Date.now();
}else if(modal.start) {
await c.click(`[...document.querySelectorAll('button[aria-label="关闭"]')].at(-1)`);
quiet=Date.now();
}else if(Date.now()-quiet>1000) return;
await new Promise(resolve=>setTimeout(resolve,150));
}
throw Error('The native onboarding dialog could not be dismissed');
}
try {
await wait(`!!document.querySelector('svg[class*="fish"]')`,45000);
await dismissOnboarding();
for(let attempt=0;attempt<10 && !await c.evaluate(`document.body.innerText.includes('DSH助手')`);attempt++) {
if(await c.evaluate(`!!document.querySelector('button[aria-label="打开侧边栏"]')`))
await c.click(`document.querySelector('button[aria-label="打开侧边栏"]')`);
@@ -41,6 +24,19 @@ try {
await wait(`document.body.innerText.includes('DSH助手')`);
await wait(`!!document.querySelector('[data-testid="dx-task-panel"]')`);
report.checks.push('official frontend and native right dock loaded');
assert.equal(await c.evaluate(`!!document.querySelector('[role="dialog"],[data-desktop-onboarding]')`),false,'Fresh launch must not show account or product onboarding');
const accountEntries=`[...document.querySelectorAll('button,a')].filter(e=>/^(登录|登入|注册|账户|账号|充值|开始使用|Sign in|Log in|Account)$/.test(e.textContent.trim()))`;
assert.equal(await c.evaluate(`${accountEntries}.length`),0);
report.checks.push('fresh profile opens without login, account or product onboarding');
await c.click(`document.querySelector('[data-testid="dx-tool-settings"]')`);
await wait(`!!document.querySelector('[data-testid="dx-tool-settings-panel"]')`);
assert.equal(await c.evaluate(`${accountEntries}.length`),0);
report.checks.push('one click opens native tool settings with DSH capabilities and no account entry');
await c.screenshot(path.join(output,'dsh-tool-settings.png'));
await c.call('Input.dispatchKeyEvent',{type:'keyDown',key:'Escape',code:'Escape'});
await c.call('Input.dispatchKeyEvent',{type:'keyUp',key:'Escape',code:'Escape'});
await wait(`!document.querySelector('[data-testid="dx-tool-settings-panel"]')`);
await c.screenshot(path.join(output,'dsh-tool-home.png'));
const context=await c.evaluate(`fetch('/dx/context').then(r=>r.json())`);
assert.ok(context.task_id,'Select a task in the task center before running this test.');
report.checks.push('current task received from task center');