CommonPageHelp.spec.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { beforeAll } from 'vitest'
  3. import { renderComponent } from '#tests/support/components/index.ts'
  4. import CommonPageHelp from '../CommonPageHelp.vue'
  5. const renderPageHelp = (options: any = {}) => {
  6. return renderComponent(CommonPageHelp, {
  7. ...options,
  8. dialog: true,
  9. router: true,
  10. })
  11. }
  12. describe('CommonPageHelp.vue', () => {
  13. beforeAll(() => {
  14. const app = document.createElement('div')
  15. app.id = 'app'
  16. document.body.appendChild(app)
  17. })
  18. afterAll(() => {
  19. document.body.innerHTML = ''
  20. })
  21. it('show help button', async () => {
  22. const view = renderPageHelp({
  23. slots: {
  24. default: () => 'A help example.',
  25. },
  26. })
  27. expect(view.getByRole('button', { name: 'Help' })).toBeInTheDocument()
  28. expect(view.getByIconName('question-circle')).toBeInTheDocument()
  29. })
  30. it('opens help dialog', async () => {
  31. const view = renderPageHelp({
  32. slots: {
  33. default: () => 'A help example.',
  34. },
  35. })
  36. await view.events.click(view.getByRole('button', { name: 'Help' }))
  37. expect(await view.findByRole('dialog')).toBeInTheDocument()
  38. expect(await view.findByText('A help example.')).toBeInTheDocument()
  39. })
  40. })