CommonPageHelp.spec.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. })
  10. }
  11. describe('CommonPageHelp.vue', () => {
  12. beforeAll(() => {
  13. const main = document.createElement('main')
  14. main.id = 'page-main-content'
  15. document.body.appendChild(main)
  16. })
  17. afterAll(() => {
  18. document.body.innerHTML = ''
  19. })
  20. it('show help button', async () => {
  21. const view = renderPageHelp({
  22. slots: {
  23. default: () => 'A help example.',
  24. },
  25. })
  26. expect(view.getByRole('button', { name: 'Help' })).toBeInTheDocument()
  27. expect(view.getByIconName('question-circle')).toBeInTheDocument()
  28. })
  29. it('opens help dialog', async () => {
  30. const view = renderPageHelp({
  31. slots: {
  32. default: () => 'A help example.',
  33. },
  34. })
  35. await view.events.click(view.getByRole('button', { name: 'Help' }))
  36. expect(await view.findByRole('dialog')).toBeInTheDocument()
  37. expect(await view.findByText('A help example.')).toBeInTheDocument()
  38. })
  39. })