@sap-ux/ui5-test-writer 1.14.0 → 1.15.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 (30) hide show
  1. package/dist/fiori-elements-opa-writer.js +13 -2
  2. package/dist/types.d.ts +2 -0
  3. package/package.json +2 -2
  4. package/templates/v4/1.148/integration/FPMJourney.js +2 -0
  5. package/templates/v4/1.148/integration/FPMJourney.ts +2 -0
  6. package/templates/v4/1.148/integration/FirstJourney.js +2 -0
  7. package/templates/v4/1.148/integration/FirstJourney.ts +2 -0
  8. package/templates/v4/1.148/integration/ListReportJourney.js +2 -0
  9. package/templates/v4/1.148/integration/ListReportJourney.ts +2 -0
  10. package/templates/v4/1.148/integration/ObjectPageJourney.js +2 -0
  11. package/templates/v4/1.148/integration/ObjectPageJourney.ts +2 -0
  12. package/templates/v4/1.148/integration/types/OpaJourneyTypes.d.ts +2 -0
  13. package/templates/v4/1.84/integration/FPMJourney.js +2 -0
  14. package/templates/v4/1.84/integration/FPMJourney.ts +2 -0
  15. package/templates/v4/1.84/integration/FirstJourney.js +2 -0
  16. package/templates/v4/1.84/integration/FirstJourney.ts +2 -0
  17. package/templates/v4/1.84/integration/ListReportJourney.js +2 -0
  18. package/templates/v4/1.84/integration/ListReportJourney.ts +2 -0
  19. package/templates/v4/1.84/integration/ObjectPageJourney.js +2 -0
  20. package/templates/v4/1.84/integration/ObjectPageJourney.ts +2 -0
  21. package/templates/v4/1.84/integration/types/OpaJourneyTypes.d.ts +2 -0
  22. package/templates/v4/latest/integration/FPMJourney.js +2 -0
  23. package/templates/v4/latest/integration/FPMJourney.ts +2 -0
  24. package/templates/v4/latest/integration/FirstJourney.js +2 -0
  25. package/templates/v4/latest/integration/FirstJourney.ts +2 -0
  26. package/templates/v4/latest/integration/ListReportJourney.js +2 -0
  27. package/templates/v4/latest/integration/ListReportJourney.ts +2 -0
  28. package/templates/v4/latest/integration/ObjectPageJourney.js +2 -0
  29. package/templates/v4/latest/integration/ObjectPageJourney.ts +2 -0
  30. package/templates/v4/latest/integration/types/OpaJourneyTypes.d.ts +2 -0
@@ -5,7 +5,7 @@ import { create as createStorage } from 'mem-fs';
5
5
  import { create } from 'mem-fs-editor';
6
6
  import { SupportedPageTypes, ValidationError, DotFileExtension } from './types.js';
7
7
  import { t } from './i18n.js';
8
- import { FileName, DirName, getWebappPath, updatePackageScript } from '@sap-ux/project-access';
8
+ import { FileName, DirName, getWebappPath, updatePackageScript, getMainService } from '@sap-ux/project-access';
9
9
  import { getAppFeatures } from './utils/modelUtils.js';
10
10
  import { addPathsToQUnitJs, readHtmlTargetFromQUnitJs } from './utils/opaQUnitUtils.js';
11
11
  import { addPagesToJourneyRunner } from './utils/journeyRunnerUtils.js';
@@ -120,7 +120,8 @@ export async function generateOPAFiles(basePath, options, metadata, fs, log, sta
120
120
  startLR: LROP.pageLR?.targetKey,
121
121
  navigatedOP: LROP.pageOP?.targetKey,
122
122
  navigatedOPTabKey,
123
- hideFilterBar: config.hideFilterBar
123
+ hideFilterBar: config.hideFilterBar,
124
+ serviceUri: getServiceUri(manifest)
124
125
  };
125
126
  const writeContext = {
126
127
  config,
@@ -396,6 +397,16 @@ function getAppFromManifest(manifest, forcedAppID) {
396
397
  }
397
398
  return { appID, appPath };
398
399
  }
400
+ /**
401
+ * Resolves the OData service URI used by `iResetMockData({ ServiceUri })` at the start of each journey.
402
+ *
403
+ * @param manifest - the app descriptor of the app
404
+ * @returns the main service's URI, or an empty string if it cannot be resolved
405
+ */
406
+ function getServiceUri(manifest) {
407
+ const mainService = getMainService(manifest);
408
+ return (mainService && manifest['sap.app']?.dataSources?.[mainService]?.uri) || '';
409
+ }
399
410
  /**
400
411
  * Create the page configuration object from the app descriptor and the target key.
401
412
  *
package/dist/types.d.ts CHANGED
@@ -53,6 +53,8 @@ export type JourneyParams = {
53
53
  navigatedOP: string | undefined;
54
54
  navigatedOPTabKey?: string;
55
55
  hideFilterBar: boolean;
56
+ /** OData service URI passed to `iResetMockData({ ServiceUri })` at the start of each journey. */
57
+ serviceUri: string;
56
58
  };
57
59
  export type FEV4ManifestTarget = {
58
60
  type?: string;
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.14.0",
4
+ "version": "1.15.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -32,7 +32,7 @@
32
32
  "@sap-ux/logger": "1.0.3",
33
33
  "@sap-ux/fiori-generator-shared": "1.2.18",
34
34
  "@sap-ux/project-access": "2.2.1",
35
- "@sap-ux/preview-middleware": "1.2.18"
35
+ "@sap-ux/preview-middleware": "1.2.19"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@jest/globals": "30.4.1",
@@ -25,6 +25,8 @@ sap.ui.define([
25
25
  QUnit.module("<%- name %> Journey");
26
26
 
27
27
  opaTest("Start application", function (Given, When, Then) {
28
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
29
+ Given.iResetTestData();
28
30
  Given.iStartMyApp();
29
31
  <%_ startPages.forEach(function(pageName) { %>
30
32
  Then.onThe<%- pageName %>Generated.iSeeThisPage();
@@ -23,6 +23,8 @@ function journey() {
23
23
  QUnit.module("<%- name %> Journey");
24
24
 
25
25
  opaTest("Start application", function (Given: Given, _When: When, Then: Then) {
26
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
27
+ Given.iResetTestData();
26
28
  Given.iStartMyApp();
27
29
  <%_ startPages.forEach(function(pageName) { %>
28
30
  Then.onThe<%- pageName %>Generated.iSeeThisPage();
@@ -8,6 +8,8 @@ sap.ui.define([
8
8
  QUnit.module("First journey");
9
9
 
10
10
  opaTest("Start application", function (Given, When, Then) {
11
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
12
+ Given.iResetTestData();
11
13
  Given.iStartMyApp();
12
14
  <% if (startLR) { %>Then.onThe<%- startLR %>.iSeeThisPage();<%} %>
13
15
  });
@@ -6,6 +6,8 @@ function journey() {
6
6
  QUnit.module("First journey");
7
7
 
8
8
  opaTest("Start application", function (Given: Given, _When: When<% if (startLR) { %>, Then: Then<% } else { %>, _Then: Then<% } %>) {
9
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
10
+ Given.iResetTestData();
9
11
  Given.iStartMyApp();
10
12
  <% if (startLR) { %>Then.onThe<%- startLR %>Generated.iSeeThisPage();<%} %>
11
13
  });
@@ -28,6 +28,8 @@ sap.ui.define([
28
28
  const defaultTableId = <%- tableIdentifiers && tableIdentifiers.length > 0 ? '"' + tableIdentifiers[0] + '"' : '""' %>;
29
29
 
30
30
  opaTest("Start application", function (Given, When, Then) {
31
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
32
+ Given.iResetTestData();
31
33
  Given.iStartMyApp();
32
34
  <%_ startPages.forEach(function(pageName) { %>
33
35
  Then.onThe<%- pageName %>Generated.iSeeThisPage();
@@ -36,6 +36,8 @@ function journey() {
36
36
  const defaultTableId = <%- tableIdentifiers && tableIdentifiers.length > 0 ? '"' + tableIdentifiers[0] + '"' : '""' %>;
37
37
 
38
38
  opaTest("Start application", function (Given: Given, _When: When, Then: Then) {
39
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
40
+ Given.iResetTestData();
39
41
  Given.iStartMyApp();
40
42
  <%_ startPages.forEach(function(pageName) { %>
41
43
  Then.onThe<%- pageName %>Generated.iSeeThisPage();
@@ -25,6 +25,8 @@ sap.ui.define([
25
25
  QUnit.module("<%- name%>ObjectPage journey");
26
26
 
27
27
  opaTest("Navigate to <%- name%>ObjectPage", function (Given, When, Then) {
28
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
29
+ Given.iResetTestData();
28
30
  Given.iStartMyApp();
29
31
  <% if(navigationParents.parentLRName) { -%>
30
32
  <% const parentTableId = navigationParents.parentLRViewKey ? '"' + navigationParents.parentLRViewKey + '"' : ''; -%>
@@ -45,6 +45,8 @@ function journey() {
45
45
  QUnit.module("<%- name%>ObjectPage journey");
46
46
 
47
47
  opaTest("Navigate to <%- name%>ObjectPage", function (Given: Given, When: When, Then: Then) {
48
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
49
+ Given.iResetTestData();
48
50
  Given.iStartMyApp();
49
51
  <% if(navigationParents.parentLRName) { -%>
50
52
  <% const parentTableId = navigationParents.parentLRViewKey ? '"' + navigationParents.parentLRViewKey + '"' : '""'; -%>
@@ -47,6 +47,8 @@ type WithAnd<T> = {
47
47
  export type Given = Opa5 & BaseArrangements & {
48
48
  iTearDownMyApp: () => Given;
49
49
  iStartMyApp: (sAppHash?: string, mInUrlParameters?: object) => Given;
50
+ iResetMockData: (oAppInfo?: { AppId?: string; ServiceUri?: string }) => Given;
51
+ iResetTestData: () => Given;
50
52
  and: Given;
51
53
  };
52
54
 
@@ -25,6 +25,8 @@ sap.ui.define([
25
25
  QUnit.module("<%- name %> Journey");
26
26
 
27
27
  opaTest("Start application", function (Given, When, Then) {
28
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
29
+ Given.iResetTestData();
28
30
  Given.iStartMyApp();
29
31
  <%_ startPages.forEach(function(pageName) { %>
30
32
  Then.onThe<%- pageName %>Generated.iSeeThisPage();
@@ -23,6 +23,8 @@ function journey() {
23
23
  QUnit.module("<%- name %> Journey");
24
24
 
25
25
  opaTest("Start application", function (Given: Given, _When: When, Then: Then) {
26
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
27
+ Given.iResetTestData();
26
28
  Given.iStartMyApp();
27
29
  <%_ startPages.forEach(function(pageName) { %>
28
30
  Then.onThe<%- pageName %>Generated.iSeeThisPage();
@@ -8,6 +8,8 @@ sap.ui.define([
8
8
  QUnit.module("First journey");
9
9
 
10
10
  opaTest("Start application", function (Given, When, Then) {
11
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
12
+ Given.iResetTestData();
11
13
  Given.iStartMyApp();
12
14
  <% if (startLR) { %>Then.onThe<%- startLR %>.iSeeThisPage();<%} %>
13
15
  });
@@ -6,6 +6,8 @@ function journey() {
6
6
  QUnit.module("First journey");
7
7
 
8
8
  opaTest("Start application", function (Given: Given, _When: When<% if (startLR) { %>, Then: Then<% } else { %>, _Then: Then<% } %>) {
9
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
10
+ Given.iResetTestData();
9
11
  Given.iStartMyApp();
10
12
  <% if (startLR) { %>Then.onThe<%- startLR %>Generated.iSeeThisPage();<%} %>
11
13
  });
@@ -28,6 +28,8 @@ sap.ui.define([
28
28
  const defaultTableId = <%- tableIdentifiers && tableIdentifiers.length > 0 ? '"' + tableIdentifiers[0] + '"' : '""' %>;
29
29
 
30
30
  opaTest("Start application", function (Given, When, Then) {
31
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
32
+ Given.iResetTestData();
31
33
  Given.iStartMyApp();
32
34
  <%_ startPages.forEach(function(pageName) { %>
33
35
  Then.onThe<%- pageName %>Generated.iSeeThisPage();
@@ -35,6 +35,8 @@ function journey() {
35
35
  const defaultTableId = <%- tableIdentifiers && tableIdentifiers.length > 0 ? '"' + tableIdentifiers[0] + '"' : '""' %>;
36
36
 
37
37
  opaTest("Start application", function (Given: Given, _When: When, Then: Then) {
38
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
39
+ Given.iResetTestData();
38
40
  Given.iStartMyApp();
39
41
  <%_ startPages.forEach(function(pageName) { %>
40
42
  Then.onThe<%- pageName %>Generated.iSeeThisPage();
@@ -25,6 +25,8 @@ sap.ui.define([
25
25
  QUnit.module("<%- name%>ObjectPage journey");
26
26
 
27
27
  opaTest("Navigate to <%- name%>ObjectPage", function (Given, When, Then) {
28
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
29
+ Given.iResetTestData();
28
30
  Given.iStartMyApp();
29
31
  <% if(navigationParents.parentLRName) { -%>
30
32
  <% const parentTableId = navigationParents.parentLRViewKey ? '"' + navigationParents.parentLRViewKey + '"' : ''; -%>
@@ -44,6 +44,8 @@ function journey() {
44
44
  QUnit.module("<%- name%>ObjectPage journey");
45
45
 
46
46
  opaTest("Navigate to <%- name%>ObjectPage", function (Given: Given, When: When, Then: Then) {
47
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
48
+ Given.iResetTestData();
47
49
  Given.iStartMyApp();
48
50
  <% if(navigationParents.parentLRName) { -%>
49
51
  <% const parentTableId = navigationParents.parentLRViewKey ? '"' + navigationParents.parentLRViewKey + '"' : '""'; -%>
@@ -47,6 +47,8 @@ type WithAnd<T> = {
47
47
  export type Given = Opa5 & BaseArrangements & {
48
48
  iTearDownMyApp: () => Given;
49
49
  iStartMyApp: (sAppHash?: string, mInUrlParameters?: object) => Given;
50
+ iResetMockData: (oAppInfo?: { AppId?: string; ServiceUri?: string }) => Given;
51
+ iResetTestData: () => Given;
50
52
  and: Given;
51
53
  };
52
54
 
@@ -25,6 +25,8 @@ sap.ui.define([
25
25
  QUnit.module("<%- name %> Journey");
26
26
 
27
27
  opaTest("Start application", function (Given, When, Then) {
28
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
29
+ Given.iResetTestData();
28
30
  Given.iStartMyApp();
29
31
  <%_ startPages.forEach(function(pageName) { %>
30
32
  Then.onThe<%- pageName %>Generated.iSeeThisPage();
@@ -23,6 +23,8 @@ function journey() {
23
23
  QUnit.module("<%- name %> Journey");
24
24
 
25
25
  opaTest("Start application", function (Given: Given, _When: When, Then: Then) {
26
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
27
+ Given.iResetTestData();
26
28
  Given.iStartMyApp();
27
29
  <%_ startPages.forEach(function(pageName) { %>
28
30
  Then.onThe<%- pageName %>Generated.iSeeThisPage();
@@ -8,6 +8,8 @@ sap.ui.define([
8
8
  QUnit.module("First journey");
9
9
 
10
10
  opaTest("Start application", function (Given, When, Then) {
11
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
12
+ Given.iResetTestData();
11
13
  Given.iStartMyApp();
12
14
  <% if (startLR) { %>Then.onThe<%- startLR %>.iSeeThisPage();<%} %>
13
15
  });
@@ -6,6 +6,8 @@ function journey() {
6
6
  QUnit.module("First journey");
7
7
 
8
8
  opaTest("Start application", function (Given: Given, _When: When<% if (startLR) { %>, Then: Then<% } else { %>, _Then: Then<% } %>) {
9
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
10
+ Given.iResetTestData();
9
11
  Given.iStartMyApp();
10
12
  <% if (startLR) { %>Then.onThe<%- startLR %>Generated.iSeeThisPage();<%} %>
11
13
  });
@@ -28,6 +28,8 @@ sap.ui.define([
28
28
  const defaultTableId = <%- tableIdentifiers && tableIdentifiers.length > 0 ? '"' + tableIdentifiers[0] + '"' : '""' %>;
29
29
 
30
30
  opaTest("Start application", function (Given, When, Then) {
31
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
32
+ Given.iResetTestData();
31
33
  Given.iStartMyApp();
32
34
  <%_ startPages.forEach(function(pageName) { %>
33
35
  Then.onThe<%- pageName %>Generated.iSeeThisPage();
@@ -40,6 +40,8 @@ function journey() {
40
40
  const defaultTableId = <%- tableIdentifiers && tableIdentifiers.length > 0 ? '"' + tableIdentifiers[0] + '"' : '""' %>;
41
41
 
42
42
  opaTest("Start application", function (Given: Given, _When: When, Then: Then) {
43
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
44
+ Given.iResetTestData();
43
45
  Given.iStartMyApp();
44
46
  <%_ startPages.forEach(function(pageName) { %>
45
47
  Then.onThe<%- pageName %>Generated.iSeeThisPage();
@@ -25,6 +25,8 @@ sap.ui.define([
25
25
  QUnit.module("<%- name%>ObjectPage journey");
26
26
 
27
27
  opaTest("Navigate to <%- name%>ObjectPage", function (Given, When, Then) {
28
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
29
+ Given.iResetTestData();
28
30
  Given.iStartMyApp();
29
31
  <% if(navigationParents.parentLRName) { -%>
30
32
  <% const parentTableId = navigationParents.parentLRViewKey ? '"' + navigationParents.parentLRViewKey + '"' : ''; -%>
@@ -53,6 +53,8 @@ function journey() {
53
53
  QUnit.module("<%- name%>ObjectPage journey");
54
54
 
55
55
  opaTest("Navigate to <%- name%>ObjectPage", function (Given: Given, When: When, Then: Then) {
56
+ Given.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> });
57
+ Given.iResetTestData();
56
58
  Given.iStartMyApp();
57
59
  <% if(navigationParents.parentLRName) { -%>
58
60
  <% const parentTableId = navigationParents.parentLRViewKey ? '"' + navigationParents.parentLRViewKey + '"' : '""'; -%>
@@ -47,6 +47,8 @@ type WithAnd<T> = {
47
47
  export type Given = Opa5 & BaseArrangements & {
48
48
  iTearDownMyApp: () => Given;
49
49
  iStartMyApp: (sAppHash?: string, mInUrlParameters?: object) => Given;
50
+ iResetMockData: (oAppInfo?: { AppId?: string; ServiceUri?: string }) => Given;
51
+ iResetTestData: () => Given;
50
52
  and: Given;
51
53
  };
52
54