Skip to content

Commit

Permalink
Added everything for Step 8: Testing Navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
wridgeu committed Jun 6, 2020
1 parent 44858d9 commit 2b69492
Show file tree
Hide file tree
Showing 5 changed files with 204 additions and 76 deletions.
3 changes: 2 additions & 1 deletion webapp/test/integration/AllJourneys.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
sap.ui.define([
"sap/ui/test/Opa5",
"./arrangements/Startup",
"./WorklistJourney"
"./WorklistJourney",
"./PostJourney"
], function (Opa5, Startup) {
"use strict";

Expand Down
45 changes: 45 additions & 0 deletions webapp/test/integration/PostJourney.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
sap.ui.define(
[
"sap/ui/test/opaQunit",
"./pages/Worklist",
"./pages/Browser",
"./pages/Post",
],
function (opaTest) {
"use strict";

QUnit.module("Post");

opaTest(
"Should see the post page when a user click on an entry of the list",
function (Given, When, Then) {
//Arrangements
Given.iStartMyApp();

//Actions
When.onTheWorklistPage.iPressOnTheItemWithTheID("PostID_15");

//Assertion
Then.onThePostPage.theTitleShouldDisplayTheName("Jeans");
}
);

opaTest("Should go back to the TablePage", function (Given, When, Then) {
// Actions
When.onThePostPage.iPressTheBackButton();

// Assertions
Then.onTheWorklistPage.iShouldSeeTheTable();
});
opaTest("Should be on the post page again when the browser's forward button is pressed", function (Given, When, Then) {
// Actions
When.onTheBrowser.iPressOnTheForwardButton();

// Assertions
Then.onThePostPage.theTitleShouldDisplayTheName("Jeans");

// Cleanup
Then.iTeardownMyApp();
});
}
);
17 changes: 17 additions & 0 deletions webapp/test/integration/pages/Browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
sap.ui.define(["sap/ui/test/Opa5"], function (Opa5) {
"use strict";
Opa5.createPageObjects({
onTheBrowser: {
actions: {
iPressOnTheForwardButton: function () {
return this.waitFor({
success: function () {
Opa5.getWindow().history.forward();
},
});
},
},
assertions: {},
},
});
});
41 changes: 41 additions & 0 deletions webapp/test/integration/pages/Post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
sap.ui.define([
'sap/ui/test/Opa5',
'sap/ui/test/matchers/Properties',
'sap/ui/test/actions/Press'
], function (Opa5, Properties, Press) {
"use strict";
var sViewName = "Post";
Opa5.createPageObjects({
onThePostPage: {
actions: {
iPressTheBackButton: function () {
return this.waitFor({
id: "page",
viewName: sViewName,
actions: new Press(),
errorMessage: "Did not find the nav button on object page"
});
}
},
assertions: {
theTitleShouldDisplayTheName: function (sName) {
return this.waitFor({
success: function () {
return this.waitFor({
id: "objectHeader",
viewName: sViewName,
matchers: new Properties({
title: sName
}),
success: function (oPage) {
Opa5.assert.ok(true, "was on the remembered detail page");
},
errorMessage: "The Post " + sName + " is not shown"
});
}
});
}
}
}
});
});
174 changes: 99 additions & 75 deletions webapp/test/integration/pages/Worklist.js
Original file line number Diff line number Diff line change
@@ -1,78 +1,102 @@
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";
sap.ui.define(
[
"sap/ui/test/Opa5",
"sap/ui/test/matchers/AggregationLengthEquals",
"sap/ui/test/matchers/I18NText",
"sap/ui/test/actions/Press",
"sap/ui/test/matchers/BindingPath",
],
function (Opa5, AggregationLengthEquals, I18NText, Press, BindingPath) {
"use strict";

var sViewName = "Worklist",
sTableId = "table";
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."
});
},
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.",
});
},
iPressOnTheItemWithTheID: function (sId) {
return this.waitFor({
controlType: "sap.m.ColumnListItem",
viewName: sViewName,
matchers: new BindingPath({
path: "/Posts('" + sId + "')",
}),
actions: new Press(),
errorMessage: "No list item with the id " + sId + " was found.",
});
},
},
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",
});
},
iShouldSeeTheTable: function () {
return this.waitFor({
id: sTableId,
viewName: sViewName,
success: function () {
Opa5.assert.ok(true, "The table is visible");
},
errorMessage: "Was not able to see the table.",
});
},
},
},
});
}
);

1 comment on commit 2b69492

@wridgeu
Copy link
Owner Author

@wridgeu wridgeu commented on 2b69492 Jun 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor beautifying was also done in with this commit.

Please sign in to comment.