Prechádzať zdrojové kódy

Merge pull request #1013 from transloadit/fix/provider-test

Provider integration test fixes
Ifedapo .A. Olarewaju 6 rokov pred
rodič
commit
47851e91f6

+ 9 - 9
test/endtoend/create-react-app/package-lock.json

@@ -8752,9 +8752,9 @@
       }
     },
     "react": {
-      "version": "16.4.1",
-      "resolved": "https://registry.npmjs.org/react/-/react-16.4.1.tgz",
-      "integrity": "sha512-3GEs0giKp6E0Oh/Y9ZC60CmYgUPnp7voH9fbjWsvXtYFb4EWtgQub0ADSq0sJR0BbHc4FThLLtzlcFaFXIorwg==",
+      "version": "16.4.2",
+      "resolved": "https://registry.npmjs.org/react/-/react-16.4.2.tgz",
+      "integrity": "sha512-dMv7YrbxO4y2aqnvA7f/ik9ibeLSHQJTI6TrYAenPSaQ6OXfb+Oti+oJiy8WBxgRzlKatYqtCjphTgDSCEiWFg==",
       "requires": {
         "fbjs": "^0.8.16",
         "loose-envify": "^1.1.0",
@@ -8788,9 +8788,9 @@
       }
     },
     "react-dom": {
-      "version": "16.4.1",
-      "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.4.1.tgz",
-      "integrity": "sha512-1Gin+wghF/7gl4Cqcvr1DxFX2Osz7ugxSwl6gBqCMpdrxHjIFUS7GYxrFftZ9Ln44FHw0JxCFD9YtZsrbR5/4A==",
+      "version": "16.4.2",
+      "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.4.2.tgz",
+      "integrity": "sha512-Usl73nQqzvmJN+89r97zmeUpQDKDlh58eX6Hbs/ERdDHzeBzWy+ENk7fsGQ+5KxArV1iOFPT46/VneklK9zoWw==",
       "requires": {
         "fbjs": "^0.8.16",
         "loose-envify": "^1.1.0",
@@ -10497,9 +10497,9 @@
       }
     },
     "url-parse": {
-      "version": "1.4.1",
-      "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.1.tgz",
-      "integrity": "sha512-x95Td74QcvICAA0+qERaVkRpTGKyBHHYdwL2LXZm5t/gBtCB9KQSO/0zQgSTYEV1p0WcvSg79TLNPSvd5IDJMQ==",
+      "version": "1.4.3",
+      "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.3.tgz",
+      "integrity": "sha512-rh+KuAW36YKo0vClhQzLLveoj8FwPJNu65xLb7Mrt+eZht0IPT0IXgSv8gcMegZ6NvjJUALf6Mf25POlMwD1Fw==",
       "requires": {
         "querystringify": "^2.0.0",
         "requires-port": "^1.0.0"

+ 2 - 2
test/endtoend/create-react-app/package.json

@@ -5,8 +5,8 @@
   "homepage": "/create-react-app/",
   "dependencies": {
     "es6-shim": "^0.35.3",
-    "react": "^16.4.1",
-    "react-dom": "^16.4.1",
+    "react": "^16.4.2",
+    "react-dom": "^16.4.2",
     "react-scripts": "1.1.4"
   },
   "scripts": {

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

@@ -1,7 +1,48 @@
 /* global browser, expect  */
+const path = require('path')
+const { spawn } = require('child_process')
 const testURL = 'http://localhost:4567/providers'
 
 describe('File upload with Providers', () => {
+  let companion
+  function prematureExit () {
+    throw new Error('Companion exited early')
+  }
+  before(() => {
+    companion = spawn('node', [
+      path.join(__dirname, '../../../packages/@uppy/companion/lib/standalone/start-server')
+    ], {
+      stdio: 'pipe',
+      env: Object.assign({}, process.env, {
+        UPPYSERVER_DATADIR: path.join(__dirname, '../../../output'),
+        UPPYSERVER_DOMAIN: 'localhost:3020',
+        UPPYSERVER_PROTOCOL: 'http',
+        UPPYSERVER_PORT: 3020,
+        UPPY_ENDPOINTS: '',
+        UPPYSERVER_SECRET: 'test'
+      })
+    })
+    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(() => {
     browser.url(testURL)
   })
@@ -10,24 +51,36 @@ describe('File upload with Providers', () => {
     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')
     signIntoGoogle(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')
     // do oauth authentication
     browser.waitForExist('input[name=username]')
     browser.setValue('input[name=username]', process.env.UPPY_INSTAGRAM_USERNAME)
     browser.setValue('input[name=password]', process.env.UPPY_INSTAGRAM_PASSWORD)
-    browser.click('button')
+    browser.click('form button')
 
     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')
     // do oauth authentication
     browser.waitForVisible('button.auth-google')