Kaynağa Gözat

Add end to end tests

pull/342/head
Guillaume Vincent 7 yıl önce
ebeveyn
işleme
89c1ff6753
18 değiştirilmiş dosya ile 937 ekleme ve 19 silme
  1. +1
    -0
      .gitignore
  2. +7
    -7
      dist/lesspass.min.js
  3. +789
    -0
      package-lock.json
  4. +8
    -2
      package.json
  5. +14
    -1
      server.js
  6. +2
    -1
      src/components/MasterPassword.vue
  7. +2
    -1
      src/views/PasswordGenerator.vue
  8. +12
    -0
      test/e2e/globals.js
  9. +25
    -0
      test/e2e/nightwatch.conf.js
  10. +22
    -0
      test/e2e/runner.js
  11. +27
    -0
      test/e2e/specs/loginLogout.js
  12. +21
    -0
      test/e2e/specs/passwordGeneration.js
  13. +1
    -1
      test/unit/api.password.js
  14. +1
    -1
      test/unit/api.user.js
  15. +1
    -1
      test/unit/form-validator.js
  16. +1
    -1
      test/unit/store.getters.js
  17. +2
    -2
      test/unit/store.mutations.js
  18. +1
    -1
      test/unit/url-parser.js

+ 1
- 0
.gitignore Dosyayı Görüntüle

@@ -1,3 +1,4 @@
.DS_Store
node_modules/
npm-debug.log
test/e2e/reports/

+ 7
- 7
dist/lesspass.min.js
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 789
- 0
package-lock.json
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 8
- 2
package.json Dosyayı Görüntüle

@@ -12,7 +12,8 @@
"build": "rm -rf dist && cross-env NODE_ENV=production webpack -p",
"build:i18n": "cd scripts && node buildI18n.js",
"dev": "webpack-dev-server --inline --hot --host 0.0.0.0",
"test": "ava test"
"test": "ava",
"test:e2e": "node test/e2e/runner.js"
},
"babel": {
"presets": [
@@ -47,6 +48,7 @@
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-env": "^1.6.0",
"babel-register": "^6.24.1",
"chromedriver": "^2.30.1",
"copy-webpack-plugin": "^4.0.1",
"cross-env": "^5.0.1",
"css-loader": "^0.28.4",
@@ -54,6 +56,7 @@
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^0.11.2",
"husky": "^0.14.3",
"nightwatch": "^0.9.16",
"nock": "^9.0.14",
"node-sass": "^4.5.3",
"sass-loader": "^6.0.6",
@@ -69,6 +72,9 @@
},
"ava": {
"require": "babel-register",
"babel": "inherit"
"babel": "inherit",
"files": [
"test/unit/**/*.js"
]
}
}

+ 14
- 1
server.js Dosyayı Görüntüle

@@ -7,6 +7,19 @@ app.get('/', function(req, res) {
res.sendFile(__dirname + '/index.html');
});

app.listen(8080, function() {
var _resolve;
var readyPromise = new Promise(resolve => {
_resolve = resolve
});

var server = app.listen(8080, function() {
console.log('frontend listening on port 8080');
_resolve();
});

module.exports = {
ready: readyPromise,
close: () => {
server.close()
}
};

+ 2
- 1
src/components/MasterPassword.vue Dosyayı Görüntüle

@@ -43,7 +43,8 @@
</button>
</span>
</div>
<button type="button"
<button id="encryptMasterPassword__btn"
type="button"
class="btn btn-link btn-sm p-0"
v-if="showEncryptButton"
v-on:click="encryptMasterPassword($refs.passwordField.value)"


+ 2
- 1
src/views/PasswordGenerator.vue Dosyayı Görüntüle

@@ -53,7 +53,8 @@
<div class="form-group"
v-bind:class="{ 'mb-0': !showOptions }">
<div v-if="!passwordGenerated">
<button type="button"
<button id="generatePassword__btn"
type="button"
class="btn"
v-on:click="generatePassword"
v-bind:class="{ 'btn-warning': password.version===1, 'btn-primary': password.version===2 }">


+ 12
- 0
test/e2e/globals.js Dosyayı Görüntüle

@@ -0,0 +1,12 @@
var chromedriver = require("chromedriver");

module.exports = {
before: function(done) {
chromedriver.start();
done();
},

after: function() {
chromedriver.stop();
}
};

+ 25
- 0
test/e2e/nightwatch.conf.js Dosyayı Görüntüle

@@ -0,0 +1,25 @@
module.exports = {
src_folders: ["test/e2e/specs"],
output_folder: "test/e2e/reports",
globals_path: "test/e2e/globals.js",
selenium: {
start_process: false
},
test_settings: {
default: {
launch_url: "http://localhost:8080",
selenium_port: 9515,
selenium_host: "localhost",
default_path_prefix: "",
globals: {
waitForConditionTimeout: 5000
},
desiredCapabilities: {
browserName: "chrome",
// chromeOptions: {
// args: ['--headless','--no-sandbox','--disable-gpu','--window-size=1920x1080']
// }
}
}
}
};

+ 22
- 0
test/e2e/runner.js Dosyayı Görüntüle

@@ -0,0 +1,22 @@
process.env.NODE_ENV = 'testing';
var child_process = require('child_process');
var server = require('../../server.js');

server.ready.then(() => {
var opts = process.argv.slice(2);
if (opts.indexOf('--config') === -1) {
opts = opts.concat(['--config', 'test/e2e/nightwatch.conf.js']);
}

var runner = child_process.spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' });

runner.on('exit', function (code) {
server.close();
process.exit(code);
});

runner.on('error', function (err) {
server.close();
throw err;
});
});

+ 27
- 0
test/e2e/specs/loginLogout.js Dosyayı Görüntüle

@@ -0,0 +1,27 @@
var assert = require("assert");

module.exports = {
"Login logout tests": function(browser) {
browser
.url(browser.launch_url)
.waitForElementVisible(".fa-sign-in")
.click(".fa-sign-in")
.waitForElementVisible("#baseURL")
.assert.value('#baseURL', 'https://lesspass.com')
.setValue("#email", "test@lesspass.com")
.setValue("#passwordField", "test@lesspass.com")
.waitForElementVisible("#fingerprint .fa-cutlery")
.waitForElementVisible("#fingerprint .fa-subway")
.waitForElementVisible("#fingerprint .fa-plane")
.waitForElementVisible("#encryptMasterPassword__btn")
.click("#encryptMasterPassword__btn")
.waitForElementVisible("#fingerprint .fa-university")
.waitForElementVisible("#fingerprint .fa-btc")
.waitForElementVisible("#fingerprint .fa-subway")
.waitForElementVisible("#signInButton")
.click("#signInButton")
.waitForElementVisible("#site");

browser.end();
}
};

+ 21
- 0
test/e2e/specs/passwordGeneration.js Dosyayı Görüntüle

@@ -0,0 +1,21 @@
var assert = require("assert");

module.exports = {
"Password generation tests": function(browser) {
browser
.url(browser.launch_url)
.waitForElementVisible("#site")
.setValue("#site", "lesspass.com")
.setValue("#login", "test@lesspass.com")
.setValue("#passwordField", "test@lesspass.com")
.waitForElementVisible("#fingerprint .fa-cutlery")
.waitForElementVisible("#fingerprint .fa-subway")
.waitForElementVisible("#fingerprint .fa-plane")
.waitForElementVisible("#generatePassword__btn")
.click("#generatePassword__btn")
.waitForElementVisible("#generated-password")
.assert.value('#generated-password', 'hjV@\\5ULp3bIs,6B');

browser.end();
}
};

test/api.password.js → test/unit/api.password.js Dosyayı Görüntüle

@@ -1,6 +1,6 @@
import test from "ava";
import nock from "nock";
import Passwords from "../src/api/password";
import Passwords from "../../src/api/password";

const token =
"ZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFt";

test/api.user.js → test/unit/api.user.js Dosyayı Görüntüle

@@ -1,6 +1,6 @@
import test from "ava";
import nock from "nock";
import User from "../src/api/user";
import User from "../../src/api/user";

test("login", t => {
const token = "5e0651";

test/form-validator.js → test/unit/form-validator.js Dosyayı Görüntüle

@@ -1,5 +1,5 @@
import test from "ava";
import formValidator from "../src/services/form-validator";
import formValidator from "../../src/services/form-validator";

test("formValidator.increment()", t => {
t.is(formValidator.increment(1, { min: 0, max: 10 }), 2);

test/store.getters.js → test/unit/store.getters.js Dosyayı Görüntüle

@@ -1,5 +1,5 @@
import test from "ava";
import * as getters from "../src/store/getters";
import * as getters from "../../src/store/getters";

test("version", t => {
const state = {

test/store.mutations.js → test/unit/store.mutations.js Dosyayı Görüntüle

@@ -1,7 +1,7 @@
import test from "ava";
import timekeeper from "timekeeper";
import mutations from "../src/store/mutations";
import * as types from "../src/store/mutation-types";
import mutations from "../../src/store/mutations";
import * as types from "../../src/store/mutation-types";

test("LOGOUT", t => {
const LOGOUT = mutations[types.LOGOUT];

test/url-parser.js → test/unit/url-parser.js Dosyayı Görüntüle

@@ -1,5 +1,5 @@
import test from "ava";
import * as urlParser from "../src/services/url-parser";
import * as urlParser from "../../src/services/url-parser";

test("getDomainName", t => {
t.is("lesspass.com", urlParser.cleanUrl("https://lesspass.com/#!/"));

Yükleniyor…
İptal
Kaydet