siesta-lite
Version:
Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers
83 lines (64 loc) • 2.8 kB
JavaScript
/*
Siesta 5.6.1
Copyright(c) 2009-2022 Bryntum AB
https://bryntum.com/contact
https://bryntum.com/products/siesta/license
*/
Class('Ariadne.ExtJSComponentQueryFinder.Identifier.PropertyValue', {
isa : Ariadne.QueryFinder.Identifier,
does : [
Ariadne.ExtJSComponentQueryFinder.Role.ExtJSComponentHelper,
Ariadne.ExtJSDomQueryFinder.Role.ExtJSHelper
],
has : {
// an array of attribute names, which can be used for matching
properties : function () {
return [
'name', // form fields
'text', // menu items, buttons
'dataIndex', // Column component
'iconCls', // button/menuitem
'type', // Panel header tools
'title', // identifying panels, tab panels headers
// 'cls', // Cmp, TODO discuss
'inputType',
'boxLabel',
'fieldLabel'
]
}
},
methods : {
initialize : function (cfg) {
this.properties = this.mergeArrayAttributeFromClassHierarchy('properties', cfg)
},
ignoreProperty : function (target, property) {
return this.valueIsAutoGeneratedByComponent(target, target[ property ])
},
identify : function (target, root, maze) {
var Ext = this.finder.Ext
var properties = this.properties
var segments = []
var safeXtype = this.getExt4ProofXtype(target, Ext)
for (var i = 0; i < properties.length; i++) {
var property = properties[ i ]
var value = target[ property ]
if (
value && typeof value === 'string' && !(
this.ignoreProperty(target, property) ||
// ignore the "inputType" for sliders which is always a "text"
(property == 'inputType' && Ext.slider && Ext.slider.Multi && (target instanceof Ext.slider.Multi)) ||
(property == 'inputType' && Ext.form && Ext.form.field && Ext.form.field.ComboBox && (target instanceof Ext.form.field.ComboBox)) ||
// Some Ext Components have an empty title/text - ignore
(value == ' ')
)
) {
segments.push({
query : safeXtype.query + '[' + property + '=' + this.escapeCQSelector(value) + ']',
leading : safeXtype.leading
})
}
}
return segments
}
}
});