Преглед изворни кода

companion: fix box provider tests + remove unused e2e test files (#2628)

Ifedapo .A. Olarewaju пре 4 година
родитељ
комит
9fff34b11e

+ 1 - 1
packages/@uppy/companion/test/__tests__/provider-manager.js

@@ -96,7 +96,7 @@ describe('Test Provider options', () => {
     providerManager.addProviderOptions(companionOptions, grantConfig)
 
     expect(grantConfig.dropbox.secret).toBe('xobpord')
-    expect(grantConfig.box.secret).toBe('xobpord')
+    expect(grantConfig.box.secret).toBe('xwbepqd')
     expect(grantConfig.google.secret).toBe('elgoog')
     expect(grantConfig.instagram.secret).toBe('margatsni')
     expect(grantConfig.zoom.secret).toBe('u8Z5ceq')

+ 37 - 0
packages/@uppy/companion/test/fixtures/box.js

@@ -0,0 +1,37 @@
+const defaults = require('./constants')
+
+module.exports.responses = {
+  'users/me': {
+    get: {
+      login: defaults.USERNAME
+    }
+  },
+  'folders/0/items': {
+    get: {
+      entries: [
+        {
+          type: 'file',
+          name: defaults.ITEM_NAME,
+          id: defaults.ITEM_ID,
+          modified_at: '2015-05-12T15:50:38Z',
+          size: defaults.FILE_SIZE
+        }
+      ]
+    }
+  },
+  [`files/${defaults.ITEM_ID}`]: {
+    get: {
+      size: defaults.FILE_SIZE
+    }
+  },
+  'https://api.box.com/oauth2/revoke': {
+    post: {}
+  },
+  [`files/${defaults.ITEM_ID}/content`]: {
+    get: {}
+  }
+}
+
+module.exports.expects = {
+  itemIcon: 'file'
+}

+ 1 - 0
packages/@uppy/companion/test/fixtures/index.js

@@ -1,4 +1,5 @@
 module.exports.providers = {
+  box: require('./box'),
   drive: require('./drive'),
   dropbox: require('./dropbox'),
   instagram: require('./instagram'),

+ 1 - 1
packages/@uppy/companion/test/fixtures/onedrive.js

@@ -7,7 +7,7 @@ module.exports.responses = {
       mail: defaults.USERNAME
     }
   },
-  '/drive/root/children': {
+  '/me/drive/root/children': {
     get: {
       value: [
         {

+ 1 - 0
packages/@uppy/companion/test/resources/box_secret_file

@@ -0,0 +1 @@
+xwbepqd

+ 0 - 2
test/endtoend/providers/main.js

@@ -5,7 +5,6 @@ const Dashboard = require('@uppy/dashboard')
 const GoogleDrive = require('@uppy/google-drive')
 const Instagram = require('@uppy/instagram')
 const Dropbox = require('@uppy/dropbox')
-const Box = require('@uppy/box')
 const Tus = require('@uppy/tus')
 
 const isOnTravis = !!(process.env.TRAVIS && process.env.CI)
@@ -23,7 +22,6 @@ window.uppy = new Uppy({
   .use(GoogleDrive, { target: Dashboard, companionUrl })
   .use(Instagram, { target: Dashboard, companionUrl })
   .use(Dropbox, { target: Dashboard, companionUrl })
-  .use(Box, { target: Dashboard, companionUrl })
   .use(Tus, { endpoint: 'https://master.tus.io/files/' })
 
 if (window.location.search === '?socketerr=true') {

+ 0 - 90
test/endtoend/providers/provider.box.test.js

@@ -1,90 +0,0 @@
-/* global browser  */
-
-/*
-  WARNING! PLEASE READ THIS BEFORE ENABLING THIS TEST ON TRAVIS.
-
-  Before enabling this test on travis, please keep in mind that with this "no_ssl_bump_domains" option set
-  here https://github.com/transloadit/uppy/blob/998c7b1805acb8d305a562dd9726ebae98575e07/.travis.yml#L33
-  SSL encryption may not be enabled between the running companion and the testing browser client.
-
-  Hence, provider tokens (Google, Instagram, Dropbox) may be at risk of getting hijacked.
-*/
-// TODO: @cartfisk - box provider
-const { finishUploadTest, startUploadTest, uploadWithRetry } = require('./helper')
-const testURL = 'http://localhost:4567/providers'
-
-describe('File upload with Box Provider', () => {
-  beforeEach(async () => {
-    await browser.url(testURL)
-  })
-
-  // not using arrow functions as cb so to keep mocha in the 'this' context
-  it('should upload a file completely with Box', async function () {
-    if (!process.env.UPPY_GOOGLE_EMAIL) {
-      console.log('skipping Box integration test')
-      return this.skip()
-    }
-
-    // ensure session is cleared
-    await startUploadTest(browser, 'Box', /box/)
-    // do oauth authentication
-    const authButton = await browser.$('button.auth-google')
-    await authButton.waitForDisplayed()
-    await authButton.click()
-    await browser.pause(3000)
-    // we login with google to avoid captcha
-    await signIntoGoogle(browser)
-    await browser.pause(5000)
-    // if we box displays a warning about trusting the companion app
-    //  we allow it because we trust companion. Companion is our friend.
-    const acceptWarning = await browser.$('#warning-button-continue')
-    if (await acceptWarning.isExisting()) {
-      await acceptWarning.click()
-    }
-
-    await browser.pause(3000)
-    // finish oauth
-    const allowAccessButton = await browser.$('button[name=allow_access]')
-    await allowAccessButton.waitForDisplayed()
-    await allowAccessButton.click()
-
-    await finishUploadTest(browser)
-  })
-
-  // not using arrow functions as cb so to keep mocha in the 'this' context
-  it('should resume uploads when retry is triggered with Box', async function () {
-    if (!process.env.UPPY_GOOGLE_EMAIL) {
-      console.log('skipping Box integration test')
-      return this.skip()
-    }
-
-    await uploadWithRetry(browser, 'Box', testURL)
-  })
-})
-
-const signIntoGoogle = async (browser) => {
-  const emailInput = await browser.$('#identifierId')
-  await emailInput.waitForExist(30000)
-  await emailInput.setValue(process.env.UPPY_GOOGLE_EMAIL)
-  let nextButton = await browser.$('#identifierNext')
-  await nextButton.click()
-
-  const passwordInput = await browser.$('input[name=password]')
-  await passwordInput.waitForDisplayed(30000)
-  await passwordInput.setValue(process.env.UPPY_GOOGLE_PASSWORD)
-  nextButton = await browser.$('#passwordNext')
-  await nextButton.click()
-  await browser.pause(3000)
-
-  const emailListItem = await browser.$(`li div[data-identifier="${process.env.UPPY_GOOGLE_EMAIL}"]`)
-  if (await emailListItem.isExisting()) {
-    // if user is already signed in, just select user
-    await emailListItem.click()
-  }
-
-  const allowBoxButton = await browser.$('#submit_approve_access')
-  if (await allowBoxButton.isExisting()) {
-    // if box has never been allowed, allow it
-    await allowBoxButton.click()
-  }
-}

+ 0 - 69
test/endtoend/providers/provider.zoom.test.js

@@ -1,69 +0,0 @@
-/* global browser  */
-
-/*
-  WARNING! PLEASE READ THIS BEFORE ENABLING THIS TEST ON TRAVIS.
-
-  Before enabling this test on travis, please keep in mind that with this "no_ssl_bump_domains" option set
-  here https://github.com/transloadit/uppy/blob/998c7b1805acb8d305a562dd9726ebae98575e07/.travis.yml#L33
-  SSL encryption may not be enabled between the running companion and the testing browser client.
-
-  Hence, provider tokens (Google, Instagram, Zoom) may be at risk of getting hijacked.
-*/
-const { finishUploadTest, startUploadTest, uploadWithRetry } = require('./helper')
-const testURL = 'http://localhost:4567/providers'
-
-describe('File upload with Zoom Provider', () => {
-  beforeEach(async () => {
-    await browser.url(testURL)
-  })
-
-  // not using arrow functions as cb so to keep mocha in the 'this' context
-  it('should upload a file completely with Zoom', async function () {
-    if (!process.env.UPPY_GOOGLE_EMAIL) {
-      console.log('skipping Zoom integration test')
-      return this.skip()
-    }
-
-    // ensure session is cleared
-    await startUploadTest(browser, 'Zoom', /zoom/)
-    await signIntoGoogle(browser)
-    await finishUploadTest(browser)
-  })
-
-  // not using arrow functions as cb so to keep mocha in the 'this' context
-  it('should resume uploads when retry is triggered with Zoom', async function () {
-    if (!process.env.UPPY_GOOGLE_EMAIL) {
-      console.log('skipping Zoom integration test')
-      return this.skip()
-    }
-
-    await uploadWithRetry(browser, 'Zoom', testURL)
-  })
-})
-
-const signIntoGoogle = async (browser) => {
-  const emailInput = await browser.$('#identifierId')
-  await emailInput.waitForExist(30000)
-  await emailInput.setValue(process.env.UPPY_GOOGLE_EMAIL)
-  let nextButton = await browser.$('#identifierNext')
-  await nextButton.click()
-
-  const passwordInput = await browser.$('input[name=password]')
-  await passwordInput.waitForDisplayed(30000)
-  await passwordInput.setValue(process.env.UPPY_GOOGLE_PASSWORD)
-  nextButton = await browser.$('#passwordNext')
-  await nextButton.click()
-  await browser.pause(3000)
-
-  const emailListItem = await browser.$(`li div[data-identifier="${process.env.UPPY_GOOGLE_EMAIL}"]`)
-  if (await emailListItem.isExisting()) {
-    // if user is already signed in, just select user
-    await emailListItem.click()
-  }
-
-  const allowZoomButton = await browser.$('#submit_approve_access')
-  if (await allowZoomButton.isExisting()) {
-    // if Zoom has never been allowed, allow it
-    await allowZoomButton.click()
-  }
-}

+ 0 - 2
test/endtoend/typescript/main.ts

@@ -5,7 +5,6 @@ import {
   Dashboard,
   Instagram,
   Dropbox,
-  Box,
   GoogleDrive,
   Url,
   Webcam,
@@ -38,7 +37,6 @@ const uppy = Core<Core.StrictTypes>({
   .use(GoogleDrive, { target: Dashboard, companionUrl: 'http://localhost:3020' })
   .use(Instagram, { target: Dashboard, companionUrl: 'http://localhost:3020' })
   .use(Dropbox, { target: Dashboard, companionUrl: 'http://localhost:3020' })
-  .use(Box, { target: Dashboard, companionUrl: 'http://localhost:3020' })
   .use(Url, { target: Dashboard, companionUrl: 'http://localhost:3020' })
   .use(Webcam, { target: Dashboard })
   .use(Tus, { endpoint: TUS_ENDPOINT })

+ 0 - 2
test/endtoend/utils.js

@@ -79,8 +79,6 @@ class CompanionService {
         COMPANION_SECRET: process.env.TEST_COMPANION_SECRET,
         COMPANION_DROPBOX_KEY: process.env.TEST_COMPANION_DROPBOX_KEY,
         COMPANION_DROPBOX_SECRET: process.env.TEST_COMPANION_DROPBOX_SECRET,
-        COMPANION_BOX_KEY: process.env.TEST_COMPANION_BOX_KEY,
-        COMPANION_BOX_SECRET: process.env.TEST_COMPANION_BOX_SECRET,
         COMPANION_GOOGLE_KEY: process.env.TEST_COMPANION_GOOGLE_KEY,
         COMPANION_GOOGLE_SECRET: process.env.TEST_COMPANION_GOOGLE_SECRET
       }

+ 0 - 15
test/resources/1020-percent-state.json

@@ -44,11 +44,6 @@
           "name": "Dropbox",
           "type": "acquirer"
         },
-        {
-          "id": "Box",
-          "name": "Box",
-          "type": "acquirer"
-        },
         {
           "id": "Url",
           "name": "Link",
@@ -534,16 +529,6 @@
       "filterInput": "",
       "isSearchVisible": false
     },
-    "Box": {
-      "currentSelection": [],
-      "authenticated": false,
-      "files": [],
-      "folders": [],
-      "directories": [],
-      "activeRow": -1,
-      "filterInput": "",
-      "isSearchVisible": false
-    },
     "Webcam": {
       "cameraReady": false
     }

+ 0 - 1
website/inject.js

@@ -43,7 +43,6 @@ const packages = [
   '@uppy/dashboard',
   '@uppy/drag-drop',
   '@uppy/dropbox',
-  '@uppy/box',
   '@uppy/file-input',
   '@uppy/form',
   '@uppy/golden-retriever',