Browse Source

test: handle google's suspicious login

Ifedapo Olarewaju 6 years ago
parent
commit
425f9119ed
1 changed files with 22 additions and 0 deletions
  1. 22 0
      test/endtoend/providers/test.js

+ 22 - 0
test/endtoend/providers/test.js

@@ -51,8 +51,10 @@ describe('File upload with Providers', () => {
     browser.reload()
     browser.reload()
   })
   })
 
 
+  // not using arrow functions as cb so to keep mocha in the 'this' context
   it('should upload a file completely with Google Drive', function () {
   it('should upload a file completely with Google Drive', function () {
     if (process.env.UPPY_GOOGLE_EMAIL === undefined) {
     if (process.env.UPPY_GOOGLE_EMAIL === undefined) {
+      console.log('skipping Google Drive integration test')
       return this.skip()
       return this.skip()
     }
     }
 
 
@@ -61,8 +63,10 @@ describe('File upload with Providers', () => {
     finishUploadTest(browser)
     finishUploadTest(browser)
   })
   })
 
 
+  // not using arrow functions as cb so to keep mocha in the 'this' context
   it('should upload a file completely with Instagram', function () {
   it('should upload a file completely with Instagram', function () {
     if (process.env.UPPY_INSTAGRAM_USERNAME === undefined) {
     if (process.env.UPPY_INSTAGRAM_USERNAME === undefined) {
+      console.log('skipping Instagram integration test')
       return this.skip()
       return this.skip()
     }
     }
 
 
@@ -76,8 +80,10 @@ describe('File upload with Providers', () => {
     finishUploadTest(browser)
     finishUploadTest(browser)
   })
   })
 
 
+  // not using arrow functions as cb so to keep mocha in the 'this' context
   it('should upload a file completely with Dropbox', function () {
   it('should upload a file completely with Dropbox', function () {
     if (process.env.UPPY_GOOGLE_EMAIL === undefined) {
     if (process.env.UPPY_GOOGLE_EMAIL === undefined) {
+      console.log('skipping Dropbox integration test')
       return this.skip()
       return this.skip()
     }
     }
 
 
@@ -121,4 +127,20 @@ const signIntoGoogle = (browser) => {
   browser.waitForVisible('input[name=password]')
   browser.waitForVisible('input[name=password]')
   browser.setValue('input[name=password]', process.env.UPPY_GOOGLE_PASSWORD)
   browser.setValue('input[name=password]', process.env.UPPY_GOOGLE_PASSWORD)
   browser.click('#passwordNext')
   browser.click('#passwordNext')
+  // if suspicious login was detected, the window will remain unclosed
+  // so we have to confirm the recovery email or phone no
+  if (browser.getTabIds().length > 1) {
+    // confirm recovery email option
+    if (browser.isExisting('li div[data-challengetype="12"]')) {
+      browser.click('li div[data-challengetype="12"]')
+      browser.waitForVisible('input[name=knowledgePreregisteredEmailResponse]')
+      browser.setValue('input[name=knowledgePreregisteredEmailResponse]', process.env.UPPY_GOOGLE_RECOVERY_EMAIL)
+      // confirm recovery phone number
+    } else if (browser.isExisting('#countryList')) {
+      browser.click('div#countryList')
+      browser.click('div[data-value=nl]')
+      browser.setValue('input#phoneNumberId', process.env.UPPY_GOOGLE_PHONE_NO)
+    }
+    browser.click('#next[role=button]')
+  }
 }
 }