Skip to content

Commit

Permalink
Merge pull request #4427 from Cookiezaurs/master
Browse files Browse the repository at this point in the history
[SER-793]Fixes for views tests
  • Loading branch information
Cookiezaurs authored Aug 2, 2023
2 parents 124a47a + 0716957 commit c717b9d
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions plugins/views/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var APP_ID = "";
//recalculate
var myTime = Date.now();
var start = new Date(new Date().getFullYear(), 0, 0);
var startMonth = new Date(new Date().getFullYear(), new Date().getMonth(), 0);

var tableResponse = {};
var userObject = {};
Expand All @@ -32,6 +33,7 @@ graphResponse.yesterday = {};
graphResponse["30days"] = {};

var days_this_year;
var days_this_month;

function pushValues(period, index, map) {
for (var key in map) {
Expand Down Expand Up @@ -241,7 +243,9 @@ describe('Testing views plugin', function() {
describe('verify empty views tables', function() {
it('should have 0 views', function(done) {
days_this_year = Math.floor((myTime - start) / (1000 * 24 * 60 * 60));
console.log("days left in this year:" + days_this_year);
days_this_month = Math.floor((myTime - startMonth) / (1000 * 24 * 60 * 60));
console.log("days gone in this month:" + days_this_month);
console.log("days gone in this year:" + days_this_year);
API_KEY_ADMIN = testUtils.get("API_KEY_ADMIN");
APP_ID = testUtils.get("APP_ID");
APP_KEY = testUtils.get("APP_KEY");
Expand Down Expand Up @@ -300,8 +304,12 @@ describe('Testing views plugin', function() {
tableResponse.yesterday.iTotalRecords += 1;
tableResponse.yesterday.iTotalDisplayRecords += 1;
pushValues("yesterday", 0, {"u": 1, "t": 1, "s": 1, "uvalue": 1, "view": "testview0"});

pushValues("30days", 0, {"u": 1, "t": 1, "s": 1, "uvalue": 1});
if (days_this_month < 2) {
pushValues("30days", 0, {"u": 1, "t": 1, "s": 1});
}
else {
pushValues("30days", 0, {"u": 1, "t": 1, "s": 1, "uvalue": 1});
}

tableResponse["7days"].iTotalRecords += 1;
tableResponse["7days"].iTotalDisplayRecords += 1;
Expand Down Expand Up @@ -336,7 +344,13 @@ describe('Testing views plugin', function() {
tableResponse.hour.iTotalRecords += 1;
tableResponse.hour.iTotalDisplayRecords += 1;
pushValues("hour", 0, {"u": 1, "t": 1, "s": 1, "uvalue": 1});
pushValues("30days", 0, {"u": 1, "t": 1, "s": 1, 'uvalue': 1});

if (days_this_month > 1) {
pushValues("30days", 0, {"u": 1, "t": 1, "s": 1});
}
else {
pushValues("30days", 0, {"u": 1, "t": 1, "s": 1, "uvalue": 1});
}

tableResponse.month.iTotalRecords = 1;
tableResponse.month.iTotalDisplayRecords = 1;
Expand Down

0 comments on commit c717b9d

Please sign in to comment.