provider.google.test.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* global browser */
  2. /*
  3. WARNING! PLEASE READ THIS BEFORE ENABLING THIS TEST ON TRAVIS.
  4. Before enabling this test on travis, please keep in mind that with this "no_ssl_bump_domains" option set
  5. here https://github.com/transloadit/uppy/blob/998c7b1805acb8d305a562dd9726ebae98575e07/.travis.yml#L33
  6. SSL encryption may not be enabled between the running companion and the testing browser client.
  7. Hence, provider tokens (Google, Instagram, Dropbox) may be at risk of getting hijacked.
  8. */
  9. const { finishUploadTest, startUploadTest, uploadWithRetry } = require('./helper')
  10. const testURL = 'http://localhost:4567/providers'
  11. describe('File upload with Google Drive Provider', () => {
  12. beforeEach(async () => {
  13. await browser.url(testURL)
  14. })
  15. // not using arrow functions as cb so to keep mocha in the 'this' context
  16. it('should upload a file completely with Google Drive', async function () {
  17. if (!process.env.UPPY_GOOGLE_EMAIL) {
  18. console.log('skipping Google Drive integration test')
  19. return this.skip()
  20. }
  21. // ensure session is cleared
  22. await startUploadTest(browser, 'GoogleDrive', /google/)
  23. await signIntoGoogle(browser)
  24. await finishUploadTest(browser)
  25. })
  26. // not using arrow functions as cb so to keep mocha in the 'this' context
  27. it('should resume uploads when retry is triggered with Google Drive', async function () {
  28. if (!process.env.UPPY_GOOGLE_EMAIL) {
  29. console.log('skipping Google Drive integration test')
  30. return this.skip()
  31. }
  32. await uploadWithRetry(browser, 'GoogleDrive', testURL)
  33. })
  34. })
  35. const signIntoGoogle = async (browser) => {
  36. const emailInput = await browser.$('#identifierId')
  37. await emailInput.waitForExist(30000)
  38. await emailInput.setValue(process.env.UPPY_GOOGLE_EMAIL)
  39. let nextButton = await browser.$('#identifierNext')
  40. await nextButton.click()
  41. const passwordInput = await browser.$('input[name=password]')
  42. await passwordInput.waitForDisplayed(30000)
  43. await passwordInput.setValue(process.env.UPPY_GOOGLE_PASSWORD)
  44. nextButton = await browser.$('#passwordNext')
  45. await nextButton.click()
  46. }