Skip to content

Commit f598df2

Browse files
authored
Merge branch 'main' into feat/ui5-test-writer/ui-hidden-for-sections
2 parents d3e29ed + 26f9d1a commit f598df2

10 files changed

Lines changed: 109 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@sap-ux/ui5-test-writer": minor
3+
---
4+
5+
FEAT: Generate Object Page header title check using iCheckTitlePath (binding-path based)

packages/ui5-test-writer/src/utils/modelUtils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ export interface HeaderSectionItem extends SectionItem {
5656
};
5757
}
5858

59+
export interface HeaderItem extends TreeAggregation {
60+
properties?: {
61+
title?: { value?: string };
62+
description?: { value?: string };
63+
};
64+
}
65+
5966
export interface PageWithModelV4WithProperties extends PageWithModelV4 {
6067
routePattern?: string;
6168
}

packages/ui5-test-writer/src/utils/objectPageUtils.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
type AggregationItem,
1818
type BodySectionItem,
1919
type FieldItem,
20+
type HeaderItem,
2021
type HeaderSectionItem,
2122
type SectionItem,
2223
getAggregations,
@@ -70,6 +71,8 @@ export async function getObjectPageFeatures(
7071
listReportPageKey,
7172
parentLRTableIdentifier
7273
);
74+
// extract header title binding path (for iCheckTitlePath)
75+
pageFeatureData.headerTitle = getHeaderTitlePath(objectPage);
7376
// extract header sections (facets)
7477
pageFeatureData.headerSections = extractObjectPageHeaderSectionsData(objectPage);
7578
// extract body sections (includes section-level actions and standard create/delete buttons)
@@ -158,6 +161,25 @@ function getObjectPageNavigationParents(
158161
};
159162
}
160163

164+
/**
165+
* Returns the OData property path the Object Page header title is bound to, for use with
166+
* `iCheckTitlePath`. Returns undefined for static titles that expose no binding path.
167+
*
168+
* @param objectPage - object page from the application model
169+
* @returns the title binding path, or undefined
170+
*/
171+
function getHeaderTitlePath(objectPage: PageWithModelV4): string | undefined {
172+
if (!objectPage.model) {
173+
return undefined;
174+
}
175+
const header = getAggregations(objectPage.model.root)['header'] as HeaderItem | undefined;
176+
const titlePath = header?.properties?.title?.value;
177+
if (!titlePath) {
178+
return undefined;
179+
}
180+
return titlePath;
181+
}
182+
161183
/**
162184
* Extracts header sections data from an object page model.
163185
*

packages/ui5-test-writer/templates/v4/1.150/integration/ObjectPageJourney.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ sap.ui.define([
6161
});
6262
<% } -%>
6363

64+
<% if (headerTitle) { -%>
65+
opaTest("Check header title of the Object Page", function (_Given, _When, Then) {
66+
Then.onThe<%- name%>Generated.onHeader().iCheckTitlePath(<%- JSON.stringify(headerTitle) %>);
67+
});
68+
69+
<% } -%>
6470
<% if (headerSections?.length > 0) { -%>
6571
opaTest("Check header facets of the Object Page", function (Given, When, Then) {
6672
<% headerSections.forEach(function(section) { -%>

packages/ui5-test-writer/templates/v4/1.150/integration/ObjectPageJourney.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ function journey() {
8383
});
8484
<% } -%>
8585

86+
<% if (headerTitle) { -%>
87+
opaTest("Check header title of the Object Page", function (_Given: Given, _When: When, Then: Then) {
88+
Then.onThe<%- name%>Generated.onHeader().iCheckTitlePath(<%- JSON.stringify(headerTitle) %>);
89+
});
90+
91+
<% } -%>
8692
<% if (headerSections?.length > 0) { -%>
8793
opaTest("Check header facets of the Object Page", function (_Given: Given, _When: When, Then: Then) {
8894
<% headerSections.forEach(function(section) { -%>

packages/ui5-test-writer/templates/v4/1.84/integration/ObjectPageJourney.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ sap.ui.define([
6161
});
6262
<% } -%>
6363

64+
<% if (headerTitle) { -%>
65+
opaTest("Check header title of the Object Page", function (_Given, _When, Then) {
66+
Then.onThe<%- name%>Generated.onHeader().iCheckTitlePath(<%- JSON.stringify(headerTitle) %>);
67+
});
68+
69+
<% } -%>
6470
<% if (headerSections?.length > 0) { -%>
6571
opaTest("Check header facets of the Object Page", function (Given, When, Then) {
6672
<% headerSections.forEach(function(section) { -%>

packages/ui5-test-writer/templates/v4/1.84/integration/ObjectPageJourney.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ function journey() {
8080
});
8181
<% } -%>
8282

83+
<% if (headerTitle) { -%>
84+
opaTest("Check header title of the Object Page", function (_Given: Given, _When: When, Then: Then) {
85+
Then.onThe<%- name%>Generated.onHeader().iCheckTitlePath(<%- JSON.stringify(headerTitle) %>);
86+
});
87+
88+
<% } -%>
8389
<% if (headerSections?.length > 0) { -%>
8490
opaTest("Check header facets of the Object Page", function (_Given: Given, _When: When, Then: Then) {
8591
<% headerSections.forEach(function(section) { -%>

packages/ui5-test-writer/test/test-input/constants.ts

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

packages/ui5-test-writer/test/unit/fiori-elements.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,10 @@ export type Then = Opa5 & BaseArrangements & {
805805

806806
const bookingObjPageJourneyContent =
807807
fs.dump()['test/test-output/LROPv4/webapp/test/integration/BookingObjectPageJourney.gen.js'].contents;
808+
expect(bookingObjPageJourneyContent).toContain('onHeader().iCheckTitlePath("BookingID")');
809+
const travelObjPageJourneyContent =
810+
fs.dump()['test/test-output/LROPv4/webapp/test/integration/TravelObjectPageJourney.gen.js'].contents;
811+
expect(travelObjPageJourneyContent).toContain('onHeader().iCheckTitlePath("TravelID")');
808812
expect(bookingObjPageJourneyContent).toContain('iCheckHeaderFacet({ facetId: "DataPoint::FlightDate" }');
809813
expect(bookingObjPageJourneyContent).toContain('iCheckHeaderFacet({ facetId: "DataPoint::BookingDate" }');
810814
expect(bookingObjPageJourneyContent).toContain('iCheckHeaderFacet({ facetId: "FieldGroup::Names" }');

packages/ui5-test-writer/test/unit/utils/objectPageUtils.test.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,52 @@ describe('Test getObjectPageFeatures()', () => {
340340
expect(result[0].headerSections?.[0].stashed).toBe(false);
341341
});
342342

343+
test('should extract header title binding path from header.properties.title.value', async () => {
344+
const objectPage = {
345+
name: 'objectPage1',
346+
pageType: 'ObjectPage',
347+
model: {
348+
root: {
349+
aggregations: {
350+
header: {
351+
properties: {
352+
title: { value: 'Customer' }
353+
},
354+
aggregations: {}
355+
} as unknown as TreeAggregation
356+
}
357+
} as unknown as TreeAggregation,
358+
name: 'test',
359+
schema: {}
360+
}
361+
};
362+
const result = await getObjectPageFeatures([objectPage] as PageWithModelV4[], 'listReportPage', mockLogger);
363+
expect(result).toHaveLength(1);
364+
expect(result[0].headerTitle).toBe('Customer');
365+
});
366+
367+
test('should leave headerTitle undefined when no title binding path is present', async () => {
368+
const objectPage = {
369+
name: 'objectPage1',
370+
pageType: 'ObjectPage',
371+
model: {
372+
root: {
373+
aggregations: {
374+
header: {
375+
properties: { title: { value: '' } },
376+
aggregations: {}
377+
} as unknown as TreeAggregation
378+
}
379+
} as unknown as TreeAggregation,
380+
name: 'test',
381+
schema: {}
382+
}
383+
};
384+
const result = await getObjectPageFeatures([objectPage] as PageWithModelV4[], 'listReportPage', mockLogger);
385+
expect(result).toHaveLength(1);
386+
expect(result[0].headerTitle).toBeUndefined();
387+
});
388+
343389
test('should extract header sections with facetId containing # replaced with ::', async () => {
344390
const objectPage = {
345391
name: 'objectPage1',

0 commit comments

Comments
 (0)