Ver Fonte

Provider integration test fixes

- Skip tests if the credentials for google or instagram are not
available.
- Run a companion process.
Renée Kooi há 6 anos atrás
pai
commit
1e3cc35826
1 ficheiros alterados com 46 adições e 4 exclusões
  1. 46 4
      test/endtoend/providers/test.js

+ 46 - 4
test/endtoend/providers/test.js

@@ -1,7 +1,37 @@
 /* global browser, expect  */
 /* global browser, expect  */
+const { spawn } = require('child_process')
 const testURL = 'http://localhost:4567/providers'
 const testURL = 'http://localhost:4567/providers'
 
 
 describe('File upload with Providers', () => {
 describe('File upload with Providers', () => {
+  let companion
+  function prematureExit () {
+    throw new Error('Companion exited early')
+  }
+  before(() => {
+    companion = spawn('npm', ['run', 'start:companion'], {
+      stdio: 'pipe'
+    })
+    return new Promise((resolve, reject) => {
+      companion.on('error', reject)
+      companion.stdout.on('data', (chunk) => {
+        if (`${chunk}`.includes('Listening on')) {
+          resolve()
+        }
+      })
+
+      companion.on('error', console.error)
+      companion.stderr.pipe(process.stderr)
+      companion.on('exit', prematureExit)
+    })
+  })
+  after(() => {
+    return new Promise((resolve) => {
+      companion.removeListener('exit', prematureExit)
+      companion.on('exit', () => resolve())
+      companion.kill('SIGINT')
+    })
+  })
+
   beforeEach(() => {
   beforeEach(() => {
     browser.url(testURL)
     browser.url(testURL)
   })
   })
@@ -10,24 +40,36 @@ describe('File upload with Providers', () => {
     browser.reload()
     browser.reload()
   })
   })
 
 
-  it('should upload a file completely with Google Drive', () => {
+  it('should upload a file completely with Google Drive', function () {
+    if (process.env.UPPY_GOOGLE_EMAIL === undefined) {
+      return this.skip()
+    }
+
     startUploadTest(browser, 'GoogleDrive')
     startUploadTest(browser, 'GoogleDrive')
     signIntoGoogle(browser)
     signIntoGoogle(browser)
     finishUploadTest(browser)
     finishUploadTest(browser)
   })
   })
 
 
-  it('should upload a file completely with Instagram', () => {
+  it('should upload a file completely with Instagram', function () {
+    if (process.env.UPPY_INSTAGRAM_USERNAME === undefined) {
+      return this.skip()
+    }
+
     startUploadTest(browser, 'Instagram')
     startUploadTest(browser, 'Instagram')
     // do oauth authentication
     // do oauth authentication
     browser.waitForExist('input[name=username]')
     browser.waitForExist('input[name=username]')
     browser.setValue('input[name=username]', process.env.UPPY_INSTAGRAM_USERNAME)
     browser.setValue('input[name=username]', process.env.UPPY_INSTAGRAM_USERNAME)
     browser.setValue('input[name=password]', process.env.UPPY_INSTAGRAM_PASSWORD)
     browser.setValue('input[name=password]', process.env.UPPY_INSTAGRAM_PASSWORD)
-    browser.click('button')
+    browser.click('form button')
 
 
     finishUploadTest(browser)
     finishUploadTest(browser)
   })
   })
 
 
-  it('should upload a file completely with Dropbox', () => {
+  it('should upload a file completely with Dropbox', function () {
+    if (process.env.UPPY_GOOGLE_EMAIL === undefined) {
+      return this.skip()
+    }
+
     startUploadTest(browser, 'Dropbox')
     startUploadTest(browser, 'Dropbox')
     // do oauth authentication
     // do oauth authentication
     browser.waitForVisible('button.auth-google')
     browser.waitForVisible('button.auth-google')