run.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * Copyright © 2016-2018 Threema GmbH (https://threema.ch/).
  3. *
  4. * This file is part of Threema Web.
  5. */
  6. // tslint:disable:no-unused-expression
  7. import { Selector, ClientFunction } from 'testcafe';
  8. // NOTE: These tests use test cafe.
  9. // See http://devexpress.github.io/testcafe/documentation/getting-started/ for
  10. // documentation on how to write UI tests.
  11. fixture `Compose Area`
  12. .page `http://localhost:7777/tests/ui/compose_area.html`;
  13. test('Show and hide emoji selector', async (t) => {
  14. const keyboard = await Selector('.emoji-keyboard');
  15. // Not visible initially
  16. await t.expect(keyboard.visible).eql(false);
  17. // Show
  18. await t.click('.emoji-trigger');
  19. // Visible
  20. await t.expect(keyboard.visible).eql(true);
  21. // Hide
  22. await t.click('.emoji-trigger');
  23. // Visible
  24. await t.expect(keyboard.visible).eql(false);
  25. });
  26. test('Insert emoji', async (t) => {
  27. // Show emoji keyboard
  28. await t.click('.emoji-trigger');
  29. // Insert woman zombie emoji
  30. await t.click('.e1._1f9df-2640');
  31. // Insert beer
  32. await t.click('.e1-food').click('.e1._1f37b');
  33. // Ensure both have been inserted
  34. const getChildNodeCount = await ClientFunction(() => {
  35. return document.querySelector('div.compose').childNodes.length;
  36. });
  37. await t.expect(await getChildNodeCount()).eql(2);
  38. const firstEmoji = await Selector('div.compose img').nth(0)();
  39. await t.expect(firstEmoji.tagName).eql('img');
  40. await t.expect(firstEmoji.attributes.title).eql(':woman_zombie:');
  41. await t.expect(firstEmoji.classNames).eql(['e1']);
  42. const secondEmoji = await Selector('div.compose img').nth(1)();
  43. await t.expect(secondEmoji.tagName).eql('img');
  44. await t.expect(secondEmoji.attributes.title).eql(':beers:');
  45. await t.expect(secondEmoji.classNames).eql(['e1']);
  46. });