You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

29 line
2.4 KiB

  1. import fs from 'node:fs'
  2. import {chromium,expect} from '@playwright/test'
  3. import {login,call} from './role-permissions-live.mjs'
  4. const session=await login('root'),checks=[]
  5. const browser=await chromium.launch({channel:'msedge',headless:true})
  6. const page=await browser.newPage({viewport:{width:1920,height:1080}})
  7. await page.addInitScript(s=>{sessionStorage.setItem('unreal-tran:web:access-token:v1',s.accessToken);sessionStorage.setItem('unreal-tran:web:refresh-token:v1',s.refreshToken)},session)
  8. let id
  9. try{
  10. await page.goto('http://127.0.0.1:6180/content/ofd/templates')
  11. await page.locator('.library-heading button').click()
  12. await page.getByLabel('指导书名称',{exact:true}).fill('正式模板新建回归-20260911')
  13. const created=page.waitForResponse(r=>r.url().includes('/guide-templates/')&&r.url().endsWith('/projects')&&r.request().method()==='POST')
  14. await page.getByRole('button',{name:'创建并进入规划',exact:true}).click()
  15. const response=await created;const body=await response.json();id=String(body.data.project.id)
  16. checks.push({name:'模板新建实际进入正式内容服务',pass:response.ok()})
  17. await page.waitForURL(/\/ofd\/\d+\/studio/)
  18. await page.goto(`http://127.0.0.1:6180/content/ofd/${id}/studio?view=editor`)
  19. await expect(page.locator('.ofd-view-editor')).toBeVisible({timeout:60000})
  20. const before=await call(`tran/v1/content/projects/${id}`,session.accessToken)
  21. const save=page.waitForResponse(r=>r.url().endsWith(`/projects/${id}`)&&r.request().method()==='PUT')
  22. await page.locator('[data-action="save"]').click();const saved=await save
  23. checks.push({name:'模板初稿进入编辑器并保存',pass:saved.ok()})
  24. const after=await call(`tran/v1/content/projects/${id}`,session.accessToken)
  25. checks.push({name:'模板章节和步骤不丢失',pass:JSON.stringify(before.data.currentVersion.content.chapters.map(c=>[c.id,c.title,c.steps.map(s=>[s.id,s.title])]))===JSON.stringify(after.data.currentVersion.content.chapters.map(c=>[c.id,c.title,c.steps.map(s=>[s.id,s.title])]))})
  26. await page.screenshot({path:'reports/guide-formal-20260910/17-template-editor.png'})
  27. }catch(e){checks.push({name:'模板编制闭环',pass:false,detail:e.message});process.exitCode=1;await page.screenshot({path:'reports/guide-formal-20260910/template-failure.png'})}
  28. finally{console.log(checks);fs.writeFileSync('reports/guide-formal-20260910/template.json',JSON.stringify({projectId:id,checks},null,2));await browser.close()}