spec/features/rule_spec.rb in marty-4.0.0.rc2 vs spec/features/rule_spec.rb in marty-5.1.0

- old
+ new

@@ -1,7 +1,6 @@ require 'spec_helper' -require 'marty_rspec' feature 'rule view', js: true do before(:all) do marty_whodunnit @save_file = "/tmp/save_#{Process.pid}.psql" @@ -37,20 +36,18 @@ #{ext_var(v.grid, 'grid')} return #{ext_find(ext_arg('gridcolumn', text: col), 'grid')}.id JS end - # click_checkbox in marty_rspec not working here for some reason def click_checkbox(name) q = %Q(checkbox[fieldLabel="#{name}"]) page.execute_script <<-JS var checkbox = Ext.ComponentQuery.query('#{q}')[0]; checkbox.setValue(!checkbox.value); JS end - # click_col in marty_rspec is not reliable def click_column(rv, name) cid = col_id(rv, name) c = find('#' + cid) c.select_option # .click does not work reliably c.send_keys(' ') @@ -113,11 +110,11 @@ time_fill_in(0, '11:03:01') date_fill_in(1, '2030-01-01') time_fill_in(1, '08:03:01') press('OK') wait_for_ajax - expect(mrv.row_count()).to eq(9) + expect(mrv.row_count()).to eq(12) expect(mrv.get_row_vals(1)).to include('name' => 'abc', 'rule_type' => 'SimpleRule', 'start_dt' => '2013-01-01T11:03:01', 'end_dt' => '2030-01-01T08:03:01', 'other_flag' => false, @@ -337,11 +334,11 @@ computed_value = if paramb then param1 / (grid1_grid_result||1) else (grid2_grid_result||1) / param1 EOL - names = mrv.get_col_vals(:name, 9, 0) + names = mrv.get_col_vals(:name, 12, 0) idx = names.index { |n| n == 'Rule3' } + 1 mrv.select_row(idx) press('Edit') expect(find_field(:results).value).to eq(exp) press('OK') @@ -360,39 +357,72 @@ expect(page).to have_content('Rule type') expect(xrv.get_col_vals(:name, 5, 0)).to eq(['ZRule1', 'ZRule2', 'ZRule3', 'ZRule4', 'ZRule5']) xrv.select_row(1) + + expect(page).to_not have_content('NOT (G2V1)') + press('Edit') - fill_in('Range Guard 1', with: '[100,200)') - fill_in('Range Guard 2', with: '[30,40)') + + fill_in('Guard two', with: 'G2V1') + click_checkbox('Not') + + fill_in('Range Guard 1', with: '[100,200)', fill_options: { clear: :backspace }) + fill_in('Range Guard 2', with: '[30,40)', fill_options: { clear: :backspace }) press('OK') + wait_for_ajax - r = Gemini::XyzRule.get_matches('infinity', {}, 'g_range1' => 150, - 'g_range2' => 35) + r = Gemini::XyzRule.get_matches( + 'infinity', + {}, + 'g_range1' => 150, + 'g_range2' => 35, + 'guard_two' => 'G2V2' + ) + expect(r.to_a.count).to eq(1) - exp = { 'user_id' => 1, - 'o_user_id' => nil, - 'name' => 'ZRule1', - 'engine' => 'Gemini::XyzRuleScriptSet', - 'rule_type' => 'ZRule', - 'start_dt' => DateTime.parse('2017-1-1 08:01:00'), - 'simple_guards' => { 'g_bool' => false, - 'g_date' => '2017-1-1', - 'g_range1' => '[100,200)', - 'g_range2' => '[30,40)', - 'g_string' => 'aaa', - 'g_integer' => '5', - 'g_datetime' => '2017-1-1 12:00:01' }, - 'computed_guards' => {}, - 'grids' => { 'grid1' => 'DataGrid1' }, - 'results' => - { 'bvlen' => 'base_value.length', - 'bv' => 'base_value' } } + exp = { + 'user_id' => 1, + 'o_user_id' => nil, + 'name' => 'ZRule1', + 'engine' => 'Gemini::XyzRuleScriptSet', + 'rule_type' => 'ZRule', + 'start_dt' => DateTime.parse('2017-1-1 08:01:00'), + 'simple_guards' => { + 'g_bool' => false, + 'g_date' => '2017-1-1', + 'guard_two' => 'G2V1', + 'g_range1' => '[100,200)', + 'g_range2' => '[30,40)', + 'g_string' => 'aaa', + 'g_integer' => '5', + 'g_datetime' => '2017-1-1 12:00:01' + }, + 'simple_guards_options' => { + 'g_bool' => { 'not' => false }, + 'g_date' => { 'not' => false }, + 'g_datetime' => { 'not' => false }, + 'g_integer' => { 'not' => false }, + 'g_range1' => { 'not' => false }, + 'g_range2' => { 'not' => false }, + 'g_string' => { 'not' => false }, + 'guard_two' => { 'not' => true } + }, + 'computed_guards' => {}, + 'grids' => { 'grid1' => 'DataGrid1' }, + 'results' => { + 'bvlen' => 'base_value.length', + 'bv' => 'base_value' + } + } expect(r.first.as_json).to include(exp) + + expect(page).to have_content('NOT (G2V1)') + expect(xrv.get_col_vals(:g_string, 8, 0)).to eq(['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'eee', 'eee', 'eee']) click_column(xrv, 'String list Guard') expect(xrv.get_col_vals(:g_string, 8, 0)).to eq(['eee', 'eee', 'eee', 'eee', 'ddd', 'ccc', 'bbb', 'aaa']) @@ -416,12 +446,13 @@ %Q({"grid1":"DataGrid3"}), %Q({"grid1":"DataGrid3"}), %Q({"grid1":"DataGrid2"}), %Q({"grid1":"DataGrid1"}), %Q({"grid1":"DataGrid1"})]) + press('Applications') - press('Data Grids') + press('Data Grids Admin') dgv = netzke_find('data_grid_view') cvs = dgv.get_col_vals(:name, 4, 0) ind1 = cvs.index('DataGrid1') + 1 ind4 = cvs.index('DataGrid4') + 1 dgv.select_row(ind1) @@ -445,12 +476,12 @@ expect(JSON.parse(gvs[names.index('ZRule2')])).to eq(g1h) go_to_my_rules wait_for_ajax - names = mrv.get_col_vals(:name, 9, 0) - gvs = mrv.get_col_vals(:grids, 9, 0) - rvs = mrv.get_col_vals(:results, 9, 0) + names = mrv.get_col_vals(:name, 12, 0) + gvs = mrv.get_col_vals(:grids, 12, 0) + rvs = mrv.get_col_vals(:results, 12, 0) expect(JSON.parse(gvs[names.index('abc')])).to eq(g1h) expect(JSON.parse(gvs[names.index('Rule2b')])).to eq(g1h + { 'grid2' => 'DataGrid2' }) expect(JSON.parse(rvs[names.index('Rule5')])['other_grid']).to eq( '"DataGrid4 new"')