I am creating an end-to-end test for an Angular 1.5 application using Protractor. The application allows the user to upload a file to a backend Web API, by selecting a file using a standard input type="file"
control and a submit
button. I have a Controller that basically behaves like this:
function exampleController() {
var vm = this;
vm.status = "";
vm.buttonClickHandler = buttonClickHandler;
function buttonClickHandler() {
vm.status = "calling";
service.makeAsyncCall()
.then(function() {
vm.status = "success";
}, function() {
vm.status = "error";
});
}
}
The buttonClickHandler
is called when the user clicks the submit
button.
How do I write an end-to-end test using Protractor that verifies that the status changes to "calling" when the user clicks the button, and then to "success" when the promise resolves?
In most of my attempts, I could verify that vm.status
had been set to "success", or I could verify that it was set to "calling" if I set ignoreSynchronization = true
, but the latter only works when I build in an artificial delay in my Web API backend call, otherwise the process was apparently too fast and the value would show "success".