sap.ui.define([
	"sap/ui/demo/todo/test/integration/Common",
	"sap/ui/test/Opa5",
	"sap/ui/test/actions/Press",
	"sap/ui/test/matchers/PropertyStrictEquals"
], function (Common, Opa5, Press, PropertyStrictEquals ) {
	"use strict";

	Opa5.createPageObjects({
		onPage2: {
			baseClass: Common,
			viewName: "Page2",
			actions: {
				press: function(oActionProperties) {
					var actionObject = {};
					if (oActionProperties.id) {actionObject.id = oActionProperties.id.isRegex ? oActionProperties.id.value : new RegExp(oActionProperties.id.value);}
					if (oActionProperties.controlType) {actionObject.controlType = oActionProperties.controlType;}
					actionObject.visible = true;
					actionObject.actions = [new Press()];
					actionObject.success = function() {Opa5.assert.ok(true, "Press successful.")};
					actionObject.errorMessage = "Failed to click";
					actionObject.matchers =
					oActionProperties.attributes ?
						oActionProperties.attributes.map(function(el) {
							return new PropertyStrictEquals({name: Object.keys(el)[0], value: Object.values(el)[0]});
						}) : [];
					return this.waitFor(actionObject);
				}
			}
		}
	});
});