much less verbose js testing

git-svn-id: http://google-refine.googlecode.com/svn/trunk@606 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Stefano Mazzocchi 2010-05-06 00:06:39 +00:00
parent 7d63fc2f6f
commit cc1b0a8974
3 changed files with 85 additions and 57 deletions

View File

@ -0,0 +1,37 @@
var test_facets = new function() {
// test opening Food project
this.test_open_project = [
action("click", { link: "Food" } ),
action("waits.forPageLoad", { timeout: "20000" } ),
assert("gw_row_count", "7413" )
];
// create text facet from 1st word of Short Description
this.test_facet_creation = [
action('click', { jquery: '(".column-header-layout tr:contains(\'Shrt_Desc\') .column-header-menu")[0]' } ),
action('mouseOver', { jquery: '("td:contains(\'Facet\')")[0]' } ),
action("gw_wait4menuitem", { name: 'Custom Text Facet' } ),
action("click", { jquery: '(".menu-item:contains(\'Custom Text Facet\')")[0]' } ),
action("type", { jquery: '(".expression-preview-code")[0]', text: "value.split(',')[0]" } ),
action("waits.forElement", { jquery: '("td:contains(\'value.split\')")[0]' } ),
action("click", { jquery: '("button:contains(\'OK\')")[0]' } )
];
// test created facet
this.test_created_facet = [
action("waits.forElement", { jquery: '(".ui-button-text:contains(\'count\')")[0]' } ),
assert("gw_expected_top_value","ABALONE")
];
// sort the facet by count and test the result
this.test_sorted_facet = [
action("click", { jquery: '(".ui-button-text:contains(\'count\')")[0]' } ),
action("waits.forElement", { jquery: '(".ui-state-active .ui-button-text:contains(\'count\')")[0]' } ),
assert("gw_expected_top_value","BEEF")
];
};

View File

@ -0,0 +1,48 @@
// ---------------------- actions extensions ----------------------------
var actions = windmill.jsTest.actions;
function action(what,params) {
return {
method : what,
params : params
};
}
actions.gw_wait4ajaxend = function () {
return action("waits.forElement", { jquery: '("body[ajax_in_progress=\'false\']")[0]' } );
};
actions.gw_wait4menuitem = function (params) {
return action("waits.forElement", { jquery: '(".menu-item:contains(\'' + params.name + '\')")[0]' } );
};
actions.gw_click_column_header = function (params) {
return action("click", { jquery: '(".column-header-layout tr:contains("' + params.column_name + '") .column-header-menu")[0]'} );
};
// ---------------------- asserts extensions ----------------------------
var asserts = windmill.controller.asserts;
function assert(what,params) {
return function() {
windmill.controller.asserts[what](params);
};
}
asserts.gw_row_count = function (count) {
asserts.assertText( { jquery: '(".viewPanel-summary-row-count")[0]', validator: count } );
};
asserts.gw_expected_top_value = function (expected_value) {
asserts.assertEquals(expected_value, $.trim($("a.facet-choice-label")[0].text));
};
// ----------------------- register tests ---------------------------
windmill.jsTest.register([
"test_facets"
]);
windmill.jsTest.require("facets.js");

View File

@ -1,57 +0,0 @@
var wm = windmill.jsTest;
var asserts = windmill.controller.asserts;
asserts.gw = {};
asserts.gw.row_count = function (count) {
asserts.assertText( { jquery: '(".viewPanel-summary-row-count")[0]', validator: count } );
};
asserts.gw.expected_top_value = function(expected_value) {
var actual_value = $.trim($("a.facet-choice-label")[0].text);
jum.assertEquals( expected_value, actual_value );
}
/* haven't gotten this working yet....
waits.gw = {};
waits.gw.ajax = function () {
{ method: "waits.forElement", params: { jquery: '("body[ajax_in_progress=\'false\']")[0]'} };
}; */
wm.actions.gw = {};
wm.actions.gw.click_column_header = function (column_name) {
wm.actions.click( { jquery: '(".column-header-layout tr:contains("' + column_name + '") .column-header-menu")[0]'} );
};
var gwActions = wm.actions.gw;
var test_basic_functions = new function () {
// open Food project
this.test_open_project = function () { wm.actions.click( { link: "Food" } ); };
this.test_wait = { method: "waits.forPageLoad", params: { timeout: "20000" }};
this.test_got_to_main_page = function () { asserts.gw.row_count("7413"); };
// create text facet from 1st word of Short Description
// this.test_facet_short_desc = function () { wm.actions.gw.click_column_header('Shrt_Desc'); }; // currently broken
this.test_filter_column = function () {
wm.actions.click( { jquery: '(".column-header-layout tr:contains(\'Shrt_Desc\') .column-header-menu")[0]'} ); //replace w/ above when able
wm.actions.mouseOver( { jquery: '("td:contains(\'Facet\')")[0]' } );
};
this.test_wait_for_menu = { method: "waits.forElement", params: {jquery: '(".menu-item:contains(\'Custom Text Facet\')")[0]'} };
this.test_create_facet = function () {
wm.actions.click( { jquery: '(".menu-item:contains(\'Custom Text Facet\')")[0]'} );
wm.actions.type( { jquery: '(".expression-preview-code")[0]', text: "value.split(',')[0]"} );
};
this.test_wait_for_value = {method: "waits.forElement", params: { jquery: '("td:contains(\'value.split\')")[0]'} };
this.test_click_button = function () { wm.actions.click( { jquery: '("button:contains(\'OK\')")[0]'} ); };
this.test_wait_for_link = {method: "waits.forElement", params: { jquery: '(".ui-button-text:contains(\'count\')")[0]'} };
this.test_facet_worked= function () { asserts.gw.expected_top_value("ABALONE"); };
this.test_sort_by_count = function () { wm.actions.click( { jquery: '(".ui-button-text:contains(\'count\')")[0]'} ); };
this.test_wait_for_count = {method: "waits.forElement", params: { jquery: '(".ui-state-active .ui-button-text:contains(\'count\')")[0]'} };
this.test_sort_worked= function () { asserts.gw.expected_top_value("BEEF"); };
}();