-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added everything for Step 8: Testing Navigation
- Loading branch information
Showing
5 changed files
with
204 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: {}, | ||
}, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
}); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.", | ||
}); | ||
}, | ||
}, | ||
}, | ||
}); | ||
} | ||
); |
2b69492
There was a problem hiding this comment.
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.