|
| 1 | +sap.ui.define([ |
| 2 | + "sap/base/Log", |
| 3 | + "sap/ui/test/gherkin/StepDefinitions", |
| 4 | + "sap/ui/test/Opa5", |
| 5 | + "sap/ui/test/matchers/AggregationLengthEquals", |
| 6 | + "sap/ui/test/matchers/PropertyStrictEquals", |
| 7 | + "sap/ui/test/matchers/Properties", |
| 8 | + "sap/ui/test/actions/EnterText", |
| 9 | + "sap/ui/test/actions/Press" |
| 10 | +], function( |
| 11 | + Log, StepDefinitions, Opa5, |
| 12 | + AggregationLengthEquals, PropertyStrictEquals, Properties, EnterText, Press |
| 13 | +) { |
| 14 | + "use strict"; |
| 15 | + |
| 16 | + var sViewName = "sap.ui.demo.todo.view.App"; |
| 17 | + // var sAddToItemInputId = "addTodoItemInput"; |
| 18 | + // var sSearchTodoItemsInputId = "searchTodoItemsInput"; |
| 19 | + var sItemListId = "todoList"; |
| 20 | + // var sClearCompletedId = "clearCompleted"; |
| 21 | + |
| 22 | + var oOpa5 = new Opa5(); |
| 23 | + |
| 24 | + var Steps = StepDefinitions.extend("sap.ui.demo.todo.test.gherkin.Steps", { |
| 25 | + init: function() { |
| 26 | + |
| 27 | + this.register(/^I have started the app$/i, function() { |
| 28 | + oOpa5.iStartMyUIComponent({ |
| 29 | + componentConfig: { |
| 30 | + name: "sap.ui.demo.todo", |
| 31 | + async: true, |
| 32 | + manifest: true |
| 33 | + } |
| 34 | + }); |
| 35 | + }); |
| 36 | + |
| 37 | + this.register(/^I can see ([0-9]+) items? in the list$/i, function(sItemCount) { |
| 38 | + var iItemCount = parseInt(sItemCount, 10); |
| 39 | + oOpa5.waitFor({ |
| 40 | + id: sItemListId, |
| 41 | + viewName: sViewName, |
| 42 | + matchers: [new AggregationLengthEquals({ |
| 43 | + name: "items", |
| 44 | + length: iItemCount |
| 45 | + })], |
| 46 | + success: function() { |
| 47 | + Opa5.assert.ok(true, "The list has " + iItemCount + " item(s)"); |
| 48 | + }, |
| 49 | + errorMessage: "List does not have expected number of items '" + iItemCount + "'." |
| 50 | + }); |
| 51 | + }); |
| 52 | + |
| 53 | + this.register(/^I filter for (active|completed) items$/i, function(filterKey) { |
| 54 | + oOpa5.waitFor({ |
| 55 | + viewName: sViewName, |
| 56 | + controlType: "sap.m.SegmentedButtonItem", |
| 57 | + matchers: [ |
| 58 | + new Properties({ key: filterKey }) |
| 59 | + ], |
| 60 | + actions: [new Press()], |
| 61 | + errorMessage: "SegmentedButton can not be pressed" |
| 62 | + }); |
| 63 | + }); |
| 64 | + |
| 65 | + }, |
| 66 | + |
| 67 | + closeApplication: function() { |
| 68 | + Log.info("Closing application"); |
| 69 | + } |
| 70 | + }); |
| 71 | + |
| 72 | + return Steps; |
| 73 | + |
| 74 | +}); |
0 commit comments