witten
/
luminotes
Archived
1
0
Fork 0

Removed JavaScript unit/functional tests since they weren't really maintained. At least there are several hundred Python unit tests.

This commit is contained in:
Dan Helfman 2008-08-20 02:06:14 -07:00
parent 33a61b67d8
commit 573b06fc01
8 changed files with 0 additions and 426 deletions

15
INSTALL
View File

@ -218,18 +218,3 @@ package:
Then you can run unit tests by running:
nosetests
JavaScript "unit" tests
-----------------------
JsUnit is included with Luminotes, so to kick off tests of the client-side
JavaScript code, simply run:
python2.4 static/js/test/run_tests.py
The run_tests.py script runs the tests inside browser windows and presumes
that you have both Firefox and Internet Explorer 6 installed, and also that
the Luminotes server is running on the local machine. Edit run_tests.py if you
need to specify different paths to the browser binaries or want to test with
additional browsers.

View File

@ -1,33 +0,0 @@
function setUpPage() {
id = "fake_id";
notebook_id = "fake_notebook_id";
title = "the title"
note_text = "<h3>" + title + "</h3>blah";
deleted_from_id = undefined;
revisions_list = undefined;
read_write = true;
startup = false;
highlight = false;
editor_focus = false;
editor = new Editor( id, notebook_id, note_text, deleted_from_id, revisions_list, read_write, startup, highlight, editor_focus );
init_complete = false;
connect( editor, "init_complete", function () { init_complete = true; } );
wait_for_init_complete();
}
function wait_for_init_complete() {
// busywait for the editor initialization to complete
if ( !init_complete ) {
setTimeout( "wait_for_init_complete()", 10 );
return;
}
setUpPageStatus = "complete";
}
function tearDownPage() {
editor.shutdown();
}

View File

@ -1,133 +0,0 @@
function Editor( id, notebook_id, note_text, deleted_from_id, revisions_list, read_write, startup, highlight, focus ) {
this.id = id;
this.notebook_id = notebook_id;
this.initial_text = note_text;
this.deleted_from_id = deleted_from_id || null;
this.revisions_list = revisions_list || new Array();
this.read_write = read_write;
this.startup = startup || false; // whether this Editor is for a startup note
this.init_highlight = highlight || false;
this.init_focus = focus || false;
this.closed = false;
var iframe_id = "note_" + id;
this.document = null;
this.iframe = createDOM( "iframe", {
"id": iframe_id,
"name": iframe_id,
"class": "note_frame"
} );
this.iframe.editor = this;
this.title = null;
this.delete_button = createDOM( "input" );
this.changes_button = createDOM( "input" );
this.undelete_button = createDOM( "input" );
this.options_button = createDOM( "input" );
this.hide_button = createDOM( "input" );
connect( this.iframe, "onload", function ( event ) { self.finish_init(); } );
}
Editor.prototype.finish_init = function () {
if ( this.iframe.contentDocument ) { // browsers such as Firefox
this.document = this.iframe.contentDocument;
} else { // browsers such as IE
this.document = this.iframe.contentWindow.document;
}
if ( !this.initial_text )
this.initial_text = "<h3>";
this.document.write( this.initial_text );
this.scrape_title();
if ( this.init_focus )
this.focus();
this.calls = new Array();
}
Editor.prototype.add_call = function ( method_name, args ) {
this.calls[ this.calls.length ] = [ method_name, args || [] ];
}
Editor.prototype.highlight = function ( scroll ) {
this.add_call( "highlight", [ scroll ] );
}
Editor.prototype.exec_command = function ( command, parameter ) {
this.add_call( "exec_command", [ command, parameter ] );
}
Editor.prototype.resize = function () {
this.add_call( "resize" );
}
Editor.prototype.empty = function () {
this.add_call( "empty" );
if ( !this.document || !this.document.body )
return true; // consider it empty as of now
return ( scrapeText( this.document.body ).length == 0 );
}
Editor.prototype.start_link = function () {
this.add_call( "start_link" );
}
Editor.prototype.end_link = function () {
this.add_call( "end_link" );
}
Editor.prototype.find_link_at_cursor = function () {
this.add_call( "find_link_at_cursor" );
return null;
}
Editor.prototype.focus = function () {
this.add_call( "focus" );
}
// return true if the specified state is enabled
Editor.prototype.state_enabled = function ( state_name ) {
this.add_call( "state_enabled", [ state_name ] );
return false;
}
Editor.prototype.contents = function () {
this.add_call( "contents" );
return this.document.body.innerHTML;
}
Editor.prototype.shutdown = function( event ) {
this.add_call( "shutdown", [ event ] );
}
// convenience function for parsing a link that has an href URL containing a query string
function parse_query( link ) {
if ( !link || !link.href )
return new Array();
return parseQueryString( link.href.split( "?" ).pop() );
}
// convenience function for getting a link's title (stripped of whitespace), either from a query
// argument in the href or from the actual link title
function link_title( link, query ) {
if ( !query )
query = parse_query( link );
var link_title = strip( query.title || scrapeText( link ) );
// work around an IE quirk in which link titles are sometimes 0xa0
if ( link_title.charCodeAt( 0 ) == 160 )
return "";
return link_title;
}

View File

@ -1,49 +0,0 @@
function Invoker( handler ) {
this.handler = handler;
}
Invoker.prototype.invoke = function ( url, http_type, args, callback, form, fire_and_forget ) {
if ( form ) {
var form = formContents( getElement( form ) );
var arg_names = form[ 0 ];
var arg_values = form[ 1 ];
} else {
var arg_names = [];
var arg_values = [];
}
extend( arg_names, keys( args ) );
extend( arg_values, values( args ) );
// if there's no handler, simulate an error reaching the server
if ( !this.handler ) {
signal( self, "error_message", "There was a problem reaching the server. Please check your network connectivity." );
return;
}
var args = new Array();
for ( var i in arg_names ) {
var name = arg_names[ i ];
var value = arg_values[ i ];
args[ name ] = value;
}
// ask the stub handler for a fake response to the invocation request
var result = this.handler( url, args );
if ( fire_and_forget )
return;
if ( result.error )
signal( this, "error_message", result.error );
if ( callback )
callback( result );
if ( result.redirect )
window.location = result.redirect;
if ( result.reload )
window.location.reload();
}

View File

@ -1,30 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Luminotes Test Suite</title>
<script language="JavaScript" type="text/javascript" src="../../jsunit/app/jsUnitCore.js"></script>
<script language="JavaScript" type="text/javascript">
function mainSuite() {
var result = new top.jsUnitTestSuite();
result.addTestPage("../js/test/Test_wiki.html");
result.addTestPage("../js/test/Test_editor.html");
return result;
}
function suite() {
var newsuite = new top.jsUnitTestSuite();
newsuite.addTestSuite(mainSuite());
return newsuite;
}
</script>
</head>
<body>
<h1>Luminotes Test Suite</h1>
<p>This page contains a suite of tests for testing Luminotes.</p>
</body>
</html>

View File

@ -1,51 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html id="html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Luminotes Editor Tests</title>
<script language="JavaScript" type="text/javascript" src="../../jsunit/app/jsUnitCore.js"></script>
<script language="JavaScript" type="text/javascript" src="../MochiKit.js"></script>
<script language="JavaScript" type="text/javascript" src="../Editor.js"></script>
<script language="JavaScript" type="text/javascript" src="Editor_setup.js"></script>
<script language="JavaScript" type="text/javascript">
function test_Editor() {
assertNotUndefined( "editor should have changes_button member", editor.changes_button );
assertNotUndefined( "editor should have options_button member", editor.options_button );
assertFalse( "editor should not have closed flag set", editor.closed );
assertEquals( "editor should have correct deleted_from_id flag", editor.deleted_from_id, deleted_from_id || null );
assertNotUndefined( "editor should have document member", editor.document );
assertEquals( "editor id should have correct id", editor.id, id );
assertNotUndefined( "editor should have iframe member", editor.iframe );
assertEquals( "editor should have correct startup flag", editor.startup, startup );
assertEquals( "editor should have correct title", editor.title, title );
assertEquals( "editor should have correct read_write flag", editor.read_write, read_write );
}
function test_contents() {
assertEquals(
"contents() should start with note_text",
editor.contents().toLowerCase().indexOf( note_text.toLowerCase() ),
0
);
}
function test_empty() {
assertFalse( editor.empty() );
}
</script>
</head>
<body>
<h1>Luminotes Editor Tests</h1>
<p>This page contains tests for the Luminotes Editor class. To see them, take a look at the source.</p>
<div id="notes"></div>
</body>
</html>

View File

@ -1,94 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html id="html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Luminotes Wiki Tests</title>
<script language="JavaScript" type="text/javascript" src="../../jsunit/app/jsUnitCore.js"></script>
<script language="JavaScript" type="text/javascript" src="../MochiKit.js"></script>
<script language="JavaScript" type="text/javascript" src="Stub_invoker.js"></script>
<script language="JavaScript" type="text/javascript" src="Stub_editor.js"></script>
<script language="JavaScript" type="text/javascript" src="../Wiki.js"></script>
<script language="JavaScript" type="text/javascript">
function setUp() {
stub_invoker = new Invoker( function ( url, args ) {
var notebook = {
"name": "fake notebook",
"object_id": "fake_notebook_id",
"revision": "fake_notebook_revision",
"read_write": "true",
"trash": {
"name": "trash",
"object_id": "fake_trash_id",
"revision": "fake_trash_revision",
"read_write": "true",
"trash": null
}
}
if ( url == "/next_id" ) {
return {
"next_id": "" + Math.random()
}
}
fail( "unknown invoke() url: " + url );
} );
wiki = new Wiki( stub_invoker );
}
function test_Wiki() {
assertNotUndefined( wiki );
assertNotNull( wiki );
}
</script>
</head>
<body>
<h1>Luminotes Wiki Tests</h1>
<p>This page contains tests for the Luminotes Wiki class. To see them, take a look at the source.</p>
<form id="search_form">
<input id="search_button" type="button" />
</form>
<div id="user_area"></div>
<div id="notebooks_area"></div>
<div id="notebook_header_area"></div>
<div id="this_notebook_area"></div>
<div id="notes"></div>
<div id="toolbar">
<input id="bold" type="button" />
<input id="italic" type="button" />
<input id="underline" type="button" />
<input id="title" type="button" />
<input id="insertUnorderedList" type="button" />
<input id="insertOrderedList" type="button" />
<input id="createLink" type="button" />
<input id="newNote" type="button" />
</div>
<input type="hidden" name="storage_bytes" id="storage_bytes" value="555" />
<input type="hidden" name="rate_plan" id="rate_plan" value="{ 'name': 'super', 'storage_bytes': '1337' }" />
<input type="hidden" name="notebooks" id="notebooks" value="[ { 'title': 'my notebook', 'object_id': 'fake_notebook_id' } ]" />
<input type="hidden" name="notebook_id" id="notebook_id" value="fake_notebook_id" />
<input type="hidden" name="parent_id" id="parent_id" value="" />
<input type="hidden" name="startup_notes" id="startup_notes" value="[]" />
<input type="hidden" name="note" id="note" value="" />
<input type="hidden" name="note_read_write" id="note_read_write" value="" />
<input type="hidden" name="rename" id="rename" value="false" />
<input type="hidden" name="deleted_id" id="deleted_id" value="" />
<input type="hidden" name="invited" id="invited" value="[]" />
<div id="static_notes">
</div>
</body>
</html>

View File

@ -1,21 +0,0 @@
#!/usr/bin/python
import subprocess
import os.path
browsers = [
"firefox",
"ie6",
]
def main():
test_page = "http://localhost:8081/static/js/test/Test_Luminotes.html"
test_runner = "http://localhost:8081/static/jsunit/testRunner.html?testpage=%s&autorun=true" % test_page
# launch tests in each supported browser
for browser in browsers:
subprocess.call( [ browser, test_runner ] )
if __name__ == "__main__":
main()