From c2aa28d266efc824856948d83ce9f8b0d7f1ea5d Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Tue, 9 Jan 2018 13:39:37 -0600 Subject: [PATCH] MOAR e2e testing! CI runs are now behind the ENABLE_CI_E2E flag --- package.json | 2 +- test/e2e/cbt-globals.js | 4 ++-- test/e2e/globals.js | 5 +++++ test/e2e/nightwatch-cbt.json | 5 +---- test/e2e/nightwatch.json | 2 +- test/e2e/scenarios/informationContainer.js | 8 ++++---- test/e2e/scenarios/models.js | 4 ++-- test/e2e/scenarios/operations/pet.js | 4 ++-- test/e2e/scenarios/operations/store.js | 4 ++-- test/e2e/scenarios/operations/user.js | 4 ++-- test/e2e/scenarios/schemeContainer.js | 6 +++--- test/e2e/scenarios/topbar.js | 4 ++-- 12 files changed, 27 insertions(+), 25 deletions(-) create mode 100644 test/e2e/globals.js diff --git a/package.json b/package.json index 40aef4bf..d246409d 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "test": "npm run lint:errors && npm run test:nodejs", "test:ci": "npm-run-all lint:errors test:nodejs test:ci:e2e", "test:browser": "karma start --config karma.conf.js", - "test:ci:e2e": "npm-run-all --parallel -r hot-server test:e2e:mock-api test:e2e:all:cbt", + "test:ci:e2e": "if [[ $ENABLE_CI_E2E == true ]]; then npm-run-all --parallel -r hot-server test:e2e:mock-api test:e2e:all:cbt; else exit 0; fi", "test:coverage": "nyc npm run test:nodejs", "test:e2e": "npm-run-all --parallel -r hot-server test:e2e:mock-api test:e2e:all", "test:e2e:all": "sleep 3 && nightwatch test/e2e/scenarios/ --config test/e2e/nightwatch.json", diff --git a/test/e2e/cbt-globals.js b/test/e2e/cbt-globals.js index 82072006..cec54812 100644 --- a/test/e2e/cbt-globals.js +++ b/test/e2e/cbt-globals.js @@ -3,7 +3,7 @@ var cbt = require("cbt_tunnels") module.exports = { baseUrl: "http://local:3200", - before: function(done) { + beforeEach: function(done) { console.log("Starting up tunnel") cbt.start({ username: process.env.CBT_USERNAME || "", @@ -16,7 +16,7 @@ module.exports = { } }) }, - after: function(done) { + afterEach: function(done) { console.log("Closing Down Tunnel") cbt.stop() done() diff --git a/test/e2e/globals.js b/test/e2e/globals.js new file mode 100644 index 00000000..5ee3ab20 --- /dev/null +++ b/test/e2e/globals.js @@ -0,0 +1,5 @@ +var cbt = require("cbt_tunnels") + +module.exports = { + baseUrl: "http://localhost:3200" +} diff --git a/test/e2e/nightwatch-cbt.json b/test/e2e/nightwatch-cbt.json index 11128ed8..1df35e87 100644 --- a/test/e2e/nightwatch-cbt.json +++ b/test/e2e/nightwatch-cbt.json @@ -1,14 +1,11 @@ { "src_folders" : ["test/e2e/scenarios"], "output_folder" : "reports", + "live_output": true, "custom_commands_path" : "", "custom_assertions_path" : "", "page_objects_path" : "test/e2e/pages", "globals_path" : "test/e2e/cbt-globals.js", - "test_workers" : { - "enabled" : true, - "workers" : "auto" - }, "test_runner" : { "type" : "mocha", diff --git a/test/e2e/nightwatch.json b/test/e2e/nightwatch.json index 861a72ec..719b46e0 100644 --- a/test/e2e/nightwatch.json +++ b/test/e2e/nightwatch.json @@ -5,7 +5,7 @@ "custom_commands_path" : "", "custom_assertions_path" : "", "page_objects_path" : "test/e2e/pages", - "globals_path" : "", + "globals_path" : "test/e2e/globals.js", "test_workers" : { "enabled" : true, "workers" : "auto" diff --git a/test/e2e/scenarios/informationContainer.js b/test/e2e/scenarios/informationContainer.js index c5af4148..bda9fee5 100644 --- a/test/e2e/scenarios/informationContainer.js +++ b/test/e2e/scenarios/informationContainer.js @@ -4,12 +4,12 @@ describe("render informationContainer", function () { beforeEach(function (client, done) { mainPage = client - .url("localhost:3200") + .url(client.globals.baseUrl) .page.main() client.waitForElementVisible(".download-url-input", 5000) .pause(5000) .clearValue(".download-url-input") - .setValue(".download-url-input", "http://localhost:3200/test-specs/petstore.json") + .setValue(".download-url-input", client.globals.baseUrl + "/test-specs/petstore.json") .click("button.download-url-button") .pause(1000) @@ -29,8 +29,8 @@ describe("render informationContainer", function () { .assert.containsText("@title", "Swagger Petstore") .assert.containsText("@version", "1.0.0") .assert.containsText("@baseUrl", "[ Base URL: localhost:3204/ ]") - .assert.attributeEquals("@mainUrl", "href", "http://localhost:3200/test-specs/petstore.json") - .assert.containsText("@mainUrlContent", "http://localhost:3200/test-specs/petstore.json") + .assert.attributeEquals("@mainUrl", "href", client.globals.baseUrl + "/test-specs/petstore.json") + .assert.containsText("@mainUrlContent", client.globals.baseUrl + "/test-specs/petstore.json") .assert.containsText("@description", "This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key special-key to test the authorization filters.") .assert.attributeEquals("@swaggerUrl", "href", "http://swagger.io/") .assert.attributeEquals("@swaggerircUrl", "href", "http://swagger.io/irc/") diff --git a/test/e2e/scenarios/models.js b/test/e2e/scenarios/models.js index 9749b811..50296b36 100644 --- a/test/e2e/scenarios/models.js +++ b/test/e2e/scenarios/models.js @@ -3,12 +3,12 @@ describe("Render Model Wrapper", function () { beforeEach(function (client, done) { mainPage = client - .url("localhost:3200") + .url(client.globals.baseUrl) .page.main() client.waitForElementVisible(".download-url-input", 5000) .pause(5000) .clearValue(".download-url-input") - .setValue(".download-url-input", "http://localhost:3200/test-specs/petstore.json") + .setValue(".download-url-input", client.globals.baseUrl + "/test-specs/petstore.json") .click("button.download-url-button") .pause(1000) diff --git a/test/e2e/scenarios/operations/pet.js b/test/e2e/scenarios/operations/pet.js index 337b5877..915e4620 100644 --- a/test/e2e/scenarios/operations/pet.js +++ b/test/e2e/scenarios/operations/pet.js @@ -3,13 +3,13 @@ describe("render pet api container", function () { let apiWrapper beforeEach(function (client, done) { mainPage = client - .url("localhost:3200") + .url(client.globals.baseUrl) .page.main() client.waitForElementVisible(".download-url-input", 5000) .pause(5000) .clearValue(".download-url-input") - .setValue(".download-url-input", "http://localhost:3200/test-specs/petstore.json") + .setValue(".download-url-input", client.globals.baseUrl + "/test-specs/petstore.json") .click("button.download-url-button") .pause(1000) diff --git a/test/e2e/scenarios/operations/store.js b/test/e2e/scenarios/operations/store.js index 7dbcbc24..34b1938e 100644 --- a/test/e2e/scenarios/operations/store.js +++ b/test/e2e/scenarios/operations/store.js @@ -3,13 +3,13 @@ describe("render store api container", function(){ let apiWrapper beforeEach( function(client, done){ mainPage = client - .url("localhost:3200") + .url(client.globals.baseUrl) .page.main() client.waitForElementVisible(".download-url-input", 5000) .pause(3000) .clearValue(".download-url-input") - .setValue(".download-url-input", "http://localhost:3200/test-specs/petstore.json") + .setValue(".download-url-input", client.globals.baseUrl + "/test-specs/petstore.json") .click("button.download-url-button") .pause(1000) diff --git a/test/e2e/scenarios/operations/user.js b/test/e2e/scenarios/operations/user.js index e84984b7..cb53fd7d 100644 --- a/test/e2e/scenarios/operations/user.js +++ b/test/e2e/scenarios/operations/user.js @@ -3,13 +3,13 @@ describe("render user api container", function(){ let apiWrapper beforeEach( function(client, done){ mainPage = client - .url("localhost:3200") + .url(client.globals.baseUrl) .page.main() client.waitForElementVisible(".download-url-input", 5000) .pause(5000) .clearValue(".download-url-input") - .setValue(".download-url-input", "http://localhost:3200/test-specs/petstore.json") + .setValue(".download-url-input", client.globals.baseUrl + "/test-specs/petstore.json") .click("button.download-url-button") .pause(1000) diff --git a/test/e2e/scenarios/schemeContainer.js b/test/e2e/scenarios/schemeContainer.js index 51a309b1..a78e1069 100644 --- a/test/e2e/scenarios/schemeContainer.js +++ b/test/e2e/scenarios/schemeContainer.js @@ -4,7 +4,7 @@ describe("Render scheme", function () { beforeEach(function (client, done) { mainPage = client - .url("localhost:3200") + .url(client.globals.baseUrl) .page.main() schemeContainer = mainPage.section.schemeContainer @@ -12,7 +12,7 @@ describe("Render scheme", function () { client.waitForElementVisible(".download-url-input", 5000) .pause(5000) .clearValue(".download-url-input") - .setValue(".download-url-input", "http://localhost:3200/test-specs/petstore.json") + .setValue(".download-url-input", client.globals.baseUrl + "/test-specs/petstore.json") .click("button.download-url-button") .pause(1000) @@ -49,4 +49,4 @@ describe("Render scheme", function () { client.end() }) -}) \ No newline at end of file +}) diff --git a/test/e2e/scenarios/topbar.js b/test/e2e/scenarios/topbar.js index d7a17efe..2218b461 100644 --- a/test/e2e/scenarios/topbar.js +++ b/test/e2e/scenarios/topbar.js @@ -18,7 +18,7 @@ describe("initial render", function () { beforeEach(function (client, done) { mainPage = client - .url("localhost:3200") + .url(client.globals.baseUrl) .page.main() topbar = mainPage.section.topbar @@ -26,7 +26,7 @@ describe("initial render", function () { client.waitForElementVisible(".download-url-input", 10000) .pause(5000) .clearValue(".download-url-input") - .setValue(".download-url-input", "http://localhost:3200/test-specs/petstore.json") + .setValue(".download-url-input", client.globals.baseUrl + "/test-specs/petstore.json") .click("button.download-url-button") .pause(1000)