0

I am having a two UI elements based on ng-if condition

<widget id="widget1" ng-if="vm.WidgetEnabled"
</widget>
<widget id="widget2" ng-if="!vm.WidgetEnabled"
</widget>

Controller makes REST API call which sets

WidgetEnabled = true

Now how can I test UI for

WidgetEnabled= false

scenario?

Any suggestions?

Can I set manually WidgetEnabled = false in protractor test case?

anand
  • 11,071
  • 28
  • 101
  • 159

2 Answers2

0

As you do an e2e test scenario you typically would simulate the users actions, that would be required for the widget to be disabled (a button click which calls the REST API and disabled it, logging in as another user, who has other permissions or sth. like that). I would not recommend to change angular controller variables in protractor tests, because this is not the way e2e tests are intended to work.

Daniel Beckmann
  • 286
  • 2
  • 8
0

You can use mocking and mock the response of the REST API with true and false values. However ideally that should be a part of your unit tests and not e2e tests.

demouser123
  • 4,108
  • 9
  • 50
  • 82