@sap-ux/ui5-test-writer 0.7.108 → 0.7.110

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.
@@ -12,6 +12,8 @@ const i18n_1 = require("./i18n");
12
12
  const project_access_1 = require("@sap-ux/project-access");
13
13
  const modelUtils_1 = require("./utils/modelUtils");
14
14
  const opaQUnitUtils_1 = require("./utils/opaQUnitUtils");
15
+ const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
16
+ const flpSandboxUtils_1 = require("./utils/flpSandboxUtils");
15
17
  /**
16
18
  * Generate OPA test files for a Fiori elements for OData V4 application.
17
19
  * Note: this can potentially overwrite existing files in the webapp/test folder.
@@ -54,11 +56,7 @@ async function generateOPAFiles(basePath, opaConfig, metadata, fs, log, standalo
54
56
  writeJourneyFiles(appFeatures, writeContext, true, true, virtualOPA5Configured);
55
57
  }
56
58
  else {
57
- editor.move((0, node_path_1.join)(testOutDirPath, 'integration', '**'), (0, node_path_1.join)(testOutDirPath, 'integration_old'));
58
- await (0, opaQUnitUtils_1.addIntegrationOldToGitignore)(basePath, editor);
59
- const htmlTarget = (0, opaQUnitUtils_1.readHtmlTargetFromQUnitJs)(testOutDirPath, editor) ?? config.htmlTarget;
60
- const standaloneConfig = { ...config, htmlTarget };
61
- const standaloneWriteContext = { ...writeContext, config: standaloneConfig };
59
+ const standaloneWriteContext = await resolveStandaloneWriteContext(basePath, testOutDirPath, writeContext, editor);
62
60
  if (!virtualOPA5Configured) {
63
61
  writeCommonAndPageFiles(standaloneWriteContext, rootCommonTemplateDirPath);
64
62
  }
@@ -71,6 +69,57 @@ async function generateOPAFiles(basePath, opaConfig, metadata, fs, log, standalo
71
69
  }
72
70
  return editor;
73
71
  }
72
+ /**
73
+ * Resolves the write context for standalone mode when no JourneyRunner.js exists yet.
74
+ * Moves any existing integration folder to integration_old, or adds the int-test script
75
+ * and resolves the htmlTarget from flpSandbox.html if present.
76
+ *
77
+ * @param basePath - the absolute target path of the application
78
+ * @param testOutDirPath - output test directory (.../webapp/test)
79
+ * @param writeContext - shared write context to base the resolved context on
80
+ * @param editor - a reference to a mem-fs editor
81
+ * @returns a new WriteContext with the resolved htmlTarget
82
+ */
83
+ async function resolveStandaloneWriteContext(basePath, testOutDirPath, writeContext, editor) {
84
+ const { config } = writeContext;
85
+ let htmlTarget = (0, opaQUnitUtils_1.readHtmlTargetFromQUnitJs)(testOutDirPath, editor) ?? config.htmlTarget;
86
+ if ((0, node_fs_1.existsSync)((0, node_path_1.join)(testOutDirPath, 'integration'))) {
87
+ editor.move((0, node_path_1.join)(testOutDirPath, 'integration', '**'), (0, node_path_1.join)(testOutDirPath, 'integration_old'));
88
+ await (0, opaQUnitUtils_1.addIntegrationOldToGitignore)(basePath, editor);
89
+ }
90
+ else {
91
+ const hasIntTestScript = checkScriptInPackageJson(editor, basePath, 'int-test');
92
+ if (!hasIntTestScript) {
93
+ const script = (0, fiori_generator_shared_1.getPackageScripts)({ localOnly: false, addTest: true })['int-test'];
94
+ if (script) {
95
+ await (0, project_access_1.updatePackageScript)(basePath, 'int-test', script, editor);
96
+ }
97
+ }
98
+ if ((0, node_fs_1.existsSync)((0, node_path_1.join)(testOutDirPath, 'flpSandbox.html'))) {
99
+ const hashFromFlpSandbox = (0, flpSandboxUtils_1.readHashFromFlpSandbox)((0, node_path_1.join)('test', 'flpSandbox.html'), await (0, project_access_1.getWebappPath)(basePath), editor);
100
+ if (hashFromFlpSandbox) {
101
+ htmlTarget = `test/flpSandbox.html#${hashFromFlpSandbox}`;
102
+ }
103
+ }
104
+ }
105
+ return { ...writeContext, config: { ...config, htmlTarget } };
106
+ }
107
+ /**
108
+ * Checks whether a script with the given name exists in the package.json.
109
+ *
110
+ * @param editor - a reference to a mem-fs editor
111
+ * @param basePath - the root folder of the app
112
+ * @param scriptName - the name of the script to check for
113
+ * @returns true if the script exists, false otherwise
114
+ */
115
+ function checkScriptInPackageJson(editor, basePath, scriptName) {
116
+ const packageJsonPath = (0, node_path_1.join)(basePath, project_access_1.FileName.Package);
117
+ if (!editor.exists(packageJsonPath)) {
118
+ return false;
119
+ }
120
+ const packageJson = editor.readJSON(packageJsonPath);
121
+ return !!packageJson.scripts?.[scriptName];
122
+ }
74
123
  /**
75
124
  * Reads the manifest for an app.
76
125
  *
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": "0.7.108",
4
+ "version": "0.7.110",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -29,7 +29,8 @@
29
29
  "@sap-ux/annotation-converter": "0.10.21",
30
30
  "@sap-ux/ui5-application-writer": "1.8.7",
31
31
  "@sap-ux/logger": "0.8.5",
32
- "@sap-ux/project-access": "1.36.1"
32
+ "@sap-ux/fiori-generator-shared": "0.13.104",
33
+ "@sap-ux/project-access": "1.36.2"
33
34
  },
34
35
  "devDependencies": {
35
36
  "@types/ejs": "3.1.5",
@@ -39,6 +39,7 @@ sap.ui.define([
39
39
  });
40
40
  <%_ } -%>
41
41
 
42
+ <%_ if ((toolBarActions && toolBarActions.length > 0 ) || (tableColumns && Object.keys(tableColumns).length > 0)) { -%>
42
43
  opaTest("Check table columns and actions", function (Given, When, Then) {
43
44
  <%_ if (toolBarActions && toolBarActions.length > 0) { -%>
44
45
  <%_ if (createButton.visible && !isALP) { _%>
@@ -57,9 +58,10 @@ sap.ui.define([
57
58
  <%_ }); -%>
58
59
  <%_ } -%>
59
60
  <%_ if (tableColumns && Object.keys(tableColumns).length > 0) { -%>
60
- Then.onThe<%- startLR %>.onTable().iCheckColumns(<%- Object.keys(tableColumns).length %>, <%- JSON.stringify(tableColumns) %>);
61
+ Then.onThe<%- startLR %>.onTable().iCheckColumns(undefined, <%- JSON.stringify(tableColumns) %>);
61
62
  <%_ } %>
62
63
  });
64
+ <%_ } %>
63
65
 
64
66
  <% if (startLR) { %>
65
67
  opaTest("Navigate to ObjectPage", function (Given, When, Then) {