diff --git a/webapp/test/integration/AllJourneys.js b/webapp/test/integration/AllJourneys.js index 9c10ac8..91331bd 100644 --- a/webapp/test/integration/AllJourneys.js +++ b/webapp/test/integration/AllJourneys.js @@ -1,7 +1,8 @@ sap.ui.define([ "sap/ui/test/Opa5", "./arrangements/Startup", - "./WorklistJourney" + "./WorklistJourney", + "./PostJourney" ], function (Opa5, Startup) { "use strict"; diff --git a/webapp/test/integration/PostJourney.js b/webapp/test/integration/PostJourney.js new file mode 100644 index 0000000..5ebc624 --- /dev/null +++ b/webapp/test/integration/PostJourney.js @@ -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(); + }); + } +); diff --git a/webapp/test/integration/pages/Browser.js b/webapp/test/integration/pages/Browser.js new file mode 100644 index 0000000..00966ac --- /dev/null +++ b/webapp/test/integration/pages/Browser.js @@ -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: {}, + }, + }); +}); diff --git a/webapp/test/integration/pages/Post.js b/webapp/test/integration/pages/Post.js new file mode 100644 index 0000000..c5a0243 --- /dev/null +++ b/webapp/test/integration/pages/Post.js @@ -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" + }); + } + }); + } + } + } + }); + }); \ No newline at end of file diff --git a/webapp/test/integration/pages/Worklist.js b/webapp/test/integration/pages/Worklist.js index 7c3808f..249ec31 100644 --- a/webapp/test/integration/pages/Worklist.js +++ b/webapp/test/integration/pages/Worklist.js @@ -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.", + }); + }, + }, + }, + }); + } +);