Skip to content

Commit

Permalink
OpenUI5 Documentation Update 17.05.2024
Browse files Browse the repository at this point in the history
  • Loading branch information
openui5bot committed May 17, 2024
1 parent 1cdf47d commit bddb553
Showing 1 changed file with 70 additions and 77 deletions.
147 changes: 70 additions & 77 deletions docs/Step_6_A_First_OPA_Test_1b47457.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ The journey uses another structuring element of OPA called “page object” tha

```js
sap.ui.define([
"sap/ui/test/opaQunit",
"./pages/Worklist"
'sap/ui/test/opaQunit',
'./pages/Worklist'
], function (opaTest) {
"use strict";

Expand Down Expand Up @@ -116,86 +116,79 @@ Now you might wonder where all those descriptive functions and the helper object

```js
sap.ui.define([
'sap/ui/test/Opa5',
'sap/ui/test/matchers/AggregationLengthEquals',
'sap/ui/test/matchers/I18NText',
'sap/ui/test/actions/Press'
],
function (Opa5,
AggregationLengthEquals,
I18NText,
Press) {
"use strict";

var sViewName = "Worklist",
sTableId = "table";

Opa5.createPageObjects({
onTheWorklistPage: {
actions: {
iPressOnMoreData: function () {
// Press action hits the "more" trigger on a table
return this.waitFor({
id: sTableId,
viewName: sViewName,
actions: new Press(),
errorMessage: "The table does not have a trigger."
});
}
'sap/ui/test/Opa5',
'sap/ui/test/matchers/AggregationLengthEquals',
'sap/ui/test/matchers/I18NText',
'sap/ui/test/actions/Press'
], function (Opa5, AggregationLengthEquals, I18NText, Press) {
"use strict";

var sViewName = "Worklist",
sTableId = "table";

Opa5.createPageObjects({
onTheWorklistPage: {
actions: {
iPressOnMoreData: function () {
// Press action hits the "more" trigger on a table
return this.waitFor({
id: sTableId,
viewName: sViewName,
actions: new Press(),
errorMessage: "The table does not have a trigger."
});
}
},
assertions: {
theTableShouldHavePagination: function () {
return this.waitFor({
id: sTableId,
viewName: sViewName,
matchers: new AggregationLengthEquals({
name: "items",
length: 20
}),
success: function () {
Opa5.assert.ok(true, "The table has 20 items on the first page");
},
errorMessage: "The table does not contain all items."
});
},

theTableShouldHaveAllEntries: function () {
return this.waitFor({
id: sTableId,
viewName: sViewName,
matchers: new AggregationLengthEquals({
name: "items",
length: 23
}),
success: function () {
Opa5.assert.ok(true, "The table has 23 items");
},
errorMessage: "The table does not contain all items."
});
},
assertions: {
theTableShouldHavePagination: function () {
return this.waitFor({
id: sTableId,
viewName: sViewName,
matchers: new AggregationLengthEquals({
name: "items",
length: 20
}),
success: function () {
Opa5.assert.ok(true, "The table has 20 items on the first page");
},
errorMessage: "The table does not contain all items."
});
},

theTableShouldHaveAllEntries: function () {
return this.waitFor({
id: sTableId,
viewName: sViewName,
matchers: new AggregationLengthEquals({
name: "items",
length: 23
}),
success: function () {
Opa5.assert.ok(true, "The table has 23 items");
},
errorMessage: "The table does not contain all items."
});
},

theTitleShouldDisplayTheTotalAmountOfItems: function () {
return this.waitFor({
id: "tableHeader",
viewName: sViewName,
matchers: new I18NText({
key: "worklistTableTitleCount",
propertyName: "text",
parameters: [23]
}),
success: function () {
Opa5.assert.ok(true, "The table header has 23 items");
},
errorMessage: "The table header does not contain the number of items: 23"
});
}

theTitleShouldDisplayTheTotalAmountOfItems: function () {
return this.waitFor({
id: "tableHeader",
viewName: sViewName,
matchers: new I18NText({
key: "worklistTableTitleCount",
propertyName: "text",
parameters: [23]
}),
success: function () {
Opa5.assert.ok(true, "The table header has 23 items");
},
errorMessage: "The table header does not contain the number of items: 23"
});
}
}
});

}
});

});
```

As you can see, the OPA page object is constructed with the call `Opa5.createPageObjects` and a `configuration` object that contains the actions and assertions properties.
Expand Down

0 comments on commit bddb553

Please sign in to comment.