bot-share-search-scrapers.test.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. const listenForErrors = require('./lib/errors.js').listenForErrors;
  2. describe('Video embed page', () => {
  3. async function getMetaTagContent(property) {
  4. const selector = `meta[property="${property}"]`;
  5. const tag = await page.evaluate((selector) => {
  6. return document.head.querySelector(selector).getAttribute("content");
  7. }, selector);
  8. return tag;
  9. }
  10. beforeAll(async () => {
  11. await page.setViewport({ width: 1080, height: 720 });
  12. listenForErrors(browser, page);
  13. page.setUserAgent(
  14. "Mastodon"
  15. );
  16. await page.goto('http://localhost:5309');
  17. });
  18. afterAll(async () => {
  19. await page.waitForTimeout(3000);
  20. await page.screenshot({ path: 'screenshots/screenshot_bots_share_search_scrapers.png', fullPage: true });
  21. });
  22. it('should have rendered the simple bot accessible html page', async () => {
  23. await page.waitForSelector('h1');
  24. await page.waitForSelector('h3');
  25. const ogVideo = await getMetaTagContent('og:video');
  26. expect(ogVideo).toBe('http://localhost:5309/embed/video');
  27. const ogVideoType = await getMetaTagContent('og:video:type');
  28. expect(ogVideoType).toBe('text/html');
  29. // When stream is live the thumbnail is provided as the image.
  30. const ogImage = await getMetaTagContent('og:image');
  31. expect(ogImage).toBe('http://localhost:5309/thumbnail.jpg');
  32. const twitterUrl = await getMetaTagContent('twitter:url');
  33. expect(twitterUrl).toBe('http://localhost:5309/');
  34. const twitterImage = await getMetaTagContent('twitter:image');
  35. expect(twitterImage).toBe('http://localhost:5309/logo/external');
  36. });
  37. });