Error during loading: Uncaught ReferenceError: jqxBaseFramework is not defined - karma-jasmine

Error during loading: Uncaught ReferenceError: jqxBaseFramework is not defined in http://localhost:9876/_karma_webpack_/vendor.js line 125124
getting this error in jasmin unit testing
switch (item) {
case 'Add Privilage':
selectedItem = this.myTree.getSelectedItem();
// document.getElementById("Update").click();
if (selectedItem != null) {
this.selectedParentName = selectedItem.label;
this.selectedParentUId = selectedItem.value.privilegeId;
this.showAddPrivilageDiv = true;
// this.myTree.addTo({ label: 'Item' }, selectedItem.element);
}

Related

Unhandled promise rejection, testcafe upgrade v1.19.0/1.20.0

After I have upgraded testcafe from v1.9.0 into v1.19.0. Then one of the test starts failing with following error :
Unhandled promise rejection:
{
code: 'E1',
isTestCafeError: true,
callsite: CallsiteRecord {
filename: 'file-path',
lineNum: 8,
callsiteFrameIdx: 4,
stackFrames: [
[Object], [Object],
[Object], [Object],
[Object], CallSite {},
[Object], [Object],
[Object], CallSite {},
[Object], [Object],
[Object], [Object]
],
isV8Frames: true
},
errStack: 'TypeError: Illegal invocation\n at r._removeInternalProperties (hammerhead.js:16:5547)\n at r.dispose (hammerhead.js:16:5776)\n at t.eval (hammerhead.js:16:5310)\n at e.emit (hammerhead.js:4:7566)\n at t._emitEvent (hammerhead.js:15:3098)\n at t.handleEvent (hammerhead.js:15:5541)\n at HTMLBodyElement.setter [as innerHTML] (http://localhost:58539/hammerhead.js:13:5643)\n at file:'file-path'\n at c ('file-path')',
pageDestUrl: 'file-path',
id: '0atD-CZ'
}
It seems that it is related with hammerhead.js package. Currently we are handling that error, by added additional try/catch for it. However I'd like to understand why it is happening. The function works fine in multiple other tests with similar logic.
Function :
return new Promise((resolve, reject) => {
const timerStart = new Date().getTime();
let tryCount = 0;
const testInterval = setInterval(async () => {
const { log } = await t.getBrowserConsoleMessages();
let filteredLogs = [];
if (typeof expectedValue === 'string') {
filteredLogs = exactMatch
? log.filter((line) => line === expectedValue)
: log.filter((line) => line.includes(expectedValue));
} else if (expectedValue instanceof RegExp) {
filteredLogs = log.filter((line) => expectedValue.test(line));
}
tryCount++;
const correctCount = exactCount ? filteredLogs.length === exactCount : true;
if (filteredLogs.length && correctCount) {
clearInterval(testInterval);
resolve(await t.expect(filteredLogs.length && correctCount).ok());
}
if (new Date().getTime() - timerStart > timeout) {
let errorMessage = '';
if (filteredLogs.length && !correctCount) {
errorMessage = `Console log "${expectedValue}" was expected ${exactCount} time(s) but found ${filteredLogs.length} time(s).`;
}
if (!filteredLogs.length) {
errorMessage = `Console log "${expectedValue}" not found after ${timeout} ms and ${tryCount} attempts.`;
}
clearInterval(testInterval);
reject(new Error(errorMessage));
}
}, 500);
});

I am writing a client side code to retreive a record but facing the below issue

I am writing this code using Xrm.Webapi.RetreiveRecord as below but I am getting the below error when debugging.
TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
if (typeof (ContosoPermit) == "undefined") { var ContosoPermit = { __namespace: true }; }
if (typeof (ContosoPermit.Scripts) == "undefined") { ContosoPermit.Scripts = { __namespace: true }; }
ContosoPermit.Scripts.PermitForm = {
handleOnLoad: function (executionContext) {
console.log('on load - permit form');
},
handleOnChangePermitType: function (executionContext)
{
console.log('on change - permit type');
},
_handlePermitTypeSettings: function (executionContext) {
var formContext = executionContext.getFormContext();
var permitType = formContext.getAttribute("contoso_permittype").getValue();
if (permitType == null) {
formContext.ui.tabs.get("inspectionsTab").setVisible(false);
return;
} else {
var permitTypeID = permitType[0].id;
debugger;
Xrm.WebApi.retrieveRecord("contoso_permittype", permitTypeID).then(
function success(result) {
if (result.contoso_requireinspections) {
formContext.ui.tabs.get("inspectionstab").setVisible(true);
}
else {
formContext.ui.tabs.get("inspectionstab").setVisible(false);
}
},
function (error) { alert('Error' + error.message) });
}
},
__namespace: true
}

Karma TypeError: Cannot set properties of undefined (setting 'pageSize')

Below is my Angular code,
#ViewChild('commandtable') commandtable!: NgbdTableComplete;
processResponse(): void {
this.searchService
.getCommandsID(this.url, this.commandtable.pageSize)
.subscribe((res) => {
let response: CommmandsQuery = JSON.parse(JSON.stringify(res));
this.readCommands(response);
this.display_cards = true;
});
}
processLoadMoreResponse (token: string, size: number) {
this.commandtable.pageSize = size;
this.processResponse();
}
In karma test file :
it('processLoadMoreResponse ', () => {
(component as any).commandtable.pageSize = 1;
spyOn((component as any),'processResponse');
component.processLoadMoreResponse ('tocken', 3);
expect((component as any).processResponse).toHaveBeenCalled();
expect((component as any).processResponse).toHaveBeenCalledTimes(1);
});
when I run the test I get the below error
TypeError: Cannot set properties of undefined (setting 'pageSize')

Render a template in a onchage of text field in odoo 14

I am trying to render a template in onchange of a input field.
Here is the onchange method.
*.js
_onClickBasketInputChange: function(){
console.log('inside input change',this.basketVerificationId);
var self = this;
var barcode = $('.basket_barcode_input').val();
console.log('barcode',barcode);
// var rec = this._rpc({
return this._rpc({
model: 'mobile.basket.verification',
method: 'get_picking_details',
args: [this.basketVerificationId,barcode],
}).then(function(res){
// console.log('this',self);
console.log('picking_id',res);
var $body = this.$el.filter('.o_barcode_lines');// Here i am getting the error ' Uncaught (in promise) TypeError: this is undefined'
console.log('body',$body);
if (res['status'] == true){
console.log('successs');
var $lines = $(Qweb.render('basketVerificationLines', {
picking:res['picking_id'],
customer:res['partner_id'],
lines:res['line_ids']
}));
$body.prepend($lines);
}
// $('.basket_barcode_input').val('');
var message = res['result'];
if (res['status'] == false){
Dialog.alert(self, message);
}
});
},
But i am getting following error
Uncaught (in promise) TypeError: this is undefined
Update:
When change this to self, the value of $body is
body
Object { length: 0, prevObject: {…} }
​
length: 0
​
prevObject: Object { 0: div.o_action, length: 1 }
​
And the template not prepend to the body.
Please help to resolve this.
I got the solution,
I replace the .filter with .find then it works.
var $body = self.$el.find('.o_barcode_lines');

IBM Worklight 6.0 - Getting "Uncaught type error cannot call method 'initCollection' of undefined"

I'm working with Worklight to build an application which uses a local storage. I declared a function createCollection() in common/js/myApp.js.
However when I run it on the browser simulator, the console JavaScript shows:
Uncaught TypeError: Cannot call method 'initCollection' of undefined.
Any suggestions?
My JavaScript:
function wlCommonInit(){
// Common initialization code goes here
}
// inizializzazione json
window.onload = createCollection;
var isOpen = true;
var menuboxw = $("#menubox").css("width");
$("#contentbox").css("left",menuboxw);
var headerh = $("#header").height();
$("#contentbox").css("top", headerh);
$("#menu_btn").click(function(){menu()});
// apertura/chiusura menu principale
function menu() {
if(isOpen){
$('#contentbox').animate({ left: -5 }, 1);
$("#menubox").css("visibility", "hidden");
isOpen = false;
}
else{
$('#contentbox').animate({ left: menuboxw }, 1);
$("#menubox").css("visibility", "visible");
isOpen = true;
}
}
// creazione collection 'canti' e 'categorie'
function createCollection(){
WL.Logger.debug("Called createCollection");
WL.SimpleDialog.show("Message", "createCollection called", [{text: "Ok"}]);
var collectionCanti = "canti";
var searchFieldsCanti = {titolo: "string", autore: "string", id_categoria: "string", testo: "string"};
var collectionCategorie = "categorie";
var searchFieldsCategorie = {titolo: "string", attiva: "number"};
var success = function(data){
logMessage("Collection created successfully " + data);
};
var failure = function(data){
logMessage("Collection doesn't created " + data);
};
var options = {onSuccess: success, onFailure: failure};
canti = WL.JSONStore.initCollection(collectionCanti, searchFieldsCanti, options);
categorie = WL.JSONStore.initCollection(collectionCategorie, searchFieldsCategorie, options);
}
Do the following:
Remove window.onload = createCollection;
Add createCollection(); inside wlCommonInit()
BTW, that logMessage produces errors. Should probably be changed to WL.Logger.debug (which you are already utilizing in the code...).
Please go over the IBM Worklight Getting Started training material. No skipping.