Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

104 righe
2.8 KiB

  1. 'use strict';
  2. var expect = require('chai').expect;
  3. var driver = require('./driver');
  4. var servers = require('./servers');
  5. var webdriver = require('selenium-webdriver');
  6. var until = webdriver.until;
  7. var elements = [
  8. 'swagger-ui-container',
  9. 'resources_container',
  10. 'api_info',
  11. 'resource_pet',
  12. 'resource_store',
  13. 'resource_user',
  14. 'header'
  15. ];
  16. describe('swagger 1.x spec tests', function () {
  17. this.timeout(10 * 1000);
  18. before(function (done) {
  19. this.timeout(25 * 1000);
  20. servers.start('/v1.2/petstore/api-docs.json', done);
  21. });
  22. afterEach(function(){
  23. it('should not have any console errors', function (done) {
  24. driver.manage().logs().get('browser').then(function(browserLogs) {
  25. var errors = [];
  26. browserLogs.forEach(function(log){
  27. // 900 and above is "error" level. Console should not have any errors
  28. if (log.level.value > 900) {
  29. console.log('browser error message:', log.message); errors.push(log);
  30. }
  31. });
  32. expect(errors).to.be.empty;
  33. done();
  34. });
  35. });
  36. });
  37. it('should have "Swagger UI" in title', function () {
  38. return driver.wait(until.titleIs('Swagger UI'), 1000);
  39. });
  40. elements.forEach(function (id) {
  41. it('should render element: ' + id, function (done) {
  42. var locator = webdriver.By.id(id);
  43. driver.isElementPresent(locator).then(function (isPresent) {
  44. expect(isPresent).to.be.true;
  45. done();
  46. });
  47. });
  48. });
  49. // TODO: enable me
  50. xit('should find the contact name element', function(done){
  51. var locator = webdriver.By.css('.info_name');
  52. driver.isElementPresent(locator).then(function (isPresent) {
  53. expect(isPresent).to.be.true;
  54. done();
  55. });
  56. });
  57. it('should find the pet link', function(done){
  58. var locator = webdriver.By.xpath('//*[@data-id="pet"]');
  59. driver.isElementPresent(locator).then(function (isPresent) {
  60. expect(isPresent).to.be.true;
  61. done();
  62. });
  63. });
  64. // TODO: enable me
  65. xit('should find the pet resource description', function(done){
  66. var locator = webdriver.By.xpath('//div[contains(., "Operations about pets")]');
  67. driver.findElements(locator).then(function (elements) {
  68. expect(elements.length).to.not.equal(0);
  69. done();
  70. });
  71. });
  72. it('should find the user link', function(done){
  73. var locator = webdriver.By.xpath('//*[@data-id="user"]');
  74. driver.isElementPresent(locator).then(function (isPresent) {
  75. expect(isPresent).to.be.true;
  76. done();
  77. });
  78. });
  79. it('should find the store link', function(done){
  80. var locator = webdriver.By.xpath('//*[@data-id="store"]');
  81. driver.isElementPresent(locator).then(function (isPresent) {
  82. expect(isPresent).to.be.true;
  83. done();
  84. });
  85. });
  86. after(function(done){
  87. servers.close();
  88. done();
  89. });
  90. });