@sap-ux/ui5-test-writer 1.7.4 → 1.8.1

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.
Files changed (26) hide show
  1. package/dist/fiori-elements-opa-writer.js +4 -16
  2. package/dist/utils/journeyRunnerUtils.js +18 -4
  3. package/dist/utils/opaJourneyTypesUtils.d.ts +4 -4
  4. package/dist/utils/opaJourneyTypesUtils.js +48 -10
  5. package/package.json +1 -1
  6. package/templates/v4/1.148/integration/FPMJourney.js +0 -8
  7. package/templates/v4/1.148/integration/FPMJourney.ts +38 -0
  8. package/templates/v4/1.148/integration/ObjectPageJourney.js +2 -0
  9. package/templates/v4/1.148/integration/ObjectPageJourney.ts +2 -0
  10. package/templates/v4/1.148/integration/pages/FPM.ts +25 -0
  11. package/templates/v4/1.148/integration/pages/JourneyRunner.ts +9 -1
  12. package/templates/v4/1.148/integration/types/OpaJourneyTypes.d.ts +27 -6
  13. package/templates/v4/1.84/integration/FPMJourney.js +0 -8
  14. package/templates/v4/1.84/integration/FPMJourney.ts +38 -0
  15. package/templates/v4/1.84/integration/ObjectPageJourney.js +2 -0
  16. package/templates/v4/1.84/integration/ObjectPageJourney.ts +2 -0
  17. package/templates/v4/1.84/integration/pages/FPM.ts +25 -0
  18. package/templates/v4/1.84/integration/pages/JourneyRunner.ts +9 -1
  19. package/templates/v4/1.84/integration/types/OpaJourneyTypes.d.ts +27 -6
  20. package/templates/v4/latest/integration/FPMJourney.js +0 -8
  21. package/templates/v4/latest/integration/FPMJourney.ts +38 -0
  22. package/templates/v4/latest/integration/ObjectPageJourney.js +3 -1
  23. package/templates/v4/latest/integration/ObjectPageJourney.ts +6 -1
  24. package/templates/v4/latest/integration/pages/FPM.ts +25 -0
  25. package/templates/v4/latest/integration/pages/JourneyRunner.ts +9 -1
  26. package/templates/v4/latest/integration/types/OpaJourneyTypes.d.ts +27 -6
@@ -50,12 +50,9 @@ export async function generateOPAFiles(basePath, options, metadata, fs, log, sta
50
50
  const manifest = readManifest(editor, basePath);
51
51
  const { applicationType, hideFilterBar } = getAppTypeAndHideFilterBarFromManifest(manifest);
52
52
  const config = createConfig(manifest, options, hideFilterBar);
53
- // When any page in the app uses the FPM template, all generated files must be JS.
54
- // FPM has no TypeScript templates, so a mixed FPM + LR/OP app cannot use TS test files.
55
- const hasFPMPage = config.pages.some((page) => page.template === 'FPM');
56
53
  // In standalone mode, auto-detect TS vs JS from the project (presence of `tsconfig.json`)
57
54
  // when the caller has not made an explicit choice. This enforces "TS app → TS tests, JS app → JS tests".
58
- const enableTypeScript = !hasFPMPage && (options.enableTypeScript ?? (standalone && existsSync(join(basePath, FileName.Tsconfig))));
55
+ const enableTypeScript = options.enableTypeScript ?? (standalone && existsSync(join(basePath, FileName.Tsconfig)));
59
56
  const dotFileExtension = enableTypeScript ? DotFileExtension.TS : DotFileExtension.JS;
60
57
  const rootCommonTemplateDirPath = join(__dirname, '../templates/common');
61
58
  const templateUi5Version = getTemplateUi5Version(options.ui5Version);
@@ -574,14 +571,7 @@ function writeJourneyFiles(appFeatures, writeContext) {
574
571
  });
575
572
  }
576
573
  if (writeContext.generateUxSpecJourneys && appFeatures.fpm?.name) {
577
- // FPM TypeScript support is out of scope for the initial TS OPA5 work
578
- // (LROP only). The FPM journey path below is hardcoded `.js` and there is
579
- // no `FPM.ts` template, so we force `DotFileExtension.JS` for the FPM
580
- // page-object regardless of the configured `dotFileExtension`. Otherwise
581
- // an LR-OP-FPM mix with `enableTypeScript` would crash in `writePageObject`
582
- // when trying to load the missing `FPM.ts` template.
583
- // Future work: add FPM.ts/FPMJourney.ts templates and switch to `dotFileExtension`.
584
- 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}`), {
585
575
  ...journeyParams,
586
576
  ...appFeatures.fpm
587
577
  }, undefined, {
@@ -737,16 +727,14 @@ function updateReferencesInOpaTestsStartupFiles(writeContext, generatedJourneys
737
727
  * @returns path to the written page object
738
728
  */
739
729
  function writePageObject(pageConfig, rootTemplateDirPath, testOutDirPath, fs, dotFileExtension) {
740
- // FPM has no .ts template; force .js regardless of the configured extension
741
- const ext = pageConfig.template === 'FPM' ? DotFileExtension.JS : dotFileExtension;
742
- 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, {
743
731
  globOptions: { dot: true }
744
732
  });
745
733
  return {
746
734
  targetKey: pageConfig.targetKey,
747
735
  appPath: pageConfig.appPath,
748
736
  fileName: `${pageConfig.targetKey}.gen`,
749
- dotFileExtension: ext,
737
+ dotFileExtension,
750
738
  template: pageConfig.template,
751
739
  appID: pageConfig.appID,
752
740
  componentID: pageConfig.componentID,
@@ -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 (ListReport / ObjectPage) are missing and need to be added.
238
- const frameworkTemplates = Array.from(new Set(toAdd.map((page) => page.template).filter((template) => Boolean(template))));
239
- const missingFrameworkImports = frameworkTemplates.filter((template) => !fileContent.includes(`from "sap/fe/test/${template}"`));
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((template) => `import ${template} from "sap/fe/test/${template}";`),
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);
@@ -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
- return (`${indent}onThe${page.targetKey}Generated: Opa5 & ${page.template}${frameworkSuffix} & TemplatePage${frameworkSuffix} & ` +
70
- `typeof ${page.targetKey}Generated${customSuffix};`);
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
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.7.4",
4
+ "version": "1.8.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -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
 
@@ -0,0 +1,38 @@
1
+ /******************************************************************************
2
+ * ╔═══════════════════════════════════════════════════════════════════════╗ *
3
+ * ║ ║ *
4
+ * ║ WARNING: AUTO-GENERATED FILE ║ *
5
+ * ║ ║ *
6
+ * ║ This file is automatically generated by SAP Fiori tools and is ║ *
7
+ * ║ overwritten when you run the OPA test generator again. ║ *
8
+ * ║ ║ *
9
+ * ║ To add your own custom tests: ║ *
10
+ * ║ - Create a new journey test file in this directory. ║ *
11
+ * ║ - Follow the same pattern as this file. ║ *
12
+ * ║ - Add the new file to the opaTests.qunit.js config file. ║ *
13
+ * ║ - Custom journey files are not overwritten. ║ *
14
+ * ║ ║ *
15
+ * ╚═══════════════════════════════════════════════════════════════════════╝ *
16
+ ******************************************************************************/
17
+
18
+ import opaTest from "sap/ui/test/opaQunit";
19
+ import type { Given, When, Then } from "./types/OpaJourneyTypes.gen";
20
+ import runner from "./pages/JourneyRunner";
21
+
22
+ function journey() {
23
+ QUnit.module("FPM journey");
24
+
25
+ opaTest("Start application", function (Given: Given, _When: When, Then: Then) {
26
+ Given.iStartMyApp();
27
+ <%_ startPages.forEach(function(pageName) { %>
28
+ Then.onThe<%- pageName %>Generated.iSeeThisPage();
29
+ <%_ }); -%>
30
+ });
31
+
32
+ opaTest("Teardown", function (Given: Given) {
33
+ // Cleanup
34
+ Given.iTearDownMyApp();
35
+ });
36
+ }
37
+
38
+ runner.run([journey]);
@@ -132,8 +132,10 @@ sap.ui.define([
132
132
  <% } -%>
133
133
  <% if (section?.subSections?.length > 0) { -%>
134
134
  <% section.subSections.forEach(function(subSection) { -%>
135
+ <% if (section.subSections.length > 1) { -%>
135
136
  //When.onThe<%- name%>Generated.iGoToSection({ section: "<%- section.id %>", subSection: "<%- subSection.id %>" });
136
137
  Then.onThe<%- name%>Generated.iCheckSubSection({ section: "<%- subSection.id %>" });
138
+ <% } -%>
137
139
  <% if (subSection.fields && subSection.fields.length > 0) { -%>
138
140
  <% subSection.fields.forEach(function(field) { -%>
139
141
  Then.onThe<%- name%>Generated.onForm({ section: "<%- subSection.id %>" }).iCheckField({ property: "<%- field.property %>"<% if (field.connectedFields) { %>, connectedFields: "<%- field.connectedFields %>"<% } %><% if (field.fieldGroup) { %>, fieldGroup: "<%- field.fieldGroup %>"<% } %> });
@@ -151,8 +151,10 @@ function journey() {
151
151
  <% } -%>
152
152
  <% if (section?.subSections?.length > 0) { -%>
153
153
  <% section.subSections.forEach(function(subSection) { -%>
154
+ <% if (section.subSections.length > 1) { -%>
154
155
  //When.onThe<%- name%>Generated.iGoToSection({ section: "<%- section.id %>", subSection: "<%- subSection.id %>" });
155
156
  Then.onThe<%- name%>Generated.iCheckSubSection({ section: "<%- subSection.id %>" }, {});
157
+ <% } -%>
156
158
  <% if (subSection.fields && subSection.fields.length > 0) { -%>
157
159
  <% subSection.fields.forEach(function(field) { -%>
158
160
  Then.onThe<%- name%>Generated.onForm({ section: "<%- subSection.id %>" } as unknown as FormIdentifier).iCheckField({ property: "<%- field.property %>"<% if (field.connectedFields) { %>, connectedFields: "<%- field.connectedFields %>"<% } %><% if (field.fieldGroup) { %>, fieldGroup: "<%- field.fieldGroup %>"<% } %> });
@@ -0,0 +1,25 @@
1
+ /******************************************************************************
2
+ * ╔═══════════════════════════════════════════════════════════════════════╗ *
3
+ * ║ ║ *
4
+ * ║ WARNING: AUTO-GENERATED FILE ║ *
5
+ * ║ ║ *
6
+ * ║ This file is automatically generated by SAP Fiori tools and is ║ *
7
+ * ║ overwritten when you run the OPA test generator again. ║ *
8
+ * ║ ║ *
9
+ * ║ To add your own custom pages: ║ *
10
+ * ║ - Create a new page file in this directory. ║ *
11
+ * ║ - Follow the same pattern as this file. ║ *
12
+ * ║ - Add the new file to the JourneyRunner. ║ *
13
+ * ║ - Custom page files are not overwritten. ║ *
14
+ * ║ ║ *
15
+ * ╚═══════════════════════════════════════════════════════════════════════╝ *
16
+ ******************************************************************************/
17
+
18
+ export const actions = {};
19
+
20
+ export const assertions = {};
21
+
22
+ export default class FPM {
23
+ actions = actions;
24
+ assertions = assertions;
25
+ }
@@ -5,13 +5,21 @@ import ListReport from "sap/fe/test/ListReport";
5
5
  <% if (pages.some((p) => p.template === 'ObjectPage')) { -%>
6
6
  import ObjectPage from "sap/fe/test/ObjectPage";
7
7
  <% } -%>
8
+ <% if (pages.some((p) => p.template === 'FPM')) { -%>
9
+ import TemplatePage from "sap/fe/test/TemplatePage";
10
+ <% } -%>
8
11
  <%- pages.map((page) => 'import Custom' + page.targetKey + 'Generated from "./' + page.targetKey + '.gen";').join('\n') %>
9
12
 
10
13
  const runner = new JourneyRunner({
11
14
  launchUrl: sap.ui.require.toUrl("<%- appPath %>") + "/<%- htmlTarget %>",
12
15
  pages: {
13
16
  <%- pages.map((page) =>
14
- ' onThe' + page.targetKey + 'Generated: new ' + page.template + '(\n' +
17
+ page.template === 'FPM'
18
+ ? ' onThe' + page.targetKey + 'Generated: new (TemplatePage as unknown as new (id: string, defs: object) => object)(\n' +
19
+ ' "' + page.appID + '::' + page.componentID + '",\n' +
20
+ ' Custom' + page.targetKey + 'Generated\n' +
21
+ ' )'
22
+ : ' onThe' + page.targetKey + 'Generated: new ' + page.template + '(\n' +
15
23
  ' {\n' +
16
24
  ' appId: "' + page.appID + '",\n' +
17
25
  ' componentId: "' + page.componentID + '",\n' +
@@ -18,15 +18,32 @@ import type { actions as ListReportActions, assertions as ListReportAssertions }
18
18
  <% if (pages.some(p => p.template === 'ObjectPage')) { -%>
19
19
  import type { actions as ObjectPageActions, assertions as ObjectPageAssertions } from "sap/fe/test/ObjectPage";
20
20
  <% } -%>
21
- <% if (pages.some(p => p.template === 'ListReport' || p.template === 'ObjectPage')) { -%>
21
+ <% if (pages.some(p => p.template === 'ListReport' || p.template === 'ObjectPage' || p.template === 'FPM')) { -%>
22
22
  import type { actions as TemplatePageActions, assertions as TemplatePageAssertions } from "sap/fe/test/TemplatePage";
23
23
  <% } -%>
24
24
  import type Shell from "sap/fe/test/Shell";
25
25
  import type BaseArrangements from "sap/fe/test/BaseArrangements";
26
- <% pages.filter((p) => p.template === 'ListReport' || p.template === 'ObjectPage').forEach(function(page) { -%>
26
+ <% pages.filter((p) => p.template === 'ListReport' || p.template === 'ObjectPage' || p.template === 'FPM').forEach(function(page) { -%>
27
27
  import type { actions as <%- page.targetKey %>GeneratedCustomActions, assertions as <%- page.targetKey %>GeneratedCustomAssertions } from "../pages/<%- page.targetKey %>.gen";
28
28
  <% }); -%>
29
29
 
30
+ /**
31
+ * Enables OPA5 fluent `.and` chaining on page objects and their sub-objects.
32
+ *
33
+ * @example
34
+ * Then.onTheObjectPageGenerated.iCheckSection({ section: "A" }).and.iCheckSection({ section: "B" });
35
+ * When.onTheListReportGenerated.onFilterBar().iExecuteSearch().and.iClearFilterBar();
36
+ */
37
+ type WithAnd<T> = {
38
+ [K in keyof T | 'and']: K extends 'and'
39
+ ? WithAnd<T>
40
+ : K extends keyof T
41
+ ? T[K] extends (...args: infer A) => infer R
42
+ ? (...args: A) => (R extends Opa5 | object ? (keyof R extends never ? WithAnd<T> : [R] extends [Opa5] ? WithAnd<T> : WithAnd<R>) : WithAnd<T>)
43
+ : T[K]
44
+ : never;
45
+ };
46
+
30
47
  export type Given = Opa5 & BaseArrangements & {
31
48
  iTearDownMyApp: () => Given;
32
49
  iStartMyApp: (sAppHash?: string, mInUrlParameters?: object) => Given;
@@ -36,9 +53,11 @@ export type Given = Opa5 & BaseArrangements & {
36
53
  export type When = Opa5 & BaseArrangements & {
37
54
  <% pages.forEach(function(page) { -%>
38
55
  <% if (page.template === 'ListReport') { -%>
39
- onThe<%- page.targetKey %>Generated: Opa5 & ListReportActions & TemplatePageActions & typeof <%- page.targetKey %>GeneratedCustomActions;
56
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & ListReportActions & TemplatePageActions & typeof <%- page.targetKey %>GeneratedCustomActions>;
40
57
  <% } else if (page.template === 'ObjectPage') { -%>
41
- onThe<%- page.targetKey %>Generated: Opa5 & ObjectPageActions & TemplatePageActions & typeof <%- page.targetKey %>GeneratedCustomActions;
58
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & ObjectPageActions & TemplatePageActions & typeof <%- page.targetKey %>GeneratedCustomActions>;
59
+ <% } else if (page.template === 'FPM') { -%>
60
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & TemplatePageActions & typeof <%- page.targetKey %>GeneratedCustomActions>;
42
61
  <% } -%>
43
62
  <% }); -%>
44
63
  onTheShell: Shell;
@@ -47,9 +66,11 @@ export type When = Opa5 & BaseArrangements & {
47
66
  export type Then = Opa5 & BaseArrangements & {
48
67
  <% pages.forEach(function(page) { -%>
49
68
  <% if (page.template === 'ListReport') { -%>
50
- onThe<%- page.targetKey %>Generated: Opa5 & ListReportAssertions & TemplatePageAssertions & typeof <%- page.targetKey %>GeneratedCustomAssertions;
69
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & ListReportAssertions & TemplatePageAssertions & typeof <%- page.targetKey %>GeneratedCustomAssertions>;
51
70
  <% } else if (page.template === 'ObjectPage') { -%>
52
- onThe<%- page.targetKey %>Generated: Opa5 & ObjectPageAssertions & TemplatePageAssertions & typeof <%- page.targetKey %>GeneratedCustomAssertions;
71
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & ObjectPageAssertions & TemplatePageAssertions & typeof <%- page.targetKey %>GeneratedCustomAssertions>;
72
+ <% } else if (page.template === 'FPM') { -%>
73
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & TemplatePageAssertions & typeof <%- page.targetKey %>GeneratedCustomAssertions>;
53
74
  <% } -%>
54
75
  <% }); -%>
55
76
  onTheShell: Shell;
@@ -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
 
@@ -0,0 +1,38 @@
1
+ /******************************************************************************
2
+ * ╔═══════════════════════════════════════════════════════════════════════╗ *
3
+ * ║ ║ *
4
+ * ║ WARNING: AUTO-GENERATED FILE ║ *
5
+ * ║ ║ *
6
+ * ║ This file is automatically generated by SAP Fiori tools and is ║ *
7
+ * ║ overwritten when you run the OPA test generator again. ║ *
8
+ * ║ ║ *
9
+ * ║ To add your own custom tests: ║ *
10
+ * ║ - Create a new journey test file in this directory. ║ *
11
+ * ║ - Follow the same pattern as this file. ║ *
12
+ * ║ - Add the new file to the opaTests.qunit.js config file. ║ *
13
+ * ║ - Custom journey files are not overwritten. ║ *
14
+ * ║ ║ *
15
+ * ╚═══════════════════════════════════════════════════════════════════════╝ *
16
+ ******************************************************************************/
17
+
18
+ import opaTest from "sap/ui/test/opaQunit";
19
+ import type { Given, When, Then } from "./types/OpaJourneyTypes.gen";
20
+ import runner from "./pages/JourneyRunner";
21
+
22
+ function journey() {
23
+ QUnit.module("FPM journey");
24
+
25
+ opaTest("Start application", function (Given: Given, _When: When, Then: Then) {
26
+ Given.iStartMyApp();
27
+ <%_ startPages.forEach(function(pageName) { %>
28
+ Then.onThe<%- pageName %>Generated.iSeeThisPage();
29
+ <%_ }); -%>
30
+ });
31
+
32
+ opaTest("Teardown", function (Given: Given) {
33
+ // Cleanup
34
+ Given.iTearDownMyApp();
35
+ });
36
+ }
37
+
38
+ runner.run([journey]);
@@ -132,8 +132,10 @@ sap.ui.define([
132
132
  <% } -%>
133
133
  <% if (section?.subSections?.length > 0) { -%>
134
134
  <% section.subSections.forEach(function(subSection) { -%>
135
+ <% if (section.subSections.length > 1) { -%>
135
136
  //When.onThe<%- name%>Generated.iGoToSection({ section: "<%- section.id %>", subSection: "<%- subSection.id %>" });
136
137
  Then.onThe<%- name%>Generated.iCheckSubSection({ section: "<%- subSection.id %>" });
138
+ <% } -%>
137
139
  <% if (subSection.fields && subSection.fields.length > 0) { -%>
138
140
  <% subSection.fields.forEach(function(field) { -%>
139
141
  Then.onThe<%- name%>Generated.onForm({ section: "<%- subSection.id %>" }).iCheckField({ property: "<%- field.property %>"<% if (field.connectedFields) { %>, connectedFields: "<%- field.connectedFields %>"<% } %><% if (field.fieldGroup) { %>, fieldGroup: "<%- field.fieldGroup %>"<% } %> });
@@ -151,8 +151,10 @@ function journey() {
151
151
  <% } -%>
152
152
  <% if (section?.subSections?.length > 0) { -%>
153
153
  <% section.subSections.forEach(function(subSection) { -%>
154
+ <% if (section.subSections.length > 1) { -%>
154
155
  //When.onThe<%- name%>Generated.iGoToSection({ section: "<%- section.id %>", subSection: "<%- subSection.id %>" });
155
156
  Then.onThe<%- name%>Generated.iCheckSubSection({ section: "<%- subSection.id %>" }, {});
157
+ <% } -%>
156
158
  <% if (subSection.fields && subSection.fields.length > 0) { -%>
157
159
  <% subSection.fields.forEach(function(field) { -%>
158
160
  Then.onThe<%- name%>Generated.onForm({ section: "<%- subSection.id %>" } as unknown as FormIdentifier).iCheckField({ property: "<%- field.property %>"<% if (field.connectedFields) { %>, connectedFields: "<%- field.connectedFields %>"<% } %><% if (field.fieldGroup) { %>, fieldGroup: "<%- field.fieldGroup %>"<% } %> });
@@ -0,0 +1,25 @@
1
+ /******************************************************************************
2
+ * ╔═══════════════════════════════════════════════════════════════════════╗ *
3
+ * ║ ║ *
4
+ * ║ WARNING: AUTO-GENERATED FILE ║ *
5
+ * ║ ║ *
6
+ * ║ This file is automatically generated by SAP Fiori tools and is ║ *
7
+ * ║ overwritten when you run the OPA test generator again. ║ *
8
+ * ║ ║ *
9
+ * ║ To add your own custom pages: ║ *
10
+ * ║ - Create a new page file in this directory. ║ *
11
+ * ║ - Follow the same pattern as this file. ║ *
12
+ * ║ - Add the new file to the JourneyRunner. ║ *
13
+ * ║ - Custom page files are not overwritten. ║ *
14
+ * ║ ║ *
15
+ * ╚═══════════════════════════════════════════════════════════════════════╝ *
16
+ ******************************************************************************/
17
+
18
+ export const actions = {};
19
+
20
+ export const assertions = {};
21
+
22
+ export default class FPM {
23
+ actions = actions;
24
+ assertions = assertions;
25
+ }
@@ -5,13 +5,21 @@ import ListReport from "sap/fe/test/ListReport";
5
5
  <% if (pages.some((p) => p.template === 'ObjectPage')) { -%>
6
6
  import ObjectPage from "sap/fe/test/ObjectPage";
7
7
  <% } -%>
8
+ <% if (pages.some((p) => p.template === 'FPM')) { -%>
9
+ import TemplatePage from "sap/fe/test/TemplatePage";
10
+ <% } -%>
8
11
  <%- pages.map((page) => 'import Custom' + page.targetKey + 'Generated from "./' + page.targetKey + '.gen";').join('\n') %>
9
12
 
10
13
  const runner = new JourneyRunner({
11
14
  launchUrl: sap.ui.require.toUrl("<%- appPath %>") + "/<%- htmlTarget %>",
12
15
  pages: {
13
16
  <%- pages.map((page) =>
14
- ' onThe' + page.targetKey + 'Generated: new ' + page.template + '(\n' +
17
+ page.template === 'FPM'
18
+ ? ' onThe' + page.targetKey + 'Generated: new (TemplatePage as unknown as new (id: string, defs: object) => object)(\n' +
19
+ ' "' + page.appID + '::' + page.componentID + '",\n' +
20
+ ' Custom' + page.targetKey + 'Generated\n' +
21
+ ' )'
22
+ : ' onThe' + page.targetKey + 'Generated: new ' + page.template + '(\n' +
15
23
  ' {\n' +
16
24
  ' appId: "' + page.appID + '",\n' +
17
25
  ' componentId: "' + page.componentID + '",\n' +
@@ -18,15 +18,32 @@ import type { actions as ListReportActions, assertions as ListReportAssertions }
18
18
  <% if (pages.some(p => p.template === 'ObjectPage')) { -%>
19
19
  import type { actions as ObjectPageActions, assertions as ObjectPageAssertions } from "sap/fe/test/ObjectPage";
20
20
  <% } -%>
21
- <% if (pages.some(p => p.template === 'ListReport' || p.template === 'ObjectPage')) { -%>
21
+ <% if (pages.some(p => p.template === 'ListReport' || p.template === 'ObjectPage' || p.template === 'FPM')) { -%>
22
22
  import type { actions as TemplatePageActions, assertions as TemplatePageAssertions } from "sap/fe/test/TemplatePage";
23
23
  <% } -%>
24
24
  import type Shell from "sap/fe/test/Shell";
25
25
  import type BaseArrangements from "sap/fe/test/BaseArrangements";
26
- <% pages.filter((p) => p.template === 'ListReport' || p.template === 'ObjectPage').forEach(function(page) { -%>
26
+ <% pages.filter((p) => p.template === 'ListReport' || p.template === 'ObjectPage' || p.template === 'FPM').forEach(function(page) { -%>
27
27
  import type { actions as <%- page.targetKey %>GeneratedCustomActions, assertions as <%- page.targetKey %>GeneratedCustomAssertions } from "../pages/<%- page.targetKey %>.gen";
28
28
  <% }); -%>
29
29
 
30
+ /**
31
+ * Enables OPA5 fluent `.and` chaining on page objects and their sub-objects.
32
+ *
33
+ * @example
34
+ * Then.onTheObjectPageGenerated.iCheckSection({ section: "A" }).and.iCheckSection({ section: "B" });
35
+ * When.onTheListReportGenerated.onFilterBar().iExecuteSearch().and.iClearFilterBar();
36
+ */
37
+ type WithAnd<T> = {
38
+ [K in keyof T | 'and']: K extends 'and'
39
+ ? WithAnd<T>
40
+ : K extends keyof T
41
+ ? T[K] extends (...args: infer A) => infer R
42
+ ? (...args: A) => (R extends Opa5 | object ? (keyof R extends never ? WithAnd<T> : [R] extends [Opa5] ? WithAnd<T> : WithAnd<R>) : WithAnd<T>)
43
+ : T[K]
44
+ : never;
45
+ };
46
+
30
47
  export type Given = Opa5 & BaseArrangements & {
31
48
  iTearDownMyApp: () => Given;
32
49
  iStartMyApp: (sAppHash?: string, mInUrlParameters?: object) => Given;
@@ -36,9 +53,11 @@ export type Given = Opa5 & BaseArrangements & {
36
53
  export type When = Opa5 & BaseArrangements & {
37
54
  <% pages.forEach(function(page) { -%>
38
55
  <% if (page.template === 'ListReport') { -%>
39
- onThe<%- page.targetKey %>Generated: Opa5 & ListReportActions & TemplatePageActions & typeof <%- page.targetKey %>GeneratedCustomActions;
56
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & ListReportActions & TemplatePageActions & typeof <%- page.targetKey %>GeneratedCustomActions>;
40
57
  <% } else if (page.template === 'ObjectPage') { -%>
41
- onThe<%- page.targetKey %>Generated: Opa5 & ObjectPageActions & TemplatePageActions & typeof <%- page.targetKey %>GeneratedCustomActions;
58
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & ObjectPageActions & TemplatePageActions & typeof <%- page.targetKey %>GeneratedCustomActions>;
59
+ <% } else if (page.template === 'FPM') { -%>
60
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & TemplatePageActions & typeof <%- page.targetKey %>GeneratedCustomActions>;
42
61
  <% } -%>
43
62
  <% }); -%>
44
63
  onTheShell: Shell;
@@ -47,9 +66,11 @@ export type When = Opa5 & BaseArrangements & {
47
66
  export type Then = Opa5 & BaseArrangements & {
48
67
  <% pages.forEach(function(page) { -%>
49
68
  <% if (page.template === 'ListReport') { -%>
50
- onThe<%- page.targetKey %>Generated: Opa5 & ListReportAssertions & TemplatePageAssertions & typeof <%- page.targetKey %>GeneratedCustomAssertions;
69
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & ListReportAssertions & TemplatePageAssertions & typeof <%- page.targetKey %>GeneratedCustomAssertions>;
51
70
  <% } else if (page.template === 'ObjectPage') { -%>
52
- onThe<%- page.targetKey %>Generated: Opa5 & ObjectPageAssertions & TemplatePageAssertions & typeof <%- page.targetKey %>GeneratedCustomAssertions;
71
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & ObjectPageAssertions & TemplatePageAssertions & typeof <%- page.targetKey %>GeneratedCustomAssertions>;
72
+ <% } else if (page.template === 'FPM') { -%>
73
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & TemplatePageAssertions & typeof <%- page.targetKey %>GeneratedCustomAssertions>;
53
74
  <% } -%>
54
75
  <% }); -%>
55
76
  onTheShell: Shell;
@@ -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
 
@@ -0,0 +1,38 @@
1
+ /******************************************************************************
2
+ * ╔═══════════════════════════════════════════════════════════════════════╗ *
3
+ * ║ ║ *
4
+ * ║ WARNING: AUTO-GENERATED FILE ║ *
5
+ * ║ ║ *
6
+ * ║ This file is automatically generated by SAP Fiori tools and is ║ *
7
+ * ║ overwritten when you run the OPA test generator again. ║ *
8
+ * ║ ║ *
9
+ * ║ To add your own custom tests: ║ *
10
+ * ║ - Create a new journey test file in this directory. ║ *
11
+ * ║ - Follow the same pattern as this file. ║ *
12
+ * ║ - Add the new file to the opaTests.qunit.js config file. ║ *
13
+ * ║ - Custom journey files are not overwritten. ║ *
14
+ * ║ ║ *
15
+ * ╚═══════════════════════════════════════════════════════════════════════╝ *
16
+ ******************************************************************************/
17
+
18
+ import opaTest from "sap/ui/test/opaQunit";
19
+ import type { Given, When, Then } from "./types/OpaJourneyTypes.gen";
20
+ import runner from "./pages/JourneyRunner";
21
+
22
+ function journey() {
23
+ QUnit.module("FPM journey");
24
+
25
+ opaTest("Start application", function (Given: Given, _When: When, Then: Then) {
26
+ Given.iStartMyApp();
27
+ <%_ startPages.forEach(function(pageName) { %>
28
+ Then.onThe<%- pageName %>Generated.iSeeThisPage();
29
+ <%_ }); -%>
30
+ });
31
+
32
+ opaTest("Teardown", function (Given: Given) {
33
+ // Cleanup
34
+ Given.iTearDownMyApp();
35
+ });
36
+ }
37
+
38
+ runner.run([journey]);
@@ -104,7 +104,7 @@ sap.ui.define([
104
104
  <% } -%>
105
105
  <% if (bodySections?.length > 0) { -%>
106
106
  <% bodySections.forEach(function(section) { -%>
107
- opaTest("Check the <%- section.id %> section of the Object Page", function (_Given, <% if (bodySections.length > 1 || (section.subSections && section.subSections.length > 0)) { %>When<% } else { %>_When<% } %>, Then) {
107
+ opaTest("Check the <%- section.id %> section of the Object Page", function (_Given, <% if (bodySections.length > 1 || (section.subSections && section.subSections.length > 1) || (section.contactCardFields && section.contactCardFields.length > 0) || (section.contactCardColumns && section.contactCardColumns.length > 0) || (section.subSections || []).some(function(sub){ return (sub.contactCardFields && sub.contactCardFields.length > 0) || (sub.contactCardColumns && sub.contactCardColumns.length > 0); })) { %>When<% } else { %>_When<% } %>, Then) {
108
108
  <% if (bodySections.length > 1) { -%>
109
109
  When.onThe<%- name%>Generated.iGoToSection({ section: "<%- section.id %>" });
110
110
  <% } -%>
@@ -146,8 +146,10 @@ sap.ui.define([
146
146
  <% } -%>
147
147
  <% if (section?.subSections?.length > 0) { -%>
148
148
  <% section.subSections.forEach(function(subSection) { -%>
149
+ <% if (section.subSections.length > 1) { -%>
149
150
  When.onThe<%- name%>Generated.iGoToSection({ section: "<%- section.id %>", subSection: "<%- subSection.id %>" });
150
151
  Then.onThe<%- name%>Generated.iCheckSubSection({ section: "<%- subSection.id %>" });
152
+ <% } -%>
151
153
  <% if (subSection.fields && subSection.fields.length > 0) { -%>
152
154
  <% subSection.fields.forEach(function(field) { -%>
153
155
  Then.onThe<%- name%>Generated.onForm({ section: "<%- subSection.id %>" }).iCheckField({ property: "<%- field.property %>"<% if (field.connectedFields) { %>, connectedFields: "<%- field.connectedFields %>"<% } %><% if (field.fieldGroup) { %>, fieldGroup: "<%- field.fieldGroup %>"<% } %> });
@@ -32,7 +32,10 @@ const usesFormIdentifier = (bodySections || []).some(function(section) {
32
32
  return subSectionsHaveForm || sectionHasFormFields || hasFormAction;
33
33
  });
34
34
  const usesWhenInBody = (bodySections || []).length > 1 || (bodySections || []).some(function(section) {
35
- return section.subSections && section.subSections.length > 0;
35
+ return (section.subSections && section.subSections.length > 1)
36
+ || (section.contactCardFields && section.contactCardFields.length > 0)
37
+ || (section.contactCardColumns && section.contactCardColumns.length > 0)
38
+ || (section.subSections || []).some(function(sub) { return (sub.contactCardFields && sub.contactCardFields.length > 0) || (sub.contactCardColumns && sub.contactCardColumns.length > 0); });
36
39
  });
37
40
  -%>
38
41
  <% if (usesFieldIdentifier) { -%>
@@ -168,8 +171,10 @@ function journey() {
168
171
  <% } -%>
169
172
  <% if (section?.subSections?.length > 0) { -%>
170
173
  <% section.subSections.forEach(function(subSection) { -%>
174
+ <% if (section.subSections.length > 1) { -%>
171
175
  When.onThe<%- name%>Generated.iGoToSection({ section: "<%- section.id %>", subSection: "<%- subSection.id %>" });
172
176
  Then.onThe<%- name%>Generated.iCheckSubSection({ section: "<%- subSection.id %>" }, {});
177
+ <% } -%>
173
178
  <% if (subSection.fields && subSection.fields.length > 0) { -%>
174
179
  <% subSection.fields.forEach(function(field) { -%>
175
180
  Then.onThe<%- name%>Generated.onForm({ section: "<%- subSection.id %>" } as unknown as FormIdentifier).iCheckField({ property: "<%- field.property %>"<% if (field.connectedFields) { %>, connectedFields: "<%- field.connectedFields %>"<% } %><% if (field.fieldGroup) { %>, fieldGroup: "<%- field.fieldGroup %>"<% } %> });
@@ -0,0 +1,25 @@
1
+ /******************************************************************************
2
+ * ╔═══════════════════════════════════════════════════════════════════════╗ *
3
+ * ║ ║ *
4
+ * ║ WARNING: AUTO-GENERATED FILE ║ *
5
+ * ║ ║ *
6
+ * ║ This file is automatically generated by SAP Fiori tools and is ║ *
7
+ * ║ overwritten when you run the OPA test generator again. ║ *
8
+ * ║ ║ *
9
+ * ║ To add your own custom pages: ║ *
10
+ * ║ - Create a new page file in this directory. ║ *
11
+ * ║ - Follow the same pattern as this file. ║ *
12
+ * ║ - Add the new file to the JourneyRunner. ║ *
13
+ * ║ - Custom page files are not overwritten. ║ *
14
+ * ║ ║ *
15
+ * ╚═══════════════════════════════════════════════════════════════════════╝ *
16
+ ******************************************************************************/
17
+
18
+ export const actions = {};
19
+
20
+ export const assertions = {};
21
+
22
+ export default class FPM {
23
+ actions = actions;
24
+ assertions = assertions;
25
+ }
@@ -5,13 +5,21 @@ import ListReport from "sap/fe/test/ListReport";
5
5
  <% if (pages.some((p) => p.template === 'ObjectPage')) { -%>
6
6
  import ObjectPage from "sap/fe/test/ObjectPage";
7
7
  <% } -%>
8
+ <% if (pages.some((p) => p.template === 'FPM')) { -%>
9
+ import TemplatePage from "sap/fe/test/TemplatePage";
10
+ <% } -%>
8
11
  <%- pages.map((page) => 'import Custom' + page.targetKey + 'Generated from "./' + page.targetKey + '.gen";').join('\n') %>
9
12
 
10
13
  const runner = new JourneyRunner({
11
14
  launchUrl: sap.ui.require.toUrl("<%- appPath %>") + "/<%- htmlTarget %>",
12
15
  pages: {
13
16
  <%- pages.map((page) =>
14
- ' onThe' + page.targetKey + 'Generated: new ' + page.template + '(\n' +
17
+ page.template === 'FPM'
18
+ ? ' onThe' + page.targetKey + 'Generated: new (TemplatePage as unknown as new (id: string, defs: object) => object)(\n' +
19
+ ' "' + page.appID + '::' + page.componentID + '",\n' +
20
+ ' Custom' + page.targetKey + 'Generated\n' +
21
+ ' )'
22
+ : ' onThe' + page.targetKey + 'Generated: new ' + page.template + '(\n' +
15
23
  ' {\n' +
16
24
  ' appId: "' + page.appID + '",\n' +
17
25
  ' componentId: "' + page.componentID + '",\n' +
@@ -18,15 +18,32 @@ import type { actions as ListReportActions, assertions as ListReportAssertions }
18
18
  <% if (pages.some(p => p.template === 'ObjectPage')) { -%>
19
19
  import type { actions as ObjectPageActions, assertions as ObjectPageAssertions } from "sap/fe/test/ObjectPage";
20
20
  <% } -%>
21
- <% if (pages.some(p => p.template === 'ListReport' || p.template === 'ObjectPage')) { -%>
21
+ <% if (pages.some(p => p.template === 'ListReport' || p.template === 'ObjectPage' || p.template === 'FPM')) { -%>
22
22
  import type { actions as TemplatePageActions, assertions as TemplatePageAssertions } from "sap/fe/test/TemplatePage";
23
23
  <% } -%>
24
24
  import type Shell from "sap/fe/test/Shell";
25
25
  import type BaseArrangements from "sap/fe/test/BaseArrangements";
26
- <% pages.filter((p) => p.template === 'ListReport' || p.template === 'ObjectPage').forEach(function(page) { -%>
26
+ <% pages.filter((p) => p.template === 'ListReport' || p.template === 'ObjectPage' || p.template === 'FPM').forEach(function(page) { -%>
27
27
  import type { actions as <%- page.targetKey %>GeneratedCustomActions, assertions as <%- page.targetKey %>GeneratedCustomAssertions } from "../pages/<%- page.targetKey %>.gen";
28
28
  <% }); -%>
29
29
 
30
+ /**
31
+ * Enables OPA5 fluent `.and` chaining on page objects and their sub-objects.
32
+ *
33
+ * @example
34
+ * Then.onTheObjectPageGenerated.iCheckSection({ section: "A" }).and.iCheckSection({ section: "B" });
35
+ * When.onTheListReportGenerated.onFilterBar().iExecuteSearch().and.iClearFilterBar();
36
+ */
37
+ type WithAnd<T> = {
38
+ [K in keyof T | 'and']: K extends 'and'
39
+ ? WithAnd<T>
40
+ : K extends keyof T
41
+ ? T[K] extends (...args: infer A) => infer R
42
+ ? (...args: A) => (R extends Opa5 | object ? (keyof R extends never ? WithAnd<T> : [R] extends [Opa5] ? WithAnd<T> : WithAnd<R>) : WithAnd<T>)
43
+ : T[K]
44
+ : never;
45
+ };
46
+
30
47
  export type Given = Opa5 & BaseArrangements & {
31
48
  iTearDownMyApp: () => Given;
32
49
  iStartMyApp: (sAppHash?: string, mInUrlParameters?: object) => Given;
@@ -36,9 +53,11 @@ export type Given = Opa5 & BaseArrangements & {
36
53
  export type When = Opa5 & BaseArrangements & {
37
54
  <% pages.forEach(function(page) { -%>
38
55
  <% if (page.template === 'ListReport') { -%>
39
- onThe<%- page.targetKey %>Generated: Opa5 & ListReportActions & TemplatePageActions & typeof <%- page.targetKey %>GeneratedCustomActions;
56
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & ListReportActions & TemplatePageActions & typeof <%- page.targetKey %>GeneratedCustomActions>;
40
57
  <% } else if (page.template === 'ObjectPage') { -%>
41
- onThe<%- page.targetKey %>Generated: Opa5 & ObjectPageActions & TemplatePageActions & typeof <%- page.targetKey %>GeneratedCustomActions;
58
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & ObjectPageActions & TemplatePageActions & typeof <%- page.targetKey %>GeneratedCustomActions>;
59
+ <% } else if (page.template === 'FPM') { -%>
60
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & TemplatePageActions & typeof <%- page.targetKey %>GeneratedCustomActions>;
42
61
  <% } -%>
43
62
  <% }); -%>
44
63
  onTheShell: Shell;
@@ -47,9 +66,11 @@ export type When = Opa5 & BaseArrangements & {
47
66
  export type Then = Opa5 & BaseArrangements & {
48
67
  <% pages.forEach(function(page) { -%>
49
68
  <% if (page.template === 'ListReport') { -%>
50
- onThe<%- page.targetKey %>Generated: Opa5 & ListReportAssertions & TemplatePageAssertions & typeof <%- page.targetKey %>GeneratedCustomAssertions;
69
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & ListReportAssertions & TemplatePageAssertions & typeof <%- page.targetKey %>GeneratedCustomAssertions>;
51
70
  <% } else if (page.template === 'ObjectPage') { -%>
52
- onThe<%- page.targetKey %>Generated: Opa5 & ObjectPageAssertions & TemplatePageAssertions & typeof <%- page.targetKey %>GeneratedCustomAssertions;
71
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & ObjectPageAssertions & TemplatePageAssertions & typeof <%- page.targetKey %>GeneratedCustomAssertions>;
72
+ <% } else if (page.template === 'FPM') { -%>
73
+ onThe<%- page.targetKey %>Generated: WithAnd<Opa5 & TemplatePageAssertions & typeof <%- page.targetKey %>GeneratedCustomAssertions>;
53
74
  <% } -%>
54
75
  <% }); -%>
55
76
  onTheShell: Shell;