siesta-lite
Version:
Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers
128 lines (100 loc) • 3.79 kB
JavaScript
/*
Siesta 5.6.1
Copyright(c) 2009-2022 Bryntum AB
https://bryntum.com/contact
https://bryntum.com/products/siesta/license
*/
Ext.define('Siesta.Project.Browser.UI.TestNameColumn', {
extend : 'Ext.tree.Column',
xtype : 'testnamecolumn',
requires : [
'Siesta.Project.Browser.UI.TreeFilterField'
],
dataIndex : 'title',
sortable : false,
menuDisabled : true,
flex : 1,
tdCls : 'test-name-cell',
scope : this,
project : null,
filterGroups : null,
store : null,
initComponent : function () {
var R = Siesta.Resource('Siesta.Project.Browser.UI.TestGrid');
Ext.apply(this, {
items : [
{
xtype : 'treefilter',
emptyText : R.get('filterTestsText'),
margins : '0 0 0 10',
itemId : 'trigger',
filterGroups : this.filterGroups,
filterField : 'title',
store : this.store,
tipText : R.get('filterFieldTooltip')
}
]
});
this.callParent(arguments);
},
// HACK OVERRIDE
treeRenderer : function (value, metaData, testFile) {
metaData.tdCls = 'test-name-cell-' + (testFile.data.leaf ? 'leaf' : 'parent');
var iconCls = ''
if (testFile.isLeaf()) {
var test = testFile.get('test')
if (test) {
if (testFile.get('isFailed'))
iconCls = 'siesta-test-failed fa-flag'
else if (testFile.get('isRunning') && !test.isFinished())
iconCls = 'fa-flash siesta-running-not-finished'
else if (test.isFinished()) {
if (test.isPassed())
iconCls = 'fa-check siesta-test-passed'
else
iconCls = 'fa-bug siesta-test-failed'
} else
iconCls = 'fa-hourglass-o siesta-test-starting'
} else {
if (testFile.get('isMissing'))
iconCls = 'fa-close siesta-test-file-missing'
else if (testFile.get('isStarting'))
iconCls = 'fa-hourglass-o siesta-test-starting'
else
iconCls = this.getTestIcon(testFile) + ' siesta-test-file'
}
} else {
var status = testFile.get('folderStatus');
if (status == 'working') {
iconCls = ' fa-hourglass-o siesta-folder-running';
} else if (status == 'green') {
iconCls = ' fa-check siesta-folder-pass';
} else if (status == 'red') {
iconCls = ' fa-bug siesta-folder-fail';
} else {
iconCls = '';
}
}
testFile.data.iconCls = iconCls
if (testFile.isLeaf()) {
var tooltip = testFile.get('tooltip') || value
metaData.tdAttr = 'title="' + tooltip + '"';
}
return this.callParent(arguments);
},
getTestIcon : function(test) {
if (this.project.getDescriptorConfig(test.get('descriptor'), 'pageUrl')) {
return 'fa-desktop'; // Application test
} else {
return 'fa-file-o'; // Unit test
}
},
renderer : function (v, m, r) {
return v + (
r.get('descriptor').referenceUrl ?
'<span style="padding-left: 3px; vertical-align: super; font-size: xx-small" class="fa fa-external-link" aria-hidden="true"></span>'
:
''
);
}
})