@sap-ux/ui5-test-writer 1.2.31 → 1.2.35

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/README.md CHANGED
@@ -69,7 +69,7 @@ const fs = await generateOPAFiles(myProjectPath, { enableTypeScript: true });
69
69
  What changes in the generated output:
70
70
 
71
71
  - Page objects, journeys, and `JourneyRunner` are emitted as `.ts` files.
72
- - A `webapp/test/integration/types/OpaJourneyTypes.d.ts` file is generated with `Given` / `When` / `Then` definitions tailored to the app's pages.
72
+ - A `webapp/test/integration/types/OpaJourneyTypes.gen.d.ts` file is generated with `Given` / `When` / `Then` definitions tailored to the app's pages.
73
73
  - The QUnit bootstrap (`opaTests.qunit.js`) and the HTML harness stay as `.js` / `.html` (they are loaded directly by the browser).
74
74
 
75
75
  When run in standalone mode against an existing project, `enableTypeScript` is auto-detected from the presence of a `tsconfig.json`. An explicit value passed in the options always takes precedence.
@@ -46,6 +46,19 @@ export async function generateOPAFiles(basePath, options, metadata, fs, log, sta
46
46
  // OPA Journey file
47
47
  const startPages = config.pages.filter((page) => page.isStartup).map((page) => page.targetKey);
48
48
  const LROP = findLROP(config.pages, manifest);
49
+ // Only projects with a startup ListReport page (LROP) or an FPM page get ux-specification-derived
50
+ // journeys. All other project types (ObjectPage-only, Analytical List Page, unrecognized) fall back
51
+ // to the generic FirstJourney starter.
52
+ const generateUxSpecJourneys = !!LROP.pageLR || !!appFeatures.fpm;
53
+ // ALP pages are tagged with the `AnalyticalListPage` template in `createPageConfig`, which already
54
+ // excludes them from `findLROP` above (it matches only `template === 'ListReport'`). An ALP is a
55
+ // ListReport component under the hood with no dedicated page-object template or framework class, so
56
+ // now that detection is done, normalize the marker back to `ListReport` for all downstream rendering.
57
+ for (const page of config.pages) {
58
+ if (page.template === 'AnalyticalListPage') {
59
+ page.template = 'ListReport';
60
+ }
61
+ }
49
62
  const journeyParams = {
50
63
  startPages,
51
64
  startLR: LROP.pageLR?.targetKey,
@@ -62,6 +75,7 @@ export async function generateOPAFiles(basePath, options, metadata, fs, log, sta
62
75
  log,
63
76
  journeyParams,
64
77
  dotFileExtension,
78
+ generateUxSpecJourneys,
65
79
  modifiedFiles: []
66
80
  };
67
81
  if (standalone) {
@@ -350,6 +364,9 @@ function createPageConfig(manifest, targetKey, forcedAppID) {
350
364
  isStartup: false,
351
365
  fileName: targetKey + '.gen'
352
366
  };
367
+ if (target.options?.settings?.views) {
368
+ pageConfig.template = 'AnalyticalListPage';
369
+ }
353
370
  if (target.options.settings.contextPath) {
354
371
  pageConfig.contextPath = target.options.settings.contextPath;
355
372
  }
@@ -490,16 +507,16 @@ function writeJourneyRunner(writeContext) {
490
507
  modifiedFiles.push(`integration/pages/JourneyRunner${dotFileExtension}`);
491
508
  }
492
509
  /**
493
- * Writes the OpaJourneyTypes.d.ts type definition file used by generated TypeScript OPA tests.
510
+ * Writes the OpaJourneyTypes.gen.d.ts type definition file used by generated TypeScript OPA tests.
494
511
  *
495
512
  * @param writeContext - shared write context (config, paths, editor, journey params)
496
513
  */
497
514
  function writeOpaJourneyTypes(writeContext) {
498
515
  const { config, rootV4TemplateDirPath, testOutDirPath, editor, modifiedFiles } = writeContext;
499
- editor.copyTpl(join(rootV4TemplateDirPath, 'integration', 'types', 'OpaJourneyTypes.d.ts'), join(testOutDirPath, 'integration', 'types', 'OpaJourneyTypes.d.ts'), config, undefined, {
516
+ editor.copyTpl(join(rootV4TemplateDirPath, 'integration', 'types', 'OpaJourneyTypes.d.ts'), join(testOutDirPath, 'integration', 'types', 'OpaJourneyTypes.gen.d.ts'), config, undefined, {
500
517
  globOptions: { dot: true }
501
518
  });
502
- modifiedFiles.push('integration/types/OpaJourneyTypes.d.ts');
519
+ modifiedFiles.push('integration/types/OpaJourneyTypes.gen.d.ts');
503
520
  }
504
521
  /**
505
522
  * Writes journey files for list report, object pages and FPM pages.
@@ -511,7 +528,7 @@ function writeOpaJourneyTypes(writeContext) {
511
528
  function writeJourneyFiles(appFeatures, writeContext) {
512
529
  const { config, rootV4TemplateDirPath, testOutDirPath, editor, journeyParams, dotFileExtension } = writeContext;
513
530
  const generatedJourneys = [];
514
- if (appFeatures.listReport?.name) {
531
+ if (writeContext.generateUxSpecJourneys && appFeatures.listReport?.name) {
515
532
  editor.copyTpl(join(rootV4TemplateDirPath, 'integration', `ListReportJourney${dotFileExtension}`), join(testOutDirPath, 'integration', `${appFeatures.listReport.name}Journey.gen${dotFileExtension}`), {
516
533
  ...journeyParams,
517
534
  ...appFeatures.listReport,
@@ -521,7 +538,7 @@ function writeJourneyFiles(appFeatures, writeContext) {
521
538
  });
522
539
  generatedJourneys.push(appFeatures.listReport.name);
523
540
  }
524
- if (appFeatures.objectPages && appFeatures.objectPages.length > 0) {
541
+ if (writeContext.generateUxSpecJourneys && appFeatures.objectPages && appFeatures.objectPages.length > 0) {
525
542
  appFeatures.objectPages.forEach((objectPage) => {
526
543
  if (objectPage.name) {
527
544
  editor.copyTpl(join(rootV4TemplateDirPath, 'integration', `ObjectPageJourney${dotFileExtension}`), join(testOutDirPath, 'integration', `${objectPage.name}Journey.gen${dotFileExtension}`), {
@@ -535,7 +552,7 @@ function writeJourneyFiles(appFeatures, writeContext) {
535
552
  }
536
553
  });
537
554
  }
538
- if (appFeatures.fpm?.name) {
555
+ if (writeContext.generateUxSpecJourneys && appFeatures.fpm?.name) {
539
556
  // FPM TypeScript support is out of scope for the initial TS OPA5 work
540
557
  // (LROP only). The FPM journey path below is hardcoded `.js` and there is
541
558
  // no `FPM.ts` template, so we force `DotFileExtension.JS` for the FPM
@@ -551,7 +568,7 @@ function writeJourneyFiles(appFeatures, writeContext) {
551
568
  });
552
569
  generatedJourneys.push(appFeatures.fpm.name);
553
570
  }
554
- if (generatedJourneys.length === 0 && !writeContext.hasPreexistingTests) {
571
+ if (generatedJourneys.length === 0 && !writeContext.incompatibleTestSetup) {
555
572
  writeFallbackJourney(writeContext);
556
573
  }
557
574
  return generatedJourneys;
@@ -564,12 +581,17 @@ function writeJourneyFiles(appFeatures, writeContext) {
564
581
  */
565
582
  function writeFallbackJourney(writeContext) {
566
583
  const { config, rootV4TemplateDirPath, testOutDirPath, editor, journeyParams, dotFileExtension } = writeContext;
567
- editor.copyTpl(join(rootV4TemplateDirPath, 'integration', `FirstJourney${dotFileExtension}`), join(testOutDirPath, 'integration', `${config.opaJourneyFileName}${dotFileExtension}`), journeyParams, undefined, {
584
+ const fallbackPath = join(testOutDirPath, 'integration', `${config.opaJourneyFileName}${dotFileExtension}`);
585
+ // Do not clobber an existing fallback file (e.g. a user-edited FirstJourney in a preexisting test setup).
586
+ if (editor.exists(fallbackPath)) {
587
+ return;
588
+ }
589
+ editor.copyTpl(join(rootV4TemplateDirPath, 'integration', `FirstJourney${dotFileExtension}`), fallbackPath, journeyParams, undefined, {
568
590
  globOptions: { dot: true }
569
591
  });
570
592
  }
571
593
  /**
572
- * Update the `OpaJourneyTypes.d.ts` type-definition file used by generated TypeScript OPA tests.
594
+ * Update the `OpaJourneyTypes.gen.d.ts` type-definition file used by generated TypeScript OPA tests.
573
595
  *
574
596
  * @param writeContext - shared write context (config, paths, editor, journey params)
575
597
  * @param generatedPages - pages whose journeys should be reflected in the type definitions
@@ -582,7 +604,7 @@ function handleOPAJourneyTypes(writeContext, generatedPages) {
582
604
  if (writeContext.hasPreexistingTests) {
583
605
  const written = addJourneysToOpaJourneyTypes(generatedPages, writeContext.testOutDirPath, writeContext.editor, writeContext.log);
584
606
  if (written) {
585
- writeContext.modifiedFiles.push('integration/types/OpaJourneyTypes.d.ts');
607
+ writeContext.modifiedFiles.push('integration/types/OpaJourneyTypes.gen.d.ts');
586
608
  }
587
609
  }
588
610
  else {
@@ -676,9 +698,12 @@ function writeOpaTestsStartupFiles(writeContext, generatedJourneys = []) {
676
698
  * @returns true if the file was written, false otherwise
677
699
  */
678
700
  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);
701
+ // With no ux-spec journeys, wire the fallback journey (plain `opaJourneyFileName`, no `Journey.gen`
702
+ // suffix) into the existing qunit harness so the test setup remains runnable.
703
+ const journeyPaths = generatedJourneys.length > 0
704
+ ? generatedJourneys.map((page) => `${writeContext.config.appPath}/test/integration/${page}Journey.gen`)
705
+ : [`${writeContext.config.appPath}/test/integration/${writeContext.config.opaJourneyFileName}`];
706
+ return addPathsToQUnitJs(journeyPaths, writeContext.testOutDirPath, writeContext.editor, writeContext.log);
682
707
  }
683
708
  /**
684
709
  * Writes a page object in a mem-fs-editor.
@@ -10,11 +10,11 @@
10
10
  "warn": {
11
11
  "cannotUpdateJourneyRunner": "Could not update `JourneyRunner.js`. The existing file may be missing or unreadable. New pages were not registered.",
12
12
  "cannotUpdateOpaTestsQunit": "Could not update `opaTests.qunit.js`. The existing file may be missing or unreadable. New journey paths were not registered.",
13
- "cannotUpdateOpaJourneyTypes": "Could not update `OpaJourneyTypes.d.ts`. The existing file may be missing or unreadable. New journey type definitions were not registered.",
13
+ "cannotUpdateOpaJourneyTypes": "Could not update `OpaJourneyTypes.gen.d.ts`. The existing file may be missing or unreadable. New journey type definitions were not registered.",
14
14
  "noFilterFieldTests": "Unable to extract filter fields from the project model using specification. No filter field tests are generated."
15
15
  },
16
16
  "info": {
17
- "opaJourneyTypesNotUpdated": "`OpaJourneyTypes.d.ts` was not updated due to an incompatible existing test setup.",
17
+ "opaJourneyTypesNotUpdated": "`OpaJourneyTypes.gen.d.ts` was not updated due to an incompatible existing test setup.",
18
18
  "incompatibleTestSetupSkipped": "`testsuite.qunit` and `opaTests.qunit` files were not updated due to an incompatible existing test setup.",
19
19
  "manualIntegrationRequired": "Please ensure the generated journeys and pages are integrated into your existing OPA5 test setup."
20
20
  }
package/dist/types.d.ts CHANGED
@@ -243,6 +243,12 @@ export type WriteContext = {
243
243
  hasPreexistingTests?: boolean;
244
244
  incompatibleTestSetup?: boolean;
245
245
  dotFileExtension: DotFileExtension;
246
+ /**
247
+ * When true, ux-specification-derived journeys (ListReport, ObjectPage, FPM) are generated.
248
+ * When false (e.g. ObjectPage-only or Analytical List Page projects), only the generic
249
+ * fallback `FirstJourney` is written.
250
+ */
251
+ generateUxSpecJourneys: boolean;
246
252
  modifiedFiles: string[];
247
253
  };
248
254
  export type FormField = {
@@ -1,8 +1,8 @@
1
1
  import { join } from 'node:path';
2
2
  import { t } from '../i18n.js';
3
3
  import { MAX_FILE_CONTENT_LENGTH, escapeRegex, findBracedBlock, insertAfterLastImport } from './fileWritingUtils.js';
4
- /** Relative path from the test output directory to OpaJourneyTypes.d.ts */
5
- const OPA_JOURNEY_TYPES_FILE = join('integration', 'types', 'OpaJourneyTypes.d.ts');
4
+ /** Relative path from the test output directory to OpaJourneyTypes.gen.d.ts */
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
7
  const SUPPORTED_FRAMEWORKS = new Set(['ListReport', 'ObjectPage']);
8
8
  /**
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.31",
4
+ "version": "1.2.35",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -28,11 +28,11 @@
28
28
  "@sap/ux-specification": "1.144.5",
29
29
  "@sap-ux/edmx-parser": "0.10.0",
30
30
  "@sap-ux/annotation-converter": "0.10.21",
31
- "@sap-ux/ui5-application-writer": "2.1.1",
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.3",
34
- "@sap-ux/preview-middleware": "1.0.47",
35
- "@sap-ux/project-access": "2.1.8"
33
+ "@sap-ux/fiori-generator-shared": "1.2.5",
34
+ "@sap-ux/project-access": "2.1.9",
35
+ "@sap-ux/preview-middleware": "1.0.49"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@jest/globals": "30.4.1",
@@ -41,7 +41,7 @@
41
41
  "@types/mem-fs": "1.1.2",
42
42
  "@types/mem-fs-editor": "7.0.1",
43
43
  "rimraf": "6.1.3",
44
- "fs-extra": "11.3.5",
44
+ "fs-extra": "11.3.6",
45
45
  "@sap-ux/vocabularies-types": "0.15.0",
46
46
  "@sap-ux/jest-file-matchers": "1.0.2"
47
47
  },
@@ -1,5 +1,5 @@
1
1
  import opaTest from "sap/ui/test/opaQunit";
2
- import type { Given, When, Then } from "./types/OpaJourneyTypes";
2
+ import type { Given, When, Then } from "./types/OpaJourneyTypes.gen";
3
3
  import runner from "./pages/JourneyRunner";
4
4
 
5
5
  function journey() {
@@ -16,7 +16,7 @@
16
16
  ******************************************************************************/
17
17
 
18
18
  import opaTest from "sap/ui/test/opaQunit";
19
- import type { Given, When, Then } from "./types/OpaJourneyTypes";
19
+ import type { Given, When, Then } from "./types/OpaJourneyTypes.gen";
20
20
  <%_
21
21
  const usesFilterFieldIdentifier =
22
22
  !hideFilterBar && filterBarItems && filterBarItems.some(function(item) { return item.custom; });
@@ -16,7 +16,7 @@
16
16
  ******************************************************************************/
17
17
 
18
18
  import opaTest from "sap/ui/test/opaQunit";
19
- import type { Given, When, Then } from "./types/OpaJourneyTypes";
19
+ import type { Given, When, Then } from "./types/OpaJourneyTypes.gen";
20
20
  <%_
21
21
  const usesFieldIdentifier = (headerSections || []).some(function(section) {
22
22
  return section.form && section.fields && section.fields.length > 0;