@sap-ux/ui5-test-writer 1.2.34 → 1.3.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.
Files changed (37) hide show
  1. package/dist/fiori-elements-opa-writer.js +46 -9
  2. package/dist/types.d.ts +10 -0
  3. package/package.json +3 -3
  4. package/templates/v4/1.84/integration/FPMJourney.js +49 -0
  5. package/templates/v4/1.84/integration/FirstJourney.js +35 -0
  6. package/templates/v4/1.84/integration/FirstJourney.ts +32 -0
  7. package/templates/v4/1.84/integration/ListReportJourney.js +129 -0
  8. package/templates/v4/1.84/integration/ListReportJourney.ts +133 -0
  9. package/templates/v4/1.84/integration/ObjectPageJourney.js +160 -0
  10. package/templates/v4/1.84/integration/ObjectPageJourney.ts +178 -0
  11. package/templates/v4/1.84/integration/opaTests.qunit.html +27 -0
  12. package/templates/v4/1.84/integration/opaTests.qunit.js +33 -0
  13. package/templates/v4/1.84/integration/pages/FPM.js +30 -0
  14. package/templates/v4/1.84/integration/pages/JourneyRunner.js +17 -0
  15. package/templates/v4/1.84/integration/pages/JourneyRunner.ts +28 -0
  16. package/templates/v4/1.84/integration/pages/ListReport.js +35 -0
  17. package/templates/v4/1.84/integration/pages/ListReport.ts +25 -0
  18. package/templates/v4/1.84/integration/pages/ObjectPage.js +42 -0
  19. package/templates/v4/1.84/integration/pages/ObjectPage.ts +35 -0
  20. package/templates/v4/1.84/integration/types/OpaJourneyTypes.d.ts +56 -0
  21. /package/templates/v4/{integration → 1.150/integration}/FPMJourney.js +0 -0
  22. /package/templates/v4/{integration → 1.150/integration}/FirstJourney.js +0 -0
  23. /package/templates/v4/{integration → 1.150/integration}/FirstJourney.ts +0 -0
  24. /package/templates/v4/{integration → 1.150/integration}/ListReportJourney.js +0 -0
  25. /package/templates/v4/{integration → 1.150/integration}/ListReportJourney.ts +0 -0
  26. /package/templates/v4/{integration → 1.150/integration}/ObjectPageJourney.js +0 -0
  27. /package/templates/v4/{integration → 1.150/integration}/ObjectPageJourney.ts +0 -0
  28. /package/templates/v4/{integration → 1.150/integration}/opaTests.qunit.html +0 -0
  29. /package/templates/v4/{integration → 1.150/integration}/opaTests.qunit.js +0 -0
  30. /package/templates/v4/{integration → 1.150/integration}/pages/FPM.js +0 -0
  31. /package/templates/v4/{integration → 1.150/integration}/pages/JourneyRunner.js +0 -0
  32. /package/templates/v4/{integration → 1.150/integration}/pages/JourneyRunner.ts +0 -0
  33. /package/templates/v4/{integration → 1.150/integration}/pages/ListReport.js +0 -0
  34. /package/templates/v4/{integration → 1.150/integration}/pages/ListReport.ts +0 -0
  35. /package/templates/v4/{integration → 1.150/integration}/pages/ObjectPage.js +0 -0
  36. /package/templates/v4/{integration → 1.150/integration}/pages/ObjectPage.ts +0 -0
  37. /package/templates/v4/{integration → 1.150/integration}/types/OpaJourneyTypes.d.ts +0 -0
@@ -13,7 +13,17 @@ 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 { compareUI5VersionGte } from '@sap-ux/ui5-application-writer';
16
17
  const __dirname = dirname(fileURLToPath(import.meta.url));
18
+ const UI5_VERSION_1_150 = '1.150.0';
19
+ const V4_TEMPLATE_1_84 = '1.84';
20
+ const V4_TEMPLATE_1_150 = '1.150';
21
+ function getTemplateUi5Version(ui5Version) {
22
+ if (!ui5Version || compareUI5VersionGte(ui5Version, UI5_VERSION_1_150)) {
23
+ return V4_TEMPLATE_1_150;
24
+ }
25
+ return V4_TEMPLATE_1_84;
26
+ }
17
27
  /**
18
28
  * Generate OPA test files for a Fiori elements for OData V4 application.
19
29
  * Note: this can potentially overwrite existing files in the webapp/test folder.
@@ -39,13 +49,27 @@ export async function generateOPAFiles(basePath, options, metadata, fs, log, sta
39
49
  const enableTypeScript = !hasFPMPage && (options.enableTypeScript ?? (standalone && existsSync(join(basePath, FileName.Tsconfig))));
40
50
  const dotFileExtension = enableTypeScript ? DotFileExtension.TS : DotFileExtension.JS;
41
51
  const rootCommonTemplateDirPath = join(__dirname, '../templates/common');
42
- const rootV4TemplateDirPath = join(__dirname, `../templates/${applicationType}`); // Only v4 is supported for the time being
52
+ const templateUi5Version = getTemplateUi5Version(options.ui5Version);
53
+ const rootV4TemplateDirPath = join(__dirname, `../templates/${applicationType}`, templateUi5Version);
43
54
  const testOutDirPath = join(await getWebappPath(basePath), 'test');
44
55
  // Access ux-specification to get feature data for OPA test generation
45
56
  const appFeatures = await getAppFeatures(basePath, editor, log, metadata, manifest);
46
57
  // OPA Journey file
47
58
  const startPages = config.pages.filter((page) => page.isStartup).map((page) => page.targetKey);
48
59
  const LROP = findLROP(config.pages, manifest);
60
+ // Only projects with a startup ListReport page (LROP) or an FPM page get ux-specification-derived
61
+ // journeys. All other project types (ObjectPage-only, Analytical List Page, unrecognized) fall back
62
+ // to the generic FirstJourney starter.
63
+ const generateUxSpecJourneys = !!LROP.pageLR || !!appFeatures.fpm;
64
+ // ALP pages are tagged with the `AnalyticalListPage` template in `createPageConfig`, which already
65
+ // excludes them from `findLROP` above (it matches only `template === 'ListReport'`). An ALP is a
66
+ // ListReport component under the hood with no dedicated page-object template or framework class, so
67
+ // now that detection is done, normalize the marker back to `ListReport` for all downstream rendering.
68
+ for (const page of config.pages) {
69
+ if (page.template === 'AnalyticalListPage') {
70
+ page.template = 'ListReport';
71
+ }
72
+ }
49
73
  const journeyParams = {
50
74
  startPages,
51
75
  startLR: LROP.pageLR?.targetKey,
@@ -62,6 +86,8 @@ export async function generateOPAFiles(basePath, options, metadata, fs, log, sta
62
86
  log,
63
87
  journeyParams,
64
88
  dotFileExtension,
89
+ templateUi5Version,
90
+ generateUxSpecJourneys,
65
91
  modifiedFiles: []
66
92
  };
67
93
  if (standalone) {
@@ -350,6 +376,9 @@ function createPageConfig(manifest, targetKey, forcedAppID) {
350
376
  isStartup: false,
351
377
  fileName: targetKey + '.gen'
352
378
  };
379
+ if (target.options?.settings?.views) {
380
+ pageConfig.template = 'AnalyticalListPage';
381
+ }
353
382
  if (target.options.settings.contextPath) {
354
383
  pageConfig.contextPath = target.options.settings.contextPath;
355
384
  }
@@ -511,7 +540,7 @@ function writeOpaJourneyTypes(writeContext) {
511
540
  function writeJourneyFiles(appFeatures, writeContext) {
512
541
  const { config, rootV4TemplateDirPath, testOutDirPath, editor, journeyParams, dotFileExtension } = writeContext;
513
542
  const generatedJourneys = [];
514
- if (appFeatures.listReport?.name) {
543
+ if (writeContext.generateUxSpecJourneys && appFeatures.listReport?.name) {
515
544
  editor.copyTpl(join(rootV4TemplateDirPath, 'integration', `ListReportJourney${dotFileExtension}`), join(testOutDirPath, 'integration', `${appFeatures.listReport.name}Journey.gen${dotFileExtension}`), {
516
545
  ...journeyParams,
517
546
  ...appFeatures.listReport,
@@ -521,7 +550,7 @@ function writeJourneyFiles(appFeatures, writeContext) {
521
550
  });
522
551
  generatedJourneys.push(appFeatures.listReport.name);
523
552
  }
524
- if (appFeatures.objectPages && appFeatures.objectPages.length > 0) {
553
+ if (writeContext.generateUxSpecJourneys && appFeatures.objectPages && appFeatures.objectPages.length > 0) {
525
554
  appFeatures.objectPages.forEach((objectPage) => {
526
555
  if (objectPage.name) {
527
556
  editor.copyTpl(join(rootV4TemplateDirPath, 'integration', `ObjectPageJourney${dotFileExtension}`), join(testOutDirPath, 'integration', `${objectPage.name}Journey.gen${dotFileExtension}`), {
@@ -535,7 +564,7 @@ function writeJourneyFiles(appFeatures, writeContext) {
535
564
  }
536
565
  });
537
566
  }
538
- if (appFeatures.fpm?.name) {
567
+ if (writeContext.generateUxSpecJourneys && appFeatures.fpm?.name) {
539
568
  // FPM TypeScript support is out of scope for the initial TS OPA5 work
540
569
  // (LROP only). The FPM journey path below is hardcoded `.js` and there is
541
570
  // no `FPM.ts` template, so we force `DotFileExtension.JS` for the FPM
@@ -551,7 +580,7 @@ function writeJourneyFiles(appFeatures, writeContext) {
551
580
  });
552
581
  generatedJourneys.push(appFeatures.fpm.name);
553
582
  }
554
- if (generatedJourneys.length === 0 && !writeContext.hasPreexistingTests) {
583
+ if (generatedJourneys.length === 0 && !writeContext.incompatibleTestSetup) {
555
584
  writeFallbackJourney(writeContext);
556
585
  }
557
586
  return generatedJourneys;
@@ -564,7 +593,12 @@ function writeJourneyFiles(appFeatures, writeContext) {
564
593
  */
565
594
  function writeFallbackJourney(writeContext) {
566
595
  const { config, rootV4TemplateDirPath, testOutDirPath, editor, journeyParams, dotFileExtension } = writeContext;
567
- editor.copyTpl(join(rootV4TemplateDirPath, 'integration', `FirstJourney${dotFileExtension}`), join(testOutDirPath, 'integration', `${config.opaJourneyFileName}${dotFileExtension}`), journeyParams, undefined, {
596
+ const fallbackPath = join(testOutDirPath, 'integration', `${config.opaJourneyFileName}${dotFileExtension}`);
597
+ // Do not clobber an existing fallback file (e.g. a user-edited FirstJourney in a preexisting test setup).
598
+ if (editor.exists(fallbackPath)) {
599
+ return;
600
+ }
601
+ editor.copyTpl(join(rootV4TemplateDirPath, 'integration', `FirstJourney${dotFileExtension}`), fallbackPath, journeyParams, undefined, {
568
602
  globOptions: { dot: true }
569
603
  });
570
604
  }
@@ -676,9 +710,12 @@ function writeOpaTestsStartupFiles(writeContext, generatedJourneys = []) {
676
710
  * @returns true if the file was written, false otherwise
677
711
  */
678
712
  function updateReferencesInOpaTestsStartupFiles(writeContext, generatedJourneys = []) {
679
- return addPathsToQUnitJs(generatedJourneys.map((page) => {
680
- return `${writeContext.config.appPath}/test/integration/${page}Journey.gen`;
681
- }), writeContext.testOutDirPath, writeContext.editor, writeContext.log);
713
+ // With no ux-spec journeys, wire the fallback journey (plain `opaJourneyFileName`, no `Journey.gen`
714
+ // suffix) into the existing qunit harness so the test setup remains runnable.
715
+ const journeyPaths = generatedJourneys.length > 0
716
+ ? generatedJourneys.map((page) => `${writeContext.config.appPath}/test/integration/${page}Journey.gen`)
717
+ : [`${writeContext.config.appPath}/test/integration/${writeContext.config.opaJourneyFileName}`];
718
+ return addPathsToQUnitJs(journeyPaths, writeContext.testOutDirPath, writeContext.editor, writeContext.log);
682
719
  }
683
720
  /**
684
721
  * Writes a page object in a mem-fs-editor.
package/dist/types.d.ts CHANGED
@@ -19,6 +19,8 @@ export type OPAGenerationOptions = {
19
19
  useVirtualPreviewEndpoints?: boolean;
20
20
  /** If true, generate TypeScript files instead of JavaScript. */
21
21
  enableTypeScript?: boolean;
22
+ /** Minimum UI5 version of the target app — selects template bucket ('1.84' / '1.150'). */
23
+ ui5Version?: string;
22
24
  };
23
25
  export declare const SupportedPageTypes: {
24
26
  [id: string]: string;
@@ -243,6 +245,14 @@ export type WriteContext = {
243
245
  hasPreexistingTests?: boolean;
244
246
  incompatibleTestSetup?: boolean;
245
247
  dotFileExtension: DotFileExtension;
248
+ /** Resolved template bucket folder name: '1.84' or '1.150'. */
249
+ templateUi5Version: string;
250
+ /**
251
+ * When true, ux-specification-derived journeys (ListReport, ObjectPage, FPM) are generated.
252
+ * When false (e.g. ObjectPage-only or Analytical List Page projects), only the generic
253
+ * fallback `FirstJourney` is written.
254
+ */
255
+ generateUxSpecJourneys: boolean;
246
256
  modifiedFiles: string[];
247
257
  };
248
258
  export type FormField = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/ui5-test-writer",
3
3
  "description": "SAP UI5 tests writer",
4
- "version": "1.2.34",
4
+ "version": "1.3.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.21",
31
31
  "@sap-ux/ui5-application-writer": "2.1.2",
32
32
  "@sap-ux/logger": "1.0.3",
33
+ "@sap-ux/fiori-generator-shared": "1.2.5",
33
34
  "@sap-ux/project-access": "2.1.9",
34
- "@sap-ux/preview-middleware": "1.0.49",
35
- "@sap-ux/fiori-generator-shared": "1.2.5"
35
+ "@sap-ux/preview-middleware": "1.0.49"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@jest/globals": "30.4.1",
@@ -0,0 +1,49 @@
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
+ sap.ui.define([
19
+ "sap/ui/test/opaQunit",
20
+ "./pages/JourneyRunner"
21
+ ], function (opaTest, runner) {
22
+ "use strict";
23
+
24
+ function journey() {
25
+ QUnit.module("FPM journey");
26
+
27
+ opaTest("Start application", function (Given, When, Then) {
28
+ Given.iStartMyApp();
29
+ <%_ startPages.forEach(function(pageName) { %>
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
+ <%_ }); -%>
40
+ });
41
+
42
+ opaTest("Teardown", function (Given, When, Then) {
43
+ // Cleanup
44
+ Given.iTearDownMyApp();
45
+ });
46
+ }
47
+
48
+ runner.run([journey]);
49
+ });
@@ -0,0 +1,35 @@
1
+ sap.ui.define([
2
+ "sap/ui/test/opaQunit",
3
+ "./pages/JourneyRunner"
4
+ ], function (opaTest, runner) {
5
+ "use strict";
6
+
7
+ function journey() {
8
+ QUnit.module("First journey");
9
+
10
+ opaTest("Start application", function (Given, When, Then) {
11
+ Given.iStartMyApp();
12
+ <% if (startLR) { %>Then.onThe<%- startLR %>.iSeeThisPage();<%} %>
13
+ });
14
+
15
+ <% if (startLR) { %>
16
+ opaTest("Navigate to ObjectPage", function (Given, When, Then) {
17
+ // Note: this test will fail if the ListReport page doesn't show any data
18
+ <% if (!hideFilterBar) { %>
19
+ When.onThe<%- startLR%>.onFilterBar().iExecuteSearch();
20
+ <%} %>
21
+ Then.onThe<%- startLR%>.onTable().iCheckRows();
22
+ <% if (navigatedOP) { %>
23
+ When.onThe<%- startLR%>.onTable().iPressRow(0);
24
+ Then.onThe<%- navigatedOP%>.iSeeThisPage();
25
+ <%} %>
26
+ });
27
+ <%} %>
28
+ opaTest("Teardown", function (Given, When, Then) {
29
+ // Cleanup
30
+ Given.iTearDownMyApp();
31
+ });
32
+ }
33
+
34
+ runner.run([journey]);
35
+ });
@@ -0,0 +1,32 @@
1
+ import opaTest from "sap/ui/test/opaQunit";
2
+ import type { Given, When, Then } from "./types/OpaJourneyTypes.gen";
3
+ import runner from "./pages/JourneyRunner";
4
+
5
+ function journey() {
6
+ QUnit.module("First journey");
7
+
8
+ opaTest("Start application", function (Given: Given, _When: When<% if (startLR) { %>, Then: Then<% } else { %>, _Then: Then<% } %>) {
9
+ Given.iStartMyApp();
10
+ <% if (startLR) { %>Then.onThe<%- startLR %>Generated.iSeeThisPage();<%} %>
11
+ });
12
+
13
+ <% if (startLR) { %>
14
+ opaTest("Navigate to ObjectPage", function (_Given: Given, When: When, Then: Then) {
15
+ // Note: this test will fail if the ListReport page doesn't show any data
16
+ <% if (!hideFilterBar) { %>
17
+ When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
18
+ <%} %>
19
+ Then.onThe<%- startLR%>Generated.onTable("").iCheckRows();
20
+ <% if (navigatedOP) { %>
21
+ When.onThe<%- startLR%>Generated.onTable("").iPressRow(0);
22
+ Then.onThe<%- navigatedOP%>Generated.iSeeThisPage();
23
+ <%} %>
24
+ });
25
+ <%} %>
26
+ opaTest("Teardown", function (Given: Given) {
27
+ // Cleanup
28
+ Given.iTearDownMyApp();
29
+ });
30
+ }
31
+
32
+ runner.run([journey]);
@@ -0,0 +1,129 @@
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
+ sap.ui.define([
19
+ "sap/ui/test/opaQunit",
20
+ "./pages/JourneyRunner"
21
+ ], function (opaTest, runner) {
22
+ "use strict";
23
+
24
+ function journey() {
25
+ QUnit.module("<%- name%>ListReport journey");
26
+
27
+ const defaultTableId = <%- tableIdentifiers && tableIdentifiers.length > 0 ? '"' + tableIdentifiers[0] + '"' : '""' %>;
28
+
29
+ opaTest("Start application", function (Given, When, Then) {
30
+ Given.iStartMyApp();
31
+ <%_ startPages.forEach(function(pageName) { %>
32
+ Then.onThe<%- pageName %>Generated.iSeeThisPage();
33
+ <%_ }); -%>
34
+ });
35
+
36
+ <%_ if (!hideFilterBar && filterBarItems && filterBarItems.length > 0) { -%>
37
+ opaTest("Check filter bar", function (Given, When, Then) {
38
+ <%_ filterBarItems.forEach(function(item) { _%>
39
+ <%_ if (item.custom) { _%>
40
+ Then.onThe<%- startLR%>Generated.onFilterBar().iCheckFilterField("<%- item.description %>");
41
+ <%_ } else { _%>
42
+ Then.onThe<%- startLR%>Generated.onFilterBar().iCheckFilterField({ property: "<%- item.property %>" });
43
+ <%_ } _%>
44
+ <%_ }); -%>
45
+ });
46
+ <%_ } -%>
47
+ <%_ if (semanticKey && semanticKey.missingFromFilterBar && semanticKey.missingFromFilterBar.length > 0) { %>
48
+ opaTest("Add semantic key properties to filter bar", function (Given, When, Then) {
49
+ When.onThe<%- startLR%>Generated.onFilterBar().iOpenFilterAdaptation();
50
+ <%_ semanticKey.missingFromFilterBar.forEach(function(property) { _%>
51
+ When.onThe<%- startLR%>Generated.onFilterBar().iAddAdaptationFilterField({ property: "<%- property %>" });
52
+ <%_ }); -%>
53
+ When.onThe<%- startLR%>Generated.onFilterBar().iConfirmFilterAdaptation();
54
+ <%_ semanticKey.missingFromFilterBar.forEach(function(property) { _%>
55
+ Then.onThe<%- startLR%>Generated.onFilterBar().iCheckFilterField({ property: "<%- property %>" });
56
+ <%_ }); -%>
57
+ <%_ semanticKey.missingFromFilterBar.forEach(function(property) { _%>
58
+ // When.onThe<%- startLR%>Generated.onFilterBar().iChangeFilterField({ property: "<%- property %>" }, "<value to filter>", false);
59
+ <%_ }); -%>
60
+ // When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
61
+ // Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckRows();
62
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iSelectRows(0);
63
+ // Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<Action Name>", { enabled: true });
64
+ });
65
+ <%_ } -%>
66
+
67
+ // Note: this test will only work if the ListReport page has a search field and shows data that matches the search term. Please ensure that the test data and search term are set up accordingly.
68
+ // opaTest("Perform a global search and check the result", function (Given, When, Then) {
69
+ // When.onThe<%- startLR%>Generated.onFilterBar().iChangeSearchField("Search Term");
70
+ // When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
71
+ // Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckRows();
72
+ // });
73
+
74
+ <%_ if ((toolBarActions && toolBarActions.length > 0 ) || (tableColumns && Object.keys(tableColumns).length > 0)) { -%>
75
+ opaTest("Check table columns and actions", function (Given, When, Then) {
76
+ <%_ if (toolBarActions && toolBarActions.length > 0) { -%>
77
+ <%_ if (createButton.visible && !isALP) { _%>
78
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckCreate({ visible: true });
79
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressCreate();
80
+ <%_ } _%>
81
+ <%_ if (deleteButton.visible) { _%>
82
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressDelete();
83
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckDelete({ visible: true });
84
+ <%_ } _%>
85
+ <%_ toolBarActions.forEach(function(item) { _%>
86
+ <%_ if (item.visible) { _%>
87
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressAction("<%- item.label %>");
88
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>", { enabled: <%- item.enabled === true %> });
89
+ <%_ } _%>
90
+ <%_ }); -%>
91
+ <%_ } -%>
92
+ <%_ if (tableColumns && Object.keys(tableColumns).length > 0) { -%>
93
+ Then.onThe<%- startLR %>Generated.onTable(defaultTableId).iCheckColumns(undefined, <%- JSON.stringify(tableColumns) %>);
94
+ <%_ } -%>
95
+ });
96
+ <%_ } -%>
97
+
98
+ <%_ if (startLR) { -%>
99
+ opaTest("Navigate to ObjectPage", function (Given, When, Then) {
100
+ // Note: this test will fail if the ListReport page doesn't show any data
101
+ <%_ if (!hideFilterBar) { -%>
102
+ When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
103
+ <%_ } -%>
104
+ <%_ if (tableIdentifiers && tableIdentifiers.length > 0) { -%>
105
+ <%_ tableIdentifiers.forEach(function(tabId) { _%>
106
+ When.onThe<%- startLR%>Generated.iGoToView({ key: "<%- tabId %>" });
107
+ Then.onThe<%- startLR%>Generated.onTable("<%- tabId %>").iCheckRows();
108
+ <%_ }); -%>
109
+ <%_ } else { -%>
110
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckRows();
111
+ <%_ } -%>
112
+ <%_ if (navigatedOP) { -%>
113
+ <%_ if (tableIdentifiers && tableIdentifiers.length > 0) { _%>
114
+ When.onThe<%- startLR%>Generated.iGoToView({ key: defaultTableId });
115
+ <%_ } _%>
116
+ When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressRow(0);
117
+ Then.onThe<%- navigatedOP%>Generated.iSeeThisPage();
118
+ <%_ } -%>
119
+ });
120
+ <%_ } -%>
121
+
122
+ opaTest("Teardown", function (Given, When, Then) {
123
+ // Cleanup
124
+ Given.iTearDownMyApp();
125
+ });
126
+ }
127
+
128
+ runner.run([journey]);
129
+ });
@@ -0,0 +1,133 @@
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
+ <%_
21
+ const usesFilterFieldIdentifier =
22
+ !hideFilterBar && filterBarItems && filterBarItems.some(function(item) { return item.custom; });
23
+ -%>
24
+ <% if (usesFilterFieldIdentifier) { -%>
25
+ import type { FilterFieldIdentifier } from "sap/fe/test/api/FilterBarAPI";
26
+ <% } -%>
27
+ import runner from "./pages/JourneyRunner";
28
+
29
+ function journey() {
30
+ QUnit.module("<%- name%>ListReport journey");
31
+
32
+ const defaultTableId = <%- tableIdentifiers && tableIdentifiers.length > 0 ? '"' + tableIdentifiers[0] + '"' : '""' %>;
33
+
34
+ opaTest("Start application", function (Given: Given, _When: When, Then: Then) {
35
+ Given.iStartMyApp();
36
+ <%_ startPages.forEach(function(pageName) { %>
37
+ Then.onThe<%- pageName %>Generated.iSeeThisPage();
38
+ <%_ }); -%>
39
+ });
40
+
41
+ <%_ if (!hideFilterBar && filterBarItems && filterBarItems.length > 0) { -%>
42
+ opaTest("Check filter bar", function (_Given: Given, _When: When, Then: Then) {
43
+ <%_ filterBarItems.forEach(function(item) { _%>
44
+ <%_ if (item.custom) { _%>
45
+ Then.onThe<%- startLR%>Generated.onFilterBar().iCheckFilterField("<%- item.description %>" as unknown as FilterFieldIdentifier);
46
+ <%_ } else { _%>
47
+ Then.onThe<%- startLR%>Generated.onFilterBar().iCheckFilterField({ property: "<%- item.property %>" });
48
+ <%_ } _%>
49
+ <%_ }); -%>
50
+ });
51
+ <%_ } -%>
52
+ <%_ if (semanticKey && semanticKey.missingFromFilterBar && semanticKey.missingFromFilterBar.length > 0) { %>
53
+ opaTest("Add semantic key properties to filter bar", function (_Given: Given, When: When, Then: Then) {
54
+ When.onThe<%- startLR%>Generated.onFilterBar().iOpenFilterAdaptation();
55
+ <%_ semanticKey.missingFromFilterBar.forEach(function(property) { _%>
56
+ When.onThe<%- startLR%>Generated.onFilterBar().iAddAdaptationFilterField({ property: "<%- property %>" });
57
+ <%_ }); -%>
58
+ When.onThe<%- startLR%>Generated.onFilterBar().iConfirmFilterAdaptation();
59
+ <%_ semanticKey.missingFromFilterBar.forEach(function(property) { _%>
60
+ Then.onThe<%- startLR%>Generated.onFilterBar().iCheckFilterField({ property: "<%- property %>" });
61
+ <%_ }); -%>
62
+ <%_ semanticKey.missingFromFilterBar.forEach(function(property) { _%>
63
+ // When.onThe<%- startLR%>Generated.onFilterBar().iChangeFilterField({ property: "<%- property %>" }, "<value to filter>", false);
64
+ <%_ }); -%>
65
+ // When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
66
+ // Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckRows();
67
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iSelectRows(0);
68
+ // Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<Action Name>", { enabled: true });
69
+ });
70
+ <%_ } -%>
71
+
72
+ // Note: this test will only work if the ListReport page has a search field and shows data that matches the search term. Please ensure that the test data and search term are set up accordingly.
73
+ // opaTest("Perform a global search and check the result", function (Given: Given, When: When, Then: Then) {
74
+ // When.onThe<%- startLR%>Generated.onFilterBar().iChangeSearchField("Search Term");
75
+ // When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
76
+ // Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckRows();
77
+ // });
78
+
79
+ <%_ if ((toolBarActions && toolBarActions.length > 0 ) || (tableColumns && Object.keys(tableColumns).length > 0)) { -%>
80
+ opaTest("Check table columns and actions", function (_Given: Given, _When: When, Then: Then) {
81
+ <%_ if (toolBarActions && toolBarActions.length > 0) { -%>
82
+ <%_ if (createButton.visible && !isALP) { _%>
83
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckCreate({ visible: true });
84
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressCreate();
85
+ <%_ } _%>
86
+ <%_ if (deleteButton.visible) { _%>
87
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressDelete();
88
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckDelete({ visible: true });
89
+ <%_ } _%>
90
+ <%_ toolBarActions.forEach(function(item) { _%>
91
+ <%_ if (item.visible) { _%>
92
+ // When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressAction("<%- item.label %>");
93
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckAction("<%- item.label %>", { enabled: <%- item.enabled === true %> });
94
+ <%_ } _%>
95
+ <%_ }); -%>
96
+ <%_ } -%>
97
+ <%_ if (tableColumns && Object.keys(tableColumns).length > 0) { -%>
98
+ Then.onThe<%- startLR %>Generated.onTable(defaultTableId).iCheckColumns(undefined, <%- JSON.stringify(tableColumns) %>);
99
+ <%_ } -%>
100
+ });
101
+ <%_ } -%>
102
+
103
+ <%_ if (startLR) { -%>
104
+ opaTest("Navigate to ObjectPage", function (_Given: Given, When: When, Then: Then) {
105
+ // Note: this test will fail if the ListReport page doesn't show any data
106
+ <%_ if (!hideFilterBar) { -%>
107
+ When.onThe<%- startLR%>Generated.onFilterBar().iExecuteSearch();
108
+ <%_ } -%>
109
+ <%_ if (tableIdentifiers && tableIdentifiers.length > 0) { -%>
110
+ <%_ tableIdentifiers.forEach(function(tabId) { _%>
111
+ When.onThe<%- startLR%>Generated.iGoToView({ key: "<%- tabId %>" });
112
+ Then.onThe<%- startLR%>Generated.onTable("<%- tabId %>").iCheckRows();
113
+ <%_ }); -%>
114
+ <%_ } else { -%>
115
+ Then.onThe<%- startLR%>Generated.onTable(defaultTableId).iCheckRows();
116
+ <%_ } -%>
117
+ <%_ if (navigatedOP) { -%>
118
+ <%_ if (tableIdentifiers && tableIdentifiers.length > 0) { _%>
119
+ When.onThe<%- startLR%>Generated.iGoToView({ key: defaultTableId });
120
+ <%_ } _%>
121
+ When.onThe<%- startLR%>Generated.onTable(defaultTableId).iPressRow(0);
122
+ Then.onThe<%- navigatedOP%>Generated.iSeeThisPage();
123
+ <%_ } -%>
124
+ });
125
+ <%_ } -%>
126
+
127
+ opaTest("Teardown", function (Given: Given) {
128
+ // Cleanup
129
+ Given.iTearDownMyApp();
130
+ });
131
+ }
132
+
133
+ runner.run([journey]);