native-environment.spec.ts 1.6 KB

1234567891011121314
  1. import {test,expect} from '@playwright/test'
  2. import {mkdirSync} from 'node:fs'
  3. test('Web shows native desktop permissions',async({page})=>{
  4. const evidence='test-results/native-environment';mkdirSync(evidence,{recursive:true})
  5. await page.goto('/conversations');await page.getByRole('textbox',{name:'账号',exact:true}).fill('fixture');await page.getByRole('textbox',{name:'密码',exact:true}).fill('fixture-pass');await page.getByRole('button',{name:'登录',exact:true}).click()
  6. await page.locator('.desktop-sidebar .sidebar-create-trigger').click();await page.getByRole('menuitem',{name:'新建 Bot',exact:true}).click();const editor=page.getByRole('dialog');await editor.getByRole('textbox',{name:'名称',exact:true}).fill('本机控制验收');await editor.getByRole('button',{name:'保存',exact:true}).click()
  7. await page.getByRole('button',{name:'电脑与定时任务',exact:true}).click()
  8. const panel=page.getByRole('complementary',{name:'机器人电脑面板'})
  9. const desktop=panel.getByRole('combobox',{name:'显示的桌面'})
  10. await expect(desktop).toBeEnabled({timeout:15000});await desktop.selectOption('desktop:local')
  11. await expect(panel.getByRole('button',{name:'在桌面端授权',exact:true})).toBeVisible();await expect(panel.getByText(/服务器是运行夭夭服务的电脑;电脑是连接这台服务器的 Mac/)).toBeVisible();await page.screenshot({path:evidence+'/desktop-native-permissions.png'})
  12. await expect(panel.getByRole('tab',{name:'仅浏览器',exact:true})).toHaveCount(0)
  13. await expect(panel.getByRole('checkbox',{name:'电脑浏览器',exact:true})).toHaveCount(0)
  14. })