test.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* global browser, expect, $, $$ */
  2. const testURL = 'http://localhost:4567/create-react-app'
  3. describe('webpack build', () => {
  4. beforeEach(() => {
  5. browser.url(testURL)
  6. })
  7. it('should include CSS', () => {
  8. const el = $('#inline-dashboard .uppy-Dashboard-inner')
  9. el.waitForExist()
  10. const bgColor = el.getCssProperty('background-color').value
  11. // computed value is rgb() or rgba(), not hex (but listing it here to show the expected value too)
  12. expect(/^rgb\(250, ?250, ?250(?:, ?1)?\)$|^#fafafa$/.test(bgColor)).to.equal(true)
  13. })
  14. })
  15. describe('React: Dashboard', () => {
  16. beforeEach(() => {
  17. browser.url(testURL)
  18. })
  19. it('should have Google Drive panel', () => {
  20. const el = $('#inline-dashboard .uppy-Dashboard-inner')
  21. el.waitForExist()
  22. const tabs = $$('.uppy-DashboardTab-name')
  23. expect(tabs.some(name => name.getText() === 'Google Drive')).to.equal(true)
  24. })
  25. it('should survive being mounted and unmounted', () => {
  26. const el = $('#inline-dashboard .uppy-Dashboard-inner')
  27. el.waitForExist()
  28. // close
  29. browser.click('#inline-dashboard-toggle')
  30. browser.pause(50)
  31. // open
  32. browser.click('#inline-dashboard-toggle')
  33. browser.pause(50)
  34. // close
  35. browser.click('#inline-dashboard-toggle')
  36. browser.pause(50)
  37. // open
  38. browser.click('#inline-dashboard-toggle')
  39. browser.pause(50)
  40. // open GDrive panel
  41. browser.click('.uppy-DashboardTab:nth-child(2) button')
  42. browser.pause(50)
  43. // side effecting property access, not a function!
  44. // eslint-disable-next-line no-unused-expressions
  45. expect($('.uppy-Provider-authBtn')).to.exist
  46. })
  47. })
  48. describe('React: DashboardModal', () => {
  49. beforeEach(() => {
  50. browser.url(testURL)
  51. })
  52. it('should have controlled open and close', () => {
  53. const modalToggle = $('#modal-dashboard-toggle')
  54. const modalWrapper = $('#modal-dashboard .uppy-Dashboard--modal')
  55. const modalClose = $('#modal-dashboard .uppy-Dashboard-close')
  56. expect(modalWrapper.getAttribute('aria-hidden')).to.equal('true')
  57. modalToggle.click()
  58. browser.pause(50) // wait for the animation to start
  59. expect(modalWrapper.getAttribute('aria-hidden')).to.equal(null)
  60. browser.pause(500) // wait for the animation to complete
  61. modalClose.click()
  62. browser.pause(500) // wait for the animation to complete
  63. expect(modalWrapper.getAttribute('aria-hidden')).to.equal('true')
  64. })
  65. })