-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
e2e: reintroduce e2e test for providers locally #1706
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export UPPY_INSTAGRAM_USERNAME="***" | ||
export UPPY_INSTAGRAM_PASSWORD="***" | ||
export UPPY_GOOGLE_EMAIL="***" | ||
export UPPY_GOOGLE_PASSWORD="****" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
exports.finishUploadTest = async (browser) => { | ||
// switch back to uppy tab | ||
await browser.switchWindow(/localhost/) | ||
const fileItem = await browser.$('.uppy-ProviderBrowser-list li.uppy-ProviderBrowserItem:last-child button') | ||
await fileItem.waitForDisplayed() | ||
await fileItem.click() | ||
|
||
const uploadButton = await browser.$('.uppy-ProviderBrowser-footer .uppy-u-reset.uppy-c-btn.uppy-c-btn-primary') | ||
await uploadButton.click() | ||
const completeBar = await browser.$('.uppy-StatusBar-content[title="Complete"]') | ||
await completeBar.waitForDisplayed(20000) | ||
} | ||
|
||
exports.startUploadTest = async (browser, providerName, tabMatch) => { | ||
const providerButton = await browser.$( | ||
`.uppy-DashboardTab-btn[aria-controls=uppy-DashboardContent-panel--${providerName}]`) | ||
await providerButton.click() | ||
await browser.pause(2000) | ||
const authButton = await browser.$('.uppy-Provider-authBtn') | ||
await authButton.waitForDisplayed() | ||
await authButton.click() | ||
await browser.pause(5000) | ||
// move control to provider oauth tab | ||
await browser.switchWindow(tabMatch) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* 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. | ||
*/ | ||
const { finishUploadTest, startUploadTest } = require('./helper') | ||
const testURL = 'http://localhost:4567/providers' | ||
|
||
describe('File upload with Dropbox 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 Dropbox', async function () { | ||
if (!process.env.UPPY_GOOGLE_EMAIL) { | ||
console.log('skipping Dropbox integration test') | ||
return this.skip() | ||
} | ||
|
||
// ensure session is cleared | ||
await startUploadTest(browser, 'Dropbox', /dropbox/) | ||
// 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 dropbox 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) | ||
}) | ||
}) | ||
|
||
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 allowDropboxButton = await browser.$('#submit_approve_access') | ||
if (await allowDropboxButton.isExisting()) { | ||
// if dropbox has never been allowed, allow it | ||
await allowDropboxButton.click() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* 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. | ||
*/ | ||
const { finishUploadTest, startUploadTest } = require('./helper') | ||
const testURL = 'http://localhost:4567/providers' | ||
|
||
describe('File upload with Google Drive 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 Google Drive', async function () { | ||
if (!process.env.UPPY_GOOGLE_EMAIL) { | ||
console.log('skipping Google Drive integration test') | ||
return this.skip() | ||
} | ||
|
||
// ensure session is cleared | ||
await startUploadTest(browser, 'GoogleDrive', /google/) | ||
await signIntoGoogle(browser) | ||
await finishUploadTest(browser) | ||
}) | ||
}) | ||
|
||
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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* 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. | ||
*/ | ||
const { finishUploadTest, startUploadTest } = require('./helper') | ||
const testURL = 'http://localhost:4567/providers' | ||
|
||
describe('File upload with Instagram 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 Instagram', async function () { | ||
if (!process.env.UPPY_INSTAGRAM_USERNAME) { | ||
console.log('skipping Instagram integration test') | ||
return this.skip() | ||
} | ||
|
||
// ensure session is cleared | ||
await startUploadTest(browser, 'Instagram', /instagram/) | ||
// do oauth authentication | ||
const usernameInput = await browser.$('input[name=username]') | ||
await usernameInput.waitForExist(20000) | ||
await usernameInput.setValue(process.env.UPPY_INSTAGRAM_USERNAME) | ||
const passwordInput = await browser.$('input[name=password]') | ||
await passwordInput.setValue(process.env.UPPY_INSTAGRAM_PASSWORD) | ||
const submit = await browser.$('form button[type=submit]') | ||
await submit.click() | ||
// wait a bit for submission | ||
await browser.pause(5000) | ||
if ((await browser.getWindowHandles()).length > 1) { | ||
// if suspicious login was detected, the window will remain unclosed | ||
// so we have to input the security code sent | ||
const challengeChoice = await browser.$('input[name="choice"]') | ||
if (await challengeChoice.isExisting()) { | ||
const acceptChallengButton = await browser.$('form button') | ||
await acceptChallengButton.click() | ||
|
||
const securityCodeInput = await browser.$('input[name=security_code]') | ||
await securityCodeInput.waitForExist() | ||
// we can't automate the submission of security code | ||
// because it is sent to the email. So we wait till it is filled manually | ||
await securityCodeInput.waitUntil( | ||
async () => { | ||
await securityCodeInput.getValue() | ||
}, | ||
30000, 'expected security code to be manually entered') | ||
} | ||
|
||
// instagram may ask for auth confirmation to allow companion | ||
const allowButton = await browser.$('button[value="Authorize"]') | ||
if (await allowButton.isExisting()) { | ||
await allowButton.click() | ||
} | ||
} | ||
|
||
await finishUploadTest(browser) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,6 @@ exports.config = { | |
mochaOpts: { | ||
ui: 'bdd', | ||
reporter: 'dot', | ||
timeout: 60000 | ||
timeout: 120000 | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wdio runs Companion on :3030. can't we use that here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I resorted to 3020 for the following reasons:
I think the companion at 3030 serves for url-plugin on travis which does not need Oauth dance, also it made sense to have it because the other providers were intended to run on travis, but unfortunately, that's not the case anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@goto-bus-stop any reservations on this?