Skip to content

Commit

Permalink
Added everything for Step 6: A First OPA Test
Browse files Browse the repository at this point in the history
  • Loading branch information
wridgeu committed May 25, 2020
1 parent 6b73fd4 commit 27b0b20
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 18 deletions.
34 changes: 19 additions & 15 deletions webapp/test/integration/WorklistJourney.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
/*global QUnit*/
sap.ui.define([
"sap/ui/test/opaQunit",
"./pages/Worklist"
], function (opaTest) {
"use strict";
sap.ui.define(["sap/ui/test/opaQunit", "./pages/Worklist"], function (opaTest) {
"use strict";

QUnit.module("Posts");
QUnit.module("Posts");

opaTest("Should see the table with all posts", function (Given, When, Then) {
// Arrangements
Given.iStartMyApp();
opaTest("Should see the table with all posts", function (Given, When, Then) {
// Arrangements
Given.iStartMyApp();

// Assertions
Then.onTheWorklistPage.theTableShouldHaveAllEntries().
and.theTitleShouldDisplayTheTotalAmountOfItems();
// Assertions
Then.onTheWorklistPage
.theTableShouldHavePagination()
.and.theTitleShouldDisplayTheTotalAmountOfItems();
});

// Cleanup
Then.iTeardownMyApp();
});
opaTest("Should be able to load more items", function (Given, When, Then) {
//Actions
When.onTheWorklistPage.iPressOnMoreData();

// Assertions
Then.onTheWorklistPage.theTableShouldHaveAllEntries();
// Cleanup
Then.iTeardownMyApp();
});
});
31 changes: 28 additions & 3 deletions webapp/test/integration/pages/Worklist.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,45 @@
sap.ui.define([
'sap/ui/test/Opa5',
'sap/ui/test/matchers/AggregationLengthEquals',
'sap/ui/test/matchers/I18NText'
'sap/ui/test/matchers/I18NText',
'sap/ui/test/actions/Press'
],
function (Opa5,
AggregationLengthEquals,
I18NText) {
I18NText, Press) {
"use strict";

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

Opa5.createPageObjects({
onTheWorklistPage: {
actions: {},
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,
Expand Down

0 comments on commit 27b0b20

Please sign in to comment.