@sap-ux/ui5-test-writer 1.2.19 → 1.2.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.d.ts CHANGED
@@ -101,10 +101,13 @@ export interface FFOPAConfig {
101
101
  ui5Theme?: string;
102
102
  useVirtualPreviewEndpoints?: boolean;
103
103
  }
104
+ export type ObjectPageNavigationParent = {
105
+ name: string;
106
+ navigationProperty: string;
107
+ };
104
108
  export type ObjectPageNavigationParents = {
105
109
  parentLRName?: string;
106
- parentOPName?: string;
107
- parentOPTableSection?: string;
110
+ parentOPs: ObjectPageNavigationParent[];
108
111
  };
109
112
  export type SectionFormField = {
110
113
  property: string;
@@ -60,26 +60,40 @@ export function getObjectPages(applicationModel) {
60
60
  return objectPages;
61
61
  }
62
62
  /**
63
- * Finds parent pages for the object page, and returns their identifiers.
63
+ * Finds the chain of parent Object Pages leading from the List Report down to the target page.
64
64
  *
65
65
  * @param targetObjectPageKey - key of the target object page
66
66
  * @param objectPages - the array of object pages extracted from the application model
67
67
  * @param listReportPageKey - the key of the List Report page in the application model, used to find navigation routes to object pages
68
- * @returns navigation data including parent page identifiers
68
+ * @returns navigation data including the ordered ancestor Object Page chain
69
69
  */
70
70
  function getObjectPageNavigationParents(targetObjectPageKey, objectPages, listReportPageKey) {
71
- const navigationParents = {
72
- parentLRName: listReportPageKey ?? '' // app is possibly malformed if no LR found
73
- };
74
- objectPages.forEach((objectPage) => {
75
- const navigationRoutes = getNavigationRoutes(objectPage);
76
- const routeToTargetOP = navigationRoutes.find((nav) => nav.route === targetObjectPageKey);
77
- if (routeToTargetOP) {
78
- navigationParents.parentOPName = objectPage.name;
79
- navigationParents.parentOPTableSection = routeToTargetOP.identifier;
71
+ const parentOPs = [];
72
+ const visited = new Set([targetObjectPageKey]); // guard against infinite loop in case of invalid manifest entries
73
+ let cursor = targetObjectPageKey;
74
+ while (true) {
75
+ const childKey = cursor;
76
+ let parent;
77
+ let parentNavigationProperty;
78
+ for (const objectPage of objectPages) {
79
+ const route = getNavigationRoutes(objectPage).find((navigation) => navigation.route === childKey);
80
+ if (route) {
81
+ parent = objectPage;
82
+ parentNavigationProperty = route.identifier;
83
+ break;
84
+ }
80
85
  }
81
- });
82
- return navigationParents;
86
+ if (!parent?.name || !parentNavigationProperty || visited.has(parent.name)) {
87
+ break;
88
+ }
89
+ visited.add(parent.name);
90
+ parentOPs.unshift({ name: parent.name, navigationProperty: parentNavigationProperty });
91
+ cursor = parent.name;
92
+ }
93
+ return {
94
+ parentLRName: listReportPageKey ?? '', // app is possibly malformed if no LR found
95
+ parentOPs
96
+ };
83
97
  }
84
98
  /**
85
99
  * Extracts header sections data from an object page model.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/ui5-test-writer",
3
3
  "description": "SAP UI5 tests writer",
4
- "version": "1.2.19",
4
+ "version": "1.2.20",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -33,11 +33,11 @@ sap.ui.define([
33
33
  Then.onThe<%- navigationParents.parentLRName%>Generated.onTable().iCheckRows();
34
34
  When.onThe<%- navigationParents.parentLRName%>Generated.onTable().iPressRow(0);
35
35
  <% } -%>
36
- <% if(navigationParents.parentOPName) { %>
37
- Then.onThe<%- navigationParents.parentOPName%>Generated.iSeeThisPage();
38
- Then.onThe<%- navigationParents.parentOPName%>Generated.onTable({ property: "<%- navigationParents.parentOPTableSection %>" }).iCheckRows();
39
- When.onThe<%- navigationParents.parentOPName%>Generated.onTable({ property: "<%- navigationParents.parentOPTableSection %>" }).iPressRow(0);
40
- <% } %>
36
+ <% navigationParents.parentOPs.forEach(function(parent) { %>
37
+ Then.onThe<%- parent.name %>Generated.iSeeThisPage();
38
+ Then.onThe<%- parent.name %>Generated.onTable({ property: "<%- parent.navigationProperty %>" }).iCheckRows();
39
+ When.onThe<%- parent.name %>Generated.onTable({ property: "<%- parent.navigationProperty %>" }).iPressRow(0);
40
+ <% }); %>
41
41
  Then.onThe<%- name%>Generated.iSeeThisPage();
42
42
  });
43
43
 
@@ -52,11 +52,11 @@ function journey() {
52
52
  Then.onThe<%- navigationParents.parentLRName%>Generated.onTable("").iCheckRows();
53
53
  When.onThe<%- navigationParents.parentLRName%>Generated.onTable("").iPressRow(0);
54
54
  <% } -%>
55
- <% if(navigationParents.parentOPName) { %>
56
- Then.onThe<%- navigationParents.parentOPName%>Generated.iSeeThisPage();
57
- Then.onThe<%- navigationParents.parentOPName%>Generated.onTable({ property: "<%- navigationParents.parentOPTableSection %>" }).iCheckRows();
58
- When.onThe<%- navigationParents.parentOPName%>Generated.onTable({ property: "<%- navigationParents.parentOPTableSection %>" }).iPressRow(0);
59
- <% } %>
55
+ <% navigationParents.parentOPs.forEach(function(parent) { %>
56
+ Then.onThe<%- parent.name %>Generated.iSeeThisPage();
57
+ Then.onThe<%- parent.name %>Generated.onTable({ property: "<%- parent.navigationProperty %>" }).iCheckRows();
58
+ When.onThe<%- parent.name %>Generated.onTable({ property: "<%- parent.navigationProperty %>" }).iPressRow(0);
59
+ <% }); %>
60
60
  Then.onThe<%- name%>Generated.iSeeThisPage();
61
61
  });
62
62