Write test for Client Script by ATF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2018 07:20 PM
Hi,
Can we write a test for client side like a unit test ? If it can, can you guys show me an example for my client script below
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('EmailValid');
ga.addParam('sysparm_name','isEmailValid');
ga.addParam('sysparm_id', newValue);
ga.getXML(processCallback);
function processCallback(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'false') {
var ga = new GlideAjax('CM_02');
ga.addParam('sysparm_name','isMessage');
ga.addParam('sysparm_id', 'email');
ga.getXMLAnswer(function(CM02Answer){
g_form.addErrorMessage(CM02Answer);
});
g_form.clearValue('email');
setTimeout(function() {
g_form.clearMessages();
}, 2000);
} else {
return true;
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2019 05:51 AM
Did you ever find a solution? I'm looking for the effectively same thing. I am going to dig into the server-side script test to see if I can replicate the functionality, but that's not the same as actually testing it. In my case, the glide ajax updates the choice list in a SelectBox variable based on a group role.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2019 02:39 PM
Adam , I believe you should be able to test the script functionality on the server side, but on the Client Side you might be able to check dropdown values by impersonating the qualified user and setting the drop down values one by one on the form .