out with the old

This commit is contained in:
Ron
2017-03-17 20:34:15 -07:00
parent ccf7f03dab
commit bd8344c808
189 changed files with 0 additions and 49048 deletions

View File

@@ -1,10 +0,0 @@
/*
* Web driver manager
*/
'use strict';
var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder().withCapabilities(webdriver.Capabilities.firefox()).build();
module.exports = driver;

View File

@@ -1,10 +0,0 @@
'use strict';
var path = require('path');
var SPEC_FILE_EXT = '.json';
module.exports.parseSpecFilename = function (name) {
var filename = path.parse(name);
var foldername = filename.dir.split(path.sep).splice(-1)[0];
return [path.sep, foldername, path.sep, filename.name, SPEC_FILE_EXT].join('');
};

View File

@@ -1,42 +0,0 @@
/*
* Swagger UI and Specs Servers
*/
'use strict';
var path = require('path');
var createServer = require('http-server').createServer;
var dist = path.join(__dirname, '..', '..', 'dist');
var specs = path.join(__dirname, '..', '..', 'test', 'specs');
var DOCS_PORT = 8080;
var SPEC_SERVER_PORT = 8081;
var driver = require('./driver');
var swaggerUI;
var specServer;
module.exports.start = function (specsLocation, done) {
swaggerUI = createServer({ root: dist, cors: true });
specServer = createServer({ root: specs, cors: true });
swaggerUI.listen(DOCS_PORT);
specServer.listen(SPEC_SERVER_PORT);
var swaggerSpecLocation = encodeURIComponent('http://localhost:' + SPEC_SERVER_PORT + specsLocation);
var url = 'http://localhost:' + DOCS_PORT + '/index.html?url=' + swaggerSpecLocation;
setTimeout(function(){
driver.get(url);
setTimeout(function() {
done();
}, 2000);
console.log('waiting for UI to load');
}, process.env.TRAVIS ? 20000 : 5000);
console.log('waiting for server to start');
};
module.exports.close = function() {
swaggerUI.close();
specServer.close();
};

View File

@@ -1,103 +0,0 @@
'use strict';
var expect = require('chai').expect;
var driver = require('./driver');
var servers = require('./servers');
var webdriver = require('selenium-webdriver');
var until = webdriver.until;
var elements = [
'swagger-ui-container',
'resources_container',
'api_info',
'resource_pet',
'resource_store',
'resource_user',
'header'
];
describe('swagger 1.x spec tests', function () {
this.timeout(10 * 1000);
before(function (done) {
this.timeout(25 * 1000);
servers.start('/v1.2/petstore/api-docs.json', done);
});
afterEach(function(){
it('should not have any console errors', function (done) {
driver.manage().logs().get('browser').then(function(browserLogs) {
var errors = [];
browserLogs.forEach(function(log){
// 900 and above is "error" level. Console should not have any errors
if (log.level.value > 900) {
console.log('browser error message:', log.message); errors.push(log);
}
});
expect(errors).to.be.empty;
done();
});
});
});
it('should have "Swagger UI" in title', function () {
return driver.wait(until.titleIs('Swagger UI'), 1000);
});
elements.forEach(function (id) {
it('should render element: ' + id, function (done) {
var locator = webdriver.By.id(id);
driver.isElementPresent(locator).then(function (isPresent) {
expect(isPresent).to.be.true;
done();
});
});
});
// TODO: enable me
xit('should find the contact name element', function(done){
var locator = webdriver.By.css('.info_name');
driver.isElementPresent(locator).then(function (isPresent) {
expect(isPresent).to.be.true;
done();
});
});
it('should find the pet link', function(done){
var locator = webdriver.By.xpath('//*[@data-id="pet"]');
driver.isElementPresent(locator).then(function (isPresent) {
expect(isPresent).to.be.true;
done();
});
});
// TODO: enable me
xit('should find the pet resource description', function(done){
var locator = webdriver.By.xpath('//div[contains(., "Operations about pets")]');
driver.findElements(locator).then(function (elements) {
expect(elements.length).to.not.equal(0);
done();
});
});
it('should find the user link', function(done){
var locator = webdriver.By.xpath('//*[@data-id="user"]');
driver.isElementPresent(locator).then(function (isPresent) {
expect(isPresent).to.be.true;
done();
});
});
it('should find the store link', function(done){
var locator = webdriver.By.xpath('//*[@data-id="store"]');
driver.isElementPresent(locator).then(function (isPresent) {
expect(isPresent).to.be.true;
done();
});
});
after(function(done){
servers.close();
done();
});
});

View File

@@ -1,133 +0,0 @@
'use strict';
var expect = require('chai').expect;
var webdriver = require('selenium-webdriver');
var driver = require('../driver');
var servers = require('../servers');
var until = webdriver.until;
var helpers = require('../helpers');
var elements = [
'swagger-ui-container',
'resources_container',
'api_info',
'resource_pet',
'resource_store',
'resource_user',
'header'
];
var specPath = helpers.parseSpecFilename(__filename);
describe('swagger 2.0 spec tests', function () {
this.timeout(40 * 1000);
before(function (done) {
this.timeout(50 * 1000);
servers.start(specPath, done);
});
afterEach(function(){
it('should not have any console errors', function (done) {
driver.manage().logs().get('browser').then(function(browserLogs) {
var errors = [];
browserLogs.forEach(function(log){
// 900 and above is "error" level. Console should not have any errors
if (log.level.value > 900) {
console.log('browser error message:', log.message); errors.push(log);
}
});
expect(errors).to.be.empty;
done();
});
});
});
it('should have "Swagger UI" in title', function () {
return driver.wait(until.titleIs('Swagger UI'), 1000);
});
elements.forEach(function (id) {
it('should render element: ' + id, function (done) {
var locator = webdriver.By.id(id);
driver.isElementPresent(locator).then(function (isPresent) {
expect(isPresent).to.be.true;
done();
});
});
});
it('should find the contact name element', function(done){
var locator = webdriver.By.css('.info_name');
driver.isElementPresent(locator).then(function (isPresent) {
expect(isPresent).to.be.true;
done();
});
});
it('should find the contact email element', function(done){
var locator = webdriver.By.css('.info_email');
driver.isElementPresent(locator).then(function (isPresent) {
expect(isPresent).to.be.true;
done();
});
});
it('should find the contact url element', function(done){
var locator = webdriver.By.css('.info_url');
driver.isElementPresent(locator).then(function (isPresent) {
expect(isPresent).to.be.true;
done();
});
});
it('should find the pet link', function(done){
var locator = webdriver.By.xpath('//*[@data-id="pet"]');
driver.isElementPresent(locator).then(function (isPresent) {
expect(isPresent).to.be.true;
done();
});
});
it('should find the pet resource description', function(done){
var locator = webdriver.By.xpath('//div[contains(., "Everything about your Pets")]');
driver.findElements(locator).then(function (elements) {
expect(elements.length).to.not.equal(0);
done();
});
});
it('should find the user link', function(done){
var locator = webdriver.By.xpath('//*[@data-id="user"]');
driver.isElementPresent(locator).then(function (isPresent) {
expect(isPresent).to.be.true;
done();
});
});
it('should find the store link', function(done){
var locator = webdriver.By.xpath('//*[@data-id="store"]');
driver.isElementPresent(locator).then(function (isPresent) {
expect(isPresent).to.be.true;
done();
});
});
/*
// TODO: disabling for now
['root.id','root.username','root.firstName','root.lastName', 'root.email', 'root.password', 'root.phone', 'root.userStatus']
.forEach(function (id) {
it('should find a jsoneditor for user post with field: ' + id, function (done) {
var locator = webdriver.By.xpath('//*[@id=\'user_createUser\']//*[@data-schemapath=\''+id+'\']');
driver
.wait(webdriver.until.elementLocated(locator),2000)
.then(function() { done(); });
});
});
// TODO JSonEditor Tests for POST/PUT
*/
after(function(done) {
servers.close();
done();
});
});