@sap-ux/ui5-test-writer 1.7.2 → 1.8.0
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/fiori-elements-opa-writer.js +6 -17
- package/dist/types.d.ts +5 -1
- package/dist/utils/journeyRunnerUtils.js +18 -4
- package/dist/utils/listReportUtils.d.ts +13 -0
- package/dist/utils/listReportUtils.js +35 -4
- package/dist/utils/modelUtils.js +1 -1
- package/dist/utils/objectPageUtils.d.ts +20 -1
- package/dist/utils/objectPageUtils.js +31 -9
- package/dist/utils/opaJourneyTypesUtils.d.ts +4 -4
- package/dist/utils/opaJourneyTypesUtils.js +48 -10
- package/dist/utils/tableUtils.d.ts +10 -0
- package/dist/utils/tableUtils.js +43 -6
- package/package.json +4 -4
- package/templates/v4/1.148/integration/FPMJourney.js +0 -8
- package/templates/v4/1.148/integration/FPMJourney.ts +38 -0
- package/templates/v4/1.148/integration/ListReportJourney.js +2 -0
- package/templates/v4/1.148/integration/ListReportJourney.ts +2 -0
- package/templates/v4/1.148/integration/ObjectPageJourney.js +6 -2
- package/templates/v4/1.148/integration/ObjectPageJourney.ts +6 -2
- package/templates/v4/1.148/integration/pages/FPM.ts +25 -0
- package/templates/v4/1.148/integration/pages/JourneyRunner.ts +9 -1
- package/templates/v4/1.148/integration/types/OpaJourneyTypes.d.ts +27 -6
- package/templates/v4/1.84/integration/FPMJourney.js +0 -8
- package/templates/v4/1.84/integration/FPMJourney.ts +38 -0
- package/templates/v4/1.84/integration/ListReportJourney.js +2 -0
- package/templates/v4/1.84/integration/ListReportJourney.ts +2 -0
- package/templates/v4/1.84/integration/ObjectPageJourney.js +6 -2
- package/templates/v4/1.84/integration/ObjectPageJourney.ts +6 -2
- package/templates/v4/1.84/integration/pages/FPM.ts +25 -0
- package/templates/v4/1.84/integration/pages/JourneyRunner.ts +9 -1
- package/templates/v4/1.84/integration/types/OpaJourneyTypes.d.ts +27 -6
- package/templates/v4/latest/integration/FPMJourney.js +0 -8
- package/templates/v4/latest/integration/FPMJourney.ts +38 -0
- package/templates/v4/latest/integration/ListReportJourney.js +2 -0
- package/templates/v4/latest/integration/ListReportJourney.ts +2 -0
- package/templates/v4/latest/integration/ObjectPageJourney.js +6 -2
- package/templates/v4/latest/integration/ObjectPageJourney.ts +6 -2
- package/templates/v4/latest/integration/pages/FPM.ts +25 -0
- package/templates/v4/latest/integration/pages/JourneyRunner.ts +9 -1
- package/templates/v4/latest/integration/types/OpaJourneyTypes.d.ts +27 -6
|
@@ -13,6 +13,7 @@ import { hasVirtualOPA5, addVirtualTestConfig } from './utils/virtualOpaUtils.js
|
|
|
13
13
|
import { addJourneysToOpaJourneyTypes } from './utils/opaJourneyTypesUtils.js';
|
|
14
14
|
import { getPackageScripts } from '@sap-ux/fiori-generator-shared';
|
|
15
15
|
import { readHashFromFlpSandbox } from './utils/flpSandboxUtils.js';
|
|
16
|
+
import { isALPManifestTarget } from './utils/listReportUtils.js';
|
|
16
17
|
import { compareUI5VersionGte } from '@sap-ux/ui5-application-writer';
|
|
17
18
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
18
19
|
const V4_TEMPLATE_LATEST = 'latest';
|
|
@@ -49,12 +50,9 @@ export async function generateOPAFiles(basePath, options, metadata, fs, log, sta
|
|
|
49
50
|
const manifest = readManifest(editor, basePath);
|
|
50
51
|
const { applicationType, hideFilterBar } = getAppTypeAndHideFilterBarFromManifest(manifest);
|
|
51
52
|
const config = createConfig(manifest, options, hideFilterBar);
|
|
52
|
-
// When any page in the app uses the FPM template, all generated files must be JS.
|
|
53
|
-
// FPM has no TypeScript templates, so a mixed FPM + LR/OP app cannot use TS test files.
|
|
54
|
-
const hasFPMPage = config.pages.some((page) => page.template === 'FPM');
|
|
55
53
|
// In standalone mode, auto-detect TS vs JS from the project (presence of `tsconfig.json`)
|
|
56
54
|
// when the caller has not made an explicit choice. This enforces "TS app → TS tests, JS app → JS tests".
|
|
57
|
-
const enableTypeScript =
|
|
55
|
+
const enableTypeScript = options.enableTypeScript ?? (standalone && existsSync(join(basePath, FileName.Tsconfig)));
|
|
58
56
|
const dotFileExtension = enableTypeScript ? DotFileExtension.TS : DotFileExtension.JS;
|
|
59
57
|
const rootCommonTemplateDirPath = join(__dirname, '../templates/common');
|
|
60
58
|
const templateUi5Version = getTemplateUi5Version(options.ui5Version);
|
|
@@ -384,7 +382,7 @@ function createPageConfig(manifest, targetKey, forcedAppID) {
|
|
|
384
382
|
isStartup: false,
|
|
385
383
|
fileName: targetKey + '.gen'
|
|
386
384
|
};
|
|
387
|
-
if (target
|
|
385
|
+
if (isALPManifestTarget(target)) {
|
|
388
386
|
pageConfig.template = 'AnalyticalListPage';
|
|
389
387
|
}
|
|
390
388
|
if (target.options.settings.contextPath) {
|
|
@@ -573,14 +571,7 @@ function writeJourneyFiles(appFeatures, writeContext) {
|
|
|
573
571
|
});
|
|
574
572
|
}
|
|
575
573
|
if (writeContext.generateUxSpecJourneys && appFeatures.fpm?.name) {
|
|
576
|
-
|
|
577
|
-
// (LROP only). The FPM journey path below is hardcoded `.js` and there is
|
|
578
|
-
// no `FPM.ts` template, so we force `DotFileExtension.JS` for the FPM
|
|
579
|
-
// page-object regardless of the configured `dotFileExtension`. Otherwise
|
|
580
|
-
// an LR-OP-FPM mix with `enableTypeScript` would crash in `writePageObject`
|
|
581
|
-
// when trying to load the missing `FPM.ts` template.
|
|
582
|
-
// Future work: add FPM.ts/FPMJourney.ts templates and switch to `dotFileExtension`.
|
|
583
|
-
editor.copyTpl(join(rootV4TemplateDirPath, 'integration', 'FPMJourney.js'), join(testOutDirPath, 'integration', `${appFeatures.fpm.name}Journey.gen.js`), {
|
|
574
|
+
editor.copyTpl(join(rootV4TemplateDirPath, 'integration', `FPMJourney${dotFileExtension}`), join(testOutDirPath, 'integration', `${appFeatures.fpm.name}Journey.gen${dotFileExtension}`), {
|
|
584
575
|
...journeyParams,
|
|
585
576
|
...appFeatures.fpm
|
|
586
577
|
}, undefined, {
|
|
@@ -736,16 +727,14 @@ function updateReferencesInOpaTestsStartupFiles(writeContext, generatedJourneys
|
|
|
736
727
|
* @returns path to the written page object
|
|
737
728
|
*/
|
|
738
729
|
function writePageObject(pageConfig, rootTemplateDirPath, testOutDirPath, fs, dotFileExtension) {
|
|
739
|
-
|
|
740
|
-
const ext = pageConfig.template === 'FPM' ? DotFileExtension.JS : dotFileExtension;
|
|
741
|
-
fs.copyTpl(join(rootTemplateDirPath, 'integration', 'pages', `${pageConfig.template}${ext}`), join(testOutDirPath, 'integration', 'pages', `${pageConfig.targetKey}.gen${ext}`), pageConfig, undefined, {
|
|
730
|
+
fs.copyTpl(join(rootTemplateDirPath, 'integration', 'pages', `${pageConfig.template}${dotFileExtension}`), join(testOutDirPath, 'integration', 'pages', `${pageConfig.targetKey}.gen${dotFileExtension}`), pageConfig, undefined, {
|
|
742
731
|
globOptions: { dot: true }
|
|
743
732
|
});
|
|
744
733
|
return {
|
|
745
734
|
targetKey: pageConfig.targetKey,
|
|
746
735
|
appPath: pageConfig.appPath,
|
|
747
736
|
fileName: `${pageConfig.targetKey}.gen`,
|
|
748
|
-
dotFileExtension
|
|
737
|
+
dotFileExtension,
|
|
749
738
|
template: pageConfig.template,
|
|
750
739
|
appID: pageConfig.appID,
|
|
751
740
|
componentID: pageConfig.componentID,
|
package/dist/types.d.ts
CHANGED
|
@@ -71,6 +71,9 @@ export type FEV4ManifestTarget = {
|
|
|
71
71
|
};
|
|
72
72
|
views?: {
|
|
73
73
|
paths?: Array<{
|
|
74
|
+
key?: string;
|
|
75
|
+
entitySet?: string;
|
|
76
|
+
template?: string;
|
|
74
77
|
primary?: unknown[];
|
|
75
78
|
secondary?: unknown[];
|
|
76
79
|
defaultPath?: string;
|
|
@@ -109,7 +112,8 @@ export type ObjectPageNavigationParent = {
|
|
|
109
112
|
};
|
|
110
113
|
export type ObjectPageNavigationParents = {
|
|
111
114
|
parentLRName?: string;
|
|
112
|
-
|
|
115
|
+
parentLRViewKey?: string;
|
|
116
|
+
parentLRViewIsDefault?: boolean;
|
|
113
117
|
parentOPs: ObjectPageNavigationParent[];
|
|
114
118
|
};
|
|
115
119
|
export type SectionFormField = {
|
|
@@ -175,6 +175,15 @@ function findPagesToAdd(fileContent, pages) {
|
|
|
175
175
|
*/
|
|
176
176
|
function buildPageEntry(page, pageIndent, innerIndent) {
|
|
177
177
|
const framework = page.template ?? 'ListReport';
|
|
178
|
+
// FPM pages have no dedicated sap/fe/test class; construct a TemplatePage via cast, mirroring the template.
|
|
179
|
+
if (framework === 'FPM') {
|
|
180
|
+
return [
|
|
181
|
+
`${pageIndent}onThe${page.targetKey}Generated: new (TemplatePage as unknown as new (id: string, defs: object) => object)(`,
|
|
182
|
+
`${innerIndent}"${page.appID ?? ''}::${page.componentID ?? ''}",`,
|
|
183
|
+
`${innerIndent}Custom${page.targetKey}Generated`,
|
|
184
|
+
`${pageIndent})`
|
|
185
|
+
].join('\n');
|
|
186
|
+
}
|
|
178
187
|
const innerProps = [
|
|
179
188
|
`${innerIndent} appId: "${page.appID ?? ''}"`,
|
|
180
189
|
`${innerIndent} componentId: "${page.componentID ?? ''}"`,
|
|
@@ -234,11 +243,16 @@ export function splicePageIntoJourneyRunnerTs(fileContent, pages) {
|
|
|
234
243
|
if (toAdd.length === 0) {
|
|
235
244
|
return fileContent;
|
|
236
245
|
}
|
|
237
|
-
// Determine which framework imports
|
|
238
|
-
|
|
239
|
-
const
|
|
246
|
+
// Determine which framework imports are missing and need to be added. FPM pages construct a
|
|
247
|
+
// `TemplatePage` (there is no `sap/fe/test/FPM` module), so map FPM to TemplatePage.
|
|
248
|
+
const importModuleForTemplate = (template) => (template === 'FPM' ? 'TemplatePage' : template);
|
|
249
|
+
const frameworkModules = Array.from(new Set(toAdd
|
|
250
|
+
.map((page) => page.template)
|
|
251
|
+
.filter((template) => Boolean(template))
|
|
252
|
+
.map(importModuleForTemplate)));
|
|
253
|
+
const missingFrameworkImports = frameworkModules.filter((module) => !fileContent.includes(`from "sap/fe/test/${module}"`));
|
|
240
254
|
const newImportLines = [
|
|
241
|
-
...missingFrameworkImports.map((
|
|
255
|
+
...missingFrameworkImports.map((module) => `import ${module} from "sap/fe/test/${module}";`),
|
|
242
256
|
...toAdd.map((page) => `import Custom${page.targetKey}Generated from "./${page.fileName}";`)
|
|
243
257
|
];
|
|
244
258
|
const withImports = insertAfterLastImport(fileContent, newImportLines);
|
|
@@ -117,6 +117,19 @@ export declare function getCustomFilterFieldProperties(manifest: Manifest | unde
|
|
|
117
117
|
* @returns array of non-custom tab keys in manifest order, empty for single-table LRs
|
|
118
118
|
*/
|
|
119
119
|
export declare function getTableIdentifiers(manifest: Manifest | undefined, targetKey: string | undefined): string[];
|
|
120
|
+
/**
|
|
121
|
+
* Returns the non-custom view tabs of a List Report with their optional entity set, in manifest
|
|
122
|
+
* order, used to map an Object Page to the tab that exposes it. Custom tabs (backed by an app
|
|
123
|
+
* fragment via `template`) are skipped as they host no navigable table.
|
|
124
|
+
*
|
|
125
|
+
* @param manifest - the application manifest (may be undefined)
|
|
126
|
+
* @param targetKey - routing target key of the List Report page
|
|
127
|
+
* @returns array of `{ key, entitySet? }` for non-custom tabs, empty when there is no views block
|
|
128
|
+
*/
|
|
129
|
+
export declare function getListReportViews(manifest: Manifest | undefined, targetKey: string | undefined): {
|
|
130
|
+
key: string;
|
|
131
|
+
entitySet?: string;
|
|
132
|
+
}[];
|
|
120
133
|
/**
|
|
121
134
|
* Retrieves the value of `@com.sap.vocabularies.Common.v1.Label` for a specific property
|
|
122
135
|
* of the given entity set.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getFilterFields, getSelectionFieldItems, getSelectionFieldItemsWithLabels, getTableColumnData, getAggregations } from './modelUtils.js';
|
|
2
|
-
import { extractContactCardColumnsFromNode } from './tableUtils.js';
|
|
2
|
+
import { extractContactCardColumnsFromNode, resolvePrimaryTableNode } from './tableUtils.js';
|
|
3
3
|
import { parse } from '@sap-ux/edmx-parser';
|
|
4
4
|
import { convert } from '@sap-ux/annotation-converter';
|
|
5
5
|
import { extractActionMethodName, buildActionButtonState, safeCheckButtonVisibility, safeCheckButtonVisibilityFromMetadata } from './actionUtils.js';
|
|
@@ -159,9 +159,11 @@ export function getListReportFeatures(listReportPage, log, metadata, manifest) {
|
|
|
159
159
|
* @returns The toolbar actions aggregation object.
|
|
160
160
|
*/
|
|
161
161
|
export function getToolBarActions(pageModel) {
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
const tableNode = resolvePrimaryTableNode(pageModel.root);
|
|
163
|
+
if (!tableNode) {
|
|
164
|
+
return {};
|
|
165
|
+
}
|
|
166
|
+
const toolBar = getAggregations(tableNode)['toolBar'];
|
|
165
167
|
const toolBarAggregations = getAggregations(toolBar);
|
|
166
168
|
const actions = toolBarAggregations['actions'];
|
|
167
169
|
const actionAggregations = getAggregations(actions);
|
|
@@ -280,6 +282,35 @@ export function getTableIdentifiers(manifest, targetKey) {
|
|
|
280
282
|
}
|
|
281
283
|
return identifiers;
|
|
282
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* Returns the non-custom view tabs of a List Report with their optional entity set, in manifest
|
|
287
|
+
* order, used to map an Object Page to the tab that exposes it. Custom tabs (backed by an app
|
|
288
|
+
* fragment via `template`) are skipped as they host no navigable table.
|
|
289
|
+
*
|
|
290
|
+
* @param manifest - the application manifest (may be undefined)
|
|
291
|
+
* @param targetKey - routing target key of the List Report page
|
|
292
|
+
* @returns array of `{ key, entitySet? }` for non-custom tabs, empty when there is no views block
|
|
293
|
+
*/
|
|
294
|
+
export function getListReportViews(manifest, targetKey) {
|
|
295
|
+
if (!manifest || !targetKey) {
|
|
296
|
+
return [];
|
|
297
|
+
}
|
|
298
|
+
const target = manifest['sap.ui5']?.routing?.targets?.[targetKey];
|
|
299
|
+
const paths = target?.options?.settings?.views?.paths;
|
|
300
|
+
if (!Array.isArray(paths)) {
|
|
301
|
+
return [];
|
|
302
|
+
}
|
|
303
|
+
const views = [];
|
|
304
|
+
for (const path of paths) {
|
|
305
|
+
if (path &&
|
|
306
|
+
typeof path.key === 'string' &&
|
|
307
|
+
path.key.length > 0 &&
|
|
308
|
+
!(typeof path.template === 'string' && path.template.length > 0)) {
|
|
309
|
+
views.push({ key: path.key, entitySet: path.entitySet });
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return views;
|
|
313
|
+
}
|
|
283
314
|
/**
|
|
284
315
|
* Retrieves the value of `@com.sap.vocabularies.Common.v1.Label` for a specific property
|
|
285
316
|
* of the given entity set.
|
package/dist/utils/modelUtils.js
CHANGED
|
@@ -59,7 +59,7 @@ export async function getAppFeatures(basePath, fs, log, metadata, manifest) {
|
|
|
59
59
|
featureData.listReport = getListReportFeatures(listReportPage, log, projectMetadata, manifest);
|
|
60
60
|
}
|
|
61
61
|
if (objectPages) {
|
|
62
|
-
featureData.objectPages = await getObjectPageFeatures(objectPages, listReportPage?.name, log, projectMetadata, manifest);
|
|
62
|
+
featureData.objectPages = await getObjectPageFeatures(objectPages, listReportPage?.name, log, projectMetadata, manifest, listReportPage?.entitySet);
|
|
63
63
|
}
|
|
64
64
|
if (fpmPage) {
|
|
65
65
|
featureData.fpm = getFPMFeatures(fpmPage, log);
|
|
@@ -11,9 +11,10 @@ import type { PageWithModelV4 } from '@sap/ux-specification/dist/types/src/parse
|
|
|
11
11
|
* @param log - optional logger instance
|
|
12
12
|
* @param metadata - optional metadata for the OPA test generation
|
|
13
13
|
* @param manifest - optional application manifest, used to resolve the parent List Report's default table tab
|
|
14
|
+
* @param listReportEntitySet
|
|
14
15
|
* @returns a record of object page feature data
|
|
15
16
|
*/
|
|
16
|
-
export declare function getObjectPageFeatures(objectPages: PageWithModelV4[], listReportPageKey?: string, log?: Logger, metadata?: string, manifest?: Manifest): Promise<ObjectPageFeatures[]>;
|
|
17
|
+
export declare function getObjectPageFeatures(objectPages: PageWithModelV4[], listReportPageKey?: string, log?: Logger, metadata?: string, manifest?: Manifest, listReportEntitySet?: string): Promise<ObjectPageFeatures[]>;
|
|
17
18
|
/**
|
|
18
19
|
* Retrieves all Object Page definitions from the given application model, as long as the page is reachable via standard navigation routes.
|
|
19
20
|
*
|
|
@@ -21,4 +22,22 @@ export declare function getObjectPageFeatures(objectPages: PageWithModelV4[], li
|
|
|
21
22
|
* @returns An array of Object Page definitions.
|
|
22
23
|
*/
|
|
23
24
|
export declare function getObjectPages(applicationModel: ApplicationModel): PageWithModelV4[];
|
|
25
|
+
type OriginatingView = {
|
|
26
|
+
key: string;
|
|
27
|
+
isDefault: boolean;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Resolves which List Report view/tab exposes a given Object Page. A view inherits the List Report's
|
|
31
|
+
* main entity set when it declares none of its own; the first non-custom view is the default tab.
|
|
32
|
+
*
|
|
33
|
+
* @param views - the parent List Report's non-custom views, in manifest order
|
|
34
|
+
* @param objectPageEntitySet - the Object Page's entity set
|
|
35
|
+
* @param listReportEntitySet - the List Report's main entity set
|
|
36
|
+
* @returns the originating view, or undefined for single-table List Reports
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveOriginatingView(views: {
|
|
39
|
+
key: string;
|
|
40
|
+
entitySet?: string;
|
|
41
|
+
}[], objectPageEntitySet?: string, listReportEntitySet?: string): OriginatingView | undefined;
|
|
42
|
+
export {};
|
|
24
43
|
//# sourceMappingURL=objectPageUtils.d.ts.map
|
|
@@ -4,7 +4,7 @@ import { PageTypeV4 } from '@sap/ux-specification/dist/types/src/common/page.js'
|
|
|
4
4
|
import { parse } from '@sap-ux/edmx-parser';
|
|
5
5
|
import { convert } from '@sap-ux/annotation-converter';
|
|
6
6
|
import { buildActionStateFromSpecModelKey, safeCheckButtonVisibility, safeCheckEditVisibility } from './actionUtils.js';
|
|
7
|
-
import {
|
|
7
|
+
import { getListReportViews } from './listReportUtils.js';
|
|
8
8
|
/**
|
|
9
9
|
* Extracts feature data for object pages from the application model.
|
|
10
10
|
*
|
|
@@ -13,9 +13,10 @@ import { getTableIdentifiers } from './listReportUtils.js';
|
|
|
13
13
|
* @param log - optional logger instance
|
|
14
14
|
* @param metadata - optional metadata for the OPA test generation
|
|
15
15
|
* @param manifest - optional application manifest, used to resolve the parent List Report's default table tab
|
|
16
|
+
* @param listReportEntitySet
|
|
16
17
|
* @returns a record of object page feature data
|
|
17
18
|
*/
|
|
18
|
-
export async function getObjectPageFeatures(objectPages, listReportPageKey, log, metadata, manifest) {
|
|
19
|
+
export async function getObjectPageFeatures(objectPages, listReportPageKey, log, metadata, manifest, listReportEntitySet) {
|
|
19
20
|
const objectPageFeatures = [];
|
|
20
21
|
if (!objectPages || objectPages.length === 0) {
|
|
21
22
|
log?.warn('Object Pages not found in application model. Dynamic tests will not be generated for Object Pages.');
|
|
@@ -24,13 +25,13 @@ export async function getObjectPageFeatures(objectPages, listReportPageKey, log,
|
|
|
24
25
|
// attempt to get individual feature data for each object page
|
|
25
26
|
const convertedMetadata = metadata ? convert(parse(metadata)) : undefined;
|
|
26
27
|
const schemaNamespace = convertedMetadata?.namespace ?? '';
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
const
|
|
28
|
+
// Non-custom tabs of the parent List Report with their optional entity set. Used to pick the
|
|
29
|
+
// tab a given Object Page is reached from on multi-view LRs; empty for single-table LRs.
|
|
30
|
+
const listReportViews = getListReportViews(manifest, listReportPageKey);
|
|
30
31
|
for (const objectPage of objectPages) {
|
|
31
32
|
const pageFeatureData = {};
|
|
32
33
|
pageFeatureData.name = objectPage.name;
|
|
33
|
-
pageFeatureData.navigationParents = getObjectPageNavigationParents(objectPage.name, objectPages, listReportPageKey,
|
|
34
|
+
pageFeatureData.navigationParents = getObjectPageNavigationParents(objectPage.name, objectPages, listReportPageKey, resolveOriginatingView(listReportViews, objectPage.entitySet, listReportEntitySet));
|
|
34
35
|
// extract header title binding path (for iCheckTitlePath)
|
|
35
36
|
pageFeatureData.headerTitle = getHeaderTitlePath(objectPage);
|
|
36
37
|
// extract header sections (facets)
|
|
@@ -72,10 +73,10 @@ export function getObjectPages(applicationModel) {
|
|
|
72
73
|
* @param targetObjectPageKey - key of the target object page
|
|
73
74
|
* @param objectPages - the array of object pages extracted from the application model
|
|
74
75
|
* @param listReportPageKey - the key of the List Report page in the application model, used to find navigation routes to object pages
|
|
75
|
-
* @param
|
|
76
|
+
* @param originatingView - the parent List Report view/tab this Object Page is reached from (undefined for single-table LRs)
|
|
76
77
|
* @returns navigation data including the ordered ancestor Object Page chain
|
|
77
78
|
*/
|
|
78
|
-
function getObjectPageNavigationParents(targetObjectPageKey, objectPages, listReportPageKey,
|
|
79
|
+
function getObjectPageNavigationParents(targetObjectPageKey, objectPages, listReportPageKey, originatingView) {
|
|
79
80
|
const parentOPs = [];
|
|
80
81
|
const visited = new Set([targetObjectPageKey]); // guard against infinite loop in case of invalid manifest entries
|
|
81
82
|
let cursor = targetObjectPageKey;
|
|
@@ -100,10 +101,31 @@ function getObjectPageNavigationParents(targetObjectPageKey, objectPages, listRe
|
|
|
100
101
|
}
|
|
101
102
|
return {
|
|
102
103
|
parentLRName: listReportPageKey ?? '', // app is possibly malformed if no LR found
|
|
103
|
-
|
|
104
|
+
parentLRViewKey: originatingView?.key,
|
|
105
|
+
parentLRViewIsDefault: originatingView?.isDefault,
|
|
104
106
|
parentOPs
|
|
105
107
|
};
|
|
106
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Resolves which List Report view/tab exposes a given Object Page. A view inherits the List Report's
|
|
111
|
+
* main entity set when it declares none of its own; the first non-custom view is the default tab.
|
|
112
|
+
*
|
|
113
|
+
* @param views - the parent List Report's non-custom views, in manifest order
|
|
114
|
+
* @param objectPageEntitySet - the Object Page's entity set
|
|
115
|
+
* @param listReportEntitySet - the List Report's main entity set
|
|
116
|
+
* @returns the originating view, or undefined for single-table List Reports
|
|
117
|
+
*/
|
|
118
|
+
export function resolveOriginatingView(views, objectPageEntitySet, listReportEntitySet) {
|
|
119
|
+
if (views.length === 0) {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
// No match falls back to the first (default) view, which is where a main-entity OP belongs — this also covers an undefined listReportEntitySet.
|
|
123
|
+
const matchIndex = objectPageEntitySet
|
|
124
|
+
? views.findIndex((view) => (view.entitySet ?? listReportEntitySet) === objectPageEntitySet)
|
|
125
|
+
: -1;
|
|
126
|
+
const index = matchIndex >= 0 ? matchIndex : 0;
|
|
127
|
+
return { key: views[index].key, isDefault: index === 0 };
|
|
128
|
+
}
|
|
107
129
|
/**
|
|
108
130
|
* Returns the OData property path the Object Page header title is bound to, for use with
|
|
109
131
|
* `iCheckTitlePath`. Returns undefined for static titles that expose no binding path.
|
|
@@ -2,21 +2,21 @@ import type { Editor } from 'mem-fs-editor';
|
|
|
2
2
|
import type { Logger } from '@sap-ux/logger';
|
|
3
3
|
import type { OpaPageWriteInfo } from './journeyRunnerUtils.js';
|
|
4
4
|
/**
|
|
5
|
-
* Splice new journey entries into an existing `OpaJourneyTypes.d.ts`: framework imports,
|
|
5
|
+
* Splice new journey entries into an existing `OpaJourneyTypes.gen.d.ts`: framework imports,
|
|
6
6
|
* per-page custom actions/assertions imports, and `onThe<targetKey>Generated` members in
|
|
7
7
|
* the `When` and `Then` unions. Pages already imported are skipped; all other content is preserved.
|
|
8
8
|
*
|
|
9
|
-
* @param fileContent - the full content of the OpaJourneyTypes.d.ts file
|
|
9
|
+
* @param fileContent - the full content of the OpaJourneyTypes.gen.d.ts file
|
|
10
10
|
* @param pages - pages to add
|
|
11
11
|
* @returns the updated file content, or the original content unchanged if nothing was added
|
|
12
12
|
*/
|
|
13
13
|
export declare function spliceJourneysIntoOpaJourneyTypes(fileContent: string, pages: OpaPageWriteInfo[]): string;
|
|
14
14
|
/**
|
|
15
|
-
* Read `OpaJourneyTypes.d.ts` from the project, splice entries for new pages, and write
|
|
15
|
+
* Read `OpaJourneyTypes.gen.d.ts` from the project, splice entries for new pages, and write
|
|
16
16
|
* the result back. Pages already present are skipped. If the file does not exist or
|
|
17
17
|
* cannot be read, logs a warning and returns without writing.
|
|
18
18
|
*
|
|
19
|
-
* @param pages - pages whose journeys should be reflected in OpaJourneyTypes.d.ts
|
|
19
|
+
* @param pages - pages whose journeys should be reflected in OpaJourneyTypes.gen.d.ts
|
|
20
20
|
* @param testOutDirPath - path to the test output directory (`.../webapp/test`)
|
|
21
21
|
* @param fs - mem-fs-editor instance used to read and write the file
|
|
22
22
|
* @param log - optional logger instance used to surface warnings when the file
|
|
@@ -4,12 +4,39 @@ import { MAX_FILE_CONTENT_LENGTH, escapeRegex, findBracedBlock, insertAfterLastI
|
|
|
4
4
|
/** Relative path from the test output directory to OpaJourneyTypes.gen.d.ts */
|
|
5
5
|
const OPA_JOURNEY_TYPES_FILE = join('integration', 'types', 'OpaJourneyTypes.gen.d.ts');
|
|
6
6
|
/** Frameworks the splicer knows how to render entries for. */
|
|
7
|
-
const SUPPORTED_FRAMEWORKS = new Set(['ListReport', 'ObjectPage']);
|
|
7
|
+
const SUPPORTED_FRAMEWORKS = new Set(['ListReport', 'ObjectPage', 'FPM']);
|
|
8
|
+
/** Maps a page template to the `sap/fe/test` type module supplying its actions/assertions surface. */
|
|
9
|
+
const TEMPLATE_TYPE_PREFIX = {
|
|
10
|
+
ListReport: 'ListReport',
|
|
11
|
+
ObjectPage: 'ObjectPage',
|
|
12
|
+
FPM: 'TemplatePage'
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The `WithAnd<T>` utility type enabling OPA5 fluent `.and` chaining. Kept byte-identical to the
|
|
16
|
+
* definition emitted by the `OpaJourneyTypes.d.ts` template so that splicing into a file generated
|
|
17
|
+
* before `WithAnd` existed backfills the same definition the template would have produced.
|
|
18
|
+
*/
|
|
19
|
+
const WITH_AND_TYPE_DEFINITION = `/**
|
|
20
|
+
* Enables OPA5 fluent \`.and\` chaining on page objects and their sub-objects.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* Then.onTheObjectPageGenerated.iCheckSection({ section: "A" }).and.iCheckSection({ section: "B" });
|
|
24
|
+
* When.onTheListReportGenerated.onFilterBar().iExecuteSearch().and.iClearFilterBar();
|
|
25
|
+
*/
|
|
26
|
+
type WithAnd<T> = {
|
|
27
|
+
[K in keyof T | 'and']: K extends 'and'
|
|
28
|
+
? WithAnd<T>
|
|
29
|
+
: K extends keyof T
|
|
30
|
+
? T[K] extends (...args: infer A) => infer R
|
|
31
|
+
? (...args: A) => (R extends Opa5 | object ? (keyof R extends never ? WithAnd<T> : [R] extends [Opa5] ? WithAnd<T> : WithAnd<R>) : WithAnd<T>)
|
|
32
|
+
: T[K]
|
|
33
|
+
: never;
|
|
34
|
+
};`;
|
|
8
35
|
/**
|
|
9
36
|
* Filter `pages` down to those whose generator-owned custom-actions/assertions import
|
|
10
37
|
* is not yet present (matched against `../pages/<fileName>` with the `.gen` suffix).
|
|
11
38
|
*
|
|
12
|
-
* @param fileContent - the existing OpaJourneyTypes.d.ts content
|
|
39
|
+
* @param fileContent - the existing OpaJourneyTypes.gen.d.ts content
|
|
13
40
|
* @param pages - candidate pages to splice in
|
|
14
41
|
* @returns the subset of pages that need to be added
|
|
15
42
|
*/
|
|
@@ -23,7 +50,7 @@ function findPagesToAdd(fileContent, pages) {
|
|
|
23
50
|
* Build the framework-import lines (ListReport / ObjectPage / TemplatePage) that need to be
|
|
24
51
|
* added to the file, skipping any already imported.
|
|
25
52
|
*
|
|
26
|
-
* @param fileContent - the existing OpaJourneyTypes.d.ts content
|
|
53
|
+
* @param fileContent - the existing OpaJourneyTypes.gen.d.ts content
|
|
27
54
|
* @param pages - the new pages being added
|
|
28
55
|
* @returns the list of framework-import lines to insert
|
|
29
56
|
*/
|
|
@@ -36,7 +63,7 @@ function buildMissingFrameworkImports(fileContent, pages) {
|
|
|
36
63
|
if (templates.has('ObjectPage') && !fileContent.includes('from "sap/fe/test/ObjectPage"')) {
|
|
37
64
|
lines.push(`import type { actions as ObjectPageActions, assertions as ObjectPageAssertions } from "sap/fe/test/ObjectPage";`);
|
|
38
65
|
}
|
|
39
|
-
if ((templates.has('ListReport') || templates.has('ObjectPage')) &&
|
|
66
|
+
if ((templates.has('ListReport') || templates.has('ObjectPage') || templates.has('FPM')) &&
|
|
40
67
|
!fileContent.includes('from "sap/fe/test/TemplatePage"')) {
|
|
41
68
|
lines.push(`import type { actions as TemplatePageActions, assertions as TemplatePageAssertions } from "sap/fe/test/TemplatePage";`);
|
|
42
69
|
}
|
|
@@ -66,8 +93,14 @@ function buildPageUnionEntry(page, mode, indent) {
|
|
|
66
93
|
}
|
|
67
94
|
const frameworkSuffix = mode === 'actions' ? 'Actions' : 'Assertions';
|
|
68
95
|
const customSuffix = mode === 'actions' ? 'CustomActions' : 'CustomAssertions';
|
|
69
|
-
|
|
70
|
-
|
|
96
|
+
const typePrefix = TEMPLATE_TYPE_PREFIX[page.template];
|
|
97
|
+
// FPM's whole typed surface is TemplatePage, so it needs a single TemplatePage term.
|
|
98
|
+
// LR/OP add their dedicated type on top of TemplatePage.
|
|
99
|
+
const frameworkTypes = typePrefix === 'TemplatePage'
|
|
100
|
+
? `TemplatePage${frameworkSuffix}`
|
|
101
|
+
: `${typePrefix}${frameworkSuffix} & TemplatePage${frameworkSuffix}`;
|
|
102
|
+
return (`${indent}onThe${page.targetKey}Generated: WithAnd<Opa5 & ${frameworkTypes} & ` +
|
|
103
|
+
`typeof ${page.targetKey}Generated${customSuffix}>;`);
|
|
71
104
|
}
|
|
72
105
|
/**
|
|
73
106
|
* Insert new `onThe<targetKey>Generated` member lines into the named exported type union,
|
|
@@ -97,11 +130,11 @@ function insertIntoTypeUnion(content, exportName, newEntries) {
|
|
|
97
130
|
return `${head.trimEnd()}\n${insertion}\n${tail}`;
|
|
98
131
|
}
|
|
99
132
|
/**
|
|
100
|
-
* Splice new journey entries into an existing `OpaJourneyTypes.d.ts`: framework imports,
|
|
133
|
+
* Splice new journey entries into an existing `OpaJourneyTypes.gen.d.ts`: framework imports,
|
|
101
134
|
* per-page custom actions/assertions imports, and `onThe<targetKey>Generated` members in
|
|
102
135
|
* the `When` and `Then` unions. Pages already imported are skipped; all other content is preserved.
|
|
103
136
|
*
|
|
104
|
-
* @param fileContent - the full content of the OpaJourneyTypes.d.ts file
|
|
137
|
+
* @param fileContent - the full content of the OpaJourneyTypes.gen.d.ts file
|
|
105
138
|
* @param pages - pages to add
|
|
106
139
|
* @returns the updated file content, or the original content unchanged if nothing was added
|
|
107
140
|
*/
|
|
@@ -126,16 +159,21 @@ export function spliceJourneysIntoOpaJourneyTypes(fileContent, pages) {
|
|
|
126
159
|
.map((page) => buildPageUnionEntry(page, 'assertions', ''))
|
|
127
160
|
.filter((entry) => entry !== undefined);
|
|
128
161
|
let result = insertAfterLastImport(fileContent, newImportLines);
|
|
162
|
+
// Backfill the WithAnd<T> definition for files generated before `.and` chaining support existed;
|
|
163
|
+
// spliced entries reference WithAnd<...> and would otherwise resolve to an undefined type.
|
|
164
|
+
if (!/\btype\s+WithAnd\s*</.test(result)) {
|
|
165
|
+
result = insertAfterLastImport(result, ['', WITH_AND_TYPE_DEFINITION]);
|
|
166
|
+
}
|
|
129
167
|
result = insertIntoTypeUnion(result, 'When', whenEntries);
|
|
130
168
|
result = insertIntoTypeUnion(result, 'Then', thenEntries);
|
|
131
169
|
return result;
|
|
132
170
|
}
|
|
133
171
|
/**
|
|
134
|
-
* Read `OpaJourneyTypes.d.ts` from the project, splice entries for new pages, and write
|
|
172
|
+
* Read `OpaJourneyTypes.gen.d.ts` from the project, splice entries for new pages, and write
|
|
135
173
|
* the result back. Pages already present are skipped. If the file does not exist or
|
|
136
174
|
* cannot be read, logs a warning and returns without writing.
|
|
137
175
|
*
|
|
138
|
-
* @param pages - pages whose journeys should be reflected in OpaJourneyTypes.d.ts
|
|
176
|
+
* @param pages - pages whose journeys should be reflected in OpaJourneyTypes.gen.d.ts
|
|
139
177
|
* @param testOutDirPath - path to the test output directory (`.../webapp/test`)
|
|
140
178
|
* @param fs - mem-fs-editor instance used to read and write the file
|
|
141
179
|
* @param log - optional logger instance used to surface warnings when the file
|
|
@@ -36,6 +36,16 @@ export declare function getColumnIdentifier(column: ColumnModelItem, columnKey?:
|
|
|
36
36
|
* @returns a map of column identifiers to column state objects for use with iCheckColumns()
|
|
37
37
|
*/
|
|
38
38
|
export declare function transformTableColumns(columnAggregations: ColumnAggregations): TableColumnFeatureData;
|
|
39
|
+
/**
|
|
40
|
+
* Resolves the table node that actually carries `columns`/`toolBar` aggregations.
|
|
41
|
+
* Single-table List Reports and Object Page sections expose these directly under `table`.
|
|
42
|
+
* Multi-view List Reports nest one table node per tab under `table.views[key]`; the first
|
|
43
|
+
* non-empty (non-custom) view node is returned, matching the default table tab.
|
|
44
|
+
*
|
|
45
|
+
* @param node - tree aggregation node that exposes a 'table' aggregation
|
|
46
|
+
* @returns the table node holding column/toolbar aggregations, or undefined if none is found
|
|
47
|
+
*/
|
|
48
|
+
export declare function resolvePrimaryTableNode(node: TreeAggregation): TreeAggregation | undefined;
|
|
39
49
|
/**
|
|
40
50
|
* Extracts table column data from a spec model node that contains a 'table' aggregation.
|
|
41
51
|
* Covers both page-level nodes (List Report, FPM) via their root and section-level nodes
|
package/dist/utils/tableUtils.js
CHANGED
|
@@ -45,6 +45,43 @@ export function transformTableColumns(columnAggregations) {
|
|
|
45
45
|
});
|
|
46
46
|
return columns;
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Resolves the table node that actually carries `columns`/`toolBar` aggregations.
|
|
50
|
+
* Single-table List Reports and Object Page sections expose these directly under `table`.
|
|
51
|
+
* Multi-view List Reports nest one table node per tab under `table.views[key]`; the first
|
|
52
|
+
* non-empty (non-custom) view node is returned, matching the default table tab.
|
|
53
|
+
*
|
|
54
|
+
* @param node - tree aggregation node that exposes a 'table' aggregation
|
|
55
|
+
* @returns the table node holding column/toolbar aggregations, or undefined if none is found
|
|
56
|
+
*/
|
|
57
|
+
export function resolvePrimaryTableNode(node) {
|
|
58
|
+
const tableAggregation = getAggregations(node)['table'];
|
|
59
|
+
if (!tableAggregation) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
// A usable table node exposes `columns` and/or `toolBar` directly.
|
|
63
|
+
const isTableNode = (candidate) => {
|
|
64
|
+
const children = getAggregations(candidate);
|
|
65
|
+
return !!children['columns'] || !!children['toolBar'];
|
|
66
|
+
};
|
|
67
|
+
const tableChildren = getAggregations(tableAggregation);
|
|
68
|
+
if (isTableNode(tableAggregation)) {
|
|
69
|
+
return tableAggregation;
|
|
70
|
+
}
|
|
71
|
+
// Multi-view List Report: per-tab nodes live under `views`; return the first usable one, else undefined.
|
|
72
|
+
const views = tableChildren['views'];
|
|
73
|
+
if (!views) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
const viewNodes = getAggregations(views);
|
|
77
|
+
for (const key of Object.keys(viewNodes)) {
|
|
78
|
+
const viewNode = viewNodes[key];
|
|
79
|
+
if (isTableNode(viewNode)) {
|
|
80
|
+
return viewNode;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
48
85
|
/**
|
|
49
86
|
* Extracts table column data from a spec model node that contains a 'table' aggregation.
|
|
50
87
|
* Covers both page-level nodes (List Report, FPM) via their root and section-level nodes
|
|
@@ -54,11 +91,11 @@ export function transformTableColumns(columnAggregations) {
|
|
|
54
91
|
* @returns a map of column identifiers to column state objects for use with iCheckColumns()
|
|
55
92
|
*/
|
|
56
93
|
export function extractTableColumnsFromNode(node) {
|
|
57
|
-
const
|
|
58
|
-
if (!
|
|
94
|
+
const tableNode = resolvePrimaryTableNode(node);
|
|
95
|
+
if (!tableNode) {
|
|
59
96
|
return {};
|
|
60
97
|
}
|
|
61
|
-
const columnsAggregation = getAggregations(
|
|
98
|
+
const columnsAggregation = getAggregations(tableNode)['columns'];
|
|
62
99
|
if (!columnsAggregation) {
|
|
63
100
|
return {};
|
|
64
101
|
}
|
|
@@ -72,11 +109,11 @@ export function extractTableColumnsFromNode(node) {
|
|
|
72
109
|
* @returns array of Contact-card field descriptors for use with iClickLink/iCheckLink
|
|
73
110
|
*/
|
|
74
111
|
export function extractContactCardColumnsFromNode(node) {
|
|
75
|
-
const
|
|
76
|
-
if (!
|
|
112
|
+
const tableNode = resolvePrimaryTableNode(node);
|
|
113
|
+
if (!tableNode) {
|
|
77
114
|
return [];
|
|
78
115
|
}
|
|
79
|
-
const columnsAggregation = getAggregations(
|
|
116
|
+
const columnsAggregation = getAggregations(tableNode)['columns'];
|
|
80
117
|
if (!columnsAggregation) {
|
|
81
118
|
return [];
|
|
82
119
|
}
|
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.
|
|
4
|
+
"version": "1.8.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"@sap-ux/annotation-converter": "0.10.22",
|
|
31
31
|
"@sap-ux/ui5-application-writer": "2.1.3",
|
|
32
32
|
"@sap-ux/logger": "1.0.3",
|
|
33
|
-
"@sap-ux/fiori-generator-shared": "1.2.
|
|
34
|
-
"@sap-ux/project-access": "2.1.
|
|
35
|
-
"@sap-ux/preview-middleware": "1.2.
|
|
33
|
+
"@sap-ux/fiori-generator-shared": "1.2.7",
|
|
34
|
+
"@sap-ux/project-access": "2.1.11",
|
|
35
|
+
"@sap-ux/preview-middleware": "1.2.2"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@jest/globals": "30.4.1",
|
|
@@ -28,14 +28,6 @@ sap.ui.define([
|
|
|
28
28
|
Given.iStartMyApp();
|
|
29
29
|
<%_ startPages.forEach(function(pageName) { %>
|
|
30
30
|
Then.onThe<%- pageName %>Generated.iSeeThisPage();
|
|
31
|
-
<%_ if (filterBarItems && filterBarItems.length > 0) { -%>
|
|
32
|
-
<%_ filterBarItems.forEach(function(item) { _%>
|
|
33
|
-
Then.onThe<%- pageName%>Generated.onFilterBar().iCheckFilterField({ property: "<%- item %>" });
|
|
34
|
-
<%_ }); -%>
|
|
35
|
-
<%_ } -%>
|
|
36
|
-
<%_ if (tableColumns && Object.keys(tableColumns).length > 0) { _%>
|
|
37
|
-
Then.onThe<%- pageName %>Generated.onTable().iCheckColumns(undefined, <%- JSON.stringify(tableColumns) %>);
|
|
38
|
-
<%_ } %>
|
|
39
31
|
<%_ }); -%>
|
|
40
32
|
});
|
|
41
33
|
|