introducing a wrapper around windmill-js that adds support for macros in order to make it easier to make gridworks-specific UI testing a lot more compact (this is a tiny bit more verbose than the previuos method, but it allows us to group waits with actions and assertions which wasn't possible before, so it's a good price to pay).
git-svn-id: http://google-refine.googlecode.com/svn/trunk@709 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
f341fa8db2
commit
668b763f6b
@ -5,62 +5,64 @@ var test_facets = new function() {
|
||||
//go back
|
||||
//};
|
||||
|
||||
// test opening Food project
|
||||
this.test_open_project = [
|
||||
action("click", { link: "Food" } ),
|
||||
action("waits.forPageLoad", { timeout: "20000" } ),
|
||||
assert("gw_row_count", "7413" )
|
||||
];
|
||||
// test opening Food project
|
||||
test = newTest();
|
||||
assert (test, "assertText", { jquery: '("h1")[0]', validator: "Welcome to Gridworks" });
|
||||
this.test_home_page = test;
|
||||
|
||||
// make sure the dataset was loaded properly
|
||||
test = newTest();
|
||||
action (test, "click", { link: "Food" });
|
||||
wait (test, "forPageLoad", { timeout: "20000" });
|
||||
assert (test, "rowCount", "7413" );
|
||||
this.test_open_project = test;
|
||||
|
||||
// create text facet from 1st word of Short Description column
|
||||
this.test_create_text_facet = [
|
||||
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]' } ),
|
||||
action("gw_wait4ajaxend"), //doesn't help yet, since ajax_in_progress isn't yet reliable
|
||||
action("waits.forElement", { jquery: '("a.facet-choice-label")[0]' } ),
|
||||
assert("gw_expected_top_value","ABALONE")
|
||||
];
|
||||
test = newTest();
|
||||
action (test, 'click', { jquery: '(".column-header-layout tr:contains(\'Shrt_Desc\') .column-header-menu")[0]' });
|
||||
action (test, 'mouseOver', { jquery: '("td:contains(\'Facet\')")[0]' });
|
||||
wait (test, "forMenuItem", { name: 'Custom Text Facet' });
|
||||
action (test, "click", { jquery: '(".menu-item:contains(\'Custom Text Facet\')")[0]' });
|
||||
action (test, "type", { jquery: '(".expression-preview-code")[0]', text: "value.split(',')[0]" });
|
||||
wait (test, "forElement", { jquery: '("td:contains(\'value.split\')")[0]' });
|
||||
action (test, "click", { jquery: '("button:contains(\'OK\')")[0]' });
|
||||
wait (test, "forAjaxEnd");
|
||||
assert (test, "expectedTopFacetValue", "ABALONE");
|
||||
this.test_facet = test;
|
||||
|
||||
// sort the facet by count and test the result
|
||||
this.test_sort_text_facet = [
|
||||
action("click", { jquery: '(".ui-button-text:contains(\'count\')")[0]' } ),
|
||||
action("waits.forElement", { jquery: '(".ui-state-active .ui-button-text:contains(\'count\')")[0]' } ), //wait til count is the active sort
|
||||
assert("gw_expected_top_value","BEEF")
|
||||
];
|
||||
test = newTest();
|
||||
action (test, "click", { jquery: '(".ui-button-text:contains(\'count\')")[0]' });
|
||||
wait (test, "forElement", { jquery: '(".ui-state-active .ui-button-text:contains(\'count\')")[0]' }); // wait til count is the active sort
|
||||
assert (test, "expectedTopFacetValue", "BEEF");
|
||||
this.test_sort_text_facet = test;
|
||||
|
||||
// filter down to BEEF
|
||||
this.test_fitler_text_facet = [
|
||||
action("click", { jquery: '("a.facet-choice-label")[0]' } ),
|
||||
action("waits.forElement", { jquery: '(".viewPanel-summary-row-count")[0]' } ),
|
||||
assert("gw_row_count", "457")
|
||||
];
|
||||
test = newTest();
|
||||
action (test, "click", { jquery: '("a.facet-choice-label")[0]' });
|
||||
wait (test, "forElement", { jquery: '(".viewPanel-summary-row-count")[0]' });
|
||||
assert (test, "rowCount", "457");
|
||||
this.test_fitler_text_facet = test;
|
||||
|
||||
// create numeric filter from Water column
|
||||
this.test_create_numeric_facet = [
|
||||
action("click", { jquery: '(".column-header-layout tr:contains(\'Water\') .column-header-menu")[0]' } ),
|
||||
action('mouseOver', { jquery: '("td:contains(\'Facet\')")[0]' } ),
|
||||
action("gw_wait4menuitem", { name: 'Numeric Facet' } ),
|
||||
action("click", { jquery: '(".menu-item:contains(\'Numeric Facet\')")[0]' } )//,
|
||||
//TODO: (How) can I run a JSUnit assert w/in an object?
|
||||
//function () { jum.assertTrue( $(".facet-panel span:contains(\'Water\')").length ); }
|
||||
];
|
||||
test = newTest();
|
||||
action (test, "click", { jquery: '(".column-header-layout tr:contains(\'Water\') .column-header-menu")[0]' });
|
||||
action (test, "mouseOver", { jquery: '("td:contains(\'Facet\')")[0]' });
|
||||
wait (test, "forMenuItem", { name: 'Numeric Facet' });
|
||||
action (test, "click", { jquery: '(".menu-item:contains(\'Numeric Facet\')")[0]' });
|
||||
// TODO: What to wait on, to know we're ready to do the following assert? Talk to dfhuynh.
|
||||
//assert (test, function() {
|
||||
// jum.assertTrue($(".facet-panel span:contains(\'Water\')").length > 0);
|
||||
//});
|
||||
this.test_create_numeric_facet = test;
|
||||
|
||||
// filter out BEEF with lower water content
|
||||
this.test_filter_numeric_facet = [
|
||||
action("gw_wait4ajaxend"),
|
||||
action("waits.forElement", { jquery: '((".slider-widget-draggable.left"))[0]' } ),
|
||||
action("dragDropElem", { jquery: '((".slider-widget-draggable.left"))[0]', pixels: '150, 0' } )//,
|
||||
// TODO: What to wait on, to know we're ready to do the following assert? Talk to dfhuynh.
|
||||
//assert("gw_row_count", "153")
|
||||
];
|
||||
|
||||
|
||||
test = newTest();
|
||||
wait (test, "forAjaxEnd");
|
||||
wait (test, "forElement", { jquery: '((".slider-widget-draggable.left"))[0]' }),
|
||||
action (test, "dragDropElem", { jquery: '((".slider-widget-draggable.left"))[0]', pixels: '150, 0' });
|
||||
// TODO: What to wait on, to know we're ready to do the following assert? Talk to dfhuynh.
|
||||
//assert (test, "rowCount", "153");
|
||||
this.test_filter_numeric_facet = test;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
@ -1,48 +1,85 @@
|
||||
|
||||
var test = [];
|
||||
|
||||
function newTest() {
|
||||
return [];
|
||||
}
|
||||
|
||||
windmill.macros = {};
|
||||
|
||||
// ---------------------- actions extensions ----------------------------
|
||||
|
||||
var actions = windmill.jsTest.actions;
|
||||
|
||||
function action(what,params) {
|
||||
params = params || {};
|
||||
return {
|
||||
method : what,
|
||||
params : params
|
||||
};
|
||||
function action(test, what, params) {
|
||||
if (typeof what == "function") {
|
||||
test.push(what);
|
||||
} else if (what in windmill.macros.actions) {
|
||||
windmill.macros.actions[what](params);
|
||||
} else {
|
||||
test.push({
|
||||
method: what,
|
||||
params: params
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
windmill.macros.actions = {};
|
||||
|
||||
actions.gw_wait4ajaxend = function () {
|
||||
return action("waits.forElement", { jquery: '("body[ajax_in_progress=\'false\']")[0]' } );
|
||||
windmill.macros.actions.clickColumnHeader = function (test,params) {
|
||||
action(test,"click", { jquery: '(".column-header-layout tr:contains("' + params.column_name + '") .column-header-menu")[0]'} );
|
||||
};
|
||||
|
||||
actions.gw_wait4menuitem = function (params) {
|
||||
return action("waits.forElement", { jquery: '(".menu-item:contains(\"' + params.name + '\")")[0]' } );
|
||||
// ---------------------- wait extensions -------------------------------
|
||||
|
||||
function wait(test, what, params) {
|
||||
if (typeof what == "function") {
|
||||
test.push(what);
|
||||
} else if (what in windmill.macros.waits) {
|
||||
windmill.macros.waits[what](test,params);
|
||||
} else {
|
||||
test.push({
|
||||
method: "waits." + what,
|
||||
params: params
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
windmill.macros.waits = {};
|
||||
|
||||
windmill.macros.waits.forAjaxEnd = function (test) {
|
||||
wait(test,"forElement", { jquery: '("body[ajax_in_progress=\'false\']")[0]' } );
|
||||
};
|
||||
|
||||
actions.gw_click_column_header = function (params) {
|
||||
return action("click", { jquery: '(".column-header-layout tr:contains("' + params.column_name + '") .column-header-menu")[0]'} );
|
||||
windmill.macros.waits.forMenuItem = function (test,params) {
|
||||
wait(test,"forElement", { jquery: '(".menu-item:contains(\'' + params.name + '\')")[0]' } );
|
||||
};
|
||||
|
||||
// ---------------------- asserts extensions ----------------------------
|
||||
|
||||
var asserts = windmill.controller.asserts;
|
||||
|
||||
function assert(what,params) {
|
||||
return function() {
|
||||
windmill.controller.asserts[what](params);
|
||||
};
|
||||
function assert(test, what, params) {
|
||||
if (typeof what == "function") {
|
||||
test.push(what);
|
||||
} else if (what in windmill.macros.asserts) {
|
||||
windmill.macros.asserts[what](test,params);
|
||||
} else {
|
||||
test.push({
|
||||
method: "asserts." + what,
|
||||
params: params
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: is there a way to make the assert wait first, rather than putting this before each call of the assert?,
|
||||
asserts.gw_row_count = function (count) {
|
||||
//action("waits.forElement", { jquery: '(".viewPanel-summary-row-count")[0]' } ); // doesn't work bc waits can't go inside functions
|
||||
asserts.assertText( { jquery: '(".viewPanel-summary-row-count")[0]', validator: count } );
|
||||
|
||||
windmill.macros.asserts = {};
|
||||
|
||||
windmill.macros.asserts.rowCount = function (test, count) {
|
||||
wait(test,"forElement", { jquery: '(".viewPanel-summary-row-count")[0]' } );
|
||||
assert(test,"assertText", { jquery: '(".viewPanel-summary-row-count")[0]', validator: count } );
|
||||
};
|
||||
|
||||
asserts.gw_expected_top_value = function (expected_value) {
|
||||
// action("waits.forElement", { jquery: '("a.facet-choice-label")[0]' } ); // doesn't work bc waits can't go inside functions
|
||||
asserts.assertEquals(expected_value, $.trim($("a.facet-choice-label")[0].text));
|
||||
windmill.macros.asserts.expectedTopFacetValue = function (test, expected_value) {
|
||||
wait(test, "forElement", { jquery: '("a.facet-choice-label")[0]' } );
|
||||
assert(test, function() {
|
||||
jum.assertEquals(expected_value, $.trim($("a.facet-choice-label")[0].text));
|
||||
});
|
||||
};
|
||||
|
||||
// ----------------------- register tests ---------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user