0

Below is my ui routing setup for my angular project. I am not able to bring up the work order list page. I am not sure what is wrong with the below setup, please can you advise how I can bring up the workorders list page to view my work orders.

URL invoked on the browser http://localhost:63342/vdash/index.html#/workorders

app.js

(function () {
"use strict";
var app = angular.module("workOrderManagement", ["common.services",      "ui.router", "workOrderResourceMock"]);
app.config(["$stateProvider", "$urlRouterProvider", function ($stateProvider, $urlRouterProvider) {
        $urlRouterProvider.otherwise("/workorders");

        $stateProvider.state("workOrderList", {
            url: "/workorders",
            templateUrl: "app/workorder/workOrderListView.html",
            controller: "workOrderCtrl as vm"
        })
    }]
)
})();

workOrderResourceMock.js

(function () {
"use strict";

var app = angular.module("workOrderResourceMock", ["ngMockE2E"]);
app.run(function ($httpBackend) {
    var workOrders = [
        {
            "orderNo": "WO-0000001",
            "city": "San Jose",
            "bank": "Citi Bank",
            "branch": "Maxrk",
            "creationDate": "2017-10-01",
            "clientName": "Mr.Peter",
            "status": "PENDING",
            "handledBy": "Peter",
        }           
    ];

    var workOrderUrl = "/workorders";

    $httpBackend.whenGET(workOrderUrl).respond(function(method, url, data){
      // just to see if it his this function will remove later
        alert("into the backend method");
        console.log(url);


        return [200, workOrders];
    });

$httpBackend.whenGET("/").passThrough();
   });
}());

Errors angular.js:13236 Error: Unexpected request: GET
app/workorder/workOrderListView.html No more request expected at $httpBackend (angular-mocks.js:1403)

serah
  • 2,057
  • 7
  • 36
  • 56
  • 1
    In this [link](http://stackoverflow.com/questions/18147606/why-do-i-receive-error-unexpected-request-get-internalapi-quotes), it says to use `expectGET()`. Why not try this solution and see if it works? – Daniel Netto Apr 08 '16 at 04:05

1 Answers1

0

Angular is trying to fetch the template need to show the view. I'm assuming that this is E2E test. While running tests, all calls pass through $httpBackend, so you need to let $httpBackend allow the calls to fetch templates.

Add this to the end of run method,

$httpBackend.whenGET("/app/workorder/workOrderListView.html").passThrough();

As an alternative solution, you can use $templateCache to cache your templates, so angular doesn't have to load it from server.

Vijay Purush
  • 322
  • 1
  • 12