button_smoke.cy.ts 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. describe('Forum System Button Smoke Test', () => {
  2. const username = `testuser_${Math.floor(Math.random() * 100000)}`
  3. const password = 'Password123!'
  4. it('should navigate through the main user flow using buttons', () => {
  5. // 1. Visit Home Page
  6. cy.visit('/')
  7. cy.contains('多智能体辩论框架').should('be.visible')
  8. // 2. Register
  9. cy.visit('/auth/register')
  10. cy.get('input#username').type(username)
  11. cy.get('input#password').type(password)
  12. cy.get('input#confirmPassword').type(password)
  13. // Click Register Button
  14. cy.get('button[type="submit"]').click()
  15. // Should redirect to login or auto-login? Assuming redirect to login based on common patterns
  16. // Or maybe it redirects to home? Let's check for URL change or success message.
  17. cy.url().should('include', '/auth/login')
  18. cy.contains('注册成功').should('be.visible')
  19. // 3. Login
  20. cy.get('input#username').type(username)
  21. cy.get('input#password').type(password)
  22. cy.get('button[type="submit"]').click()
  23. // Verify redirect to forums list
  24. cy.url().should('include', '/forums')
  25. cy.contains('讨论列表').should('be.visible')
  26. // 4. Create Persona (Prerequisite)
  27. cy.contains('角色管理').click()
  28. cy.url().should('include', '/personas')
  29. cy.contains('创建新角色').click() // Opens modal or goes to page?
  30. // Assuming modal for now based on typical AntD usage, or maybe a separate page.
  31. // Let's assume a button "创建新角色" triggers a modal.
  32. cy.get('.ant-modal-content').should('be.visible')
  33. cy.get('input#name').type('Cypress Tester')
  34. cy.get('textarea#bio').type('A test persona')
  35. // Submit persona
  36. cy.get('.ant-modal-footer button.ant-btn-primary').click()
  37. cy.contains('Cypress Tester').should('be.visible')
  38. // 5. Create Forum
  39. cy.contains('讨论列表').click()
  40. cy.contains('创建讨论').click() // Opens modal
  41. cy.get('.ant-modal-content').should('be.visible')
  42. cy.get('input#topic').type('Cypress Button Test Forum')
  43. // Select participant (might be complex in AntD select)
  44. // Skipping complex interaction for smoke test if possible, or selecting first available.
  45. // Assuming we can just submit if default is okay or mock it.
  46. // Actually, let's just check the button exists and opens the modal.
  47. // 6. Logout
  48. cy.get('.ant-avatar').trigger('mouseover') // Or click profile menu
  49. cy.contains('退出登录').click()
  50. cy.url().should('include', '/auth/login')
  51. })
  52. })