/* Authors: * Adam Young * * Copyright (C) 2010 Red Hat * see file 'COPYING' for use and warranty information * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ var details_container; module('details', { 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); } }); IPA.nav = {}; IPA.nav.get_state = function(key){ return $.bbq.getState(key); }; details_container = $('
').appendTo(document.body); var obj_name = 'user'; IPA.entity_factories.user= function(){ return IPA.entity({name:obj_name, metadata:IPA.metadata.objects.user}); }; }, teardown: function() { details_container.remove(); } }); test("Testing IPA.details_section.create().", function() { var facet = IPA.details_facet({ entity: IPA.get_entity('user'), sections: [ { name:'IDIDID', label:'NAMENAMENAME', fields: [ 'cn', 'uid', 'mail' ] } ] }); var section = facet.widgets.get_widget('IDIDID'); ok(section !== null, 'Verifying section existence.'); var fields = section.widgets.get_widgets(); var container = $("
"); section.create(container); var table = $('table', container); same( table.length, 1, 'Verifying table'); var rows = $('tr', table); same( rows.length, fields.length, 'Verifying table rows'); for (var i=0; i', { name: 'user', title: 'User', 'class': 'entity' }).appendTo(details_container); entity.create(entity_container); var facet = entity.get_facet('details'); var facet_container = $('
', { name: facet.name, 'class': 'facet' }); facet.create(facet_container); facet.load(result); var contact = $('.details-section[name=contact]', facet_container); ok( contact.length, 'Verifying section for contact is created'); var identity = $('.details-section[name=identity]', facet_container); ok( identity.length, 'Verifying section for identity is created'); var rows = $('tr', identity); same( rows.length, 6, 'Verifying rows for identity'); facet_container.attr('id','user'); ok (load_called, 'load manager called'); var field = facet.fields.get_field('test'); field.set_dirty(true); facet.update( 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'); ok (save_called, 'save called'); }); 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 container = $("
"); var details = $("
"); container.append(details); var result = {}; section.create(container); facet.load(result); var table = $('table', container); same( table.length, 1, 'Verifying table'); var rows = $('tr', table); same( rows.length, fields.length, 'Verifying table rows'); for (var i=0; i