2 lines
35 KiB
JavaScript
2 lines
35 KiB
JavaScript
define("taoTests/runner/areaBroker",["lodash","ui/areaBroker"],function(_,areaBroker$1){'use strict';_=_&&Object.prototype.hasOwnProperty.call(_,"default")?_["default"]:_,areaBroker$1=areaBroker$1&&Object.prototype.hasOwnProperty.call(areaBroker$1,"default")?areaBroker$1["default"]:areaBroker$1;var areaBroker=_.partial(areaBroker$1,["content","toolbox","navigation","control","header","panel"]);return areaBroker}),define("taoTests/runner/dataHolder",[],function(){'use strict';var defaultObjects=["testContext","testMap"];return function(){var map=new Map;return defaultObjects.forEach(function(entry){map.set(entry,{})}),map}}),define("taoTests/runner/plugin",["lodash","core/plugin"],function(_,pluginFactory){'use strict';_=_&&Object.prototype.hasOwnProperty.call(_,"default")?_["default"]:_,pluginFactory=pluginFactory&&Object.prototype.hasOwnProperty.call(pluginFactory,"default")?pluginFactory["default"]:pluginFactory;var plugin=_.partialRight(pluginFactory,{hostName:"testRunner"});return plugin}),define("taoTests/runner/probeOverseer",["lodash","moment","lib/uuid","lib/moment-timezone.min"],function(_,moment,uuid){'use strict';function probeOverseerFactory(runner){function collectEvent(probe){var eventNs=".probe-".concat(probe.name),probeHandler=function(){var now=moment(),data={id:uuid(12,16),type:probe.name,timestamp:now.format("x")/1e3,timezone:now.tz(timeZone).format("Z")};"function"==typeof probe.capture&&(data.context=probe.capture.apply(probe,[runner].concat(slice.call(arguments)))),overseer.push(data)};return probe.latency?collectLatencyEvent(probe):void _.forEach(probe.events,function(eventName){var listen=0<eventName.indexOf(".")?eventName:eventName+eventNs;runner.on(listen,_.partial(probeHandler,eventName))})}function collectLatencyEvent(probe){var eventNs=".probe-".concat(probe.name),startHandler=function(){var now=moment(),data={id:uuid(12,16),marker:"start",type:probe.name,timestamp:now.format("x")/1e3,timezone:now.tz(timeZone).format("Z")};"function"==typeof probe.capture&&(data.context=probe.capture.apply(probe,[runner].concat(slice.call(arguments)))),overseer.push(data)},stopHandler=function(){var last,now=moment(),data={type:probe.name,timestamp:now.format("x")/1e3,timezone:now.tz(timeZone).format("Z")},args=slice.call(arguments);last=_.findLast(immutableQueue,{type:probe.name,marker:"start"}),last&&!_.findLast(immutableQueue,{type:probe.name,marker:"end",id:last.id})&&(data.id=last.id,data.marker="end","function"==typeof probe.capture&&(data.context=probe.capture.apply(probe,[runner].concat(args))),overseer.push(data))};return probe.latency?void(_.forEach(probe.startEvents,function(eventName){var listen=0<eventName.indexOf(".")?eventName:eventName+eventNs;runner.on(listen,_.partial(startHandler,eventName))}),_.forEach(probe.stopEvents,function(eventName){var listen=0<eventName.indexOf(".")?eventName:eventName+eventNs;runner.on(listen,_.partial(stopHandler,eventName))})):collectEvent(probe)}var overseer,queueStorage,probes=[],queue=[],immutableQueue=[],writing=Promise.resolve(),started=!1,getStorage=function(){return queueStorage?Promise.resolve(queueStorage):runner.getTestStore().getStore("test-probe").then(function(newStorage){return queueStorage=newStorage,Promise.resolve(queueStorage)})},resetStorage=function(){queueStorage=null};if(!_.isPlainObject(runner)||!_.isFunction(runner.init)||!_.isFunction(runner.on))throw new TypeError("Please set a test runner");return overseer={add:function(probe){if(!_.isPlainObject(probe))throw new TypeError("A probe is a plain object");if(!_.isString(probe.name)||_.isEmpty(probe.name))throw new TypeError("A probe must have a name");if(0<_.where(probes,{name:probe.name}).length)throw new TypeError("A probe with this name is already regsitered");if(probe.latency){if(_.isString(probe.startEvents)&&!_.isEmpty(probe.startEvents)&&(probe.startEvents=[probe.startEvents]),_.isString(probe.stopEvents)&&!_.isEmpty(probe.stopEvents)&&(probe.stopEvents=[probe.stopEvents]),!probe.startEvents.length||!probe.stopEvents.length)throw new TypeError("Latency based probes must have startEvents and stopEvents defined");started&&collectLatencyEvent(probe)}else{if(_.isString(probe.events)&&!_.isEmpty(probe.events)&&(probe.events=[probe.events]),!_.isArray(probe.events)||0===probe.events.length)throw new TypeError("A probe must define events");started&&collectEvent(probe)}return probes.push(probe),this},getQueue:function(){return getStorage().then(function(storage){return storage.getItem("queue")})},getProbes:function(){return probes},push:function(entry){getStorage().then(function(storage){writing=writing.then(function(){return queue.push(entry),immutableQueue.push(entry),storage.setItem("queue",queue)})})},flush:function(){return new Promise(function(resolve){getStorage().then(function(storage){writing=writing.then(function(){return storage.getItem("queue").then(function(flushed){return queue=[],storage.setItem("queue",queue).then(function(){resolve(flushed)})})})})})},start:function(){return getStorage().then(function(storage){return storage.getItem("queue").then(function(savedQueue){_.isArray(savedQueue)&&(queue=savedQueue,immutableQueue=savedQueue),_.forEach(probes,collectEvent),started=!0})})},stop:function(){return started=!1,_.forEach(probes,function(probe){var eventNs=".probe-".concat(probe.name),removeHandler=function(eventName){runner.off(eventName+eventNs)};_.forEach(probe.startEvents,removeHandler),_.forEach(probe.stopEvents,removeHandler),_.forEach(probe.events,removeHandler)}),queue=[],immutableQueue=[],getStorage().then(function(storage){return storage.removeItem("queue").then(resetStorage)})}},overseer}_=_&&Object.prototype.hasOwnProperty.call(_,"default")?_["default"]:_,moment=moment&&Object.prototype.hasOwnProperty.call(moment,"default")?moment["default"]:moment,uuid=uuid&&Object.prototype.hasOwnProperty.call(uuid,"default")?uuid["default"]:uuid;var timeZone=moment.tz.guess(),slice=Array.prototype.slice;return probeOverseerFactory}),define("taoTests/runner/runner",["lodash","core/eventifier","core/providerRegistry","taoTests/runner/dataHolder"],function(_,eventifier,providerRegistry,dataHolderFactory){'use strict';function testRunnerFactory(providerName){function providerRun(method){for(var _len=arguments.length,args=Array(1<_len?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];return new Promise(function(resolve){return _.isFunction(provider[method])?resolve(provider[method].apply(runner,args)):resolve()})}function pluginRun(method){var execStack=[];return _.forEach(runner.getPlugins(),function(plugin){_.isFunction(plugin[method])&&execStack.push(plugin[method]())}),Promise.all(execStack)}function reportError(err){runner.trigger("error",err)}var runner,dataHolder,areaBroker,proxy,probeOverseer,testStore,pluginFactories=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[],config=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},plugins={},states={init:!1,ready:!1,render:!1,finish:!1,destroy:!1},itemStates={},provider=testRunnerFactory.getProvider(providerName);return runner=eventifier({init:function(){var _this=this;return dataHolder||(dataHolder=this.getDataHolder()),_.forEach(pluginFactories,function(pluginFactory){var plugin=pluginFactory(runner,_this.getAreaBroker());plugins[plugin.getName()]=plugin}),providerRun("install").then(_.partial(providerRun,"loadPersistentStates")).then(_.partial(pluginRun,"install")).then(_.partial(providerRun,"init")).then(_.partial(pluginRun,"init")).then(function(){_this.setState("init",!0).off("init.internal").after("init.internal",function(){return _this.render()}).trigger("init")}).catch(reportError),this},render:function(){var _this2=this;return providerRun("render").then(function(){return pluginRun("render")}).then(function(){_this2.setState("ready",!0).trigger("render").trigger("ready")}).catch(reportError),this},loadItem:function(itemRef){var _this3=this;return providerRun("loadItem",itemRef).then(function(itemData){_this3.setItemState(itemRef,"loaded",!0).off("loaditem.internal").after("loaditem.internal",function(){return _this3.renderItem(itemRef,itemData)}).trigger("loaditem",itemRef,itemData)}).catch(reportError),this},renderItem:function(itemRef,itemData){var _this4=this;return providerRun("renderItem",itemRef,itemData).then(function(){_this4.setItemState(itemRef,"ready",!0).trigger("renderitem",itemRef,itemData)}).catch(reportError),this},unloadItem:function(itemRef){var _this5=this;return providerRun("unloadItem",itemRef).then(function(){itemStates=_.omit(itemStates,itemRef),_this5.trigger("unloaditem",itemRef)}).catch(reportError),this},disableItem:function(itemRef){var _this6=this;return this.getItemState(itemRef,"disabled")||providerRun("disableItem",itemRef).then(function(){_this6.setItemState(itemRef,"disabled",!0).trigger("disableitem",itemRef)}).catch(reportError),this},enableItem:function(itemRef){var _this7=this;return this.getItemState(itemRef,"disabled")&&providerRun("enableItem",itemRef).then(function(){_this7.setItemState(itemRef,"disabled",!1).trigger("enableitem",itemRef)}).catch(reportError),this},finish:function(){var _this8=this;return providerRun("finish").then(function(){return pluginRun("finish")}).then(function(){_this8.setState("finish",!0).trigger("finish")}).catch(reportError),this},flush:function(){var _this9=this;return providerRun("flush").then(function(){return pluginRun("flush")}).then(function(){_this9.setState("flush",!0).trigger("flush")}).catch(reportError),this},destroy:function(){var _this10=this;return providerRun("destroy").then(function(){return pluginRun("destroy")}).then(function(){if(proxy)return proxy.destroy()}).then(function(){_this10.setTestContext({}).setTestMap({}).setState("destroy",!0).trigger("destroy")}).catch(reportError),this},getConfig:function(){return config||{}},getOptions:function(){return this.getConfig().options||{}},getPlugins:function(){return plugins},getPlugin:function(name){return plugins[name]},getPluginsConfig:function(){return this.getOptions().plugins||{}},getPluginConfig:function(pluginName){if(pluginName&&plugins[pluginName]){var pluginsConfig=this.getPluginsConfig();if(pluginsConfig[pluginName])return pluginsConfig[pluginName]}return{}},getAreaBroker:function(){return areaBroker||(areaBroker=provider.loadAreaBroker.call(this)),areaBroker},getProxy:function(){var _this11=this;if(!proxy){if(!_.isFunction(provider.loadProxy))throw new Error("The provider does not have a loadProxy method");proxy=provider.loadProxy.call(this),proxy.on("error",function(error){return _this11.trigger("error",error)}),proxy.install(this.getDataHolder())}return proxy},getProbeOverseer:function(){return!probeOverseer&&_.isFunction(provider.loadProbeOverseer)&&(probeOverseer=provider.loadProbeOverseer.call(this)),probeOverseer},getTestStore:function(){return!testStore&&_.isFunction(provider.loadTestStore)&&(testStore=provider.loadTestStore.call(this)),testStore},getPluginStore:function(name){var loadedStore=this.getTestStore();return loadedStore&&_.isFunction(loadedStore.getStore)?this.getTestStore().getStore(name):Promise.reject(new Error("Please configure a testStore via loadTestStore to be able to get a plugin store"))},getState:function(name){return!!states[name]},setState:function(name,active){if(!_.isString(name)||_.isEmpty(name))throw new TypeError("The state must have a name");return states[name]=!!active,this},getPersistentState:function(name){var state;return _.isFunction(provider.getPersistentState)&&(state=provider.getPersistentState.call(runner,name)),!!state},setPersistentState:function(name,active){var stored;return stored=!_.isString(name)||_.isEmpty(name)?Promise.reject(new TypeError("The state must have a name")):providerRun("setPersistentState",name,!!active),stored.catch(reportError),stored},getItemState:function(itemRef,name){if(_.isEmpty(itemRef)||_.isEmpty(name))throw new TypeError("The state is identified by an itemRef and a name");return!!(itemStates[itemRef]&&itemStates[itemRef][name])},setItemState:function(itemRef,name,active){if(_.isEmpty(itemRef)||_.isEmpty(name))throw new TypeError("The state is identified by an itemRef and a name");return itemStates[itemRef]=itemStates[itemRef]||{loaded:!1,ready:!1,disabled:!1},itemStates[itemRef][name]=!!active,this},getTestData:function(){return dataHolder&&dataHolder.get("testData")},setTestData:function(testData){return dataHolder&&_.isPlainObject(testData)&&dataHolder.set("testData",testData),this},getTestContext:function(){return dataHolder&&dataHolder.get("testContext")},setTestContext:function(testContext){return dataHolder&&_.isPlainObject(testContext)&&dataHolder.set("testContext",testContext),this},getTestMap:function(){return dataHolder&&dataHolder.get("testMap")},setTestMap:function(testMap){return dataHolder&&_.isPlainObject(testMap)&&dataHolder.set("testMap",testMap),this},getDataHolder:function(){return dataHolder||(_.isFunction(provider.loadDataHolder)?dataHolder=provider.loadDataHolder.call(this):dataHolder=dataHolderFactory()),dataHolder},next:function(scope){return _.isFunction(provider.next)?providerRun("next",scope):(this.trigger("move","next",scope),this)},previous:function(scope){return _.isFunction(provider.previous)?providerRun("previous",scope):(this.trigger("move","previous",scope),this)},jump:function(position,scope){return _.isFunction(provider.jump)?providerRun("jump",position,scope):(this.trigger("move","jump",scope,position),this)},skip:function(scope,direction,ref){return _.isFunction(provider.skip)?providerRun("skip",scope,direction,ref):(this.trigger("skip",scope,direction,ref),this)},exit:function(why){return _.isFunction(provider.exit)?providerRun("exit",why):(this.trigger("exit",why),this)},pause:function(){return _.isFunction(provider.pause)?this.getState("pause")?Promise.resolve():(this.setState("pause",!0),providerRun("pause")):(this.getState("pause")||this.setState("pause",!0).trigger("pause"),this)},resume:function(){return _.isFunction(provider.resume)?this.getState("pause")?(this.setState("pause",!1),providerRun("resume")):Promise.resolve():(!0===this.getState("pause")&&this.setState("pause",!1).trigger("resume"),this)},timeout:function(scope,ref,timer){return _.isFunction(provider.timeout)?providerRun("timeout",scope,ref,timer):(this.trigger("timeout",scope,ref,timer),this)}}),runner.on("move",function(){this.trigger.apply(this,arguments)}).after("destroy",function(){dataHolder&&dataHolder.clear(),areaBroker=null,proxy=null,probeOverseer=null,testStore=null}),runner}_=_&&Object.prototype.hasOwnProperty.call(_,"default")?_["default"]:_,eventifier=eventifier&&Object.prototype.hasOwnProperty.call(eventifier,"default")?eventifier["default"]:eventifier,providerRegistry=providerRegistry&&Object.prototype.hasOwnProperty.call(providerRegistry,"default")?providerRegistry["default"]:providerRegistry,dataHolderFactory=dataHolderFactory&&Object.prototype.hasOwnProperty.call(dataHolderFactory,"default")?dataHolderFactory["default"]:dataHolderFactory;var runner=providerRegistry(testRunnerFactory,function(provider){if(!_.isFunction(provider.loadAreaBroker))throw new TypeError("The runner provider MUST have a method that returns an areaBroker");return!0});return runner}),define("taoTests/runner/proxy",["lodash","async","core/delegator","core/eventifier","core/providerRegistry","core/tokenHandler","core/connectivity"],function(_,async,delegator,eventifier,providerRegistry,tokenHandlerFactory,connectivity){'use strict';function proxyFactory(proxyName,config){function getParams(params){var mergedParams=_.merge({},params,extraCallParams);return extraCallParams={},mergedParams}function getMiddlewares(queue){var list=middlewares[queue]||[];return middlewares.all&&(list=list.concat(middlewares.all)),list}function applyMiddlewares(request,response){var list=_.map(getMiddlewares(request.command),function(middleware){return function(next){middleware(request,response,next)}});return new Promise(function(resolve,reject){async.series(list,function(err){err||"error"!==response.status||(err=response.data),err?reject(err):(proxy.trigger("receive",response.data,"proxy"),resolve(response.data))})})}function delegate(fnName){var request={command:fnName,params:_slice.call(arguments,1)};return initialized||_.contains(["install","init"],fnName)?delegateProxy.apply(null,arguments).then(function(data){return initialized=!0,applyMiddlewares(request,{status:"success",data:data})}).catch(function(data){return applyMiddlewares(request,{status:"error",data:data})}):Promise.reject(new Error("Proxy is not properly initialized or has been destroyed!"))}var proxy,delegateProxy,communicator,communicatorPromise,testDataHolder,extraCallParams={},proxyAdapter=proxyFactory.getProvider(proxyName),initConfig=_.defaults(config||{},_defaults),tokenHandler=tokenHandlerFactory(),middlewares={},initialized=!1,onlineStatus=connectivity.isOnline();return proxy=eventifier({use:function(command){var queue=command&&_.isString(command)?command:"all",list=middlewares[queue]||[];return middlewares[queue]=list,_.each(arguments,function(cb){_.isFunction(cb)&&list.push(cb)}),this},install:function(dataHolder){return dataHolder&&(testDataHolder=dataHolder),delegate("install",initConfig)},init:function(params){return delegate("init",initConfig,getParams(params))},destroy:function(){return delegate("destroy").then(function(){if(initialized=!1,communicatorPromise)return new Promise(function(resolve,reject){function destroyCommunicator(){communicator.destroy().then(resolve).catch(reject)}communicatorPromise.then(function(){destroyCommunicator()}).catch(function(){communicator?destroyCommunicator():resolve()})})})},getDataHolder:function(){return testDataHolder},setOnline:function(){return this.isOffline()&&(onlineStatus=!0,this.trigger("reconnect")),this},setOffline:function(source){return this.isOnline()&&(onlineStatus=!1,this.trigger("disconnect",source)),this},isOnline:function(){return onlineStatus},isOffline:function(){return!onlineStatus},isConnectivityError:function(err){return _.isObject(err)&&"network"===err.source&&0===err.code&&!1===err.sent},getTokenHandler:function(){return tokenHandler},hasCommunicator:function(){return!!communicatorPromise},getCommunicator:function(){var self=this;return initialized?(communicatorPromise||(communicatorPromise=new Promise(function(resolve,reject){_.isFunction(proxyAdapter.loadCommunicator)?(communicator=proxyAdapter.loadCommunicator.call(self),communicator?communicator.before("error",function(e,err){self.isConnectivityError(err)&&self.setOffline("communicator")}).on("error",function(err){self.trigger("error",err)}).on("receive",function(response){self.setOnline(),self.trigger("receive",response,"communicator")}).init().then(function(){return communicator.open().then(function(){resolve(communicator)}).catch(reject)}).catch(reject):reject(new Error("No communicator has been set up!"))):reject(new Error("The proxy provider does not have a loadCommunicator method"))})),communicatorPromise):Promise.reject(new Error("Proxy is not properly initialized or has been destroyed!"))},channel:function(name,handler){if(!_.isString(name)||0>=name.length)throw new TypeError("A channel must have a name");if(!_.isFunction(handler))throw new TypeError("A handler must be attached to a channel");return this.getCommunicator().then(function(communicatorInstance){communicatorInstance.channel(name,handler)}).catch(_.noop),this.on("channel-".concat(name),handler),this},send:function(channel,message){return this.getCommunicator().then(function(communicatorInstance){return communicatorInstance.send(channel,message)})},addCallActionParams:function(params){return _.isPlainObject(params)&&_.merge(extraCallParams,params),this},getTestData:function(){return delegate("getTestData")},getTestContext:function(){return delegate("getTestContext")},getTestMap:function(){return delegate("getTestMap")},sendVariables:function(variables,deferred){return delegate("sendVariables",variables,deferred)},callTestAction:function(action,params,deferred){return delegate("callTestAction",action,getParams(params),deferred)},getItem:function(uri,params){return delegate("getItem",uri,params)},submitItem:function(uri,state,response,params){return delegate("submitItem",uri,state,response,getParams(params))},callItemAction:function(uri,action,params,deferred){return delegate("callItemAction",uri,action,getParams(params),deferred)},telemetry:function(uri,signal,params){return delegate("telemetry",uri,signal,params)}}),connectivity.on("offline",function(){proxy.setOffline("device")}).on("online",function(){proxy.setOnline()}),proxy.on("message",function(channel,message){this.trigger("channel-".concat(channel),message)}).use(function(request,response,next){response.data&&response.data.messages&&_.forEach(response.data.messages,function(msg){msg.channel?proxy.trigger("message",msg.channel,msg.message):proxy.trigger("message","malformed",msg)}),next()}).use(function(request,response,next){proxy.isConnectivityError(response.data)?proxy.setOffline("request"):response.data&&!0===response.data.sent&&proxy.setOnline(),next()}),delegateProxy=delegator(proxy,proxyAdapter,{name:"proxy",wrapper:function(response){return Promise.resolve(response)}}),proxy}_=_&&Object.prototype.hasOwnProperty.call(_,"default")?_["default"]:_,async=async&&Object.prototype.hasOwnProperty.call(async,"default")?async["default"]:async,delegator=delegator&&Object.prototype.hasOwnProperty.call(delegator,"default")?delegator["default"]:delegator,eventifier=eventifier&&Object.prototype.hasOwnProperty.call(eventifier,"default")?eventifier["default"]:eventifier,providerRegistry=providerRegistry&&Object.prototype.hasOwnProperty.call(providerRegistry,"default")?providerRegistry["default"]:providerRegistry,tokenHandlerFactory=tokenHandlerFactory&&Object.prototype.hasOwnProperty.call(tokenHandlerFactory,"default")?tokenHandlerFactory["default"]:tokenHandlerFactory,connectivity=connectivity&&Object.prototype.hasOwnProperty.call(connectivity,"default")?connectivity["default"]:connectivity;var _defaults={},_slice=[].slice,proxy=providerRegistry(proxyFactory);return proxy}),define("taoTests/runner/providerLoader",["core/logger","core/providerLoader","core/pluginLoader","core/communicator","taoTests/runner/runner","taoTests/runner/proxy","taoItems/runner/api/itemRunner"],function(loggerFactory,providerLoader,pluginLoader,_communicator,_runner,_proxy,_itemRunner){'use strict';function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}loggerFactory=loggerFactory&&Object.prototype.hasOwnProperty.call(loggerFactory,"default")?loggerFactory["default"]:loggerFactory,providerLoader=providerLoader&&Object.prototype.hasOwnProperty.call(providerLoader,"default")?providerLoader["default"]:providerLoader,pluginLoader=pluginLoader&&Object.prototype.hasOwnProperty.call(pluginLoader,"default")?pluginLoader["default"]:pluginLoader,_communicator=_communicator&&Object.prototype.hasOwnProperty.call(_communicator,"default")?_communicator["default"]:_communicator,_runner=_runner&&Object.prototype.hasOwnProperty.call(_runner,"default")?_runner["default"]:_runner,_proxy=_proxy&&Object.prototype.hasOwnProperty.call(_proxy,"default")?_proxy["default"]:_proxy,_itemRunner=_itemRunner&&Object.prototype.hasOwnProperty.call(_itemRunner,"default")?_itemRunner["default"]:_itemRunner;var logger=loggerFactory("taoTests/runner/loader");return function(){var providers=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},loadFromBundle=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1],loadAndRegisterProvider=function(){var providersToLoad=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],target=1<arguments.length?arguments[1]:void 0;if(!target||"function"!=typeof target.registerProvider)throw new TypeError("Trying to register providers on a target that is not a provider API");return providerLoader().addList(providersToLoad).load(loadFromBundle).then(function(loadedProviders){return loadedProviders.forEach(function(provider){return target.registerProvider(provider.name,provider)}),target})},registration={runner:function(){var runnerProviders=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[];return loadAndRegisterProvider(runnerProviders,_runner)},itemRunner:function(){var itemRunnerProviders=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[];return providerLoader().addList(itemRunnerProviders).load(loadFromBundle).then(function(loadedProviders){return loadedProviders.forEach(function(provider){return _itemRunner.register(provider.name,provider)}),_itemRunner})},communicator:function(){var communicatorProviders=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[];return loadAndRegisterProvider(communicatorProviders,_communicator)},proxy:function(){var proxyProviders=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[];return loadAndRegisterProvider(proxyProviders,_proxy)},plugins:function plugins(){var plugins=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[];return pluginLoader().addList(plugins).load(loadFromBundle)}};return loadFromBundle||logger.warn("All modules will be loaded from sources"),Promise.all(Object.keys(providers).map(function(providerType){if("function"==typeof registration[providerType]){logger.debug("Start to load and register the '".concat(providerType,"' providers"));var providersToLoad=Array.isArray(providers[providerType])?providers[providerType]:[providers[providerType]];return registration[providerType](providersToLoad).then(function(loaded){return logger.debug("'".concat(providerType,"' providers are loaded and registered")),_defineProperty({},providerType,loaded)})}logger.warn("Ignoring the '".concat(providerType,"' providers loading, no registration method found"))})).then(function(results){return results.reduce(function(acc,value){return Object.assign(acc,value)},{})}).catch(function(err){throw logger.error("Error in test runner providers and plugins loading : ".concat(err.message)),err})}}),define("taoTests/runner/proxy/sample",[],function(){'use strict';return{init:function(){return new Promise(function(resolve){resolve()})},destroy:function(){return new Promise(function(resolve){resolve()})},getTestData:function(){return new Promise(function(resolve){resolve()})},getTestContext:function(){return new Promise(function(resolve){resolve()})},callTestAction:function(){return new Promise(function(resolve){resolve()})},getItem:function(){return new Promise(function(resolve){resolve()})},submitItem:function(){return new Promise(function(resolve){resolve()})},callItemAction:function(){return new Promise(function(resolve){resolve()})},telemetry:function(){return new Promise(function(resolve){resolve()})}}}),define("taoTests/runner/runnerComponent",["lodash","ui/component","taoTests/runner/runner","taoTests/runner/providerLoader","handlebars"],function(_,component,runnerFactory,providerLoader,Handlebars){'use strict';function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},_typeof(obj)}function runnerComponentTpl(data,options,asString){var html=Template(data,options);return asString||!0?html:$(html)}function validateTestRunnerConfiguration(){var config=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},requiredProperties=["providers","options","serviceCallId"];if("object"!==_typeof(config))throw new TypeError("The runner configuration must be an object, '".concat(_typeof(config),"' received"));if(requiredProperties.some(function(property){return"undefined"==typeof config[property]}))throw new TypeError("The runner configuration must contains at least the following properties : ".concat(requiredProperties.join(",")));return!0}function getSelectedProvider(){var type=0<arguments.length&&arguments[0]!==void 0?arguments[0]:"runner",config=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{};if(config.provider&&config.provider[type])return config.provider[type];if(config.providers&&config.providers[type]){var typeProviders=config.providers[type];if("object"===_typeof(typeProviders)&&(typeProviders.id||typeProviders.name))return typeProviders.id||typeProviders.name;if(Array.isArray(typeProviders)&&0<typeProviders.length)return typeProviders[0].id||typeProviders[0].name}return!1}function runnerComponentFactory(){var container=0<arguments.length&&arguments[0]!==void 0?arguments[0]:null,config=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{},template=2<arguments.length&&arguments[2]!==void 0?arguments[2]:runnerComponentTpl,runner=null,plugins=[];if(!container)throw new TypeError("A container element must be defined to contain the runnerComponent");validateTestRunnerConfiguration(config);var runnerComponent=component({getOption:function(name){return this.config.options[name]},getRunner:function(){return runner}}).setTemplate(template).on("init",function(){var _this=this;return providerLoader(config.providers,config.loadFromBundle).then(function(results){results&&results.plugins&&(plugins=results.plugins),_this.render(container),_this.hide()}).catch(function(err){return _this.trigger("error",err)})}).on("render",function(){var _this2=this,runnerConfig=Object.assign(_.omit(this.config,["providers"]),{renderTo:this.getElement()});runnerConfig.provider=Object.keys(this.config.providers).reduce(function(acc,providerType){return acc[providerType]||"plugins"===providerType||(acc[providerType]=getSelectedProvider(providerType,_this2.config)),acc},runnerConfig.provider||{}),runner=runnerFactory(runnerConfig.provider.runner,plugins,runnerConfig).on("ready",function(){_.defer(function(){_this2.setState("ready").trigger("ready",runner).show()})}).on("destroy",function(){return runner=null}).spread(this,"error").init()}).on("destroy",function(){var destroying=runner&&runner.destroy();return runner=null,destroying}).after("destroy",function(){this.removeAllListeners()});return runnerComponent.init(config)}_=_&&Object.prototype.hasOwnProperty.call(_,"default")?_["default"]:_,component=component&&Object.prototype.hasOwnProperty.call(component,"default")?component["default"]:component,runnerFactory=runnerFactory&&Object.prototype.hasOwnProperty.call(runnerFactory,"default")?runnerFactory["default"]:runnerFactory,providerLoader=providerLoader&&Object.prototype.hasOwnProperty.call(providerLoader,"default")?providerLoader["default"]:providerLoader,Handlebars=Handlebars&&Object.prototype.hasOwnProperty.call(Handlebars,"default")?Handlebars["default"]:Handlebars;var Template=Handlebars.template(function(Handlebars,depth0,helpers){return this.compilerInfo=[4,">= 1.0.0"],helpers=this.merge(helpers,Handlebars.helpers),"<div class=\"runner-component\"></div>\n"});return runnerComponentFactory}),define("taoTests/runner/testStore",["lodash","core/store","core/logger"],function(_,store,loggerFactory){'use strict';function testStoreLoader(testId,preselectedBackend){var testMode,storeNames=[],volatiles=[],changeTracking={},isStoreModeUnified=function(){return _.isUndefined(testMode)?selectStoreMode(testId,preselectedBackend).then(function(result){return testMode=result&&"undefined"!=typeof modes[result]?result:modes.unified,logger.debug("Test store mode ".concat(result," for ").concat(testId)),result===modes.unified}):Promise.resolve(testMode===modes.unified)};if(_.isEmpty(testId))throw new TypeError("The store must be identified with a unique test identifier");return{getStore:function(storeName){var trackChange=function(){_.isBoolean(changeTracking[storeName])&&(changeTracking[storeName]=!0)};if(_.isEmpty(storeName))throw new TypeError("A store name must be provided to get the store");return _.contains(storeNames,storeName)||storeNames.push(storeName),isStoreModeUnified().then(function(isUnified){var loadStore;return loadStore=isUnified?store(testId,preselectedBackend):store("".concat(storeName,"-").concat(testId),preselectedBackend),loadStore.then(function(loadedStore){var keyPattern=new RegExp("^".concat(storeName,"__")),storeKey=function(key){return isUnified?"".concat(storeName,"__").concat(key):key};return{getItem:function(key){return loadedStore.getItem(storeKey(key))},getItems:function(){return isUnified?loadedStore.getItems().then(function(entries){return _.transform(entries,function(acc,entry,key){return keyPattern.test(key)&&(acc[key.replace(keyPattern,"")]=entry),acc},{})}):loadedStore.getItems()},setItem:function(key,value){return trackChange(),loadedStore.setItem(storeKey(key),value)},removeItem:function(key){return trackChange(),loadedStore.removeItem(storeKey(key))},clear:function(){return trackChange(),isUnified?loadedStore.getItems().then(function(entries){_.forEach(entries,function(entry,key){keyPattern.test(key)&&loadedStore.removeItem(key)})}):loadedStore.clear()}}})})},setVolatile:function(storeName){return _.contains(volatiles,storeName)||volatiles.push(storeName),this},clearVolatileIfStoreChange:function(storeId){var self=this,shouldClear=!1;return store.getIdentifier(preselectedBackend).then(function(savedStoreId){return _.isEmpty(storeId)||_.isEmpty(savedStoreId)||savedStoreId===storeId||(logger.info("Storage change detected (".concat(savedStoreId," != ").concat(storeId,") => volatiles data wipe out !")),shouldClear=!0),shouldClear}).then(function(clear){return!!clear&&self.clearVolatileStores()})},clearVolatileStores:function(){var self=this,clearing=volatiles.map(function(storeName){return self.getStore(storeName).then(function(storeInstance){return storeInstance.clear()})});return Promise.all(clearing).then(function(results){return results&&results.length===volatiles.length})},startChangeTracking:function(storeName){return changeTracking[storeName]=!1,this},hasChanges:function(storeName){return!0===changeTracking[storeName]},resetChanges:function(storeName){return _.isBoolean(changeTracking[storeName])&&(changeTracking[storeName]=!1),this},remove:function(){var legacyStoreExp=new RegExp("-".concat(testId,"$"));return isStoreModeUnified().then(function(isUnified){return isUnified?store(testId,preselectedBackend).then(function(storeInstance){return storeInstance.removeStore()}):store.removeAll(function(storeName){return legacyStoreExp.test(storeName)},preselectedBackend)})},getStorageIdentifier:function(){return store.getIdentifier(preselectedBackend)}}}_=_&&Object.prototype.hasOwnProperty.call(_,"default")?_["default"]:_,store=store&&Object.prototype.hasOwnProperty.call(store,"default")?store["default"]:store,loggerFactory=loggerFactory&&Object.prototype.hasOwnProperty.call(loggerFactory,"default")?loggerFactory["default"]:loggerFactory;var logger=loggerFactory("taoQtiTest/runner/provider/testStore"),legacyPrefixes=["actions-","duration-","test-probe","timer-"],modes={unified:"unified",fragmented:"fragmented"},selectStoreMode=function(testId,preselectedBackend){return store.getAll(function(storeName){return _.some(legacyPrefixes,function(prefix){return!_.isEmpty(storeName)&&prefix+testId===storeName})},preselectedBackend).then(function(foundStores){return _.isArray(foundStores)&&0<foundStores.length?modes.fragmented:modes.unified})};return testStoreLoader}),define("taoTests/loader/taoTestsRunner.bundle",function(){}),define("taoTests/loader/taoTestsRunner.min",["taoItems/loader/taoItems.min"],function(){});
|
|
//# sourceMappingURL=taoTestsRunner.min.js.map
|