1
0

chat.spec.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { setupPuppeteer, E2E_TIMEOUT } from 'test/helpers'
  2. describe('e2e/chat', () => {
  3. const { page, text, count, click, enterValue, sleep } = setupPuppeteer()
  4. async function testChat (url) {
  5. await page().goto(url)
  6. expect(await text('.thread-count')).toContain('Unread threads: 2')
  7. expect(await count('.thread-list-item')).toBe(3)
  8. expect(await text('.thread-list-item.active')).toContain('Functional Heads')
  9. expect(await text('.message-thread-heading')).toContain('Functional Heads')
  10. expect(await count('.message-list-item')).toBe(2)
  11. expect(await text('.message-list-item:nth-child(1) .message-author-name')).toContain('Bill')
  12. expect(await text('.message-list-item:nth-child(1) .message-text')).toContain('Hey Brian')
  13. await enterValue('.message-composer', 'hi')
  14. await sleep(50) // fake api
  15. expect(await count('.message-list-item')).toBe(3)
  16. expect(await text('.message-list-item:nth-child(3)')).toContain('hi')
  17. await click('.thread-list-item:nth-child(2)')
  18. expect(await text('.thread-list-item.active')).toContain('Dave and Bill')
  19. expect(await text('.message-thread-heading')).toContain('Dave and Bill')
  20. expect(await count('.message-list-item')).toBe(2)
  21. expect(await text('.message-list-item:nth-child(1) .message-author-name')).toContain('Bill')
  22. expect(await text('.message-list-item:nth-child(1) .message-text')).toContain('Hey Dave')
  23. await enterValue('.message-composer', 'hi')
  24. await sleep(50) // fake api
  25. expect(await count('.message-list-item')).toBe(3)
  26. expect(await text('.message-list-item:nth-child(3)')).toContain('hi')
  27. }
  28. test('classic', async () => {
  29. await testChat('http://localhost:8080/classic/chat/')
  30. }, E2E_TIMEOUT)
  31. test('composition', async () => {
  32. await testChat('http://localhost:8080/composition/chat/')
  33. }, E2E_TIMEOUT)
  34. })