1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 09:23:13 +01:00

Remove phantomJS test file

This commit is contained in:
Brett Sun 2016-02-04 12:02:12 +01:00
parent 02c25c323d
commit 6362a3651f
2 changed files with 3 additions and 74 deletions

View File

@ -190,9 +190,9 @@ current execution state of that breakpoint on the page you're on.
---
To simplify triaging simple issues and test if everything is working, I've added a short test script that can be run
with PhantomJS to check if it can access the web app and log in. You can edit the `lauch_app_and_login.js` file to
change the environment to run against.
To simplify triaging simple issues and test if everything is working, The repo had a short test script that can be run
with PhantomJS to check if it can access the web app and log in. Find `onion/test/phantomjs/launch_app_and_login.js` in
the repo's history, restore it, and then run:
```bash
# In root /onion folder

View File

@ -1,71 +0,0 @@
'use strict';
var liveEnv = 'https://www.ascribe.io/app/login';
// Note that if you are trying to access staging, you will need to use
// the --ignore-ssl-errors=true flag on phantomjs
var stagingEnv = 'https://www.ascribe.ninja/app/login';
var localEnv = 'http://localhost.com:3000/login';
function launchAppAndLogin(env) {
console.log('Running test to launch ' + env + ' and log into the app');
var page = require('webpage').create();
page.open(localEnv, function(status) {
var attemptedToLogIn;
var loginCheckInterval;
console.log('Load ' + env + ': ' + status);
if (status === 'success') {
console.log('Attempting to log in...');
attemptedToLogIn = page.evaluate(function () {
try {
var inputForm = document.querySelector('.ascribe-login-wrapper');
var email = inputForm.querySelector('input[name=email]');
var password = inputForm.querySelector('input[name=password]');
var submitBtn = inputForm.querySelector('button[type=submit]');
email.value = 'dimi@mailinator.com';
password.value = '0000000000';
submitBtn.click();
return true;
} catch (ex) {
console.log('Error while trying to find login elements, not logging in.');
return false;
}
});
if (attemptedToLogIn) {
loginCheckInterval = setInterval(function () {
var loggedIn = page.evaluate(function () {
// When they log in, they are taken to the collections page.
// When the piece list is loaded, the accordion list is either available or
// shows a placeholder, so let's check for these elements to determine
// when login is finished
return !!(document.querySelector('.ascribe-accordion-list:not(.ascribe-loading-position)') ||
document.querySelector('.ascribe-accordion-list-placeholder'));
});
if (loggedIn) {
clearInterval(loginCheckInterval);
console.log('Successfully logged in.');
console.log('Edit the onion/test/phantomjs/launch_app_and_login.js file to do further actions after logging in.');
console.log('Stopping phantomJS...');
phantom.exit();
}
}, 1000);
} else {
console.log('Something happened while trying to log in, aborting...');
phantom.exit();
}
} else {
console.log('Failed to load page, exiing...');
phantom.exit();
}
});
}
launchAppAndLogin(localEnv);