From 143c8e44dfd1b3270c33aade4045213f70af1b3f Mon Sep 17 00:00:00 2001 From: Kenny Date: Wed, 12 Jul 2017 05:51:00 -0700 Subject: [PATCH] Modify test running script, rewrite some test based on local son --- package.json | 9 ++++---- test/e2e/scenarios/initial-render/test.js | 27 +++++++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 00ab6fce..1a8504ec 100644 --- a/package.json +++ b/package.json @@ -32,14 +32,13 @@ "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": "sleep 3 && nightwatch test/e2e/scenarios --config test/e2e/nightwatch.json", - "e2e-initial-render": "nightwatch test/e2e/scenarios --config test/e2e/nightwatch.json --group initial-render", - "mock:api": "json-server --watch test/e2e/db.json --port 3204", - "e2e-flow": "npm-run-all --parallel -r hot-server mock:api e2e" + "test-e2e": "sleep 3 && nightwatch test/e2e/scenarios --config test/e2e/nightwatch.json", + "test-e2e-initial-render": "nightwatch test/e2e/scenarios --config test/e2e/nightwatch.json --group initial-render", + "mock-api": "json-server --watch test/e2e/db.json --port 3204", + "e2e-flow": "npm-run-all --parallel -r hot-server mock-api test-e2e" }, "dependencies": { "base64-js": "^1.2.0", - "brace": "0.10.0", "deep-extend": "0.4.1", "expect": "1.20.2", "getbase": "^3.4.2", diff --git a/test/e2e/scenarios/initial-render/test.js b/test/e2e/scenarios/initial-render/test.js index 5fbea302..43820c12 100644 --- a/test/e2e/scenarios/initial-render/test.js +++ b/test/e2e/scenarios/initial-render/test.js @@ -1,6 +1,7 @@ describe("initial render", function () { let mainPage + describe("for topbar", function () { let topbar before(function (client, done) { @@ -21,19 +22,25 @@ describe("initial render", function () { mainPage = client .url("localhost:3200") .page.main() + topbar = mainPage.section.topbar + + client.waitForElementVisible('.download-url-input', 5000) + .pause(1000) + .clearValue('.download-url-input') + .setValue('.download-url-input', 'http://localhost:3200/test-specs/1.json') + .click('button.download-url-button') + 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() }) @@ -45,13 +52,20 @@ describe("initial render", function () { }) describe("for information", function () { - let informationContainer + let informationContainer, topbar beforeEach(function (client, done) { mainPage = client .url("localhost:3200") .page.main() + client.waitForElementVisible('.download-url-input', 5000) + .pause(1000) + .clearValue('.download-url-input') + .setValue('.download-url-input', 'http://localhost:3200/test-specs/1.json') + .click('button.download-url-button') + informationContainer = mainPage.section.informationContainer + done() }) @@ -71,15 +85,15 @@ describe("initial render", function () { it("renders base url", function (client) { informationContainer.waitForElementVisible("@baseUrl", 5000) - .assert.containsText("@baseUrl", "[ Base url: petstore.swagger.io/v2]") + .assert.containsText("@baseUrl", "[ Base url: localhost:3204/]") client.end() }) it("render main url", function (client) { informationContainer.waitForElementVisible("@mainUrl", 5000) - .assert.attributeEquals("@mainUrl", "href", "http://petstore.swagger.io/v2/swagger.json") - .assert.containsText("@mainUrlContent", "http://petstore.swagger.io/v2/swagger.json") + .assert.attributeEquals("@mainUrl", "href", "http://localhost:3200/test-specs/1.json") + .assert.containsText("@mainUrlContent", "http://localhost:3200/test-specs/1.json") client.end() }) @@ -125,7 +139,6 @@ describe("initial render", function () { client.end() }) }) - describe("for scheme", function () { let schemeContainer beforeEach(function (client, done) {