Facing error while Testing
I have updated the facebook_cb_hs.js
file.
While automatic testing on gitlab, there was a error,I have attached it below.
What I did ?
I looked into the codebase, and found that tests for the same looks for SSS
class , and then verifies.
Initial code was :
request.onreadystatechange = function () {
if (request.readyState === 4) {
if (request.status === 200) {
var data = JSON.parse(request.responseText);
var clickbait_probability = data.Result;
var clickbait_label = document.createElement('div');
if (clickbait_probability > 0.9) {
clickbait_label.style.textDecoration = 'underline';
clickbait_label.style.color = 'rgb(128, 0, 0)';
clickbait_label.style.fontSize = '18px';
clickbait_label.setAttribute('class', 'SSS');
clickbait_label.style.textAlign = 'right';
clickbait_label.textContent = 'Clickbait';
} else if ( (clickbait_probability > 0.6) && (clickbait_probability < 0.9) ) {
clickbait_label.style.textDecoration = 'underline';
clickbait_label.style.color = 'rgb(' + Number((clickbait_probability) * 1.28).toFixed(0) + ', ' + Number((100 - clickbait_probability) * 1.28).toFixed(0) + ', 0)';
//console.log(clickbait_banner.style.color);
clickbait_label.style.textAlign = 'right';
clickbait_label.setAttribute('class', 'SSS');
clickbait_label.style.fontSize = '18px';
var probability= Math.round(clickbait_probability*100);
clickbait_label.textContent = (probability) + '% Clickbait';
}
Since SSS class will only be set when probability is above 0.6, hence the test case should show error.
New Changes :
var request = new XMLHttpRequest();
request.onreadystatechange = function () {
if (request.readyState === 4) {
if (request.status === 200) {
var data = JSON.parse(request.responseText);
var clickbait_probability = data.Result;
var clickbait_label = document.createElement('div');
clickbait_label.setAttribute('class', 'SSS');
if (clickbait_probability > 0.9) {
clickbait_label.style.textDecoration = 'underline';
clickbait_label.style.color = 'rgb(128, 0, 0)';
clickbait_label.style.fontSize = '18px';
clickbait_label.style.textAlign = 'right';
clickbait_label.textContent = 'Clickbait';
} else if ( (clickbait_probability > 0.6) && (clickbait_probability < 0.9) ) {
clickbait_label.style.textDecoration = 'underline';
clickbait_label.style.color = 'rgb(' + Number((clickbait_probability) * 1.28).toFixed(0) + ', ' + Number((100 - clickbait_probability) * 1.28).toFixed(0) + ', 0)';
//console.log(clickbait_banner.style.color);
clickbait_label.style.textAlign = 'right';
clickbait_label.style.fontSize = '18px';
var probability= Math.round(clickbait_probability*100);
clickbait_label.textContent = (probability) + '% Clickbait';
}
Hence it would set the SSS
class.
But I still get the same error.
Could you please help me ? @us241098 ,@pranavgoyanka