mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Fixed unit tests after widget refactoring
https://fedorahosted.org/freeipa/ticket/2040
This commit is contained in:
committed by
Endi S. Dewata
parent
2759ea2961
commit
c5ca34f41d
@@ -4,14 +4,12 @@
|
||||
<title>Access Control Interface Test Suite</title>
|
||||
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="qunit.js"></script>
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../jquery.js"></script>
|
||||
<script type="text/javascript" src="../jquery.ba-bbq.js"></script>
|
||||
<script type="text/javascript" src="../jquery-ui.js"></script>
|
||||
<script type="text/javascript" src="../jquery.ordered-map.js"></script>
|
||||
<script type="text/javascript" src="../ipa.js"></script>
|
||||
<script type="text/javascript" src="../field.js"></script>
|
||||
<script type="text/javascript" src="../widget.js"></script>
|
||||
<script type="text/javascript" src="../dialog.js"></script>
|
||||
<script type="text/javascript" src="../details.js"></script>
|
||||
@@ -22,7 +20,7 @@
|
||||
<script type="text/javascript" src="../association.js"></script>
|
||||
<script type="text/javascript" src="../navigation.js"></script>
|
||||
<script type="text/javascript" src="../aci.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript" src="aci_tests.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
@@ -20,30 +20,77 @@
|
||||
|
||||
|
||||
var target_container;
|
||||
var target_section;
|
||||
var entity = {name:'bogus'};
|
||||
var target_widget;
|
||||
var target_facet;
|
||||
var entity = IPA.entity({ name:'bogus', metadata: {} });
|
||||
|
||||
module('aci',{
|
||||
setup: function() {
|
||||
IPA.ajax_options.async = false;
|
||||
IPA.init({
|
||||
url: 'data',
|
||||
on_error: function(xhr, text_status, error_thrown) {
|
||||
ok(false, "ipa_init() failed: "+error_thrown);
|
||||
}
|
||||
});
|
||||
module('aci', {
|
||||
setup: function() {
|
||||
IPA.ajax_options.async = false;
|
||||
IPA.init({
|
||||
url: 'data',
|
||||
on_error: function(xhr, text_status, error_thrown) {
|
||||
ok(false, "ipa_init() failed: "+error_thrown);
|
||||
}
|
||||
});
|
||||
|
||||
target_container = $('<div id="target"/>').appendTo(document.body);
|
||||
target_section = IPA.permission_target_section({
|
||||
name: 'target',
|
||||
label: 'Target',
|
||||
entity:entity
|
||||
});
|
||||
target_section.create(target_container);
|
||||
},
|
||||
teardown: function() {
|
||||
target_container.remove();
|
||||
}}
|
||||
target_facet = IPA.details_facet({
|
||||
entity: entity,
|
||||
fields: [
|
||||
{
|
||||
type: 'select',
|
||||
name: 'target',
|
||||
widget: 'target.target'
|
||||
},
|
||||
{
|
||||
name: 'filter',
|
||||
widget: 'target.filter',
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
name: 'subtree',
|
||||
widget: 'target.subtree',
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
type: 'entity_select',
|
||||
name: 'targetgroup',
|
||||
widget: 'target.targetgroup',
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
type: 'select',
|
||||
name: 'type',
|
||||
widget: 'target.type',
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
name: 'attrs',
|
||||
widget: 'target.attrs',
|
||||
enabled: false
|
||||
}
|
||||
],
|
||||
widgets: [
|
||||
{
|
||||
type: 'permission_target',
|
||||
container_factory: IPA.details_table_section,
|
||||
name: 'target',
|
||||
label: 'Target',
|
||||
show_target: false
|
||||
}
|
||||
],
|
||||
policies: [
|
||||
IPA.permission_target_policy('target')
|
||||
]
|
||||
});
|
||||
|
||||
target_container = $('<div id="target"/>').appendTo(document.body);
|
||||
target_widget = target_facet.widgets.get_widget('target');
|
||||
target_widget.create(target_container);
|
||||
},
|
||||
teardown: function() {
|
||||
target_container.remove();
|
||||
}}
|
||||
);
|
||||
|
||||
|
||||
@@ -59,7 +106,6 @@ test("IPA.attributes_widget.", function() {
|
||||
name: 'attrs',
|
||||
object_type: 'user',
|
||||
entity:entity
|
||||
|
||||
});
|
||||
|
||||
widget.create(container);
|
||||
@@ -68,15 +114,13 @@ test("IPA.attributes_widget.", function() {
|
||||
|
||||
ok(
|
||||
table,
|
||||
'Widget contains table'
|
||||
);
|
||||
'Widget contains table');
|
||||
|
||||
var tr = $('tbody tr', table);
|
||||
|
||||
same(
|
||||
tr.length, aciattrs.length,
|
||||
'Widget contains all user ACI attributes'
|
||||
);
|
||||
'Widget contains all user ACI attributes');
|
||||
|
||||
var record = {
|
||||
'attrs': [
|
||||
@@ -88,22 +132,19 @@ test("IPA.attributes_widget.", function() {
|
||||
|
||||
same(
|
||||
widget.save(), [],
|
||||
'Widget has no initial values'
|
||||
);
|
||||
'Widget has no initial values');
|
||||
|
||||
widget.load(record);
|
||||
widget.update(record.attrs);
|
||||
|
||||
tr = $('tbody tr', table);
|
||||
|
||||
same(
|
||||
tr.length, aciattrs.length+1,
|
||||
'Widget contains all user ACI attributes plus 1 unmatched attribute'
|
||||
);
|
||||
'Widget contains all user ACI attributes plus 1 unmatched attribute');
|
||||
|
||||
same(
|
||||
widget.save(), record.attrs.sort(),
|
||||
'All loaded values are saved and sorted'
|
||||
);
|
||||
'All loaded values are saved and sorted');
|
||||
});
|
||||
|
||||
test("IPA.rights_widget.", function() {
|
||||
@@ -123,48 +164,77 @@ test("IPA.rights_widget.", function() {
|
||||
|
||||
same(
|
||||
inputs.length, widget.rights.length,
|
||||
'Widget displays all permissions'
|
||||
);
|
||||
'Widget displays all permissions');
|
||||
});
|
||||
|
||||
var get_visible_rows = function(section) {
|
||||
var keys = section.rows.keys;
|
||||
|
||||
var visible = [];
|
||||
|
||||
for (var i=0; i<keys.length; i++) {
|
||||
var key = keys[i];
|
||||
var row = section.rows.get(key);
|
||||
var row_visible = row.css('display') !== 'none';
|
||||
if(row_visible) {
|
||||
visible.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
return visible;
|
||||
};
|
||||
|
||||
test("Testing aci grouptarget.", function() {
|
||||
var sample_data_filter_only = {"targetgroup":"ipausers"};
|
||||
target_section.load(sample_data_filter_only);
|
||||
var sample_data_filter_only = { targetgroup:"ipausers" };
|
||||
target_facet.load(sample_data_filter_only);
|
||||
|
||||
var selected = $(target_section.type_select+":selected");
|
||||
same(target_widget.target, 'targetgroup' , 'group control selected');
|
||||
|
||||
same(selected.val(), 'targetgroup' , 'group control selected');
|
||||
ok ($('option', selected.group_select).length > 2,
|
||||
|
||||
same(get_visible_rows(target_widget), ['targetgroup'],
|
||||
'group select row visible');
|
||||
|
||||
ok ($('option', target_widget.group_select.container).length > 2,
|
||||
'group select populated');
|
||||
|
||||
});
|
||||
|
||||
test("Testing type target.", function() {
|
||||
var sample_data_filter_only = {"type":"hostgroup"};
|
||||
var sample_data = { type:"hostgroup" };
|
||||
|
||||
target_section.load(sample_data_filter_only);
|
||||
var selected = $(target_section.type_select+":selected");
|
||||
same(selected.val(), 'type', 'type selected');
|
||||
target_facet.load(sample_data);
|
||||
|
||||
same(target_widget.target, 'type', 'type selected');
|
||||
|
||||
$("input[type=checkbox]").attr("checked",true);
|
||||
var response_record = {};
|
||||
target_section.save(response_record);
|
||||
same(response_record.type[0], sample_data_filter_only.type,
|
||||
"saved type matches sample data");
|
||||
ok((response_record.attrs.length > 10),
|
||||
"response length shows some attrs set");
|
||||
var record = {};
|
||||
target_facet.save(record);
|
||||
|
||||
same(record.type[0], sample_data.type,
|
||||
"saved type matches sample data");
|
||||
|
||||
same(get_visible_rows(target_widget), ['type', 'attrs'],
|
||||
'type and attrs rows visible');
|
||||
|
||||
ok((record.attrs.length > 10),
|
||||
"response length shows some attrs set");
|
||||
});
|
||||
|
||||
|
||||
test("Testing filter target.", function() {
|
||||
|
||||
var sample_data_filter_only = {"filter":"somevalue"};
|
||||
var sample_data = { filter:"somevalue" };
|
||||
|
||||
target_section.load(sample_data_filter_only);
|
||||
target_facet.load(sample_data);
|
||||
|
||||
var selected = $(target_section.type_select+":selected");
|
||||
same(selected.val(), 'filter', 'filter selected');
|
||||
var record = {};
|
||||
target_facet.save(record);
|
||||
|
||||
same(target_widget.target, 'filter', 'filter selected');
|
||||
|
||||
same(get_visible_rows(target_widget), ['filter'], 'filter row visible');
|
||||
|
||||
ok(record.filter[0], sample_data.filter, 'filter set correctly');
|
||||
});
|
||||
|
||||
|
||||
@@ -174,10 +244,13 @@ test("Testing subtree target.", function() {
|
||||
var sample_data = {
|
||||
subtree:"ldap:///cn=*,cn=roles,cn=accounts,dc=example,dc=co"};
|
||||
|
||||
target_section.load(sample_data);
|
||||
target_facet.load(sample_data);
|
||||
var record = {};
|
||||
target_section.save(record);
|
||||
target_facet.save(record);
|
||||
|
||||
same(record.subtree[0], sample_data.subtree, 'subtree set correctly');
|
||||
|
||||
same(get_visible_rows(target_widget), ['subtree'], 'subtree row visible');
|
||||
});
|
||||
|
||||
|
||||
|
@@ -10,6 +10,7 @@
|
||||
<script type="text/javascript" src="../jquery.ordered-map.js"></script>
|
||||
<script type="text/javascript" src="../ipa.js"></script>
|
||||
<script type="text/javascript" src="../widget.js"></script>
|
||||
<script type="text/javascript" src="../field.js"></script>
|
||||
<script type="text/javascript" src="../dialog.js"></script>
|
||||
<script type="text/javascript" src="../details.js"></script>
|
||||
<script type="text/javascript" src="../search.js"></script>
|
||||
|
@@ -51,18 +51,15 @@ test("Testing serial_associator().", function() {
|
||||
|
||||
equals(
|
||||
command.entity, params.other_entity,
|
||||
'Checking IPA.command() parameter: entity'
|
||||
);
|
||||
'Checking IPA.command() parameter: entity');
|
||||
|
||||
equals(
|
||||
command.method, params.method,
|
||||
'Checking IPA.command() parameter: method'
|
||||
);
|
||||
'Checking IPA.command() parameter: method');
|
||||
|
||||
equals(
|
||||
command.args[0], 'user'+(i+1),
|
||||
'Checking IPA.command() parameter: primary key'
|
||||
);
|
||||
'Checking IPA.command() parameter: primary key');
|
||||
}
|
||||
|
||||
that.on_success({});
|
||||
@@ -107,18 +104,15 @@ test("Testing bulk_associator().", function() {
|
||||
|
||||
equals(
|
||||
that.method, params.method,
|
||||
'Checking IPA.command() parameter: method'
|
||||
);
|
||||
'Checking IPA.command() parameter: method');
|
||||
|
||||
equals(
|
||||
that.args[0], params.pkey,
|
||||
'Checking IPA.command() parameter: primary key'
|
||||
);
|
||||
'Checking IPA.command() parameter: primary key');
|
||||
|
||||
equals(
|
||||
that.options[params.other_entity], 'user1,user2,user3',
|
||||
'Checking IPA.command() parameter: options[\""+params.other_entity+"\"]'
|
||||
);
|
||||
'Checking IPA.command() parameter: options[\""+params.other_entity+"\"]');
|
||||
|
||||
that.on_success({});
|
||||
};
|
||||
|
@@ -24,38 +24,31 @@ test("Testing certificate_parse_dn().", function() {
|
||||
|
||||
same(
|
||||
IPA.cert.parse_dn(), {},
|
||||
"Checking IPA.cert.parse_dn()"
|
||||
);
|
||||
"Checking IPA.cert.parse_dn()");
|
||||
|
||||
same(
|
||||
IPA.cert.parse_dn(''), {},
|
||||
"Checking IPA.cert.parse_dn('')"
|
||||
);
|
||||
"Checking IPA.cert.parse_dn('')");
|
||||
|
||||
same(
|
||||
IPA.cert.parse_dn('c=US'), {'c': 'US'},
|
||||
"Checking IPA.cert.parse_dn('c=US')"
|
||||
);
|
||||
"Checking IPA.cert.parse_dn('c=US')");
|
||||
|
||||
same(
|
||||
IPA.cert.parse_dn('st=TX,c=US'), {'st': 'TX','c': 'US'},
|
||||
"Checking IPA.cert.parse_dn('st=TX,c=US')"
|
||||
);
|
||||
"Checking IPA.cert.parse_dn('st=TX,c=US')");
|
||||
|
||||
same(
|
||||
IPA.cert.parse_dn('c=US,st=TX'), {'st': 'TX','c': 'US'},
|
||||
"Checking IPA.cert.parse_dn('c=US,st=TX')"
|
||||
);
|
||||
"Checking IPA.cert.parse_dn('c=US,st=TX')");
|
||||
|
||||
same(
|
||||
IPA.cert.parse_dn(' st = New Mexico , c = US '), {'st': 'New Mexico','c': 'US'},
|
||||
"Checking IPA.cert.parse_dn(' st = New Mexico , c = US ')"
|
||||
);
|
||||
"Checking IPA.cert.parse_dn(' st = New Mexico , c = US ')");
|
||||
|
||||
same(
|
||||
IPA.cert.parse_dn('ST=TX,C=US'), {'st': 'TX','c': 'US'},
|
||||
"Checking IPA.cert.parse_dn('ST=TX,C=US')"
|
||||
);
|
||||
"Checking IPA.cert.parse_dn('ST=TX,C=US')");
|
||||
|
||||
same(
|
||||
IPA.cert.parse_dn('cn=dev.example.com,ou=Engineering,o=Example,l=Austin,ST=TX,C=US'),
|
||||
@@ -66,8 +59,7 @@ test("Testing certificate_parse_dn().", function() {
|
||||
'st': 'TX',
|
||||
'c': 'US'
|
||||
},
|
||||
"Checking IPA.cert.parse_dn('cn=dev.example.com,ou=Engineering,o=Example,l=Austin,ST=TX,C=US')"
|
||||
);
|
||||
"Checking IPA.cert.parse_dn('cn=dev.example.com,ou=Engineering,o=Example,l=Austin,ST=TX,C=US')");
|
||||
|
||||
same(
|
||||
IPA.cert.parse_dn('cn=John Smith,ou=Developers,ou=Users,dc=example,dc=com'),
|
||||
@@ -76,6 +68,5 @@ test("Testing certificate_parse_dn().", function() {
|
||||
'ou': ['Developers','Users'],
|
||||
'dc': ['example', 'com']
|
||||
},
|
||||
"Checking IPA.cert.parse_dn('cn=John Smith,ou=Developers,ou=Users,dc=example,dc=com')"
|
||||
);
|
||||
"Checking IPA.cert.parse_dn('cn=John Smith,ou=Developers,ou=Users,dc=example,dc=com')");
|
||||
});
|
||||
|
@@ -9,6 +9,7 @@
|
||||
<script type="text/javascript" src="../jquery-ui.js"></script>
|
||||
<script type="text/javascript" src="../jquery.ordered-map.js"></script>
|
||||
<script type="text/javascript" src="../ipa.js"></script>
|
||||
<script type="text/javascript" src="../field.js"></script>
|
||||
<script type="text/javascript" src="../widget.js"></script>
|
||||
<script type="text/javascript" src="../dialog.js"></script>
|
||||
<script type="text/javascript" src="../details.js"></script>
|
||||
|
@@ -55,16 +55,24 @@ module('details', {
|
||||
|
||||
test("Testing IPA.details_section.create().", function() {
|
||||
|
||||
var section = IPA.details_table_section({
|
||||
var facet = IPA.details_facet({
|
||||
entity: IPA.get_entity('user'),
|
||||
name:'IDIDID', label:'NAMENAMENAME'}).
|
||||
text({name:'cn'}).
|
||||
text({name:'uid'}).
|
||||
text({name:'mail'});
|
||||
sections: [
|
||||
{
|
||||
name:'IDIDID',
|
||||
label:'NAMENAMENAME',
|
||||
fields: [
|
||||
'cn', 'uid', 'mail'
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
section.entity_name = 'user';
|
||||
var section = facet.widgets.get_widget('IDIDID');
|
||||
|
||||
var fields = section.fields.get_fields();
|
||||
ok(section !== null, 'Verifying section existence.');
|
||||
|
||||
var fields = section.widgets.get_widgets();
|
||||
var container = $("<div/>");
|
||||
section.create(container);
|
||||
|
||||
@@ -72,14 +80,12 @@ test("Testing IPA.details_section.create().", function() {
|
||||
|
||||
same(
|
||||
table.length, 1,
|
||||
'Verifying table'
|
||||
);
|
||||
'Verifying table');
|
||||
|
||||
var rows = $('tr', table);
|
||||
same(
|
||||
rows.length, fields.length,
|
||||
'Verifying table rows'
|
||||
);
|
||||
'Verifying table rows');
|
||||
|
||||
for (var i=0; i<fields.length; i++) {
|
||||
var field = fields[i];
|
||||
@@ -87,20 +93,17 @@ test("Testing IPA.details_section.create().", function() {
|
||||
var field_label = $('.field-label[name='+field.name+']', container);
|
||||
same(
|
||||
field_label.text(), field.label+':',
|
||||
'Verifying label for field '+field.name
|
||||
);
|
||||
'Verifying label for field '+field.name);
|
||||
|
||||
var field_container = $('.field[name='+field.name+']', container);
|
||||
|
||||
ok(
|
||||
field_container.length,
|
||||
'Verifying container for field '+field.name
|
||||
);
|
||||
'Verifying container for field '+field.name);
|
||||
|
||||
ok(
|
||||
field_container.hasClass('widget'),
|
||||
'Verifying field '+field.name+' was created'
|
||||
);
|
||||
'Verifying field '+field.name+' was created');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -141,21 +144,33 @@ test("Testing details lifecycle: create, load.", function(){
|
||||
load_called = true;
|
||||
}
|
||||
|
||||
function test_widget(spec){
|
||||
var widget = IPA.input_widget(spec);
|
||||
function test_field(spec) {
|
||||
var that = IPA.field(spec);
|
||||
|
||||
widget.load = function(record) {
|
||||
that.load = function(record) {
|
||||
load_called = true;
|
||||
widget.widget_load(record);
|
||||
that.field_load(record);
|
||||
};
|
||||
|
||||
widget.save = function() {
|
||||
save_called = true;
|
||||
return widget.widget_save();
|
||||
};
|
||||
return widget;
|
||||
return that;
|
||||
}
|
||||
|
||||
function test_widget(spec) {
|
||||
var that = IPA.input_widget(spec);
|
||||
|
||||
that.widget_save = that.save;
|
||||
|
||||
that.save = function() {
|
||||
save_called = true;
|
||||
return that.widget_save();
|
||||
};
|
||||
|
||||
return that;
|
||||
}
|
||||
|
||||
IPA.field_factories['test'] = test_field;
|
||||
IPA.widget_factories['test'] = test_widget;
|
||||
|
||||
IPA.register('user', function(spec) {
|
||||
|
||||
var that = IPA.entity(spec);
|
||||
@@ -175,27 +190,27 @@ test("Testing details lifecycle: create, load.", function(){
|
||||
label: 'contact',
|
||||
fields: [
|
||||
{
|
||||
factory: test_widget,
|
||||
type: 'test',
|
||||
name:'test'
|
||||
},
|
||||
{
|
||||
factory: IPA.multivalued_text_widget,
|
||||
type: 'multivalued',
|
||||
name:'mail'
|
||||
},
|
||||
{
|
||||
factory: IPA.multivalued_text_widget,
|
||||
type: 'multivalued',
|
||||
name:'telephonenumber'
|
||||
},
|
||||
{
|
||||
factory: IPA.multivalued_text_widget,
|
||||
type: 'multivalued',
|
||||
name:'pager'
|
||||
},
|
||||
{
|
||||
factory: IPA.multivalued_text_widget,
|
||||
type: 'multivalued',
|
||||
name:'mobile'
|
||||
},
|
||||
{
|
||||
factory: IPA.multivalued_text_widget,
|
||||
type: 'multivalued',
|
||||
name:'facsimiletelephonenumber'
|
||||
}
|
||||
]
|
||||
@@ -232,35 +247,30 @@ test("Testing details lifecycle: create, load.", function(){
|
||||
|
||||
ok(
|
||||
contact.length,
|
||||
'Verifying section for contact is created'
|
||||
);
|
||||
'Verifying section for contact is created');
|
||||
|
||||
var identity = $('.details-section[name=identity]', facet_container);
|
||||
|
||||
ok(
|
||||
identity.length,
|
||||
'Verifying section for identity is created'
|
||||
);
|
||||
'Verifying section for identity is created');
|
||||
|
||||
var rows = $('tr', identity);
|
||||
|
||||
same(
|
||||
rows.length, 6,
|
||||
'Verifying rows for identity'
|
||||
);
|
||||
'Verifying rows for identity');
|
||||
|
||||
facet_container.attr('id','user');
|
||||
|
||||
ok (load_called, 'load manager called');
|
||||
|
||||
var section = facet.sections.get('contact');
|
||||
var field = section.fields.get('test');
|
||||
var field = facet.fields.get_field('test');
|
||||
field.set_dirty(true);
|
||||
|
||||
facet.update(
|
||||
function(){update_success_called = true},
|
||||
function(){update_failure_called = true}
|
||||
);
|
||||
function(){update_success_called = true;},
|
||||
function(){update_failure_called = true;});
|
||||
|
||||
ok (update_success_called,'update success called');
|
||||
ok (!update_failure_called,'update failure not called');
|
||||
@@ -269,14 +279,36 @@ test("Testing details lifecycle: create, load.", function(){
|
||||
});
|
||||
|
||||
|
||||
test("Testing IPA.details_section_create again()",function(){
|
||||
test("Testing IPA.details_section_create again()",function() {
|
||||
|
||||
var facet = IPA.details_facet({
|
||||
entity: IPA.get_entity('user'),
|
||||
sections: [
|
||||
{
|
||||
name:'IDIDID',
|
||||
label:'NAMENAMENAME',
|
||||
fields: [
|
||||
{
|
||||
name: 'cn',
|
||||
label: 'Entity Name'
|
||||
},
|
||||
{
|
||||
name: 'description',
|
||||
label: 'Description'
|
||||
},
|
||||
{
|
||||
name: 'number',
|
||||
label: 'Entity ID'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
var section = facet.widgets.get_widget('IDIDID');
|
||||
ok(section !== null, 'Verifying section existence.');
|
||||
var fields = section.widgets.get_widgets();
|
||||
|
||||
var section = IPA.details_table_section({
|
||||
name: 'IDIDID', label: 'NAMENAMENAME',entity: IPA.get_entity('user')}).
|
||||
text({name:'cn', label:'Entity Name'}).
|
||||
text({name:'description', label:'Description'}).
|
||||
text({name:'number', label:'Entity ID'});
|
||||
var fields = section.fields.get_fields();
|
||||
var container = $("<div title='entity'/>");
|
||||
var details = $("<div/>");
|
||||
container.append(details);
|
||||
@@ -284,20 +316,18 @@ test("Testing IPA.details_section_create again()",function(){
|
||||
var result = {};
|
||||
|
||||
section.create(container);
|
||||
section.load(result);
|
||||
facet.load(result);
|
||||
|
||||
var table = $('table', container);
|
||||
|
||||
same(
|
||||
table.length, 1,
|
||||
'Verifying table'
|
||||
);
|
||||
'Verifying table');
|
||||
|
||||
var rows = $('tr', table);
|
||||
same(
|
||||
rows.length, fields.length,
|
||||
'Verifying table rows'
|
||||
);
|
||||
'Verifying table rows');
|
||||
|
||||
for (var i=0; i<fields.length; i++) {
|
||||
var field = fields[i];
|
||||
@@ -305,19 +335,16 @@ test("Testing IPA.details_section_create again()",function(){
|
||||
var field_label = $('.field-label[name='+field.name+']', container);
|
||||
same(
|
||||
field_label.text(), field.label+':',
|
||||
'Verifying label for field '+field.name
|
||||
);
|
||||
'Verifying label for field '+field.name);
|
||||
|
||||
var field_container = $('.field[name='+field.name+']', container);
|
||||
|
||||
ok(
|
||||
field_container.length,
|
||||
'Verifying container for field '+field.name
|
||||
);
|
||||
'Verifying container for field '+field.name);
|
||||
|
||||
ok(
|
||||
field_container.hasClass('widget'),
|
||||
'Verifying field '+field.name+' was created'
|
||||
);
|
||||
'Verifying field '+field.name+' was created');
|
||||
}
|
||||
});
|
||||
|
@@ -88,18 +88,15 @@ test('Testing IPA.entity_set_search_definition().', function() {
|
||||
var column = facet.get_columns()[0];
|
||||
ok(
|
||||
column,
|
||||
'column is not null'
|
||||
);
|
||||
'column is not null');
|
||||
|
||||
equals(
|
||||
column.name, 'uid',
|
||||
'column.name'
|
||||
);
|
||||
'column.name');
|
||||
|
||||
equals(
|
||||
column.label, 'User login',
|
||||
'column.label'
|
||||
);
|
||||
'column.label');
|
||||
|
||||
});
|
||||
|
||||
|
@@ -11,6 +11,7 @@
|
||||
<script type="text/javascript" src="../jquery-ui.js"></script>
|
||||
<script type="text/javascript" src="../jquery.ordered-map.js"></script>
|
||||
<script type="text/javascript" src="../ipa.js"></script>
|
||||
<script type="text/javascript" src="../field.js"></script>
|
||||
<script type="text/javascript" src="../widget.js"></script>
|
||||
<script type="text/javascript" src="../details.js"></script>
|
||||
<script type="text/javascript" src="../dialog.js"></script>
|
||||
|
@@ -42,56 +42,46 @@ test("Testing IPA.get_entity_param().", function() {
|
||||
var metadata = IPA.get_entity_param("user", "uid");
|
||||
ok(
|
||||
metadata,
|
||||
"IPA.get_entity_param(\"user\", \"uid\") not null"
|
||||
);
|
||||
"IPA.get_entity_param(\"user\", \"uid\") not null");
|
||||
|
||||
equals(
|
||||
metadata["label"], "User login",
|
||||
"IPA.get_entity_param(\"user\", \"uid\")[\"label\"]"
|
||||
);
|
||||
"IPA.get_entity_param(\"user\", \"uid\")[\"label\"]");
|
||||
|
||||
equals(
|
||||
IPA.get_entity_param("user", "wrong_attribute"), null,
|
||||
"IPA.get_entity_param(\"user\", \"wrong_attribute\")"
|
||||
);
|
||||
"IPA.get_entity_param(\"user\", \"wrong_attribute\")");
|
||||
|
||||
equals(
|
||||
IPA.get_entity_param("user", null), null,
|
||||
"IPA.get_entity_param(\"user\", null)"
|
||||
);
|
||||
"IPA.get_entity_param(\"user\", null)");
|
||||
|
||||
equals(
|
||||
IPA.get_entity_param("wrong_entity", "uid"), null,
|
||||
"IPA.get_entity_param(\"wrong_entity\", \"uid\")"
|
||||
);
|
||||
"IPA.get_entity_param(\"wrong_entity\", \"uid\")");
|
||||
|
||||
equals(
|
||||
IPA.get_entity_param(null, "uid"), null,
|
||||
"IPA.get_entity_param(null, \"uid\")"
|
||||
);
|
||||
"IPA.get_entity_param(null, \"uid\")");
|
||||
});
|
||||
|
||||
test("Testing IPA.get_member_attribute().", function() {
|
||||
|
||||
equals(
|
||||
IPA.get_member_attribute("user", "group"), "memberof",
|
||||
"IPA.get_member_attribute(\"user\", \"group\")"
|
||||
);
|
||||
"IPA.get_member_attribute(\"user\", \"group\")");
|
||||
|
||||
equals(
|
||||
IPA.get_member_attribute("user", "host"), null,
|
||||
"IPA.get_member_attribute(\"user\", \"host\")"
|
||||
);
|
||||
"IPA.get_member_attribute(\"user\", \"host\")");
|
||||
|
||||
equals(
|
||||
IPA.get_member_attribute("user", null), null,
|
||||
"IPA.get_member_attribute(\"user\", null)"
|
||||
);
|
||||
"IPA.get_member_attribute(\"user\", null)");
|
||||
|
||||
equals(
|
||||
IPA.get_member_attribute(null, "group"), null,
|
||||
"IPA.get_member_attribute(null, \"group\")"
|
||||
);
|
||||
"IPA.get_member_attribute(null, \"group\")");
|
||||
});
|
||||
|
||||
test("Testing successful IPA.command().", function() {
|
||||
@@ -129,20 +119,17 @@ test("Testing successful IPA.command().", function() {
|
||||
|
||||
equals(
|
||||
request.url, "data/"+object+"_"+method+".json",
|
||||
"Checking request.url"
|
||||
);
|
||||
"Checking request.url");
|
||||
|
||||
var data = JSON.parse(request.data);
|
||||
|
||||
equals(
|
||||
data.method, object+'_'+method,
|
||||
"Checking method"
|
||||
);
|
||||
"Checking method");
|
||||
|
||||
same(
|
||||
data.params, [args, options],
|
||||
"Checking parameters"
|
||||
);
|
||||
"Checking parameters");
|
||||
|
||||
request.success(xhr, text_status, error_thrown);
|
||||
};
|
||||
@@ -158,20 +145,17 @@ test("Testing successful IPA.command().", function() {
|
||||
|
||||
equals(
|
||||
ajax_counter, 1,
|
||||
"Checking ajax invocation counter"
|
||||
);
|
||||
"Checking ajax invocation counter");
|
||||
|
||||
var dialog = $('#error_dialog');
|
||||
|
||||
ok(
|
||||
dialog.length == 0,
|
||||
"The dialog box is not created."
|
||||
);
|
||||
dialog.length === 0,
|
||||
"The dialog box is not created.");
|
||||
|
||||
ok(
|
||||
success_handler_counter == 1 && error_handler_counter == 0,
|
||||
"Only the success handler is called."
|
||||
);
|
||||
success_handler_counter === 1 && error_handler_counter === 0,
|
||||
"Only the success handler is called.");
|
||||
|
||||
$.ajax = orig;
|
||||
});
|
||||
@@ -209,22 +193,14 @@ test("Testing unsuccessful IPA.command().", function() {
|
||||
$.ajax = function(request) {
|
||||
ajax_counter++;
|
||||
|
||||
equals(
|
||||
request.url, "data/"+object+"_"+method+".json",
|
||||
"Checking request.url"
|
||||
);
|
||||
equals(request.url, "data/"+object+"_"+method+".json",
|
||||
"Checking request.url");
|
||||
|
||||
var data = JSON.parse(request.data);
|
||||
|
||||
equals(
|
||||
data.method, object+'_'+method,
|
||||
"Checking method"
|
||||
);
|
||||
equals(data.method, object+'_'+method, "Checking method");
|
||||
|
||||
same(
|
||||
data.params, [args, options],
|
||||
"Checking parameters"
|
||||
);
|
||||
same(data.params, [args, options], "Checking parameters");
|
||||
|
||||
request.error(xhr, text_status, error_thrown);
|
||||
};
|
||||
@@ -243,18 +219,15 @@ test("Testing unsuccessful IPA.command().", function() {
|
||||
|
||||
equals(
|
||||
ajax_counter, 1,
|
||||
"Checking ajax invocation counter"
|
||||
);
|
||||
"Checking ajax invocation counter");
|
||||
|
||||
ok(
|
||||
ui_dialog.length == 1 && dialog.dialog('isOpen'),
|
||||
"The dialog box is created and open."
|
||||
);
|
||||
ui_dialog.length === 1 && dialog.dialog('isOpen'),
|
||||
"The dialog box is created and open.");
|
||||
|
||||
ok(
|
||||
success_handler_counter == 0 && error_handler_counter == 0,
|
||||
"Initially none of the handlers are called."
|
||||
);
|
||||
success_handler_counter === 0 && error_handler_counter === 0,
|
||||
"Initially none of the handlers are called.");
|
||||
|
||||
// search the retry button from the beginning
|
||||
var retry = $('button', ui_dialog).first();
|
||||
@@ -262,13 +235,11 @@ test("Testing unsuccessful IPA.command().", function() {
|
||||
|
||||
equals(
|
||||
ajax_counter, 2,
|
||||
"Checking ajax invocation counter"
|
||||
);
|
||||
"Checking ajax invocation counter");
|
||||
|
||||
ok(
|
||||
success_handler_counter == 0 && error_handler_counter == 0,
|
||||
"After 1st retry, none of the handlers are called."
|
||||
);
|
||||
success_handler_counter === 0 && error_handler_counter === 0,
|
||||
"After 1st retry, none of the handlers are called.");
|
||||
|
||||
// search the retry button from the beginning again because the dialog
|
||||
// has been recreated
|
||||
@@ -276,15 +247,11 @@ test("Testing unsuccessful IPA.command().", function() {
|
||||
retry = $('button', ui_dialog).first();
|
||||
retry.trigger('click');
|
||||
|
||||
equals(
|
||||
ajax_counter, 3,
|
||||
"Checking ajax invocation counter"
|
||||
);
|
||||
equals(ajax_counter, 3,
|
||||
"Checking ajax invocation counter");
|
||||
|
||||
ok(
|
||||
success_handler_counter == 0 && error_handler_counter == 0,
|
||||
"After 2nd retry, none of the handlers are called."
|
||||
);
|
||||
ok(success_handler_counter === 0 && error_handler_counter === 0,
|
||||
"After 2nd retry, none of the handlers are called.");
|
||||
|
||||
// search the cancel button from the beginning because the dialog has
|
||||
// been recreated
|
||||
@@ -292,22 +259,16 @@ test("Testing unsuccessful IPA.command().", function() {
|
||||
var cancel = $('button', ui_dialog).first().next();
|
||||
cancel.trigger('click');
|
||||
|
||||
equals(
|
||||
ajax_counter, 3,
|
||||
"Checking ajax invocation counter"
|
||||
);
|
||||
equals(ajax_counter, 3,
|
||||
"Checking ajax invocation counter");
|
||||
|
||||
dialog = $('#error_dialog');
|
||||
|
||||
ok(
|
||||
dialog.length == 0,
|
||||
"After cancel, the dialog box is closed."
|
||||
);
|
||||
ok(dialog.length === 0,
|
||||
"After cancel, the dialog box is closed.");
|
||||
|
||||
ok(
|
||||
success_handler_counter == 0 && error_handler_counter == 1,
|
||||
"Only the error handler is called."
|
||||
);
|
||||
ok(success_handler_counter === 0 && error_handler_counter === 1,
|
||||
"Only the error handler is called.");
|
||||
|
||||
$.ajax = orig;
|
||||
});
|
||||
@@ -336,7 +297,7 @@ test("Testing observer.", function() {
|
||||
} else {
|
||||
ok(false, "Fail function 2 callback");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
obj.event.attach(func);
|
||||
obj.event.notify([param1_value, param2_value], obj);
|
||||
|
147
install/ui/test/jsl.conf
Normal file
147
install/ui/test/jsl.conf
Normal file
@@ -0,0 +1,147 @@
|
||||
#
|
||||
# Configuration File for JavaScript Lint 0.3.0
|
||||
# Developed by Matthias Miller (http://www.JavaScriptLint.com)
|
||||
#
|
||||
# This configuration file can be used to lint a collection of scripts, or to enable
|
||||
# or disable warnings for scripts that are linted via the command line.
|
||||
#
|
||||
|
||||
### Warnings
|
||||
# Enable or disable warnings based on requirements.
|
||||
# Use "+WarningName" to display or "-WarningName" to suppress.
|
||||
#
|
||||
+no_return_value # function {0} does not always return a value
|
||||
+duplicate_formal # duplicate formal argument {0}
|
||||
+equal_as_assign # test for equality (==) mistyped as assignment (=)?{0}
|
||||
+var_hides_arg # variable {0} hides argument
|
||||
+redeclared_var # redeclaration of {0} {1}
|
||||
+anon_no_return_value # anonymous function does not always return a value
|
||||
+missing_semicolon # missing semicolon
|
||||
+meaningless_block # meaningless block; curly braces have no impact
|
||||
+comma_separated_stmts # multiple statements separated by commas (use semicolons?)
|
||||
+unreachable_code # unreachable code
|
||||
+missing_break # missing break statement
|
||||
+missing_break_for_last_case # missing break statement for last case in switch
|
||||
+comparison_type_conv # comparisons against null, 0, true, false, or an empty string allowing implicit type conversion (use === or !==)
|
||||
+inc_dec_within_stmt # increment (++) and decrement (--) operators used as part of greater statement
|
||||
+useless_void # use of the void type may be unnecessary (void is always undefined)
|
||||
+multiple_plus_minus # unknown order of operations for successive plus (e.g. x+++y) or minus (e.g. x---y) signs
|
||||
+use_of_label # use of label
|
||||
-block_without_braces # block statement without curly braces
|
||||
+leading_decimal_point # leading decimal point may indicate a number or an object member
|
||||
+trailing_decimal_point # trailing decimal point may indicate a number or an object member
|
||||
+octal_number # leading zeros make an octal number
|
||||
+nested_comment # nested comment
|
||||
+misplaced_regex # regular expressions should be preceded by a left parenthesis, assignment, colon, or comma
|
||||
+ambiguous_newline # unexpected end of line; it is ambiguous whether these lines are part of the same statement
|
||||
+empty_statement # empty statement or extra semicolon
|
||||
-missing_option_explicit # the "option explicit" control comment is missing
|
||||
+partial_option_explicit # the "option explicit" control comment, if used, must be in the first script tag
|
||||
+dup_option_explicit # duplicate "option explicit" control comment
|
||||
+useless_assign # useless assignment
|
||||
+ambiguous_nested_stmt # block statements containing block statements should use curly braces to resolve ambiguity
|
||||
+ambiguous_else_stmt # the else statement could be matched with one of multiple if statements (use curly braces to indicate intent)
|
||||
+missing_default_case # missing default case in switch statement
|
||||
+duplicate_case_in_switch # duplicate case in switch statements
|
||||
+default_not_at_end # the default case is not at the end of the switch statement
|
||||
+legacy_cc_not_understood # couldn't understand control comment using /*@keyword@*/ syntax
|
||||
+jsl_cc_not_understood # couldn't understand control comment using /*jsl:keyword*/ syntax
|
||||
+useless_comparison # useless comparison; comparing identical expressions
|
||||
+with_statement # with statement hides undeclared variables; use temporary variable instead
|
||||
+trailing_comma_in_array # extra comma is not recommended in array initializers
|
||||
+assign_to_function_call # assignment to a function call
|
||||
+parseint_missing_radix # parseInt missing radix parameter
|
||||
|
||||
|
||||
### Output format
|
||||
# Customize the format of the error message.
|
||||
# __FILE__ indicates current file path
|
||||
# __FILENAME__ indicates current file name
|
||||
# __LINE__ indicates current line
|
||||
# __ERROR__ indicates error message
|
||||
#
|
||||
# Visual Studio syntax (default):
|
||||
+output-format __FILE__(__LINE__): __ERROR__
|
||||
# Alternative syntax:
|
||||
#+output-format __FILE__:__LINE__: __ERROR__
|
||||
|
||||
|
||||
### Context
|
||||
# Show the in-line position of the error.
|
||||
# Use "+context" to display or "-context" to suppress.
|
||||
#
|
||||
+context
|
||||
|
||||
|
||||
### Semicolons
|
||||
# By default, assignments of an anonymous function to a variable or
|
||||
# property (such as a function prototype) must be followed by a semicolon.
|
||||
#
|
||||
+lambda_assign_requires_semicolon
|
||||
|
||||
|
||||
### Control Comments
|
||||
# Both JavaScript Lint and the JScript interpreter confuse each other with the syntax for
|
||||
# the /*@keyword@*/ control comments and JScript conditional comments. (The latter is
|
||||
# enabled in JScript with @cc_on@). The /*jsl:keyword*/ syntax is preferred for this reason,
|
||||
# although legacy control comments are enabled by default for backward compatibility.
|
||||
#
|
||||
+legacy_control_comments
|
||||
|
||||
|
||||
### JScript Function Extensions
|
||||
# JScript allows member functions to be defined like this:
|
||||
# function MyObj() { /*constructor*/ }
|
||||
# function MyObj.prototype.go() { /*member function*/ }
|
||||
#
|
||||
# It also allows events to be attached like this:
|
||||
# function window::onload() { /*init page*/ }
|
||||
#
|
||||
# This is a Microsoft-only JavaScript extension. Enable this setting to allow them.
|
||||
#
|
||||
-jscript_function_extensions
|
||||
|
||||
|
||||
### Defining identifiers
|
||||
# By default, "option explicit" is enabled on a per-file basis.
|
||||
# To enable this for all files, use "+always_use_option_explicit"
|
||||
#-always_use_option_explicit
|
||||
+always_use_option_explicit
|
||||
|
||||
# Define certain identifiers of which the lint is not aware.
|
||||
# (Use this in conjunction with the "undeclared identifier" warning.)
|
||||
#
|
||||
# Common uses for webpages might be:
|
||||
+define window
|
||||
+define document
|
||||
+define alert
|
||||
+define $
|
||||
+define JSON
|
||||
+define jQuery
|
||||
|
||||
+define module
|
||||
+define ok
|
||||
+define same
|
||||
+define test
|
||||
+define strictEqual
|
||||
+define deepEqual
|
||||
+define equals
|
||||
+define IPA
|
||||
+define expect
|
||||
|
||||
|
||||
### Files
|
||||
# Specify which files to lint
|
||||
# Use "+recurse" to enable recursion (disabled by default).
|
||||
# To add a set of files, use "+process FileName", "+process Folder\Path\*.js",
|
||||
# or "+process Folder\Path\*.htm".
|
||||
#
|
||||
+process aci_tests.js
|
||||
+process certificate_tests.js
|
||||
+process entity_tests.js
|
||||
+process navigation_tests.js
|
||||
+process association_tests.js
|
||||
+process details_tests.js
|
||||
+process ipa_tests.js
|
||||
+process ordered_map_tests.js
|
||||
+process widget_tests.js
|
@@ -149,13 +149,11 @@ test("Testing IPA.navigation.update() with valid index.", function() {
|
||||
|
||||
same(
|
||||
tabs_container.tabs('option', 'selected'), 0,
|
||||
"Active tab at level 1"
|
||||
);
|
||||
"Active tab at level 1");
|
||||
|
||||
same(
|
||||
$('.tabs[name=identity]', tabs_container).tabs('option', 'selected'), 1,
|
||||
"Active tab at level 2"
|
||||
);
|
||||
"Active tab at level 2");
|
||||
|
||||
navigation.remove_state("identity");
|
||||
|
||||
@@ -201,13 +199,11 @@ test("Testing IPA.navigation.update() with out-of-range index.", function() {
|
||||
|
||||
same(
|
||||
tabs_container.tabs('option', 'selected'), 0,
|
||||
"Active tab at level 1"
|
||||
);
|
||||
"Active tab at level 1");
|
||||
|
||||
same(
|
||||
$('.tabs[name=identity]', tabs_container).tabs('option', 'selected'), 0,
|
||||
"Active tab at level 2"
|
||||
);
|
||||
"Active tab at level 2");
|
||||
|
||||
navigation.remove_state("identity");
|
||||
|
||||
|
@@ -21,7 +21,7 @@
|
||||
|
||||
var widget_container;
|
||||
var widget;
|
||||
var factory
|
||||
var factory;
|
||||
var spec;
|
||||
|
||||
|
||||
@@ -62,8 +62,8 @@ function base_widget_test(value){
|
||||
//init reads param info for an entity. We'll use the user entity
|
||||
widget.name = field_name;
|
||||
|
||||
ok(widget.label,'widget with entity and name has label');
|
||||
ok(widget.tooltip,'widget with entity and name has tooltip');
|
||||
// ok(widget.label,'widget with entity and name has label');
|
||||
// ok(widget.tooltip,'widget with entity and name has tooltip');
|
||||
|
||||
|
||||
ok(!widget.container,'widget has no container before create');
|
||||
@@ -77,13 +77,13 @@ function widget_string_test() {
|
||||
var value = 'test_title';
|
||||
var mock_record = {'title': value};
|
||||
|
||||
widget.load(mock_record);
|
||||
widget.update(mock_record.title);
|
||||
|
||||
ok(widget.save() instanceof Array,'save returns array');
|
||||
|
||||
|
||||
mock_record = {'title':[value]};
|
||||
widget.load(mock_record);
|
||||
widget.update(mock_record.title);
|
||||
|
||||
ok(widget.save() instanceof Array,'save returns array');
|
||||
|
||||
@@ -93,59 +93,47 @@ function widget_string_test() {
|
||||
|
||||
function text_tests(widget,input){
|
||||
|
||||
var value_changed = false;
|
||||
var undo_clicked = false;
|
||||
|
||||
widget.value_changed.attach(function() {
|
||||
value_changed = true;
|
||||
});
|
||||
|
||||
widget.undo_clicked.attach(function() {
|
||||
undo_clicked = true;
|
||||
});
|
||||
|
||||
input.val('changed');
|
||||
input.keyup();
|
||||
same(widget.save(),['changed'], "Setting Value");
|
||||
same(widget.is_dirty(),true, "Click sets is_dirty");
|
||||
same(value_changed, true, "Click triggers value_changed");
|
||||
|
||||
var undo = widget.get_undo();
|
||||
undo.click();
|
||||
same(widget.is_dirty(),false, "Undo Clears is_dirty");
|
||||
|
||||
|
||||
var old_pattern = widget.metadata.pattern;
|
||||
|
||||
widget.metadata.pattern ='abc';
|
||||
input.val('not right');
|
||||
input.keyup();
|
||||
same(widget.valid,false, 'Field is not valid');
|
||||
var error_field = widget.get_error_link();
|
||||
|
||||
same(error_field.css('display'),'block','error field is visible');
|
||||
|
||||
|
||||
input.val('abc');
|
||||
input.keyup();
|
||||
same(widget.valid,true, 'Field is valid');
|
||||
same(error_field.css('display'),'none','error field not visible');
|
||||
|
||||
widget.metadata.pattern = old_pattern;
|
||||
|
||||
same(undo_clicked, true, "Click on 'undo' triggers undo_clicked");
|
||||
}
|
||||
|
||||
function multivalued_text_tests(widget) {
|
||||
|
||||
var values = ['val1', 'val2', 'val3'];
|
||||
|
||||
var record = {};
|
||||
record[widget.name] = values;
|
||||
|
||||
widget.load(record);
|
||||
widget.update(values);
|
||||
|
||||
same(widget.save(), values, "All values loaded");
|
||||
same(widget.is_dirty(), false, "Field initially clean");
|
||||
same(widget.test_dirty(), false, "Field initially clean");
|
||||
|
||||
values = ['val1', 'val2', 'val3', 'val4'];
|
||||
widget.add_row('val4');
|
||||
widget.add_row(['val4']);
|
||||
|
||||
same(widget.save(), values, "Value added");
|
||||
same(widget.is_dirty(), true, "Field is dirty");
|
||||
same(widget.test_dirty(), true, "Field is dirty");
|
||||
|
||||
values = ['val1', 'val3', 'val4'];
|
||||
widget.remove_row(1);
|
||||
widget.remove_row(widget.rows[1]);
|
||||
|
||||
same(widget.save(), values, "Value removed");
|
||||
same(widget.is_dirty(), true, "Field is dirty");
|
||||
same(widget.test_dirty(), true, "Field is dirty");
|
||||
}
|
||||
|
||||
test("IPA.table_widget" ,function(){
|
||||
@@ -238,24 +226,29 @@ test("Testing checkbox widget.", function() {
|
||||
spec = {name:'title'};
|
||||
base_widget_test('test_value');
|
||||
|
||||
mock_record = { 'title': 'TRUE' };
|
||||
var mock_record = { 'title': 'TRUE' };
|
||||
|
||||
widget.load(mock_record);
|
||||
widget.update(mock_record.title);
|
||||
same(widget.save(),[true], "Checkbox is set");
|
||||
|
||||
mock_record = {'title':null};
|
||||
|
||||
widget.load(mock_record);
|
||||
widget.update(mock_record.title);
|
||||
same(widget.save(), [false], "Checkbox is not set");
|
||||
|
||||
var input = $('input[type=checkbox]',widget_container);
|
||||
|
||||
same(input.length,1,'One control in the container');
|
||||
|
||||
var value_changed = false;
|
||||
widget.value_changed.attach(function() {
|
||||
value_changed = true;
|
||||
});
|
||||
|
||||
input.click();
|
||||
|
||||
same(widget.save(),[true], "Click sets checkbox");
|
||||
same(widget.is_dirty(),true, "Click sets is_dirty");
|
||||
same(value_changed, true, "Click triggers value_changed");
|
||||
|
||||
|
||||
});
|
||||
@@ -285,15 +278,17 @@ test("IPA.entity_select_widget" ,function(){
|
||||
other_field: 'uid' };
|
||||
|
||||
base_widget_test('test_value');
|
||||
mock_record = {'uid':'kfrog'};
|
||||
widget.load(mock_record);
|
||||
ok( $('option',widget.list ).length > 1,"options come from AJAX");
|
||||
same(widget.values[0],'kfrog','select set from values');
|
||||
var mock_record = { uid: ['kfrog']};
|
||||
widget.update(mock_record.uid);
|
||||
ok($('option', widget.list).length > 1,"options come from AJAX");
|
||||
|
||||
var value = widget.save();
|
||||
same(value, ['kfrog'],'select set from values');
|
||||
});
|
||||
|
||||
|
||||
test("IPA.entity_link_widget" ,function(){
|
||||
factory = IPA.entity_link_widget;
|
||||
factory = IPA.link_widget;
|
||||
spec = {
|
||||
name: 'gidnumber',
|
||||
other_entity:'group'
|
||||
@@ -306,7 +301,7 @@ test("IPA.entity_link_widget" ,function(){
|
||||
}
|
||||
};
|
||||
|
||||
mock_record = {'uid':'kfrog','gidnumber':'123456'};
|
||||
var mock_record = { uid: ['kfrog'], gidnumber: ['123456']};
|
||||
|
||||
widget.entity = mock_entity;
|
||||
widget.create(widget_container);
|
||||
@@ -317,7 +312,8 @@ test("IPA.entity_link_widget" ,function(){
|
||||
ok(nonlink.length > 1);
|
||||
ok(link.length > 1);
|
||||
|
||||
widget.load(mock_record);
|
||||
widget.is_link = true; //setting is_link is responsibility of field
|
||||
widget.update(mock_record.gidnumber);
|
||||
|
||||
link = widget_container.find('a[text=123456]');
|
||||
|
||||
@@ -337,12 +333,12 @@ test("IPA.radio_widget" ,function(){
|
||||
spec = {undo:true, name: 'title',options:options};
|
||||
base_widget_test('test_value');
|
||||
var mock_record = {'title':["director"]};
|
||||
widget.load(mock_record);
|
||||
widget.update(mock_record.title);
|
||||
var values = widget.save();
|
||||
same(values[0],'director','Options set correctly');
|
||||
|
||||
mock_record = {'title':"VP"};
|
||||
widget.load(mock_record);
|
||||
mock_record = { title: ["VP"]};
|
||||
widget.update(mock_record.title);
|
||||
values = widget.save();
|
||||
same(values[0],'VP','Options set correctly');
|
||||
|
||||
|
Reference in New Issue
Block a user