Commit c905bc72 authored by Johannes Zellner's avatar Johannes Zellner

Bring tests up-to-date

parent f9b34faf
This diff is collapsed.
......@@ -7,19 +7,13 @@
"test": "mocha --bail test.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"ejs": "^3.0.1",
"expect.js": "^0.3.1",
"mkdirp": "^0.5.1",
"mocha": "^6.2.2",
"rimraf": "^3.0.0",
"superagent": "^5.1.2"
},
"license": "MIT",
"devDependencies": {},
"dependencies": {
"chromedriver": "^78.0.1",
"selenium-server-standalone-jar": "^3.141.59",
"selenium-webdriver": "^4.0.0-alpha.5",
"superagent": "^1.8.5"
"chromedriver": "^79.0.0",
"expect.js": "^0.3.1",
"mocha": "^7.0.0",
"selenium-webdriver": "^3.6.0",
"superagent": "^5.2.1"
}
}
......@@ -9,39 +9,27 @@
'use strict';
require('chromedriver');
var execSync = require('child_process').execSync,
expect = require('expect.js'),
path = require('path'),
superagent = require('superagent'),
webdriver = require('selenium-webdriver');
var by = webdriver.By,
Builder = require('selenium-webdriver').Builder;
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
{ Builder, By, until } = require('selenium-webdriver'),
{ Options } = require('selenium-webdriver/chrome');
describe('Application life cycle test', function () {
this.timeout(0);
var server, browser = new Builder().forBrowser('chrome').build();
var LOCATION = 'test';
var app;
before(function (done) {
var seleniumJar= require('selenium-server-standalone-jar');
var SeleniumServer = require('selenium-webdriver/remote').SeleniumServer;
server = new SeleniumServer(seleniumJar.path, { port: 4444 });
server.start();
var browser;
var app;
done();
before(function () {
browser = new Builder().forBrowser('chrome').setChromeOptions(new Options().windowSize({ width: 1280, height: 1024 })).build();
});
after(function (done) {
after(function () {
browser.quit();
server.kill();
done();
});
const MESSAGE2 = 'Upload/Download Text File secret message';
......@@ -51,17 +39,17 @@ describe('Application life cycle test', function () {
const testFilePath = `${path.resolve(__dirname, '.')}/test.txt`;
browser.get('https://' + app.fqdn).then(function() {
return browser.findElement(by.id('message')).sendKeys(MESSAGE2);
return browser.findElement(By.id('message')).sendKeys(MESSAGE2);
}).then(function() {
return browser.findElement(by.id('file')).sendKeys(testFilePath);
return browser.findElement(By.id('file')).sendKeys(testFilePath);
}).then(function() {
return browser.findElement(by.id('attach')).click();
return browser.findElement(By.id('attach')).click();
}).then(function() {
return browser.findElement(by.id('sendbutton')).click();
return browser.findElement(By.id('sendbutton')).click();
}).then(function() {
return browser.sleep(5000);
}).then(function() {
return browser.findElement(by.id('pasteurl')).getText();
return browser.findElement(By.id('pasteurl')).getText();
}).then(function(url) {
pasteUrl = url;
console.log(`pasteUrl is ${pasteUrl}`);
......@@ -80,15 +68,15 @@ describe('Application life cycle test', function () {
}).then(function () {
return browser.sleep(2000);
}).then(function () {
return browser.findElement(by.id('prettyprint')).getText();
return browser.findElement(By.id('prettyprint')).getText();
}).then(function(text) {
if (text !== MESSAGE2) return Promise.reject(new Error(`Message mismatch: Actual: ${text} Expected: ${MESSAGE2}`));
}).then(function () {
return browser.findElement(by.id('attachment')).getText();
return browser.findElement(By.id('attachment')).getText();
}).then(function(text) {
if (!text.includes('Download attachment')) return Promise.reject(new Error('No attachment'));
}).then(function() {
return browser.findElement(by.xpath('//div[@id="attachment"]/a')).getAttribute('href');
return browser.findElement(By.xpath('//div[@id="attachment"]/a')).getAttribute('href');
}).then(function(href) {
if (!href.includes(app.fqdn)) return Promise.reject(new Error('href does not include app fqdn'));
......@@ -97,7 +85,7 @@ describe('Application life cycle test', function () {
}).then(function() {
return browser.sleep(2000);
}).then(function() {
return browser.findElement(by.tagName('body')).getText();
return browser.findElement(By.tagName('body')).getText();
}).then(function(bodyContents) {
if (bodyContents !== 'Test txt file upload') return Promise.reject(new Error('File contents does not match'));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment