chat.spec.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { setupPuppeteer, E2E_TIMEOUT } from 'test/helpers'
  2. describe('e2e/chat', () => {
  3. const { page, text, count, click, enterValue, sleep } = setupPuppeteer()
  4. test('chat app', async () => {
  5. await page().goto('http://localhost:8080/chat/')
  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. }, E2E_TIMEOUT)
  28. })