commit merge
authorSimon Descarpentries <sid@sopinspace.com>
Thu, 13 Feb 2014 18:55:46 +0100
changeset 576 43700c10a1fc
parent 575 8ce80860c3fe (diff)
parent 574 d10b7459a6f1 (current diff)
child 577 65fab7b5ce5e
commit merge
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cm/scripts/test-suite/README.txt	Thu Feb 13 18:55:46 2014 +0100
@@ -0,0 +1,34 @@
+
+--------------------------------
+- COMT test-suite instructions -
+--------------------------------
+
+
+Prerequisite :
+--------------
+You should have a running comt installation, made from a "comt" hg snapshot.
+You should have Firefox and/or Chrome navigators installed. You'll be able to
+run the tests against more brothers configuring them in the karma.conf.js file.
+
+
+Installation :
+--------------
+apt-get install npm
+sudo ln /usr/bin/nodejs /usr/bin/node	# /usr/share/doc/nodejs/README.Debian
+sudo npm install -g karma karma-mocha karma-e2e-dsl	# goes here /usr/local/lib/node_modules/
+
+Starting comt :
+---------------
+cd comt/
+./bin/django runserver localhost:8000 --settings=settings
+
+
+Starting the test-suite :
+-------------------------
+cd comt/src/cm/scripts
+vi workspace.info.js	# Customize tested workspace settings
+./test-suite.sh
+
+So you can run the test-suite multiple times using only `karma start` after the
+first run.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cm/scripts/test-suite/karma.conf.js	Thu Feb 13 18:55:46 2014 +0100
@@ -0,0 +1,49 @@
+// Karma configuration
+// Generated on Wed Jan 29 2014 15:32:16 GMT+0100 (CET)
+
+// SID: get WORKSPACE_URL configuration from one single file to customize
+var w = require ('./workspace.info.js');
+
+module.exports = function(config) {
+	config.set({
+		// list of files or patterns to load in the browser, from current directory
+		files: [
+			{pattern: 'tests/**/*.js', included: true}
+		],
+		// list of files to exclude
+		exclude: [
+		],
+		// Start these browsers, currently available:
+		// - Firefox	; Safari	(only Mac; run `npm install karma-safari-launcher` first)
+		// - Chrome		; ChromeCanary ; Opera (run `npm install karma-opera-launcher` first)
+		// - PhantomJS	; IE		(only Windows; run `npm install karma-ie-launcher` first)
+		browsers: ['Chrome'],
+		// frameworks to use. SID: choosen mocha, added karma-e2e-dsl (end-to-end testing)
+		frameworks: ['mocha', 'karma-e2e-dsl'],
+		// SID: Karma will start and run somewhere else than '/', to allow proxying '/'
+		urlRoot: '/karma/',
+		// SID: directive added on karma-e2e-dsl purpose. Map of path-proxy pairs.
+		proxies: {
+			'/': w.WORKSPACE_URL
+		},
+		client: {
+			args:[w.WORKSPACE_NAME, w.USER_ADMIN, w.PASS_ADMIN], 
+			// captureConsole: false
+		},
+		// test results reporter to use : 'dots', 'progress', 'junit', 'growl', 'coverage'
+		reporters: ['progress'],
+		// web server port
+		port: 9876,
+		// enable / disable colors in the output (reporters and logs)
+		colors: true,
+		// level of logging : config.LOG_DISABLE || _ERROR || _WARN || _INFO || _DEBUG
+		logLevel: config.LOG_INFO || config.LOG_DEBUG,
+		// enable / disable watching file and executing tests whenever any file changes
+		autoWatch: false,
+		// If browser does not capture in given timeout [ms], kill it
+		captureTimeout: 20000,
+		// Continuous Integration mode : if true, it capture browsers, run tests and exit
+		// singleRun: false
+		singleRun: true,
+	});
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cm/scripts/test-suite/start-test-suite.sh	Thu Feb 13 18:55:46 2014 +0100
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+export CHROME_BIN=`whereis chromium | sed -r 's/[^ ]* ([^ ]*).*/\1/g' -`
+karma start
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cm/scripts/test-suite/tests/tests.js	Thu Feb 13 18:55:46 2014 +0100
@@ -0,0 +1,52 @@
+
+// console.log ('args '+args);
+
+describe ('comt', function () {
+
+	this.timeout(150000);
+
+	describe ('connexion', function () {
+		it ('should load login page', dsl(function () {
+			// here we are in Karma page
+			browser.navigateTo ('/');
+
+			/*element ('title').text (function (page_title) {
+				// here we got a value from the test iframe
+				if (typeof page_title != 'string') throw 'page_title not a string, network problem ?';
+				if (!/(Accueil|Home) - Workspace/.test (page_title)) throw 'got page '+page_title+' instead';
+			});*/
+
+			expect (element ('title').text ()).toBeDefined ();
+			expect (element ('title').text ()).toMatch (/Home - Workspace/);
+
+			// it should have a header
+				// with visible homepage and login links
+			// it should have a title
+				// with workspace name in it… ?
+			// it may have public texts
+				// how many max ?
+				// do we announce the right number of texts ?
+			// it should have a login form
+				// with labels
+				// with red stars
+				// green button
+				// forgoten password link
+			// it should have a footer
+				// with contact link, powered by co-ment logo, help link, languages links
+
+			// we should try the links
+			// we should try urls as not logged to check the access avoidance
+
+		}));
+		it ('should log in', dsl(function () {
+			browser.navigateTo ('/');
+			input ('#id_username').enter ('siltaar');
+			input ('#id_password').enter ('oaueoaue');
+			element ('#login input[type=submit]').click ();
+			browser.waitForPageLoad ()
+			browser.navigateTo ('/');
+			expect (element ('title').text ()).toMatch (/Dashboard\n - Workspace/m);
+
+		}));
+	});
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cm/scripts/test-suite/workspace.info.js	Thu Feb 13 18:55:46 2014 +0100
@@ -0,0 +1,25 @@
+
+define ("WORKSPACE_URL", 'http://192.168.2.61:8000/');
+define ("WORKSPACE_NAME", 'Workspace');
+define ("USER_ADMIN", 'siltaar');
+define ("PASS_ADMIN", 'oaueoaue');
+
+// TODO: decide wether we should populate workspaces with standard users or
+// create them on the fly ?
+
+define ("USER_EDIT", '');
+define ("PASS_EDIT", '');
+
+define ("USER_COM", '');
+define ("PASS_COM", '');
+
+define ("USER_OBSERV", '');
+define ("PASS_OBSERV", '');
+
+function define (name, value) {
+    Object.defineProperty (exports, name, {
+        value:      value,
+        enumerable: true
+    });
+}
+