diff --git a/README.md b/README.md index c21158e5..6cc4387d 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,13 @@ If you'd like to make modifications to the codebase, run the dev server with: `n If you'd like to rebuild the `/dist` folder with your codebase changes, run `npm run build`. + +##### Integrate Tests + +You will need JDK of version 7 or higher as instructed here +http://nightwatchjs.org/gettingstarted#selenium-server-setup + + ##### Browser support Swagger UI works in the latest versions of Chrome, Safari, Firefox, Edge and IE11. diff --git a/package.json b/package.json index 97cfd473..91b2b4e2 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,8 @@ "test-in-node": "npm run lint-errors && npm run just-test-in-node", "just-test": "karma start --config karma.conf.js", "just-test-in-node": "mocha --recursive --compilers js:babel-core/register test/core test/components test/bugs test/swagger-ui-dist-package", - "e2e": "nightwatch test/e2e/scenarios --config test/e2e/nightwatch.json --verbose" + "e2e": "nightwatch test/e2e/scenarios --config test/e2e/nightwatch.json --verbose", + "e2e-initial-render": "nightwatch test/e2e/scenarios --config test/e2e/nightwatch.json --group initial-render" }, "dependencies": { "babel-polyfill": "^6.23.0", diff --git a/test/e2e/nightwatch.json b/test/e2e/nightwatch.json index 6aa78be0..288184ec 100644 --- a/test/e2e/nightwatch.json +++ b/test/e2e/nightwatch.json @@ -4,7 +4,7 @@ "live_output": true, "custom_commands_path" : "", "custom_assertions_path" : "", - "page_objects_path" : "", + "page_objects_path" : "test/e2e/pages", "globals_path" : "", "test_workers" : { "enabled" : true, diff --git a/test/e2e/pages/main.js b/test/e2e/pages/main.js new file mode 100644 index 00000000..26fb03e7 --- /dev/null +++ b/test/e2e/pages/main.js @@ -0,0 +1,26 @@ +module.exports = { + sections: { + topbar: { + selector: ".topbar", + elements: { + inputBox: { + selector: "input" + }, + btnExplore: { + selector: "button" + } + } + }, + informationContainer: { + selector: ".information-container", + elements: { + title: { + selector: ".title" + }, + version: { + selector: ".version" + } + } + } + } +} diff --git a/test/e2e/scenarios/initial-render/test.js b/test/e2e/scenarios/initial-render/test.js new file mode 100644 index 00000000..45642804 --- /dev/null +++ b/test/e2e/scenarios/initial-render/test.js @@ -0,0 +1,77 @@ +describe("initial render", function () { + let mainPage + + describe("for topbar", function () { + let topbar + before(function (client, done) { + done() + }) + + after(function (client, done) { + client.end(function () { + done() + }) + }) + + afterEach(function (client, done) { + done() + }) + + beforeEach(function (client, done) { + mainPage = client + .url("localhost:3200") + .page.main() + topbar = mainPage.section.topbar + done() + }) + + it("renders section", function (client) { + mainPage.expect.section("@topbar").to.be.visible + + client.end() + }) + + it("renders input box", function (client) { + topbar.expect.element("@inputBox").to.be.visible + + client.end() + }) + + it("renders explore button", function (client) { + topbar.expect.element("@btnExplore").to.be.visible + + client.end() + }) + }) + + describe("for information", function () { + let informationContainer + beforeEach(function (client, done) { + mainPage = client + .url("localhost:3200") + .page.main() + informationContainer = mainPage.section.informationContainer + done() + }) + + it("renders section", function (client) { + mainPage.expect.section("@informationContainer").to.be.visible.before(5000) + + client.end() + }) + + it("renders title", function (client) { + // informationContainer.waitForElementVisible("@title", 5000, function() { + // informationContainer.expect.element("@title").to.contain.text("Swagger Petstore") + // informationContainer.expect.element("@version").to.contain.text("1.0.0") + + // client.end() + // }) + informationContainer.waitForElementVisible("@title", 5000) + .assert.containsText("@title", "Swagger Petstore") + .assert.containsText("@version", "1.0.0") + + client.end() + }) + }) +}) diff --git a/test/e2e/scenarios/test.js b/test/e2e/scenarios/test.js deleted file mode 100644 index 0dd66f8c..00000000 --- a/test/e2e/scenarios/test.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('Google demo test for Mocha', function () { - describe('with Nightwatch', function () { - before(function (client, done) { - done() - }) - - after(function (client, done) { - client.end(function () { - done() - }) - }) - - afterEach(function (client, done) { - done() - }) - - beforeEach(function (client, done) { - done() - }) - - it('uses TDD to run the Google simple test', function (client) { - client - .url('http://google.com') - .expect.element('body').to.be.present.before(1000) - - client.setValue('input[type=text]', ['nightwatch', client.Keys.ENTER]) - .pause(1000) - .assert.containsText('#main', 'Night Watch') - }) - }) -})