New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addMockModule with angular-mocks has problem with large response json #3212

Closed
jlin412 opened this Issue May 11, 2016 · 10 comments

Comments

Projects
None yet
8 participants
@jlin412

jlin412 commented May 11, 2016

I have been using addMockModule with angular-mocks for a while and never have any issue until I upgrade to protractor 3.2.1+. When I do the browser.refresh(); It is just loading forever.

  • Node Version: 4.2.2
  • Protractor Version: 3.2.1+
  • Browser(s): chrome/firefox
  • Operating System and Version Mac/Windows

Function To addMockModule

'use strict';
var fs = require('fs'),
  requireDir = require('require-dir'),
  mockSources = requireDir('../mocks');

global.mocks = {};

_.forEach(mockSources, function (source, sourceFileName) {
  var shortFileName = sourceFileName.replace('.js$', '');
  mocks[shortFileName] = mocks[shortFileName] || {};
  _.forEach(source, function (interceptorArray, nameOfInterceptor) {
    mocks[shortFileName][nameOfInterceptor] = function () {
      return registerInterceptors(interceptorArray);
    };
  });
});


function registerInterceptors(interceptors) {

  var angularMockSrc = fs.readFileSync('./node_modules/angular-mocks/angular-mocks.js');

  _.forEach(interceptors, function(interceptor) {
    if(interceptor.response.dataContainsEvals) {
      interceptor.response.data = processEvals(interceptor.response.data);
    }
  });

  browser.addMockModule('test.mockModule', function () {
    var args = Array.prototype.slice.call(arguments);
    eval(args[0]);
    /* eslint no-eval: 0 */

    angular.module('test.mockModule', ['ngMockE2E'])

        .run(['$httpBackend', function ($httpBackend) {
          var methods = {
            'GET': 'whenGET',
            'POST': 'whenPOST',
            'PUT': 'whenPUT',
            'DELETE': 'whenDELETE'
          };
          args[1].forEach(function (interceptor) {
            interceptor.response = interceptor.response || {};
            $httpBackend[methods[interceptor.method || 'GET']](new RegExp(interceptor.url)).respond(function () {
              return [
                interceptor.response.code || 200,
                interceptor.response.data || {},
                interceptor.response.headers || {}
              ];
            });
          });
          $httpBackend.whenPOST(/.+/).passThrough();
          $httpBackend.whenGET(/.+/).passThrough();
          $httpBackend.whenPUT(/.+/).passThrough();
          $httpBackend.whenDELETE(/.+/).passThrough();
        }]);
  }, angularMockSrc.toString(), interceptors || []);

  return browser.refresh();
}

/**
 * This processes JSON objects where values contain javascript expression.
 *
 * Example
 *  var myObject = {startDate: "{{eval('moment().format(moment.ISO_8601())')}}"};
 *  processEvals(myObject) => {startDate: "2015-07-22T10:19:26-04:00"}
 *
 * @param data
 * @returns {*}
 */
function processEvals(data) {
  var evalFunction = function(str) {
    var expression = str.replace(/\{\{eval\('([^}]*?)'\)\}\}/g,'$1');
    return eval(expression);
  };

  data = JSON.stringify(data);
  data = data.replace(/\{\{eval\('([^}]*?)\}\}/g, evalFunction);
  return JSON.parse(data);
}

API Mock

module.exports = {
  phantomPunch: [
    {
      'url': '\/v1_0\/O\/A\/timeEntryDetails',
      'response': {
        code: 200,
        data: require('./time/TED-TimestampHourly-phantom-punch.json')
      }
    }
  ]
};

data response

{
  "timeEntryDetails": {
    "timeConfiguration": [
      {
        "positionID": {
          "id": "G3QZ7HZNMTFT8BMH",
          "schemeName": "",
          "schemeAgencyName": "Enterprise eTIME"
        },
        "clockReferenceDateTime": "2015-05-28T17:09:26-04:00",
        "timeNotationCode": "12h",
        "noteIndicator": true,
        "privateNoteIndicator": false,
        "clockPolicy": {
          "entryButtons": [
            {
              "labelName": "Clock In",
              "actionCode": "clockin",
              "enableIndicator": true
            },
            {
              "labelName": "Transfer",
              "actionCode": "transfer",
              "enableIndicator": true
            }
          ],
          "entryTypeCode": "clockEntry",
          "policyExpireDateTime": "2015-05-28T18:08:28-04:00",
          "validGeoLocations": [
            {
              "id": "1",
              "coordinate": {
                "longitude": -74.424555,
                "latitude": 40.87489
              },
              "range": {
                "unitValue": 2000,
                "unitCode": "Miles"
              },
              "locationRef": {
                "address": {
                  "cityName": "Parsippany",
                  "countrySubdivisionCode": "NJ"
                }
              }
            },
            {
              "id": "2",
              "coordinate": {
                "longitude": -74.584307,
                "latitude": 40.876787
              },
              "range": {
                "unitValue": 2000,
                "unitCode": "Miles"
              },
              "locationRef": {
                "address": {
                  "cityName": "Mine Hill",
                  "countrySubdivisionCode": "NJ"
                }
              }
            },
            {
              "id": "22",
              "coordinate": {
                "longitude": -84.388343,
                "latitude": 33.756529
              },
              "range": {
                "unitValue": 2000,
                "unitCode": "Miles"
              },
              "locationRef": {
                "address": {
                  "cityName": "atlanta",
                  "countrySubdivisionCode": "ga"
                }
              }
            },
            {
              "id": "41",
              "coordinate": {
                "longitude": -60.01819,
                "latitude": -3.10468
              },
              "range": {
                "unitValue": 0,
                "unitCode": "Miles"
              },
              "locationRef": {
                "address": {
                  "cityName": "",
                  "countrySubdivisionCode": ""
                }
              }
            },
            {
              "id": "61",
              "coordinate": {
                "longitude": -75.471462,
                "latitude": 35.536935
              },
              "range": {
                "unitValue": 0,
                "unitCode": "Miles"
              },
              "locationRef": {
                "address": {
                  "cityName": "",
                  "countrySubdivisionCode": ""
                }
              }
            },
            {
              "id": "62",
              "coordinate": {
                "longitude": -74.309315,
                "latitude": 40.816636
              },
              "range": {
                "unitValue": 0,
                "unitCode": "Miles"
              },
              "locationRef": {
                "address": {
                  "cityName": "",
                  "countrySubdivisionCode": ""
                }
              }
            },
            {
              "id": "81",
              "coordinate": {
                "longitude": -122.030332,
                "latitude": 37.331741
              },
              "range": {
                "unitValue": 2,
                "unitCode": "Miles"
              },
              "locationRef": {
                "address": {
                  "cityName": "",
                  "countrySubdivisionCode": ""
                }
              }
            },
            {
              "id": "101",
              "coordinate": {
                "longitude": -86.17193,
                "latitude": 31.217937
              },
              "range": {
                "unitValue": 5,
                "unitCode": "Miles"
              },
              "locationRef": {
                "address": {
                  "cityName": "",
                  "countrySubdivisionCode": ""
                }
              }
            },
            {
              "id": "102",
              "coordinate": {
                "longitude": -119.417932,
                "latitude": 36.778261
              },
              "range": {
                "unitValue": 3,
                "unitCode": "Miles"
              },
              "locationRef": {
                "address": {
                  "cityName": "",
                  "countrySubdivisionCode": ""
                }
              }
            },
            {
              "id": "103",
              "coordinate": {
                "longitude": -74.005941,
                "latitude": 40.712783
              },
              "range": {
                "unitValue": 9,
                "unitCode": "Miles"
              },
              "locationRef": {
                "address": {
                  "cityName": "",
                  "countrySubdivisionCode": ""
                }
              }
            },
            {
              "id": "104",
              "coordinate": {
                "longitude": 55.4725,
                "latitude": 23.814045
              },
              "range": {
                "unitValue": 4,
                "unitCode": "Miles"
              },
              "locationRef": {
                "address": {
                  "cityName": "",
                  "countrySubdivisionCode": ""
                }
              }
            },
            {
              "id": "105",
              "coordinate": {
                "longitude": -82.907123,
                "latitude": 40.417287
              },
              "range": {
                "unitValue": 4,
                "unitCode": "Miles"
              },
              "locationRef": {
                "address": {
                  "cityName": "",
                  "countrySubdivisionCode": ""
                }
              }
            }
          ],
          "allowBypassIndicator": true,
          "validationTables": [
            {
              "labelName": "Division",
              "tableID": "Division",
              "typeCode": "earningAllocation",
              "requiredIndicator": false,
              "tableUri": {
                "href": "\/v1_0\/O\/A\/table\/earningAllocation\/Division"
              }
            },
            {
              "labelName": "Department",
              "tableID": "Department",
              "typeCode": "earningAllocation",
              "requiredIndicator": false,
              "tableUri": {
                "href": "\/v1_0\/O\/A\/table\/earningAllocation\/Department"
              }
            },
            {
              "labelName": "Region",
              "tableID": "Region",
              "typeCode": "earningAllocation",
              "requiredIndicator": false,
              "tableUri": {
                "href": "\/v1_0\/O\/A\/table\/earningAllocation\/Region"
              }
            },
            {
              "labelName": "Job",
              "tableID": "Job",
              "typeCode": "earningAllocation",
              "requiredIndicator": false,
              "tableUri": {
                "href": "\/v1_0\/O\/A\/table\/earningAllocation\/Job"
              }
            },
            {
              "labelName": "Location",
              "tableID": "Location",
              "typeCode": "earningAllocation",
              "requiredIndicator": false,
              "tableUri": {
                "href": "\/v1_0\/O\/A\/table\/earningAllocation\/Location"
              }
            },
            {
              "labelName": "Section",
              "tableID": "Section",
              "typeCode": "earningAllocation",
              "requiredIndicator": false,
              "tableUri": {
                "href": "\/v1_0\/O\/A\/table\/earningAllocation\/Section"
              }
            },
            {
              "labelName": "Job Code",
              "tableID": "Job Code",
              "typeCode": "earningAllocation",
              "requiredIndicator": false,
              "tableUri": {
                "href": "\/v1_0\/O\/A\/table\/earningAllocation\/Job%20Code"
              }
            },
            {
              "labelName": "Work Rule",
              "tableID": "Work Rule",
              "typeCode": "earningAllocation",
              "requiredIndicator": false,
              "tableUri": {
                "href": "\/v1_0\/O\/A\/table\/earningAllocation\/Work%20Rule"
              }
            },
            {
              "labelName": "Comments",
              "tableID": "commentCategory",
              "typeCode": "entryComments",
              "requiredIndicator": false,
              "table": {
                "tableName": "Comments",
                "header": {
                  "numberOfColumns": 2,
                  "columns": [
                    {
                      "columnName": "Comment Text",
                      "primaryKeyIndicator": true,
                      "userVisibleIndicator": true
                    },
                    {
                      "columnName": "entryTypeCategoryCode",
                      "primaryKeyIndicator": false,
                      "userVisibleIndicator": false
                    }
                  ]
                },
                "tableRows": [
                  {
                    "columnValues": [
                      "Left Early",
                      "Punch"
                    ]
                  },
                  {
                    "columnValues": [
                      "Left Early",
                      "PayCode"
                    ]
                  },
                  {
                    "columnValues": [
                      "Mobile",
                      "Punch"
                    ]
                  },
                  {
                    "columnValues": [
                      "Mobile",
                      "PayCode"
                    ]
                  },
                  {
                    "columnValues": [
                      "Mobile Location",
                      "Punch"
                    ]
                  },
                  {
                    "columnValues": [
                      "Mobile Location",
                      "PayCode"
                    ]
                  },
                  {
                    "columnValues": [
                      "Running Late",
                      "Punch"
                    ]
                  },
                  {
                    "columnValues": [
                      "Running Late",
                      "PayCode"
                    ]
                  },
                  {
                    "columnValues": [
                      "Sick",
                      "Punch"
                    ]
                  },
                  {
                    "columnValues": [
                      "Tech",
                      "PayCode"
                    ]
                  }
                ]
              }
            },
            {
              "labelName": "Applies To",
              "tableID": "noteAppliesToEntryType",
              "typeCode": "entryNoteAppliesTo",
              "requiredIndicator": false,
              "table": {
                "tableName": "Applies To",
                "header": {
                  "numberOfColumns": 2,
                  "columns": [
                    {
                      "columnName": "Description",
                      "primaryKeyIndicator": true,
                      "userVisibleIndicator": true
                    },
                    {
                      "columnName": "entryTypeCode",
                      "primaryKeyIndicator": false,
                      "userVisibleIndicator": false
                    }
                  ]
                },
                "tableRows": [
                  {
                    "columnValues": [
                      "Start Time",
                      "timePairEntry"
                    ]
                  },
                  {
                    "columnValues": [
                      "End Time",
                      "timePairEntry"
                    ]
                  },
                  {
                    "columnValues": [
                      "Entry",
                      "hoursEntry"
                    ]
                  },
                  {
                    "columnValues": [
                      "Entry",
                      "unitEntry"
                    ]
                  },
                  {
                    "columnValues": [
                      "Entry",
                      "amountEntry"
                    ]
                  }
                ]
              }
            }
          ]
        },
        "earningEntryPolicy": {
          "entryCodes": [
            {
              "code": "Time Pair Entry",
              "codeName": "Time Pair Entry",
              "entryTypeCode": "timePairEntry",
              "entryTypeCategoryCode": "Punch",
              "defaultIndicator": true
            },
            {
              "code": "Regular",
              "codeName": "Regular",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Vacation",
              "codeName": "Vacation",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Personal",
              "codeName": "Personal",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Sick",
              "codeName": "Sick",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Overtime",
              "codeName": "Overtime",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "$401K",
              "codeName": "$401K",
              "entryTypeCode": "amountEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "$Auto",
              "codeName": "$Auto",
              "entryTypeCode": "amountEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "$Birthday",
              "codeName": "$Birthday",
              "entryTypeCode": "amountEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "$Childcare",
              "codeName": "$Childcare",
              "entryTypeCode": "amountEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "$Clothing",
              "codeName": "$Clothing",
              "entryTypeCode": "amountEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "$FSA",
              "codeName": "$FSA",
              "entryTypeCode": "amountEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "$Hotel",
              "codeName": "$Hotel",
              "entryTypeCode": "amountEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "$Housing",
              "codeName": "$Housing",
              "entryTypeCode": "amountEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "$Money",
              "codeName": "$Money",
              "entryTypeCode": "amountEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "$Reimb",
              "codeName": "$Reimb",
              "entryTypeCode": "amountEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "$Repair",
              "codeName": "$Repair",
              "entryTypeCode": "amountEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "$Tolls",
              "codeName": "$Tolls",
              "entryTypeCode": "amountEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "$Tuition",
              "codeName": "$Tuition",
              "entryTypeCode": "amountEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Absent",
              "codeName": "Absent",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Bereavement",
              "codeName": "Bereavement",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Bonus$",
              "codeName": "Bonus$",
              "entryTypeCode": "amountEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Callback",
              "codeName": "Callback",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Daily-OT",
              "codeName": "Daily-OT",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Day",
              "codeName": "Day",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Day-OT",
              "codeName": "Day-OT",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Double Time",
              "codeName": "Double Time",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Eve-OT",
              "codeName": "Eve-OT",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Evening",
              "codeName": "Evening",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "FLSAOT",
              "codeName": "FLSAOT",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "FMLA",
              "codeName": "FMLA",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Hol-Credit",
              "codeName": "Hol-Credit",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Hol-Wrkd",
              "codeName": "Hol-Wrkd",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Holiday",
              "codeName": "Holiday",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Incentive$",
              "codeName": "Incentive$",
              "entryTypeCode": "amountEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Jury",
              "codeName": "Jury",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Night",
              "codeName": "Night",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Night-OT",
              "codeName": "Night-OT",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "On-Call",
              "codeName": "On-Call",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "OT",
              "codeName": "OT",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "PDO",
              "codeName": "PDO",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Salary",
              "codeName": "Salary",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "SHFLSAOT",
              "codeName": "SHFLSAOT",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "SHFTOT",
              "codeName": "SHFTOT",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "STD",
              "codeName": "STD",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "STROT",
              "codeName": "STROT",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Sunday",
              "codeName": "Sunday",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "test",
              "codeName": "test",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Train",
              "codeName": "Train",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Training",
              "codeName": "Training",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Travel$",
              "codeName": "Travel$",
              "entryTypeCode": "amountEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "UPDATE",
              "codeName": "UPDATE",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Week-OT",
              "codeName": "Week-OT",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Weekend",
              "codeName": "Weekend",
              "entryTypeCode": "hoursEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "LDays",
              "codeName": "LDays",
              "entryTypeCode": "unitEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "Test$redbox",
              "codeName": "Test$redbox",
              "entryTypeCode": "amountEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "shruabc",
              "codeName": "shruabc",
              "entryTypeCode": "unitEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "shruttest",
              "codeName": "shruttest",
              "entryTypeCode": "unitEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "shrutest",
              "codeName": "shrutest",
              "entryTypeCode": "unitEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "test234",
              "codeName": "test234",
              "entryTypeCode": "unitEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            },
            {
              "code": "defecttest",
              "codeName": "defecttest",
              "entryTypeCode": "unitEntry",
              "entryTypeCategoryCode": "PayCode",
              "defaultIndicator": false
            }
          ],
          "hourPrecision": "hh.hh",
          "viewableTimePeriod": {
            "startDateTime": "2015-05-06T00:00:00-04:00",
            "endDateTime": "2015-06-16T00:00:00-04:00"
          },
          "createTimePeriod": {
            "startDateTime": "2015-05-06T00:00:00-04:00",
            "endDateTime": "2015-06-16T00:00:00-04:00"
          },
          "validationTables": [
            {
              "labelName": "Division",
              "tableID": "Division",
              "typeCode": "earningAllocation",
              "requiredIndicator": false,
              "tableUri": {
                "href": "\/v1_0\/O\/A\/table\/earningAllocation\/Division"
              }
            },
            {
              "labelName": "Department",
              "tableID": "Department",
              "typeCode": "earningAllocation",
              "requiredIndicator": false,
              "tableUri": {
                "href": "\/v1_0\/O\/A\/table\/earningAllocation\/Department"
              }
            },
            {
              "labelName": "Region",
              "tableID": "Region",
              "typeCode": "earningAllocation",
              "requiredIndicator": false,
              "tableUri": {
                "href": "\/v1_0\/O\/A\/table\/earningAllocation\/Region"
              }
            },
            {
              "labelName": "Job",
              "tableID": "Job",
              "typeCode": "earningAllocation",
              "requiredIndicator": false,
              "tableUri": {
                "href": "\/v1_0\/O\/A\/table\/earningAllocation\/Job"
              }
            },
            {
              "labelName": "Location",
              "tableID": "Location",
              "typeCode": "earningAllocation",
              "requiredIndicator": false,
              "tableUri": {
                "href": "\/v1_0\/O\/A\/table\/earningAllocation\/Location"
              }
            },
            {
              "labelName": "Section",
              "tableID": "Section",
              "typeCode": "earningAllocation",
              "requiredIndicator": false,
              "tableUri": {
                "href": "\/v1_0\/O\/A\/table\/earningAllocation\/Section"
              }
            },
            {
              "labelName": "Job Code",
              "tableID": "Job Code",
              "typeCode": "earningAllocation",
              "requiredIndicator": false,
              "tableUri": {
                "href": "\/v1_0\/O\/A\/table\/earningAllocation\/Job%20Code"
              }
            },
            {
              "labelName": "Work Rule",
              "tableID": "Work Rule",
              "typeCode": "earningAllocation",
              "requiredIndicator": false,
              "tableUri": {
                "href": "\/v1_0\/O\/A\/table\/earningAllocation\/Work%20Rule"
              }
            },
            {
              "labelName": "Comments",
              "tableID": "commentCategory",
              "typeCode": "entryComments",
              "requiredIndicator": false,
              "table": {
                "tableName": "Comments",
                "header": {
                  "numberOfColumns": 2,
                  "columns": [
                    {
                      "columnName": "Comment Text",
                      "primaryKeyIndicator": true,
                      "userVisibleIndicator": true
                    },
                    {
                      "columnName": "entryTypeCategoryCode",
                      "primaryKeyIndicator": false,
                      "userVisibleIndicator": false
                    }
                  ]
                },
                "tableRows": [
                  {
                    "columnValues": [
                      "Left Early",
                      "Punch"
                    ]
                  },
                  {
                    "columnValues": [
                      "Left Early",
                      "PayCode"
                    ]
                  },
                  {
                    "columnValues": [
                      "Mobile",
                      "Punch"
                    ]
                  },
                  {
                    "columnValues": [
                      "Mobile",
                      "PayCode"
                    ]
                  },
                  {
                    "columnValues": [
                      "Mobile Location",
                      "Punch"
                    ]
                  },
                  {
                    "columnValues": [
                      "Mobile Location",
                      "PayCode"
                    ]
                  },
                  {
                    "columnValues": [
                      "Running Late",
                      "Punch"
                    ]
                  },
                  {
                    "columnValues": [
                      "Running Late",
                      "PayCode"
                    ]
                  },
                  {
                    "columnValues": [
                      "Sick",
                      "Punch"
                    ]
                  },
                  {
                    "columnValues": [
                      "Tech",
                      "PayCode"
                    ]
                  }
                ]
              }
            },
            {
              "labelName": "Applies To",
              "tableID": "noteAppliesToEntryType",
              "typeCode": "entryNoteAppliesTo",
              "requiredIndicator": false,
              "table": {
                "tableName": "Applies To",
                "header": {
                  "numberOfColumns": 2,
                  "columns": [
                    {
                      "columnName": "Description",
                      "primaryKeyIndicator": true,
                      "userVisibleIndicator": true
                    },
                    {
                      "columnName": "entryTypeCode",
                      "primaryKeyIndicator": false,
                      "userVisibleIndicator": false
                    }
                  ]
                },
                "tableRows": [
                  {
                    "columnValues": [
                      "Start Time",
                      "timePairEntry"
                    ]
                  },
                  {
                    "columnValues": [
                      "End Time",
                      "timePairEntry"
                    ]
                  },
                  {
                    "columnValues": [
                      "Entry",
                      "hoursEntry"
                    ]
                  },
                  {
                    "columnValues": [
                      "Entry",
                      "unitEntry"
                    ]
                  },
                  {
                    "columnValues": [
                      "Entry",
                      "amountEntry"
                    ]
                  }
                ]
              }
            }
          ]
        }
      }
    ],
    "entrySummary": [
      {
        "timeSheetID": "2015-05-06zz2015-05-19zzPrevious",
        "positionID": {
          "id": "G3QZ7HZNMTFT8BMH",
          "schemeName": "",
          "schemeAgencyName": "Enterprise eTIME"
        },
        "payPeriod": {
          "payPeriodID": "Previous",
          "labelName": "Previous Period",
          "startDate": "2015-05-06",
          "endDate": "2015-05-19"
        },
        "totalPayPeriodHours": "PT0S",
        "exceptionType": {
          "code": "error"
        },
        "meta": {
          "actions": [
            {
              "operationID": "timeSheet.review",
              "actionTypeCode": "callback",
              "requestConfirmationIndicator": true,
              "attestation": {
                "messageTxt": "This is the default Attestation message."
              },
              "links": [
                {
                  "rel": "\/adp\/invoke",
                  "href": "\/time\/v1\/timeSheets\/review",
                  "method": "POST",
                  "title": "Approve Timecard",
                  "arguments": [
                    {
                      "propertyUri": {
                        "href": "\/associateID\/idValue"
                      },
                      "propertyValue": "G3QZ7HZNMTFT8BMH"
                    },
                    {
                      "propertyUri": {
                        "href": "\/associateID\/schemeName"
                      },
                      "propertyValue": "Associate OID"
                    },
                    {
                      "propertyUri": {
                        "href": "\/associateID\/schemeAgencyName"
                      },
                      "propertyValue": "ADP Registry"
                    },
                    {
                      "propertyUri": {
                        "href": "\/timeSheetStatus\/code"
                      },
                      "propertyValue": "Approve"
                    }
                  ]
                }
              ]
            }
          ]
        },
        "entries": [
          {
            "entryDate": "2015-05-19",
            "totalHours": {
              "hourValue": "PT0S",
              "unitTimeCode": "day"
            },
            "entryDetail": [
              {
                "clockSummary": {
                  "clockEntries": [
                    {
                      "entryDateTime": "2015-05-19T08:00:00-04:00",
                      "actionCode": "clockin",
                      "description": "In Punch"
                    }
                  ]
                }
              },
              {
                "timePairSummary": [
                  {
                    "entryID": "TPzz2015-05-19%2008zx00zz13411zzzzzzzz",
                    "codeName": "Time Pair Entry",
                    "timePeriod": {
                      "startDateTime": "2015-05-19T08:00:00-04:00"
                    },
                    "entryUri": {
                      "href": "\/v1_0\/O\/A\/timeEntry\/TPzz2015-05-19%2008zx00zz13411zzzzzzzz"
                    },
                    "exceptionType": {
                      "code": "error"
                    },
                    "metadataEntitlementCodes": [
                      "r",
                      "u",
                      "d"
                    ]
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "timeSheetID": "2015-05-20zz2015-06-02zzCurrent",
        "positionID": {
          "id": "G3QZ7HZNMTFT8BMH",
          "schemeName": "",
          "schemeAgencyName": "Enterprise eTIME"
        },
        "payPeriod": {
          "payPeriodID": "Current",
          "labelName": "Current Period",
          "startDate": "2015-05-20",
          "endDate": "2015-06-02"
        },
        "totalPayPeriodHours": "PT0S",
        "meta": {
          "actions": [
            {
              "operationID": "timeSheet.review",
              "actionTypeCode": "callback",
              "requestConfirmationIndicator": true,
              "attestation": {
                "messageTxt": "This is the default Attestation message."
              },
              "links": [
                {
                  "rel": "\/adp\/invoke",
                  "href": "\/time\/v1\/timeSheets\/review",
                  "method": "POST",
                  "title": "Approve Timecard",
                  "arguments": [
                    {
                      "propertyUri": {
                        "href": "\/associateID\/idValue"
                      },
                      "propertyValue": "G3QZ7HZNMTFT8BMH"
                    },
                    {
                      "propertyUri": {
                        "href": "\/associateID\/schemeName"
                      },
                      "propertyValue": "Associate OID"
                    },
                    {
                      "propertyUri": {
                        "href": "\/associateID\/schemeAgencyName"
                      },
                      "propertyValue": "ADP Registry"
                    },
                    {
                      "propertyUri": {
                        "href": "\/timeSheetStatus\/code"
                      },
                      "propertyValue": "Approve"
                    }
                  ]
                }
              ]
            }
          ]
        }
      },
      {
        "timeSheetID": "2015-06-03zz2015-06-16zzNext",
        "positionID": {
          "id": "G3QZ7HZNMTFT8BMH",
          "schemeName": "",
          "schemeAgencyName": "Enterprise eTIME"
        },
        "payPeriod": {
          "payPeriodID": "Next",
          "labelName": "Next Period",
          "startDate": "2015-06-03",
          "endDate": "2015-06-16"
        },
        "totalPayPeriodHours": "PT0S",
        "meta": {
          "actions": [
            {
              "operationID": "timeSheet.review",
              "actionTypeCode": "callback",
              "requestConfirmationIndicator": true,
              "attestation": {
                "messageTxt": "This is the default Attestation message."
              },
              "links": [
                {
                  "rel": "\/adp\/invoke",
                  "href": "\/time\/v1\/timeSheets\/review",
                  "method": "POST",
                  "title": "Approve Timecard",
                  "arguments": [
                    {
                      "propertyUri": {
                        "href": "\/associateID\/idValue"
                      },
                      "propertyValue": "G3QZ7HZNMTFT8BMH"
                    },
                    {
                      "propertyUri": {
                        "href": "\/associateID\/schemeName"
                      },
                      "propertyValue": "Associate OID"
                    },
                    {
                      "propertyUri": {
                        "href": "\/associateID\/schemeAgencyName"
                      },
                      "propertyValue": "ADP Registry"
                    },
                    {
                      "propertyUri": {
                        "href": "\/timeSheetStatus\/code"
                      },
                      "propertyValue": "Approve"
                    }
                  ]
                }
              ]
            }
          ]
        }
      }
    ]
  }
}
@heathkit

This comment has been minimized.

Show comment
Hide comment
@heathkit

heathkit May 14, 2016

Member

Thanks for the report! Could you provide a little more information here - what version of Webdriver, Chrome, and Firefox are you on? Do you see the issue on both Chrome and Firefox?

If you have the time, a small example app demonstrating the problem would be incredibly helpful.

Member

heathkit commented May 14, 2016

Thanks for the report! Could you provide a little more information here - what version of Webdriver, Chrome, and Firefox are you on? Do you see the issue on both Chrome and Firefox?

If you have the time, a small example app demonstrating the problem would be incredibly helpful.

@cnishina

This comment has been minimized.

Show comment
Hide comment
@cnishina

cnishina May 14, 2016

Member

Looking into this: it appears that selenium-webdriver is exporting the refresh method under navigation and not under webdriver.

Member

cnishina commented May 14, 2016

Looking into this: it appears that selenium-webdriver is exporting the refresh method under navigation and not under webdriver.

@ggregoire

This comment has been minimized.

Show comment
Hide comment
@ggregoire

ggregoire May 17, 2016

We have the same problem since we updated protractor and selenium today.

Stack trace:

  1. call a first browset.get to be in Angular context.
  2. add 3 mocks with huge json responses (130,000 characters).
  3. call a second browser.get to open the page to test : this one is never reached and the tests are infinitely blocked.

If we replace the responses with empty objects, the second page is reached and the tests run until the end.

We didn't have this issue before updating.

The webdriver logs finish with

18:35:31.185 INFO - Executing: [execute script: angular.resumeBootstrap(arguments[0]);, [[protractorBaseModule_, E2E]]])
18:35:31.512 INFO - Done: [execute script: angular.resumeBootstrap(arguments[0]);, [[protractorBaseModule_, E2E]]]

E2E being the module with the methods that call browser.addMockModule.

Hope it would help!


Protractor: 3.3.0
Selenium: 2.52.0
Chromedriver: 2.21

ggregoire commented May 17, 2016

We have the same problem since we updated protractor and selenium today.

Stack trace:

  1. call a first browset.get to be in Angular context.
  2. add 3 mocks with huge json responses (130,000 characters).
  3. call a second browser.get to open the page to test : this one is never reached and the tests are infinitely blocked.

If we replace the responses with empty objects, the second page is reached and the tests run until the end.

We didn't have this issue before updating.

The webdriver logs finish with

18:35:31.185 INFO - Executing: [execute script: angular.resumeBootstrap(arguments[0]);, [[protractorBaseModule_, E2E]]])
18:35:31.512 INFO - Done: [execute script: angular.resumeBootstrap(arguments[0]);, [[protractorBaseModule_, E2E]]]

E2E being the module with the methods that call browser.addMockModule.

Hope it would help!


Protractor: 3.3.0
Selenium: 2.52.0
Chromedriver: 2.21

@jlin412

This comment has been minimized.

Show comment
Hide comment
@jlin412

jlin412 May 20, 2016

I have problem with both firefox (46.0.1) and chrome (50.0). Webdriver (2.52.0)

jlin412 commented May 20, 2016

I have problem with both firefox (46.0.1) and chrome (50.0). Webdriver (2.52.0)

@jlin412

This comment has been minimized.

Show comment
Hide comment
@jlin412

jlin412 May 31, 2016

@ggregoire My code is not easily to rewrite to be a sample code/app. Are you able to do one for debugging?

jlin412 commented May 31, 2016

@ggregoire My code is not easily to rewrite to be a sample code/app. Are you able to do one for debugging?

@barinali

This comment has been minimized.

Show comment
Hide comment
@barinali

barinali Jun 17, 2016

@jlin412, hello. I had been trying to mock my API response in this way. And I was stuck like you. Then I had found a temporary solution for this situation. As the following;

// This is a large response.
var response = { ... };
response = JSON.stringify(response);

browser.addMockModule('httpBackendMock', function() {
  var response = JSON.parse(arguments[0]);

  angular.module('httpBackendMock', ['ngMockE2E'])
    .run(function ($httpBackend) {
      console.log(response);
    });
}, response);

I hope this works for you too.

barinali commented Jun 17, 2016

@jlin412, hello. I had been trying to mock my API response in this way. And I was stuck like you. Then I had found a temporary solution for this situation. As the following;

// This is a large response.
var response = { ... };
response = JSON.stringify(response);

browser.addMockModule('httpBackendMock', function() {
  var response = JSON.parse(arguments[0]);

  angular.module('httpBackendMock', ['ngMockE2E'])
    .run(function ($httpBackend) {
      console.log(response);
    });
}, response);

I hope this works for you too.

@ricardo-cantu

This comment has been minimized.

Show comment
Hide comment
@ricardo-cantu

ricardo-cantu Jul 28, 2016

I'm having the same problem:

firefox (46.0.1) webdriver (2.53.1) protractor (4.0.2)

@barinali , your workaround is working for me, Thanks!

ricardo-cantu commented Jul 28, 2016

I'm having the same problem:

firefox (46.0.1) webdriver (2.53.1) protractor (4.0.2)

@barinali , your workaround is working for me, Thanks!

@jlin412

This comment has been minimized.

Show comment
Hide comment
@jlin412

jlin412 Sep 1, 2016

@barinali life saver. It works for me too for the workaround.

jlin412 commented Sep 1, 2016

@barinali life saver. It works for me too for the workaround.

@rjoaopereira

This comment has been minimized.

Show comment
Hide comment
@rjoaopereira

rjoaopereira Sep 8, 2016

I have the same problem. However, I believe this is related to executeScript.

I tested with version 3.1.1 and it is working fine. In the subsequent versions, the parsing of the arguments given to the function in executeScript just takes too long.

In the master branch, I used the example_spec.js that comes with protractor as a quick test.

    fit('should list todos', function() {
      expect(todoList.count()).toEqual(2);
      expect(todoList.get(1).getText()).toEqual('build an angular app');
      browser.executeScript(function (argv) {
        console.log(argv);
      }, largeObject)
    });

Passing the Object given by @jlin412 the test throws a Timeout Error. If you convert it to a string with JSON.stringify, the test runs smoothly.

I don't know if this is related to webdriver or protractor, but it seems a serialization issue.

Hope it helps.

rjoaopereira commented Sep 8, 2016

I have the same problem. However, I believe this is related to executeScript.

I tested with version 3.1.1 and it is working fine. In the subsequent versions, the parsing of the arguments given to the function in executeScript just takes too long.

In the master branch, I used the example_spec.js that comes with protractor as a quick test.

    fit('should list todos', function() {
      expect(todoList.count()).toEqual(2);
      expect(todoList.get(1).getText()).toEqual('build an angular app');
      browser.executeScript(function (argv) {
        console.log(argv);
      }, largeObject)
    });

Passing the Object given by @jlin412 the test throws a Timeout Error. If you convert it to a string with JSON.stringify, the test runs smoothly.

I don't know if this is related to webdriver or protractor, but it seems a serialization issue.

Hope it helps.

@juliemr

This comment has been minimized.

Show comment
Hide comment
@juliemr

juliemr Sep 20, 2016

Member

I think that using a mock file that large is a serious code smell for your tests. If you need to be messing this deeply with what's being returned from the server, you need some sort of test server - mocking everything out from the front end is abuse at that point. executeScript is definitely not meant to be used with thousand line JSON files.

I'm going to be mean and close this since there's nothing we can do here.

Member

juliemr commented Sep 20, 2016

I think that using a mock file that large is a serious code smell for your tests. If you need to be messing this deeply with what's being returned from the server, you need some sort of test server - mocking everything out from the front end is abuse at that point. executeScript is definitely not meant to be used with thousand line JSON files.

I'm going to be mean and close this since there's nothing we can do here.

@juliemr juliemr closed this Sep 20, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment