test.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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(/^rgba?\(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(250)
  31. // open
  32. browser.click('#inline-dashboard-toggle')
  33. browser.pause(250)
  34. // close
  35. browser.click('#inline-dashboard-toggle')
  36. browser.pause(250)
  37. // open
  38. browser.click('#inline-dashboard-toggle')
  39. browser.pause(250)
  40. // open GDrive panel
  41. browser.click('.uppy-DashboardTab:nth-child(2) button')
  42. browser.pause(500)
  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. // Edge appears to report empty string while others report null
  60. expect(modalWrapper.getAttribute('aria-hidden')).to.be.oneOf([null, ''])
  61. browser.pause(500) // wait for the animation to complete
  62. modalClose.click()
  63. browser.pause(500) // wait for the animation to complete
  64. expect(modalWrapper.getAttribute('aria-hidden')).to.equal('true')
  65. })
  66. })