/*

Siesta 5.1.0
Copyright(c) 2009-2018 Bryntum AB
https://bryntum.com/contact
https://bryntum.com/products/siesta/license

*/
Ext.define('Siesta.Project.Browser.UI.CanFillAssertionsStore', {

    processNewResult : function (assertionStore, test, result, parentResult) {
        var data            = {
            id                  : result.id,
            
            result              : result,
            
            loaded              : true,
            leaf                : !(result instanceof Siesta.Result.SubTest),
            expanded            : (result instanceof Siesta.Result.SubTest) && result.test.specType != 'it'
        };
        
        var alreadyInTheStore   = assertionStore.getNodeById(result.id)

        if (alreadyInTheStore) {

            alreadyInTheStore.triggerUIUpdate()
        } else {
            Ext.suspendLayouts()
            
            alreadyInTheStore   = (assertionStore.getNodeById(parentResult.id) || assertionStore.getRootNode()).appendChild(data);
            
            Ext.resumeLayouts()
        }

        if (result.isPassed && !result.isPassed() || result.isWarning) alreadyInTheStore.ensureVisible()
        
        alreadyInTheStore.updateFolderStatus()
    },
    

    // is bubbling and thus triggered for all tests (including sub-tests) 
    processEveryTestEnd : function (assertionStore, test) {
        var testResultNode  = assertionStore.getNodeById(test.getResults().id)
        
        // can be missing for "root" tests
        testResultNode && testResultNode.updateFolderStatus()
    }
})