diff options
author | Johannes Zellner <johannes@cloudron.io> | 2018-10-15 17:38:10 +0200 |
---|---|---|
committer | Johannes Zellner <johannes@cloudron.io> | 2018-10-15 17:38:10 +0200 |
commit | a7317b4ba7e4f37ab1e562669c03e4867c070d39 (patch) | |
tree | 9920a2dcc66d30a3b03fa5a6a7699f3ca9a6b421 | |
parent | 4d8f08f9c825c35ed3e05ce92457c2fc2e2194c6 (diff) | |
download | Surfer-a7317b4ba7e4f37ab1e562669c03e4867c070d39.tar.gz Surfer-a7317b4ba7e4f37ab1e562669c03e4867c070d39.tar.zst Surfer-a7317b4ba7e4f37ab1e562669c03e4867c070d39.zip |
Fixup tests
-rw-r--r-- | frontend/index.html | 10 | ||||
-rw-r--r-- | package-lock.json | 6 | ||||
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | test/test.js | 94 |
4 files changed, 62 insertions, 49 deletions
diff --git a/frontend/index.html b/frontend/index.html index 5337208..7d60b07 100644 --- a/frontend/index.html +++ b/frontend/index.html | |||
@@ -26,12 +26,12 @@ | |||
26 | 26 | ||
27 | <el-dialog title="Login" :visible.sync="ready && !session.valid" width="30%" :close-on-press-escape="false" :show-close="false"> | 27 | <el-dialog title="Login" :visible.sync="ready && !session.valid" width="30%" :close-on-press-escape="false" :show-close="false"> |
28 | <el-form :model="loginData" label-position="top" @submit.native.prevent> | 28 | <el-form :model="loginData" label-position="top" @submit.native.prevent> |
29 | <el-form-item label="Username"><el-input v-model="loginData.username" required autofocus :disabled="loginData.busy"></el-input></el-form-item> | 29 | <el-form-item label="Username"><el-input v-model="loginData.username" id="loginUsernameInput" required autofocus :disabled="loginData.busy"></el-input></el-form-item> |
30 | <el-form-item label="Password"><el-input v-model="loginData.password" type="password" required :disabled="loginData.busy"></el-input></el-form-item> | 30 | <el-form-item label="Password"><el-input v-model="loginData.password" id="loginPasswordInput" type="password" required :disabled="loginData.busy"></el-input></el-form-item> |
31 | <input type="submit" @click="onLogin" v-show="false"/> | 31 | <input type="submit" @click="onLogin" v-show="false"/> |
32 | </el-form> | 32 | </el-form> |
33 | <span slot="footer" class="dialog-footer"> | 33 | <span slot="footer" class="dialog-footer"> |
34 | <el-button type="primary" @click="onLogin"><i class="el-icon-loading" v-show="loginData.busy"></i><span v-show="!loginData.busy">Login</span></el-button> | 34 | <el-button type="primary" @click="onLogin" id="loginSubmitButton"><i class="el-icon-loading" v-show="loginData.busy"></i><span v-show="!loginData.busy">Login</span></el-button> |
35 | </span> | 35 | </span> |
36 | </el-dialog> | 36 | </el-dialog> |
37 | 37 | ||
@@ -57,7 +57,7 @@ | |||
57 | <el-button type="primary" icon="el-icon-plus" size="small" @click="onNewFolder">New Folder</el-button> | 57 | <el-button type="primary" icon="el-icon-plus" size="small" @click="onNewFolder">New Folder</el-button> |
58 | </el-button-group> | 58 | </el-button-group> |
59 | <el-dropdown @command="onOptionsMenu" :hide-on-click="false"> | 59 | <el-dropdown @command="onOptionsMenu" :hide-on-click="false"> |
60 | <el-button size="small" icon="el-icon-more"></el-button> | 60 | <el-button size="small" icon="el-icon-more" id="burgerMenuButton"></el-button> |
61 | <el-dropdown-menu slot="dropdown"> | 61 | <el-dropdown-menu slot="dropdown"> |
62 | <el-dropdown-item disabled>Public Folder Listing</el-dropdown-item> | 62 | <el-dropdown-item disabled>Public Folder Listing</el-dropdown-item> |
63 | <el-dropdown-item command="folderListing"> | 63 | <el-dropdown-item command="folderListing"> |
@@ -65,7 +65,7 @@ | |||
65 | </el-switch> | 65 | </el-switch> |
66 | </el-dropdown-item> | 66 | </el-dropdown-item> |
67 | <el-dropdown-item command="about" divided><i class="el-icon-info"></i> About</el-dropdown-item> | 67 | <el-dropdown-item command="about" divided><i class="el-icon-info"></i> About</el-dropdown-item> |
68 | <el-dropdown-item command="logout"><i class="el-icon-circle-close"></i> Logout</el-dropdown-item> | 68 | <el-dropdown-item command="logout" id="logoutButton"><i class="el-icon-circle-close"></i> Logout</el-dropdown-item> |
69 | </el-dropdown-menu> | 69 | </el-dropdown-menu> |
70 | </el-dropdown> | 70 | </el-dropdown> |
71 | </div> | 71 | </div> |
diff --git a/package-lock.json b/package-lock.json index 2d426e4..fb69dc2 100644 --- a/package-lock.json +++ b/package-lock.json | |||
@@ -1315,12 +1315,6 @@ | |||
1315 | "integrity": "sha1-VjsZx8HeiS4Jv8Ty/DDjwn8JUrk=", | 1315 | "integrity": "sha1-VjsZx8HeiS4Jv8Ty/DDjwn8JUrk=", |
1316 | "dev": true | 1316 | "dev": true |
1317 | }, | 1317 | }, |
1318 | "selenium-server-standalone-jar": { | ||
1319 | "version": "2.53.1", | ||
1320 | "resolved": "https://registry.npmjs.org/selenium-server-standalone-jar/-/selenium-server-standalone-jar-2.53.1.tgz", | ||
1321 | "integrity": "sha1-T8P6+ktCaL2tDbst7KCwazT1SK4=", | ||
1322 | "dev": true | ||
1323 | }, | ||
1324 | "selenium-webdriver": { | 1318 | "selenium-webdriver": { |
1325 | "version": "2.53.3", | 1319 | "version": "2.53.3", |
1326 | "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-2.53.3.tgz", | 1320 | "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-2.53.3.tgz", |
diff --git a/package.json b/package.json index 00a6fd3..6f70436 100644 --- a/package.json +++ b/package.json | |||
@@ -50,7 +50,6 @@ | |||
50 | "devDependencies": { | 50 | "devDependencies": { |
51 | "expect.js": "^0.3.1", | 51 | "expect.js": "^0.3.1", |
52 | "mocha": "^2.4.5", | 52 | "mocha": "^2.4.5", |
53 | "selenium-server-standalone-jar": "^2.52.0", | ||
54 | "selenium-webdriver": "^2.52.0" | 53 | "selenium-webdriver": "^2.52.0" |
55 | } | 54 | } |
56 | } | 55 | } |
diff --git a/test/test.js b/test/test.js index 3386596..dace05d 100644 --- a/test/test.js +++ b/test/test.js | |||
@@ -2,43 +2,44 @@ | |||
2 | 2 | ||
3 | 'use strict'; | 3 | 'use strict'; |
4 | 4 | ||
5 | /* global describe */ | ||
6 | /* global before */ | ||
7 | /* global after */ | ||
8 | /* global it */ | ||
9 | |||
5 | var execSync = require('child_process').execSync, | 10 | var execSync = require('child_process').execSync, |
6 | expect = require('expect.js'), | 11 | expect = require('expect.js'), |
7 | path = require('path'), | 12 | path = require('path'), |
8 | util = require('util'), | 13 | util = require('util'), |
9 | fs = require('fs'), | ||
10 | superagent = require('superagent'), | 14 | superagent = require('superagent'), |
11 | webdriver = require('selenium-webdriver'); | 15 | webdriver = require('selenium-webdriver'); |
12 | 16 | ||
13 | var by = webdriver.By, | 17 | var by = webdriver.By, |
14 | Keys = webdriver.Key, | ||
15 | until = webdriver.until; | 18 | until = webdriver.until; |
16 | 19 | ||
17 | process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; | ||
18 | |||
19 | if (!process.env.USERNAME || !process.env.PASSWORD) { | 20 | if (!process.env.USERNAME || !process.env.PASSWORD) { |
20 | console.log('USERNAME and PASSWORD env vars need to be set'); | 21 | console.log('USERNAME and PASSWORD env vars need to be set'); |
21 | process.exit(1); | 22 | process.exit(1); |
22 | } | 23 | } |
23 | 24 | ||
25 | const EXEC_OPTIONS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }; | ||
26 | |||
24 | describe('Application life cycle test', function () { | 27 | describe('Application life cycle test', function () { |
25 | this.timeout(0); | 28 | this.timeout(0); |
26 | 29 | ||
27 | var chrome = require('selenium-webdriver/chrome'); | 30 | var browser; |
28 | var server, browser = new chrome.Driver(); | ||
29 | 31 | ||
30 | before(function (done) { | 32 | before(function (done) { |
31 | var seleniumJar= require('selenium-server-standalone-jar'); | 33 | browser = new webdriver.Builder() |
32 | var SeleniumServer = require('selenium-webdriver/remote').SeleniumServer; | 34 | .forBrowser('chrome') |
33 | server = new SeleniumServer(seleniumJar.path, { port: 4444 }); | 35 | // .setChromeOptions(new chrome.Options().addArguments(['no-sandbox', 'headless'])) |
34 | server.start(); | 36 | .build(); |
35 | 37 | ||
36 | done(); | 38 | done(); |
37 | }); | 39 | }); |
38 | 40 | ||
39 | after(function (done) { | 41 | after(function (done) { |
40 | browser.quit(); | 42 | browser.quit(); |
41 | server.stop(); | ||
42 | done(); | 43 | done(); |
43 | }); | 44 | }); |
44 | 45 | ||
@@ -48,20 +49,24 @@ describe('Application life cycle test', function () { | |||
48 | var TEST_FILE_NAME_1 = 'test.txt'; | 49 | var TEST_FILE_NAME_1 = 'test.txt'; |
49 | var app; | 50 | var app; |
50 | 51 | ||
52 | function waitForElement(elem) { | ||
53 | return browser.wait(until.elementLocated(elem), TEST_TIMEOUT).then(function () { | ||
54 | return browser.wait(until.elementIsVisible(browser.findElement(elem)), TEST_TIMEOUT); | ||
55 | }); | ||
56 | } | ||
57 | |||
51 | // tests which are used more than once | 58 | // tests which are used more than once |
52 | function login(done) { | 59 | function login(done) { |
53 | browser.manage().deleteAllCookies(); | 60 | browser.manage().deleteAllCookies(); |
54 | browser.get('https://' + app.fqdn + '/_admin'); | 61 | browser.get('https://' + app.fqdn + '/_admin'); |
55 | 62 | ||
56 | browser.wait(until.elementLocated(by.id('inputUsername')), TEST_TIMEOUT).then(function () { | 63 | waitForElement(by.id('loginUsernameInput')).then(function () { |
57 | browser.wait(until.elementIsVisible(browser.findElement(by.id('inputUsername'))), TEST_TIMEOUT).then(function () { | 64 | browser.findElement(by.id('loginUsernameInput')).sendKeys(process.env.USERNAME); |
58 | browser.findElement(by.id('inputUsername')).sendKeys(process.env.USERNAME); | 65 | browser.findElement(by.id('loginPasswordInput')).sendKeys(process.env.PASSWORD); |
59 | browser.findElement(by.id('inputPassword')).sendKeys(process.env.PASSWORD); | 66 | browser.findElement(by.id('loginSubmitButton')).click(); |
60 | browser.findElement(by.id('loginForm')).submit(); | ||
61 | 67 | ||
62 | browser.wait(until.elementIsVisible(browser.findElement(by.id('logoutButton'))), TEST_TIMEOUT).then(function () { | 68 | waitForElement(by.id('burgerMenuButton')).then(function () { |
63 | done(); | 69 | done(); |
64 | }); | ||
65 | }); | 70 | }); |
66 | }); | 71 | }); |
67 | } | 72 | } |
@@ -69,11 +74,16 @@ describe('Application life cycle test', function () { | |||
69 | function logout(done) { | 74 | function logout(done) { |
70 | browser.get('https://' + app.fqdn + '/_admin'); | 75 | browser.get('https://' + app.fqdn + '/_admin'); |
71 | 76 | ||
72 | browser.wait(until.elementLocated(by.id('logoutButton')), TEST_TIMEOUT).then(function () { | 77 | waitForElement(by.id('burgerMenuButton')).then(function () { |
73 | browser.wait(until.elementIsVisible(browser.findElement(by.id('logoutButton'))), TEST_TIMEOUT).then(function () { | 78 | browser.findElement(by.id('burgerMenuButton')).click(); |
79 | |||
80 | // wait for open animation | ||
81 | browser.sleep(5000); | ||
82 | |||
83 | waitForElement(by.id('logoutButton')).then(function () { | ||
74 | browser.findElement(by.id('logoutButton')).click(); | 84 | browser.findElement(by.id('logoutButton')).click(); |
75 | 85 | ||
76 | browser.wait(until.elementIsVisible(browser.findElement(by.id('inputPassword'))), TEST_TIMEOUT).then(function () { | 86 | waitForElement(by.id('loginUsernameInput')).then(function () { |
77 | done(); | 87 | done(); |
78 | }); | 88 | }); |
79 | }); | 89 | }); |
@@ -83,7 +93,7 @@ describe('Application life cycle test', function () { | |||
83 | function checkFileIsListed(name, done) { | 93 | function checkFileIsListed(name, done) { |
84 | browser.get('https://' + app.fqdn + '/_admin'); | 94 | browser.get('https://' + app.fqdn + '/_admin'); |
85 | 95 | ||
86 | browser.wait(until.elementLocated(by.xpath('//*[text()="' + name + '"]')), TEST_TIMEOUT).then(function () { | 96 | waitForElement(by.xpath('//*[text()="' + name + '"]')).then(function () { |
87 | done(); | 97 | done(); |
88 | }); | 98 | }); |
89 | } | 99 | } |
@@ -91,7 +101,7 @@ describe('Application life cycle test', function () { | |||
91 | function checkFileIsPresent(done) { | 101 | function checkFileIsPresent(done) { |
92 | browser.get('https://' + app.fqdn + '/' + TEST_FILE_NAME_0); | 102 | browser.get('https://' + app.fqdn + '/' + TEST_FILE_NAME_0); |
93 | 103 | ||
94 | browser.wait(until.elementLocated(by.xpath('//*[text()="test"]')), TEST_TIMEOUT).then(function () { | 104 | waitForElement(by.xpath('//*[text()="test"]')).then(function () { |
95 | done(); | 105 | done(); |
96 | }); | 106 | }); |
97 | } | 107 | } |
@@ -99,7 +109,7 @@ describe('Application life cycle test', function () { | |||
99 | function checkIndexFileIsServedUp(done) { | 109 | function checkIndexFileIsServedUp(done) { |
100 | browser.get('https://' + app.fqdn); | 110 | browser.get('https://' + app.fqdn); |
101 | 111 | ||
102 | browser.wait(until.elementLocated(by.xpath('//*[text()="test"]')), TEST_TIMEOUT).then(function () { | 112 | waitForElement(by.xpath('//*[text()="test"]')).then(function () { |
103 | done(); | 113 | done(); |
104 | }); | 114 | }); |
105 | } | 115 | } |
@@ -107,7 +117,8 @@ describe('Application life cycle test', function () { | |||
107 | function checkFileIsGone(name, done) { | 117 | function checkFileIsGone(name, done) { |
108 | superagent.get('https://' + app.fqdn + '/' + name).end(function (error, result) { | 118 | superagent.get('https://' + app.fqdn + '/' + name).end(function (error, result) { |
109 | expect(error).to.be.an('object'); | 119 | expect(error).to.be.an('object'); |
110 | expect(result.statusCode).to.equal(404); | 120 | expect(error.response.status).to.equal(404); |
121 | expect(result).to.be.an('object'); | ||
111 | done(); | 122 | done(); |
112 | }); | 123 | }); |
113 | } | 124 | } |
@@ -125,11 +136,11 @@ describe('Application life cycle test', function () { | |||
125 | } | 136 | } |
126 | 137 | ||
127 | xit('build app', function () { | 138 | xit('build app', function () { |
128 | execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); | 139 | execSync('cloudron build', EXEC_OPTIONS); |
129 | }); | 140 | }); |
130 | 141 | ||
131 | it('install app', function () { | 142 | it('install app', function () { |
132 | execSync('cloudron install --new --wait --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); | 143 | execSync('cloudron install --new --wait --location ' + LOCATION, EXEC_OPTIONS); |
133 | }); | 144 | }); |
134 | 145 | ||
135 | it('can get app information', function () { | 146 | it('can get app information', function () { |
@@ -156,11 +167,11 @@ describe('Application life cycle test', function () { | |||
156 | it('can logout', logout); | 167 | it('can logout', logout); |
157 | 168 | ||
158 | it('backup app', function () { | 169 | it('backup app', function () { |
159 | execSync('cloudron backup create --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); | 170 | execSync('cloudron backup create --app ' + app.id, EXEC_OPTIONS); |
160 | }); | 171 | }); |
161 | 172 | ||
162 | it('restore app', function () { | 173 | it('restore app', function () { |
163 | execSync('cloudron restore --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); | 174 | execSync('cloudron restore --app ' + app.id, EXEC_OPTIONS); |
164 | }); | 175 | }); |
165 | 176 | ||
166 | it('can login', login); | 177 | it('can login', login); |
@@ -170,12 +181,17 @@ describe('Application life cycle test', function () { | |||
170 | it('second file is still gone', checkFileIsGone.bind(null, TEST_FILE_NAME_1)); | 181 | it('second file is still gone', checkFileIsGone.bind(null, TEST_FILE_NAME_1)); |
171 | it('can logout', logout); | 182 | it('can logout', logout); |
172 | 183 | ||
173 | it('move to different location', function () { | 184 | it('move to different location', function (done) { |
174 | browser.manage().deleteAllCookies(); | 185 | browser.manage().deleteAllCookies(); |
175 | execSync('cloudron configure --location ' + LOCATION + '2 --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); | 186 | |
176 | var inspect = JSON.parse(execSync('cloudron inspect')); | 187 | // ensure we don't hit NXDOMAIN in the mean time |
177 | app = inspect.apps.filter(function (a) { return a.location === LOCATION + '2'; })[0]; | 188 | browser.get('about:blank').then(function () { |
178 | expect(app).to.be.an('object'); | 189 | execSync('cloudron configure --location ' + LOCATION + '2 --app ' + app.id, EXEC_OPTIONS); |
190 | var inspect = JSON.parse(execSync('cloudron inspect')); | ||
191 | app = inspect.apps.filter(function (a) { return a.location === LOCATION + '2'; })[0]; | ||
192 | expect(app).to.be.an('object'); | ||
193 | done(); | ||
194 | }); | ||
179 | }); | 195 | }); |
180 | 196 | ||
181 | it('can login', login); | 197 | it('can login', login); |
@@ -184,7 +200,11 @@ describe('Application life cycle test', function () { | |||
184 | it('file is served up', checkIndexFileIsServedUp); | 200 | it('file is served up', checkIndexFileIsServedUp); |
185 | it('can logout', logout); | 201 | it('can logout', logout); |
186 | 202 | ||
187 | it('uninstall app', function () { | 203 | it('uninstall app', function (done) { |
188 | execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); | 204 | // ensure we don't hit NXDOMAIN in the mean time |
205 | browser.get('about:blank').then(function () { | ||
206 | execSync('cloudron uninstall --app ' + app.id, EXEC_OPTIONS); | ||
207 | done(); | ||
208 | }); | ||
189 | }); | 209 | }); |
190 | }); | 210 | }); |