mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-25 01:13:25 +01:00
run a first unit-test with egw object on login page: npm test
This commit is contained in:
parent
1ad5d321a4
commit
7733c8dfd4
1
.gitignore
vendored
1
.gitignore
vendored
@ -45,7 +45,6 @@
|
||||
/sitemgr/
|
||||
/stylite/
|
||||
/swool/
|
||||
/test/
|
||||
/tracker/
|
||||
/usage/
|
||||
/vendor/
|
||||
|
@ -2,12 +2,13 @@
|
||||
"name": "EGroupware",
|
||||
"description": "EGroupware is a groupware suite in PHP and Javascript: https://www.egroupware.org/",
|
||||
"license": "GPL-2.0",
|
||||
"version": "19.1.001",
|
||||
"version": "20.1.20200812",
|
||||
"dependencies": {},
|
||||
"repository": {},
|
||||
"devDependencies": {
|
||||
"@types/jquery": "^3.3.38",
|
||||
"@types/jqueryui": "^1.11.37",
|
||||
"chai": "^4.2.0",
|
||||
"grunt": "^1.0.3",
|
||||
"grunt-contrib-cssmin": "^2.2.1",
|
||||
"grunt-contrib-uglify-es": "^3.3.0",
|
||||
@ -15,7 +16,13 @@
|
||||
"grunt-newer": "^1.3.0",
|
||||
"grunt-terser": "^1.0.0",
|
||||
"grunt-ts": "^6.0.0-beta.22",
|
||||
"jsdom": "16.4.0",
|
||||
"mocha": "^8.1.3",
|
||||
"terser": "^4.7.0",
|
||||
"typescript": "^3.7.4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha",
|
||||
"debug-test": "mocha --inspect-brk"
|
||||
}
|
||||
}
|
||||
|
39
test/loginSpec.js
Normal file
39
test/loginSpec.js
Normal file
@ -0,0 +1,39 @@
|
||||
let expect = require('chai').expect;
|
||||
const { JSDOM } = require('jsdom'),
|
||||
|
||||
// the file I will be loading
|
||||
uri = 'https://boulder.egroupware.org/egroupware/login.php',
|
||||
|
||||
// the options that I will be giving to jsdom
|
||||
options = {
|
||||
runScripts: 'dangerously', // 'outside-only' does NOT work for scripts in the loaded page!
|
||||
resources: 'usable'
|
||||
};
|
||||
|
||||
// load from an external file
|
||||
describe('EGroupware login-page', function() {
|
||||
it('Should load egw object', function() {
|
||||
debugger
|
||||
return JSDOM.fromURL(uri, options).then(function (dom) {
|
||||
let window = dom.window,
|
||||
document = window.document;
|
||||
expect(document.querySelectorAll('form')).key(0);
|
||||
expect(document.querySelectorAll('form')[0].action).to.be.a('string').and.satisfy(msg => msg.startsWith(uri));
|
||||
return new Promise((resolve, reject) => {
|
||||
window.onload = resolve;
|
||||
}).then(function() {
|
||||
console.log('Window loaded :)');
|
||||
return new Promise((resolve, reject) => {
|
||||
window.egw_LAB.wait(function() {
|
||||
console.log('Async script-loading / egw_LAB done :)')
|
||||
resolve(window.egw);
|
||||
});
|
||||
})
|
||||
});
|
||||
}).then(function(egw) {
|
||||
expect(egw.webserverUrl).equal('/egroupware', 'egw.webserverURL !== "/egroupware"');
|
||||
expect(egw.lang('Test12345 %1', 'success')).to.equal('Test12345 success');
|
||||
egw.window.close();
|
||||
})
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user