test.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* global browser, expect, $, $$ */
  2. const testURL = 'http://localhost:4567/create-react-app'
  3. describe('webpack build', () => {
  4. beforeEach(async () => {
  5. await browser.url(testURL)
  6. })
  7. it('should include CSS', async () => {
  8. const el = await $('#inline-dashboard .uppy-Dashboard-inner')
  9. await el.waitForExist()
  10. const bgColor = await el.getCSSProperty('background-color')
  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.value)).to.equal(true)
  13. })
  14. })
  15. describe('React: Dashboard', () => {
  16. beforeEach(async () => {
  17. await browser.url(testURL)
  18. })
  19. it('should have Google Drive panel', async () => {
  20. const el = await $('#inline-dashboard .uppy-Dashboard-inner')
  21. await el.waitForExist()
  22. const tabs = await $$('.uppy-DashboardTab-name')
  23. let hasGDrive = false
  24. for (const name of tabs) {
  25. hasGDrive = (await name.getText()) === 'Google Drive'
  26. if (hasGDrive) break
  27. }
  28. expect(hasGDrive).to.equal(true)
  29. })
  30. it('should survive being mounted and unmounted', async () => {
  31. const el = await $('#inline-dashboard .uppy-Dashboard-inner')
  32. await el.waitForExist()
  33. async function toggle () {
  34. const button = await $('#inline-dashboard-toggle')
  35. await button.click()
  36. await browser.pause(250)
  37. }
  38. // close
  39. await toggle()
  40. // open
  41. await toggle()
  42. // close
  43. await toggle()
  44. // open
  45. await toggle()
  46. // open GDrive panel
  47. const gdriveButton = await $('.uppy-DashboardTab[data-uppy-acquirer-id="GoogleDrive"] button')
  48. await gdriveButton.click()
  49. await browser.pause(500)
  50. // side effecting property access, not a function!
  51. // eslint-disable-next-line no-unused-expressions
  52. expect(await $('.uppy-Provider-authBtn')).to.exist
  53. })
  54. })
  55. describe('React: DashboardModal', () => {
  56. beforeEach(async () => {
  57. await browser.url(testURL)
  58. })
  59. it('should have controlled open and close', async () => {
  60. const modalToggle = await $('#modal-dashboard-toggle')
  61. const modalWrapper = await $('#modal-dashboard .uppy-Dashboard--modal')
  62. const modalClose = await $('#modal-dashboard .uppy-Dashboard-close')
  63. await modalToggle.waitForExist()
  64. expect(await modalWrapper.getAttribute('aria-hidden')).to.equal('true')
  65. await modalToggle.click()
  66. await browser.pause(50) // wait for the animation to start
  67. // Edge appears to report empty string while others report null
  68. expect(await modalWrapper.getAttribute('aria-hidden')).to.be.oneOf([null, 'false'])
  69. await browser.pause(500) // wait for the animation to complete
  70. await modalClose.click()
  71. await browser.pause(500) // wait for the animation to complete
  72. expect(await modalWrapper.getAttribute('aria-hidden')).to.equal('true')
  73. })
  74. })