Skip to content

Instantly share code, notes, and snippets.

@betobaz
Last active August 2, 2016 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save betobaz/bca898b2311e524fda6911f7d69ba008 to your computer and use it in GitHub Desktop.
Save betobaz/bca898b2311e524fda6911f7d69ba008 to your computer and use it in GitHub Desktop.
SugarCRM:: Sidecar unit test
ddescribe("Dashlet dashlet", function () {
var viewName = 'dashlet',
view,
layout,
context,
layoutName = 'record',
moduleName = 'Opportunities',
model;
beforeEach(function () {
app = SugarTest.app;
SugarTest.testMetadata.init();
SugarTest.loadCustomHandlebarsTemplate(viewName, 'view', 'base');
SugarTest.loadCustomComponent('base', 'view', viewName);
SugarTest.testMetadata.addViewDefinition(
viewName,
{
'panels': [
{
fields: []
}
]
},
moduleName
);
var metadata = {
modules: {
Products: { fields: {"my_favorite":{"massupdate":false,"name":"my_favorite","vname":"LBL_FAVORITE","type":"bool","source":"non-db","comment":"Favorite for the user","studio":{"list":false,"recordview":false},"link":"favorite_link","rname":"id","rname_exists":true},"favorite_link":{"name":"favorite_link","type":"link","relationship":"products_favorite","source":"non-db","vname":"LBL_FAVORITE"},"following":{"massupdate":false,"name":"following","vname":"LBL_FOLLOWING","type":"bool","source":"non-db","comment":"Is user following this record","studio":"false","link":"following_link","rname":"id","rname_exists":true},"following_link":{"name":"following_link","type":"link","relationship":"products_following","source":"non-db","vname":"LBL_FOLLOWING"},"id":{"name":"id","vname":"LBL_ID","type":"id","required":true,"reportable":true,"duplicate_on_record_copy":"no","comment":"Unique identifier","mandatory_fetch":true},"name":{"name":"name","vname":"LBL_NAME","dbType":"varchar","type":"name","len":50,"unified_search":true,"full_text_search":{"enabled":true,"boost":1},"comment":"Name of the product","reportable":true,"importable":"required","required":true,"formula":"ifElse(equal($product_template_name, \"\"), $name, $product_template_name)"},"date_entered":{"name":"date_entered","vname":"LBL_DATE_ENTERED","type":"datetime","group":"created_by_name","comment":"Date record created","enable_range_search":true,"options":"date_range_search_dom","studio":{"portaleditview":false},"duplicate_on_record_copy":"no","readonly":true,"massupdate":false},"date_modified":{"name":"date_modified","vname":"LBL_DATE_MODIFIED","type":"datetime","group":"modified_by_name","comment":"Date record last modified","enable_range_search":true,"studio":{"portaleditview":false},"options":"date_range_search_dom","duplicate_on_record_copy":"no","readonly":true,"massupdate":false},"modified_user_id":{"name":"modified_user_id","rname":"user_name","id_name":"modified_user_id","vname":"LBL_MODIFIED","type":"assigned_user_name","table":"users","isnull":false,"group":"modified_by_name","dbType":"id","reportable":true,"comment":"User who last modified record","massupdate":false,"duplicate_on_record_copy":"no","readonly":true},"modified_by_name":{"name":"modified_by_name","vname":"LBL_MODIFIED","type":"relate","reportable":false,"source":"non-db","rname":"full_name","table":"users","id_name":"modified_user_id","module":"Users","link":"modified_user_link","duplicate_merge":"disabled","massupdate":false,"duplicate_on_record_copy":"no","readonly":true,"sort_on":["last_name"]},"created_by":{"name":"created_by","rname":"user_name","id_name":"modified_user_id","vname":"LBL_CREATED","type":"assigned_user_name","table":"users","isnull":false,"dbType":"id","group":"created_by_name","comment":"User who created record","massupdate":false,"duplicate_on_record_copy":"no","readonly":true},"created_by_name":{"name":"created_by_name","vname":"LBL_CREATED","type":"relate","reportable":false,"link":"created_by_link","rname":"full_name","source":"non-db","table":"users","id_name":"created_by","module":"Users","duplicate_merge":"disabled","importable":false,"massupdate":false,"duplicate_on_record_copy":"no","readonly":true,"sort_on":["last_name"]},"doc_owner":{"name":"doc_owner","vname":"LBL_DOC_OWNER","type":"id","reportable":false,"source":"non-db","duplicate_merge":"disabled","importable":"false","massupdate":false,"full_text_search":{"enabled":true},"default":""},"user_favorites":{"name":"user_favorites","vname":"LBL_USER_FAVORITES","type":"id","reportable":false,"source":"non-db","duplicate_merge":"disabled","importable":"false","massupdate":false,"full_text_search":{"enabled":true},"default":""},"description":{"name":"description","vname":"LBL_DESCRIPTION","type":"text","comment":"Full text of the note","rows":6,"cols":80,"duplicate_on_record_copy":"always"},"deleted":{"name":"deleted","vname":"LBL_DELETED","type":"bool","default":false,"reportable":false,"duplicate_on_record_copy":"no","comment":"Record deletion indicator"},"created_by_link":{"name":"created_by_link","type":"link","relationship":"products_created_by","vname":"LBL_CREATED_USER","link_type":"one","module":"Users","bean_name":"User","source":"non-db"},"modified_user_link":{"name":"modified_user_link","type":"link","relationship":"products_modified_user","vname":"LBL_MODIFIED_USER","link_type":"one","module":"Users","bean_name":"User","source":"non-db"},"activities":{"name":"activities","type":"link","relationship":"product_activities","vname":"LBL_ACTIVITY_STREAM","link_type":"many","module":"Activities","bean_name":"Activity","source":"non-db"},"assigned_user_id":{"name":"assigned_user_id","vname":"LBL_ASSIGNED_TO_ID","group":"assigned_user_name","type":"id","reportable":false,"isnull":"false","audited":true,"duplicate_on_record_copy":"always","comment":"User ID assigned to record","duplicate_merge":"disabled","mandatory_fetch":true,"massupdate":false},"assigned_user_name":{"name":"assigned_user_name","link":"assigned_user_link","vname":"LBL_ASSIGNED_TO","rname":"full_name","type":"relate","reportable":false,"source":"non-db","table":"users","id_name":"assigned_user_id","module":"Users","duplicate_merge":"disabled","duplicate_on_record_copy":"always","sort_on":["last_name"],"exportable":true,"massupdate":true},"assigned_user_link":{"name":"assigned_user_link","type":"link","relationship":"products_assigned_user","vname":"LBL_ASSIGNED_TO_USER","link_type":"one","module":"Users","bean_name":"User","source":"non-db","duplicate_merge":"enabled","id_name":"assigned_user_id","table":"users"},"team_id":{"name":"team_id","vname":"LBL_TEAM_ID","group":"team_name","reportable":false,"dbType":"id","type":"team_list","audited":true,"duplicate_on_record_copy":"always","comment":"Team ID for the account"},"team_set_id":{"name":"team_set_id","rname":"id","id_name":"team_set_id","vname":"LBL_TEAM_SET_ID","type":"id","audited":true,"studio":"false","dbType":"id","duplicate_on_record_copy":"always","full_text_search":{"enabled":true}},"team_count":{"name":"team_count","rname":"team_count","id_name":"team_id","vname":"LBL_TEAMS","join_name":"ts1","table":"teams","type":"relate","required":true,"isnull":"true","module":"Teams","link":"team_count_link","massupdate":false,"dbType":"int","source":"non-db","importable":"false","reportable":false,"duplicate_merge":"disabled","duplicate_on_record_copy":"always","studio":"false","hideacl":true},"team_name":{"name":"team_name","db_concat_fields":["name","name_2"],"sort_on":"tj.name","join_name":"tj","rname":"name","id_name":"team_id","vname":"LBL_TEAMS","type":"teamset","required":true,"table":"teams","isnull":"true","module":"Teams","link":"team_link","massupdate":true,"dbType":"varchar","source":"non-db","custom_type":"teamset","studio":{"portallistview":false,"portalrecordview":false},"duplicate_on_record_copy":"always","exportable":true},"team_link":{"name":"team_link","type":"link","relationship":"products_team","vname":"LBL_TEAMS_LINK","link_type":"one","module":"Teams","bean_name":"Team","source":"non-db","duplicate_merge":"disabled","studio":"false"},"team_count_link":{"name":"team_count_link","type":"link","relationship":"products_team_count_relationship","link_type":"one","module":"Teams","bean_name":"TeamSet","source":"non-db","duplicate_merge":"disabled","reportable":false,"studio":"false"},"teams":{"name":"teams","type":"link","relationship":"products_teams","bean_filter_field":"team_set_id","rhs_key_override":true,"source":"non-db","vname":"LBL_TEAMS","link_class":"TeamSetLink","link_file":"modules/Teams/TeamSetLink.php","studio":"false","reportable":false},"revenuelineitem_id":{"name":"revenuelineitem_id","type":"id","vname":"LBL_REVENUELINEITEM_ID","required":false,"reportable":false,"comment":"Associated Revenue Line Item that served as the source.","massupdate":false},"revenuelineitem_name":{"name":"revenuelineitem_name","rname":"name","id_name":"revenuelineitem_id","vname":"LBL_REVENUELINEITEM_NAME","type":"relate","link":"revenuelineitems","isnull":"true","module":"RevenueLineItems","dbType":"varchar","source":"non-db","studio":false,"massupdate":true},"product_template_id":{"name":"product_template_id","type":"id","vname":"LBL_PRODUCT_TEMPLATE_ID","required":false,"reportable":false,"comment":"Product (in Admin Products) from which this product is derived (in user Products)","massupdate":false},"product_template_name":{"name":"product_template_name","rname":"name","id_name":"product_template_id","vname":"LBL_PRODUCT_TEMPLATE","join_name":"templates","type":"relate","link":"product_templates_link","table":"product_templates","isnull":"true","module":"ProductTemplates","dbType":"varchar","source":"non-db","studio":{"editview":false,"detailview":false,"quickcreate":false},"auto_populate":true,"populate_list":{"name":"name","category_id":"category_id","category_name":"category_name","mft_part_num":"mft_part_num","list_price":"list_price","cost_price":"cost_price","discount_price":"discount_price","list_usdollar":"list_usdollar","cost_usdollar":"cost_usdollar","discount_usdollar":"discount_usdollar","tax_class":"tax_class","weight":"weight","type_name":"type_name","manufacturer_id":"manufacturer_id","manufacturer_name":"manufacturer_name"},"massupdate":true},"account_id":{"name":"account_id","type":"id","vname":"LBL_ACCOUNT_ID","required":false,"reportable":false,"audited":true,"comment":"Account this product is associated with","massupdate":false},"contact_id":{"name":"contact_id","type":"id","vname":"LBL_CONTACT_ID","group":"contact_name","required":false,"reportable":false,"audited":true,"comment":"Contact this product is associated with","massupdate":false},"subtotal":{"name":"subtotal","vname":"LBL_SUBTOTAL","type":"currency","len":26,"related_fields":["currency_id","base_rate"],"formula":"","calculated":false,"enforced":false,"default":"","audited":false,"massupdate":false,"duplicate_merge":"enabled","duplicate_merge_dom_value":"1","merge_filter":"disabled","enable_range_search":false},"total_amount":{"name":"total_amount","default":"","formula":"ifElse(and(ifElse(equal($promocional_c,1),true,false),ifElse(equal($total_amount,0.01),true,false)),multiply($quantity,0.01),$total_amount)","calculated":"true","enforced":true,"vname":"LBL_CALCULATED_LINE_ITEM_AMOUNT","reportable":true,"type":"currency","related_fields":["currency_id","base_rate"],"audited":false,"massupdate":false,"duplicate_merge":"disabled","duplicate_merge_dom_value":0,"merge_filter":"disabled","enable_range_search":false,"importable":"false"},"contact_name":{"name":"contact_name","rname":"name","db_concat_fields":["first_name","last_name"],"source":"non-db","group":"contact_name","vname":"LBL_CONTACT_NAME","reportable":false,"id_name":"contact_id","join_name":"contacts","type":"relate","module":"Contacts","link":"contact_link","table":"contacts","massupdate":true},"type_id":{"name":"type_id","vname":"LBL_TYPE","type":"id","required":false,"reportable":false,"function":{"name":"getProductTypes","returns":"html","include":"modules/ProductTemplates/ProductTemplate.php"},"comment":"Product type (ex: hardware, software)","massupdate":false},"quote_id":{"name":"quote_id","type":"id","vname":"LBL_QUOTE_ID","required":false,"reportable":false,"comment":"If product created via Quote, this is quote ID","massupdate":false},"manufacturer_id":{"name":"manufacturer_id","vname":"LBL_MANUFACTURER","type":"id","required":false,"reportable":false,"massupdate":false,"comment":"Manufacturer of product"},"manufacturer_name":{"name":"manufacturer_name","rname":"name","id_name":"manufacturer_id","type":"relate","vname":"LBL_MANUFACTURER_NAME","join_name":"manufacturers","link":"manufacturers","table":"manufacturers","isnull":"true","source":"non-db","module":"Manufacturers","dbType":"varchar","massupdate":false,"related_fields":["manufacturer_id"]},"category_id":{"name":"category_id","vname":"LBL_CATEGORY","type":"id","group":"category_name","reportable":true,"comment":"Product category","massupdate":false},"category_name":{"name":"category_name","rname":"name","id_name":"category_id","vname":"LBL_CATEGORY_NAME","join_name":"categories","type":"relate","link":"product_categories_link","table":"product_categories","isnull":"true","module":"ProductCategories","dbType":"varchar","source":"non-db","studio":{"editview":false,"detailview":false,"quickcreate":false},"massupdate":true},"mft_part_num":{"name":"mft_part_num","vname":"LBL_MFT_PART_NUM","type":"varchar","len":50,"comment":"Manufacturer part number"},"vendor_part_num":{"name":"vendor_part_num","vname":"LBL_VENDOR_PART_NUM","type":"varchar","len":50,"comment":"Vendor part number"},"date_purchased":{"name":"date_purchased","vname":"LBL_DATE_PURCHASED","type":"date","comment":"Date product purchased","massupdate":true},"cost_price":{"name":"cost_price","vname":"LBL_COST_PRICE","type":"currency","len":null,"audited":true,"comment":"Product cost (\"Cost\" in Quote)","related_fields":["currency_id","base_rate"]},"discount_price":{"name":"discount_price","vname":"LBL_DISCOUNT_PRICE","type":"currency","len":null,"audited":true,"comment":"Discounted price (\"Unit Price\" in Quote)","related_fields":["currency_id","base_rate"]},"discount_amount":{"name":"discount_amount","vname":"LBL_DISCOUNT_AMOUNT","dbType":"currency","type":"discount","len":null,"precision":"6","comment":"Discounted amount","related_fields":["currency_id","base_rate","discount_select"]},"discount_rate_percent":{"name":"discount_rate_percent","formula":"ifElse(isNumeric($discount_price), ifElse(equal($discount_price, 0), 0, multiply(divide($discount_amount, $discount_price), 100)), 0)","calculated":true,"enforced":true,"vname":"LBL_DISCOUNT_RATE","reportable":false,"type":"decimal","precision":2,"len":null,"massupdate":false},"discount_amount_usdollar":{"name":"discount_amount_usdollar","vname":"LBL_DISCOUNT_RATE_USDOLLAR","type":"currency","currency_id":"-99","len":null,"studio":{"editview":false,"mobile":false},"formula":"ifElse(isNumeric($discount_amount), currencyDivide($discount_amount, $base_rate), \"\")","calculated":true,"enforced":true,"massupdate":false},"discount_select":{"name":"discount_select","vname":"LBL_DISCOUNT_AS_PERCENT","type":"bool","reportable":false,"massupdate":true},"deal_calc":{"name":"deal_calc","vname":"LBL_DISCOUNT_TOTAL","type":"currency","len":null,"group":"deal_calc","comment":"deal_calc","formula":"ifElse(equal($discount_select, \"1\"),\n currencyMultiply(currencyMultiply($discount_price, $quantity), currencyDivide($discount_amount, 100)),\n ifElse(isNumeric($discount_amount), $discount_amount, 0)\n )","calculated":true,"enforced":true,"related_fields":["currency_id","base_rate","discount_price","quantity","discount_amount"],"massupdate":false},"deal_calc_usdollar":{"name":"deal_calc_usdollar","vname":"LBL_DISCOUNT_TOTAL_USDOLLAR","type":"currency","currency_id":"-99","len":null,"group":"deal_calc","comment":"deal_calc_usdollar","studio":{"editview":false,"mobile":false},"related_fields":["currency_id","base_rate"],"formula":"ifElse(isNumeric($deal_calc), currencyDivide($deal_calc, $base_rate), \"\")","calculated":true,"enforced":true,"massupdate":false},"list_price":{"name":"list_price","vname":"LBL_LIST_PRICE","type":"currency","len":null,"audited":true,"comment":"List price of product (\"List\" in Quote)","related_fields":["currency_id","base_rate"]},"cost_usdollar":{"name":"cost_usdollar","vname":"LBL_COST_USDOLLAR","dbType":"decimal","group":"cost_price","type":"currency","currency_id":"-99","len":null,"comment":"Cost expressed in USD","studio":{"editview":false,"mobile":false},"related_fields":["currency_id","base_rate"],"formula":"ifElse(isNumeric($cost_price), currencyDivide($cost_price, $base_rate), \"\")","calculated":true,"enforced":true,"massupdate":false},"discount_usdollar":{"name":"discount_usdollar","vname":"LBL_DISCOUNT_USDOLLAR","dbType":"decimal","group":"discount_price","type":"currency","currency_id":"-99","len":null,"comment":"Discount price expressed in USD","studio":{"editview":false,"mobile":false},"formula":"divide($discount_price, $base_rate)","calculated":true,"enforced":true,"massupdate":false},"list_usdollar":{"name":"list_usdollar","vname":"LBL_LIST_USDOLLAR","dbType":"decimal","type":"currency","currency_id":"-99","group":"list_price","len":null,"comment":"List price expressed in USD","studio":{"editview":false,"mobile":false},"related_fields":["currency_id","base_rate"],"formula":"ifElse(isNumeric($list_price), currencyDivide($list_price, $base_rate), \"\")","calculated":true,"enforced":true,"massupdate":false},"currency_id":{"name":"currency_id","dbType":"id","vname":"LBL_CURRENCY_ID","type":"currency_id","function":"getCurrencies","function_bean":"Currencies","required":false,"reportable":false,"default":"-99","comment":"Currency of the product"},"base_rate":{"name":"base_rate","vname":"LBL_CURRENCY_RATE","type":"decimal","len":null,"studio":false},"status":{"name":"status","vname":"LBL_STATUS","type":"enum","options":"product_status_dom","default":"","len":100,"audited":true,"comment":"Product status (ex: Quoted, Ordered, Shipped)","massupdate":true},"tax_class":{"name":"tax_class","vname":"LBL_TAX_CLASS","type":"enum","options":"tax_class_dom","len":100,"comment":"Tax classification (ex: Taxable, Non-taxable)","massupdate":true},"website":{"name":"website","vname":"LBL_URL","type":"varchar","len":255,"comment":"Product URL"},"weight":{"name":"weight","vname":"LBL_WEIGHT","type":"decimal","len":null,"precision":2,"comment":"Weight of the product"},"quantity":{"name":"quantity","vname":"LBL_QUANTITY","type":"decimal","len":12,"precision":2,"validation":{"type":"range","greaterthan":0},"comment":"Quantity in use","default":"","audited":false,"massupdate":false,"comments":"Quantity in use","duplicate_merge":"enabled","duplicate_merge_dom_value":"1","merge_filter":"disabled","full_text_search":{"boost":"0","enabled":false},"calculated":false,"enable_range_search":false},"support_name":{"name":"support_name","vname":"LBL_SUPPORT_NAME","type":"varchar","len":50,"comment":"Name of product for support purposes"},"support_description":{"name":"support_description","vname":"LBL_SUPPORT_DESCRIPTION","type":"varchar","len":255,"comment":"Description of product for support purposes"},"support_contact":{"name":"support_contact","vname":"LBL_SUPPORT_CONTACT","type":"varchar","len":50,"comment":"Contact for support purposes"},"support_term":{"name":"support_term","vname":"LBL_SUPPORT_TERM","type":"varchar","len":100,"function":{"name":"getSupportTerms","returns":"html","include":"modules/ProductTemplates/ProductTemplate.php"},"comment":"Term (length) of support contract"},"date_support_expires":{"name":"date_support_expires","vname":"LBL_DATE_SUPPORT_EXPIRES","type":"date","comment":"Support expiration date","massupdate":true},"date_support_starts":{"name":"date_support_starts","vname":"LBL_DATE_SUPPORT_STARTS","type":"date","comment":"Support start date","massupdate":true},"pricing_formula":{"name":"pricing_formula","vname":"LBL_PRICING_FORMULA","type":"varchar","len":100,"comment":"Pricing formula (ex: Fixed, Markup over Cost)"},"pricing_factor":{"name":"pricing_factor","vname":"LBL_PRICING_FACTOR","type":"int","group":"pricing_formula","len":4,"comment":"Variable pricing factor depending on pricing_formula"},"serial_number":{"name":"serial_number","vname":"LBL_SERIAL_NUMBER","type":"varchar","len":50,"comment":"Serial number of product in use"},"asset_number":{"name":"asset_number","vname":"LBL_ASSET_NUMBER","type":"varchar","len":50,"comment":"Asset tag number of product in use"},"book_value":{"name":"book_value","vname":"LBL_BOOK_VALUE","type":"currency","len":null,"comment":"Book value of product in use","related_fields":["currency_id","base_rate"]},"book_value_usdollar":{"name":"book_value_usdollar","vname":"LBL_BOOK_VALUE_USDOLLAR","group":"book_value","type":"currency","len":null,"comment":"Book value expressed in USD","studio":{"editview":false,"mobile":false},"related_fields":["currency_id","base_rate"],"formula":"ifElse(isNumeric($book_value), currencyDivide($book_value, $base_rate), \"\")","calculated":true,"enforced":true,"massupdate":false},"book_value_date":{"name":"book_value_date","vname":"LBL_BOOK_VALUE_DATE","type":"date","comment":"Date of book value for product in use","massupdate":true},"quotes":{"name":"quotes","type":"link","relationship":"quote_products","vname":"LBL_QUOTE","source":"non-db"},"revenuelineitems":{"name":"revenuelineitems","type":"link","relationship":"products_revenuelineitems","vname":"LBL_REVENUELINEITEM","source":"non-db","workflow":false},"date_closed":{"name":"date_closed","vname":"LBL_DATE_CLOSED","type":"date","audited":true,"comment":"Expected or actual date the product (for opportunity) will close","enable_range_search":true,"options":"date_range_search_dom","massupdate":true},"date_closed_timestamp":{"name":"date_closed_timestamp","vname":"LBL_DATE_CLOSED_TIMESTAMP","type":"int","reportable":false,"studio":false},"next_step":{"name":"next_step","vname":"LBL_NEXT_STEP","type":"varchar","len":100,"comment":"The next step in the sales process","merge_filter":"enabled"},"campaign_id":{"name":"campaign_id","comment":"Campaign that generated lead","vname":"LBL_CAMPAIGN_ID","rname":"id","type":"id","dbType":"id","table":"campaigns","isnull":"true","module":"Campaigns","reportable":false,"massupdate":false,"duplicate_merge":"disabled"},"campaign_name":{"name":"campaign_name","rname":"name","id_name":"campaign_id","vname":"LBL_CAMPAIGN","type":"relate","link":"campaign_products","isnull":"true","table":"campaigns","module":"Campaigns","source":"non-db","massupdate":true},"campaign_products":{"name":"campaign_products","type":"link","vname":"LBL_CAMPAIGN_PRODUCT","relationship":"campaign_products","source":"non-db"},"related_products":{"name":"related_products","type":"link","relationship":"product_product","source":"non-db","vname":"LBL_RELATED_PRODUCTS"},"notes":{"name":"notes","type":"link","relationship":"product_notes","source":"non-db","vname":"LBL_NOTES"},"documents":{"name":"documents","type":"link","relationship":"documents_products","source":"non-db","vname":"LBL_DOCUMENTS_SUBPANEL_TITLE"},"contracts":{"name":"contracts","type":"link","vname":"LBL_CONTRACTS","relationship":"contracts_products","link_type":"one","source":"non-db"},"currency_name":{"name":"currency_name","rname":"name","id_name":"currency_id","vname":"LBL_CURRENCY_NAME","type":"relate","link":"currencies","isnull":true,"table":"currencies","module":"Currencies","source":"non-db","function":"getCurrencies","function_bean":"Currencies","studio":false,"duplicate_merge":"disabled","massupdate":false},"currency_symbol":{"name":"currency_symbol","rname":"symbol","id_name":"currency_id","vname":"LBL_CURRENCY_SYMBOL","type":"relate","link":"currencies","isnull":true,"table":"currencies","module":"Currencies","source":"non-db","function":"getCurrencySymbols","function_bean":"Currencies","studio":false,"duplicate_merge":"disabled","massupdate":false},"currencies":{"name":"currencies","type":"link","relationship":"product_currencies","source":"non-db","vname":"LBL_CURRENCIES"},"quote_name":{"name":"quote_name","rname":"name","id_name":"quote_id","join_name":"quotes","type":"relate","link":"quotes","table":"quotes","isnull":"true","module":"Quotes","dbType":"varchar","vname":"LBL_QUOTE_NAME","source":"non-db","comment":"Quote Name","massupdate":true},"opportunity_id":{"name":"opportunity_id","type":"id","vname":"LBL_OPPORTUNITY_ID","required":false,"isnull":true,"reportable":false,"comment":"The opportunity id for the line item entry","massupdate":false},"opportunity_name":{"name":"opportunity_name","rname":"name","id_name":"opportunity_id","vname":"LBL_OPPORTUNITY_NAME","join_name":"opportunities","type":"relate","link":"opportunities","table":"opportunities","isnull":"true","module":"Opportunities","source":"non-db","comment":"The opportunity name associated with the opportunity_id","auto_populate":true,"populate_list":{"account_id":"account_id","account_name":"account_name"},"massupdate":true},"opportunities":{"name":"opportunities","type":"link","relationship":"opportunities_products","source":"non-db","link_type":"one","module":"Opportunities","bean_name":"Opportunity","vname":"LBL_OPPORTUNITIES"},"type_name":{"name":"type_name","rname":"name","id_name":"type_id","vname":"LBL_TYPE","join_name":"types","type":"relate","link":"product_types_link","table":"product_types","isnull":"true","module":"ProductTypes","importable":"false","dbType":"varchar","source":"non-db","massupdate":true},"account_link":{"name":"account_link","type":"link","relationship":"products_accounts","link_file":"modules/Products/AccountLink.php","link_class":"AccountLink","vname":"LBL_ACCOUNT","link_type":"one","module":"Accounts","bean_name":"Account","source":"non-db"},"product_categories_link":{"name":"product_categories_link","type":"link","relationship":"product_categories","vname":"LBL_PRODUCT_CATEGORIES","link_type":"one","module":"ProductCategories","bean_name":"ProductCategory","source":"non-db"},"product_templates_link":{"name":"product_templates_link","type":"link","relationship":"product_templates","vname":"LBL_PRODUCT_TEMPLATES","link_type":"one","module":"ProductTemplates","bean_name":"ProductTemplate","source":"non-db"},"product_types_link":{"name":"product_types_link","type":"link","relationship":"product_types","vname":"LBL_PRODUCT_TYPES","link_type":"one","module":"ProductTypes","bean_name":"ProductType","source":"non-db"},"contact_link":{"name":"contact_link","type":"link","relationship":"contact_products","vname":"LBL_CONTACT","link_type":"one","module":"Contacts","bean_name":"Contact","source":"non-db","duplicate_merge":"disabled"},"account_name":{"name":"account_name","rname":"name","id_name":"account_id","vname":"LBL_ACCOUNT_NAME","join_name":"accounts","type":"relate","link":"account_link","table":"accounts","module":"Accounts","source":"non-db","massupdate":true},"emails":{"name":"emails","type":"link","relationship":"emails_products_rel","module":"Emails","bean_name":"Email","source":"non-db","vname":"LBL_EMAILS","studio":{"formula":false}},"projects":{"name":"projects","type":"link","relationship":"projects_products","source":"non-db","vname":"LBL_PROJECTS"},"product_bundles":{"name":"product_bundles","type":"link","relationship":"product_bundle_product","module":"ProductBundles","bean_name":"ProductBundle","source":"non-db","rel_fields":{"product_index":{"type":"integer"}},"vname":"LBL_PRODUCTS"},"product_index":{"name":"product_index","type":"integer","source":"non-db","vname":"LBL_PRODUCT_INDEX","link":"product_bundles","rname_link":"product_index"},"calls":{"name":"calls","type":"link","relationship":"product_calls","module":"Calls","bean_name":"Call","source":"non-db","vname":"LBL_CALLS"},"meetings":{"name":"meetings","type":"link","relationship":"product_meetings","module":"Meetings","bean_name":"Meeting","source":"non-db","vname":"LBL_MEETINGS"},"manufacturers":{"name":"manufacturers","type":"link","relationship":"product_manufacturers","vname":"LBL_MANUFACTURERS","link_type":"one","module":"Manufacturers","bean_name":"Manufacturer","source":"non-db"},"promocional_c":{"labelValue":"Promocional","enforced":"","dependency":"","required":false,"source":"custom_fields","name":"promocional_c","vname":"LBL_PROMOCIONAL","type":"bool","massupdate":false,"default":false,"no_default":false,"comments":"","help":"","importable":"true","duplicate_merge":"enabled","duplicate_merge_dom_value":"1","audited":false,"reportable":true,"unified_search":false,"merge_filter":"disabled","calculated":false,"len":255,"size":20,"id":"Productspromocional_c","custom_module":"Products"},"tipo_prom_c":{"labelValue":"Tipo de promoción","dependency":"","visibility_grid":"","required":false,"source":"custom_fields","name":"tipo_prom_c","vname":"LBL_TIPO_PROM","type":"enum","massupdate":true,"default":"","no_default":false,"comments":"","help":"","importable":"true","duplicate_merge":"enabled","duplicate_merge_dom_value":"1","audited":false,"reportable":true,"unified_search":false,"merge_filter":"disabled","calculated":false,"len":100,"size":20,"options":"products_tipo_prom_list","id":"Productstipo_prom_c","custom_module":"Products"},"piezas_factor_c":{"labelValue":"piezas factor","full_text_search":{"boost":"0","enabled":false},"enforced":"","dependency":"","required":false,"source":"custom_fields","name":"piezas_factor_c","vname":"LBL_PIEZAS_FACTOR","type":"int","massupdate":false,"default":"","no_default":false,"comments":"","help":"","importable":"true","duplicate_merge":"enabled","duplicate_merge_dom_value":"1","audited":false,"reportable":true,"unified_search":false,"merge_filter":"disabled","calculated":false,"len":255,"size":20,"enable_range_search":false,"disable_num_format":"","min":false,"max":false,"id":"Productspiezas_factor_c","custom_module":"Products"},"litros_movil_c":{"labelValue":"litros calculados en movil","full_text_search":{"boost":"0","enabled":false},"enforced":"","dependency":"","required":false,"source":"custom_fields","name":"litros_movil_c","vname":"LBL_LITROS_MOVIL_C","type":"decimal","massupdate":false,"default":"","no_default":false,"comments":"","help":"","importable":"true","duplicate_merge":"enabled","duplicate_merge_dom_value":"1","audited":false,"reportable":true,"unified_search":false,"merge_filter":"disabled","calculated":false,"len":18,"size":20,"enable_range_search":false,"precision":8,"id":"Productslitros_movil_c","custom_module":"Products"},"aplico_precio_especial_c":{"labelValue":"Aplicó precio especial","enforced":"","dependency":"","required":false,"source":"custom_fields","name":"aplico_precio_especial_c","vname":"LBL_APLICO_PRECIO_ESPECIAL","type":"bool","massupdate":false,"default":false,"no_default":false,"comments":"","help":"","importable":"true","duplicate_merge":"enabled","duplicate_merge_dom_value":"1","audited":false,"reportable":true,"unified_search":false,"merge_filter":"disabled","calculated":false,"len":255,"size":20,"id":"Productsaplico_precio_especial_c","custom_module":"Products"},"code_prom_c":{"labelValue":"Code prom","full_text_search":{"boost":"0","enabled":false},"enforced":"","dependency":"","required":false,"source":"custom_fields","name":"code_prom_c","vname":"LBL_CODE_PROM","type":"varchar","massupdate":false,"default":"","no_default":false,"comments":"","help":"","importable":"true","duplicate_merge":"enabled","duplicate_merge_dom_value":"1","audited":false,"reportable":true,"unified_search":false,"merge_filter":"disabled","calculated":false,"len":10,"size":20,"id":"Productscode_prom_c","custom_module":"Products"},"qty_convert_c":{"labelValue":"cantidad","full_text_search":{"boost":"0","enabled":false},"enforced":"","dependency":"","required":false,"source":"custom_fields","name":"qty_convert_c","vname":"LBL_QTY_CONVERT_C","type":"decimal","massupdate":false,"default":"","no_default":false,"comments":"Cantidad de piezas capturadas","help":"","importable":"true","duplicate_merge":"enabled","duplicate_merge_dom_value":"1","audited":false,"reportable":true,"unified_search":false,"merge_filter":"disabled","calculated":false,"len":18,"size":20,"enable_range_search":false,"precision":8,"id":"Productsqty_convert_c","custom_module":"Products"},"unidad_medida_c":{"labelValue":"unidad medida","full_text_search":{"boost":"0","enabled":false},"enforced":"","dependency":"","required":false,"source":"custom_fields","name":"unidad_medida_c","vname":"LBL_UNIDAD_MEDIDA_C","type":"varchar","massupdate":false,"default":"","no_default":false,"comments":"","help":"","importable":"true","duplicate_merge":"enabled","duplicate_merge_dom_value":"1","audited":false,"reportable":true,"unified_search":false,"merge_filter":"disabled","calculated":false,"len":255,"size":20,"id":"Productsunidad_medida_c","custom_module":"Products"},"lista_de_precio_promocion_c":{"labelValue":"Lista de precio promocion","full_text_search":{"boost":"0","enabled":false},"enforced":"","dependency":"","required":false,"source":"custom_fields","name":"lista_de_precio_promocion_c","vname":"LBL_LISTA_DE_PRECIO_PROMOCION","type":"varchar","massupdate":false,"default":"","no_default":false,"comments":"","help":"","importable":"true","duplicate_merge":"enabled","duplicate_merge_dom_value":"1","audited":false,"reportable":true,"unified_search":false,"merge_filter":"disabled","calculated":false,"len":32,"size":20,"id":"Productslista_de_precio_promocion_c","custom_module":"Products"},"precio_despues_descuento_c":{"labelValue":"Precio despues descuento","enforced":"","dependency":"","related_fields":["currency_id","base_rate"],"required":false,"source":"custom_fields","name":"precio_despues_descuento_c","vname":"LBL_PRECIO_DESPUES_DESCUENTO","type":"currency","massupdate":false,"default":"0","no_default":false,"comments":"","help":"","importable":"true","duplicate_merge":"enabled","duplicate_merge_dom_value":"1","audited":false,"reportable":true,"unified_search":false,"merge_filter":"disabled","calculated":false,"len":26,"size":20,"enable_range_search":false,"precision":6,"id":"Productsprecio_despues_descuento_c","custom_module":"Products"},"precio_especial_c":{"labelValue":"Precio especial","dependency":"","visibility_grid":"","required":false,"source":"custom_fields","name":"precio_especial_c","vname":"LBL_PRECIO_ESPECIAL","type":"enum","massupdate":true,"default":"","no_default":false,"comments":"","help":"","importable":"true","duplicate_merge":"enabled","duplicate_merge_dom_value":"1","audited":false,"reportable":true,"unified_search":false,"merge_filter":"disabled","calculated":false,"len":100,"size":20,"options":"products_precio_especial_list","id":"Productsprecio_especial_c","custom_module":"Products"},"litros_c":{"duplicate_merge_dom_value":0,"labelValue":"Litros","full_text_search":{"boost":"0","enabled":false},"calculated":"true","formula":"multiply($quantity,related($product_templates_link,\"litros_c\"))","enforced":"true","dependency":"","required":false,"source":"custom_fields","name":"litros_c","vname":"LBL_LITROS","type":"decimal","massupdate":false,"default":"","no_default":false,"comments":"","help":"","importable":"false","duplicate_merge":"disabled","audited":false,"reportable":true,"unified_search":false,"merge_filter":"disabled","len":18,"size":20,"enable_range_search":false,"precision":8,"id":"Productslitros_c","custom_module":"Products"},"litros_factor_c":{"labelValue":"litros factor","full_text_search":{"boost":"0","enabled":false},"enforced":"","dependency":"","required":false,"source":"custom_fields","name":"litros_factor_c","vname":"LBL_LITROS_FACTOR","type":"decimal","massupdate":false,"default":"","no_default":false,"comments":"","help":"","importable":"true","duplicate_merge":"enabled","duplicate_merge_dom_value":"1","audited":false,"reportable":true,"unified_search":false,"merge_filter":"disabled","calculated":false,"len":18,"size":20,"enable_range_search":false,"precision":2,"id":"Productslitros_factor_c","custom_module":"Products"},"discount_c":{"labelValue":"Discount","full_text_search":{"boost":"0","enabled":false},"enforced":"","dependency":"","required":false,"source":"custom_fields","name":"discount_c","vname":"LBL_DISCOUNT","type":"decimal","massupdate":false,"default":"","no_default":false,"comments":"","help":"","importable":"true","duplicate_merge":"enabled","duplicate_merge_dom_value":"1","audited":false,"reportable":true,"unified_search":false,"merge_filter":"disabled","calculated":false,"len":6,"size":20,"enable_range_search":false,"precision":2,"id":"Productsdiscount_c","custom_module":"Products"},"tipo_de_descuento_c":{"labelValue":"Tipo de descuento","dependency":"","visibility_grid":"","required":false,"source":"custom_fields","name":"tipo_de_descuento_c","vname":"LBL_TIPO_DE_DESCUENTO","type":"enum","massupdate":true,"default":"","no_default":false,"comments":"","help":"","importable":"true","duplicate_merge":"enabled","duplicate_merge_dom_value":"1","audited":false,"reportable":true,"unified_search":false,"merge_filter":"disabled","calculated":false,"len":100,"size":20,"options":"products_tipo_de_descuento_list","id":"Productstipo_de_descuento_c","custom_module":"Products"},"_hash":"1ce909875d7c04e2d6965ceb91b49274"}},
}
};
app.data.declareModel('Products', metadata.modules.Products);
SugarTest.testMetadata.set();
app.metadata.set(metadata); 
context = app.context.getContext();
model = app.data.createBean("Opportunities", {id: '123',account_id: '1234'});
context.set({
module: moduleName,
layout: layoutName,
model: model
});
context.prepare();
//Create parent layout for our view using fake context
layout = app.view.createLayout({
name: layoutName,
context: context
});
view = app.view.createView({
name: viewName,
context: context,
module: moduleName,
platform: 'base',
layout: layout,
});
});
afterEach(function () {
SugarTest.testMetadata.dispose();
SugarTest.app.view.reset();
view.dispose();
view = null;
});
it('Should view exists', function (argument) {
expect(view).toBeTruthy();
expect(view.model.id).toEqual('123');
});
});
@yvan33
Copy link

yvan33 commented Jun 29, 2016

You should just call SugarTest.app.data.declareModels(); if you need to instantiate a bean (But do you even need to do that?)
I don't understand why you would need to do lines 28-34.

What do you want to test in this file? What is your dashlet doing?
Because l74 you are just testing that app.view.createView and app.data.createBean are working. And for that we already have sidecar unit tests :)

Also, to create a view, you should use SugarTest.createView

Hope it helps,

Yvan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment