105 lines
3.8 KiB
TypeScript
105 lines
3.8 KiB
TypeScript
import { describe, it, beforeAll, afterAll, beforeEach } from 'vitest';
|
||
import { IOSAgent } from '@midscene/ios';
|
||
import { getAgent, destroyAgent, backToHomepage, sleep } from '../../utils/agent';
|
||
import { APP_CONFIG } from '../../config/app.config';
|
||
|
||
describe('Bot Logs - 设备日志验证', () => {
|
||
let agent: IOSAgent;
|
||
let botDeviceName: string;
|
||
|
||
beforeAll(async () => {
|
||
agent = await getAgent();
|
||
await backToHomepage(agent);
|
||
botDeviceName = await agent.aiQuery(
|
||
'首页设备列表中Bot设备卡片上显示的设备名称是什么?只返回名称文本'
|
||
);
|
||
});
|
||
|
||
afterAll(async () => {
|
||
await destroyAgent();
|
||
});
|
||
|
||
beforeEach(async () => {
|
||
await backToHomepage(agent);
|
||
});
|
||
|
||
it('Press模式-操作后查看历史日志', async () => {
|
||
// 确保处于Press模式
|
||
const isPress = await agent.aiBoolean(
|
||
`"${botDeviceName}"设备卡片状态是否显示Press Mode`
|
||
);
|
||
|
||
if (!isPress) {
|
||
await agent.aiAct(`点击"${botDeviceName}"设备卡片`);
|
||
await agent.aiAct('点击设备设置按钮');
|
||
await agent.aiAct('点击Bot Mode选项');
|
||
await agent.aiAct('点击模式切换按钮');
|
||
await agent.aiAct('选择Press Mode');
|
||
await agent.aiAct('如果有确认弹窗,点击Confirm确认');
|
||
await agent.aiWaitFor('当前模式已显示为Press Mode', {
|
||
timeoutMs: APP_CONFIG.timeouts.bleOperation,
|
||
});
|
||
await backToHomepage(agent);
|
||
}
|
||
|
||
// 执行按压操作产生日志
|
||
await agent.aiAct(`在"${botDeviceName}"设备卡片上点击Bot按压按钮`);
|
||
await sleep(APP_CONFIG.timeouts.bleOperation);
|
||
|
||
// 进入设置页查看日志
|
||
await agent.aiAct(`点击"${botDeviceName}"设备卡片`);
|
||
await agent.aiAct('点击设备设置按钮');
|
||
await agent.aiScroll('设置页面', { direction: 'down', distance: 300 });
|
||
await agent.aiAct('点击Log或历史记录选项');
|
||
await agent.aiWaitFor('历史日志页面已显示');
|
||
|
||
// AI验证日志内容
|
||
await agent.aiAssert(
|
||
'日志页面中显示了最近的操作记录,包含Press动作、App Control来源、且执行状态为成功'
|
||
);
|
||
await agent.recordToReport('Press模式日志');
|
||
|
||
await backToHomepage(agent);
|
||
});
|
||
|
||
it('Switch模式-开关后查看历史日志', async () => {
|
||
// 确保处于Switch模式
|
||
const isPress = await agent.aiBoolean(
|
||
`"${botDeviceName}"设备卡片状态是否显示Press Mode`
|
||
);
|
||
|
||
if (isPress) {
|
||
await agent.aiAct(`点击"${botDeviceName}"设备卡片`);
|
||
await agent.aiAct('点击Bot Mode选项');
|
||
await agent.aiAct('点击模式切换按钮');
|
||
await agent.aiAct('选择Switch Mode');
|
||
await agent.aiAct('如果有确认弹窗,点击Confirm确认');
|
||
await agent.aiWaitFor('当前模式已显示为Switch Mode', {
|
||
timeoutMs: APP_CONFIG.timeouts.bleOperation,
|
||
});
|
||
await backToHomepage(agent);
|
||
}
|
||
|
||
// 执行开关操作(开 -> 关)产生日志
|
||
await agent.aiAct(`在"${botDeviceName}"设备卡片上点击开关按钮`);
|
||
await sleep(APP_CONFIG.timeouts.bleOperation);
|
||
await agent.aiAct(`在"${botDeviceName}"设备卡片上点击开关按钮`);
|
||
await sleep(APP_CONFIG.timeouts.bleOperation);
|
||
|
||
// 进入设置页查看日志
|
||
await agent.aiAct(`点击"${botDeviceName}"设备卡片`);
|
||
await agent.aiAct('点击设备设置按钮');
|
||
await agent.aiScroll('设置页面', { direction: 'down', distance: 300 });
|
||
await agent.aiAct('点击Log或历史记录选项');
|
||
await agent.aiWaitFor('历史日志页面已显示');
|
||
|
||
// AI验证日志内容
|
||
await agent.aiAssert(
|
||
'日志页面中显示了最近的Turned on和Turned off操作记录,来源为App Control,且状态为执行成功'
|
||
);
|
||
await agent.recordToReport('Switch模式日志');
|
||
|
||
await backToHomepage(agent);
|
||
});
|
||
});
|