test.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* global browser, expect, $ */
  2. const path = require('path')
  3. const fs = require('fs')
  4. const { selectFakeFile, supportsChooseFile } = require('../utils')
  5. const testURL = 'http://localhost:4567/thumbnails'
  6. const images = [
  7. path.join(__dirname, '../../resources/image.jpg'),
  8. path.join(__dirname, '../../resources/baboon.png'),
  9. path.join(__dirname, '../../resources/kodim23.png')
  10. ]
  11. describe.only('ThumbnailGenerator', () => {
  12. beforeEach(() => {
  13. browser.url(testURL)
  14. })
  15. it('should generate thumbnails for images', () => {
  16. $('#uppyThumbnails .uppy-FileInput-input').waitForExist()
  17. if (supportsChooseFile()) {
  18. for (const img of images) {
  19. browser.chooseFile('#uppyThumbnails .uppy-FileInput-input', img)
  20. }
  21. } else {
  22. for (const img of images) {
  23. browser.execute(
  24. selectFakeFile,
  25. 'uppyThumbnails',
  26. path.basename(img), // name
  27. `image/${path.extname(img).slice(1)}`, // type
  28. fs.readFileSync(img, 'base64') // b64
  29. )
  30. }
  31. }
  32. browser.pause(20 * 1000)
  33. })
  34. })