From 1582836dca0214eba38b88676da8c4ddb44d4394 Mon Sep 17 00:00:00 2001 From: Jeff Fry Date: Wed, 5 May 2010 00:43:20 +0000 Subject: [PATCH] Reworked in as functions instead of an array of commands git-svn-id: http://google-refine.googlecode.com/svn/trunk@598 7d457c2a-affb-35e4-300a-418c747d4874 --- tests/windmill/js/test_basic_functions.js | 81 ++++++++++++++++------- 1 file changed, 56 insertions(+), 25 deletions(-) diff --git a/tests/windmill/js/test_basic_functions.js b/tests/windmill/js/test_basic_functions.js index 66de68d24..3ed9aa371 100644 --- a/tests/windmill/js/test_basic_functions.js +++ b/tests/windmill/js/test_basic_functions.js @@ -1,25 +1,56 @@ -var test_basicFunctionality = new function() {//try cutting 'new' at some point - this.test_openProject = [ - { params: { "link": "Food" }, method: "click" }, - { params: {"timeout": "20000"}, method: "waits.forPageLoad"} - //assert the project is open - ]; - var column_name = 'Shrt_Desc'; - this.test_filterColumn = [ -// {method: "click", params: { jquery: '(".column-header-layout tr:contains( '+ column_name + ' ) .column-header-menu")[0]' } }, - {method: "click", params: { jquery: '(".column-header-layout tr:contains(\'Shrt_Desc\') .column-header-menu")[0]'} }, - {method: "mouseOver", params: { jquery: '("td:contains(\'Facet\')")[0]'} }, - {method: "click", params: { jquery: '(".menu-item:contains(\'Custom Text Facet\')")[0]'} }, - {method: "type", params: { jquery: '(".expression-preview-code")[0]', text: "value.split(',')[0]"} }, - {method: "waits.forElement", params: { jquery: '("td:contains(\'value.split\')")[0]'} }, - {method: "click", params: { jquery: '("button:contains(\'OK\')")[0]'} }, - {method: "waits.forElement", params: { jquery: '("a:contains(\'Count\')")[0]'} }, - {method: "click", params: { jquery: '("a:contains(\'Count\')")[0]'} } -// assert_expected_top_value(client, 'BEEF') - - ]; -}; - - - -// {method: "waits.forElement", params: { jquery: '("body[ajax_in_progress=\'false\']")[0]'} }, //wants to be a method \ No newline at end of file +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_sort_worked= function () { asserts.gw.expected_top_value("SPAGHETTIOS"); }; + this.test_sort_by_count = function () { wm.actions.click( { jquery: '(".ui-button-text:contains(\'count\')")[0]'} ); }; + this.test_sort_worked= function () { asserts.gw.expected_top_value("BEEF"); }; + +}(); + + +