@sap-ux/ui5-test-writer 0.9.14 → 1.0.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.
- package/dist/fiori-elements-opa-writer.js +52 -54
- package/dist/fiori-freestyle-opa-writer.d.ts +1 -1
- package/dist/fiori-freestyle-opa-writer.js +28 -29
- package/dist/i18n.js +9 -19
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -9
- package/dist/types.js +2 -6
- package/dist/utils/actionUtils.d.ts +4 -4
- package/dist/utils/actionUtils.js +20 -38
- package/dist/utils/flpSandboxUtils.js +3 -6
- package/dist/utils/listReportUtils.d.ts +5 -5
- package/dist/utils/listReportUtils.js +35 -55
- package/dist/utils/modelUtils.d.ts +3 -3
- package/dist/utils/modelUtils.js +21 -31
- package/dist/utils/objectPageUtils.d.ts +3 -3
- package/dist/utils/objectPageUtils.js +39 -43
- package/dist/utils/opaQUnitUtils.js +24 -34
- package/dist/utils/tableUtils.d.ts +2 -2
- package/dist/utils/tableUtils.js +7 -12
- package/package.json +11 -9
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const page_1 = require("@sap/ux-specification/dist/types/src/common/page");
|
|
8
|
-
const edmx_parser_1 = require("@sap-ux/edmx-parser");
|
|
9
|
-
const annotation_converter_1 = require("@sap-ux/annotation-converter");
|
|
10
|
-
const actionUtils_1 = require("./actionUtils");
|
|
1
|
+
import { getAggregations } from './modelUtils.js';
|
|
2
|
+
import { extractTableColumnsFromNode } from './tableUtils.js';
|
|
3
|
+
import { PageTypeV4 } from '@sap/ux-specification/dist/types/src/common/page.js';
|
|
4
|
+
import { parse } from '@sap-ux/edmx-parser';
|
|
5
|
+
import { convert } from '@sap-ux/annotation-converter';
|
|
6
|
+
import { buildActionStateFromSpecModelKey, safeCheckButtonVisibility, safeCheckEditVisibility } from './actionUtils.js';
|
|
11
7
|
/**
|
|
12
8
|
* Extracts feature data for object pages from the application model.
|
|
13
9
|
*
|
|
@@ -17,14 +13,14 @@ const actionUtils_1 = require("./actionUtils");
|
|
|
17
13
|
* @param metadata - optional metadata for the OPA test generation
|
|
18
14
|
* @returns a record of object page feature data
|
|
19
15
|
*/
|
|
20
|
-
async function getObjectPageFeatures(objectPages, listReportPageKey, log, metadata) {
|
|
16
|
+
export async function getObjectPageFeatures(objectPages, listReportPageKey, log, metadata) {
|
|
21
17
|
const objectPageFeatures = [];
|
|
22
18
|
if (!objectPages || objectPages.length === 0) {
|
|
23
19
|
log?.warn('Object Pages not found in application model. Dynamic tests will not be generated for Object Pages.');
|
|
24
20
|
return objectPageFeatures;
|
|
25
21
|
}
|
|
26
22
|
// attempt to get individual feature data for each object page
|
|
27
|
-
const convertedMetadata = metadata ?
|
|
23
|
+
const convertedMetadata = metadata ? convert(parse(metadata)) : undefined;
|
|
28
24
|
const schemaNamespace = convertedMetadata?.namespace ?? '';
|
|
29
25
|
for (const objectPage of objectPages) {
|
|
30
26
|
const pageFeatureData = {};
|
|
@@ -40,7 +36,7 @@ async function getObjectPageFeatures(objectPages, listReportPageKey, log, metada
|
|
|
40
36
|
: [];
|
|
41
37
|
// determine edit button visibility from UpdateRestrictions on the OP entity set
|
|
42
38
|
if (metadata && objectPage.entitySet) {
|
|
43
|
-
pageFeatureData.editButton =
|
|
39
|
+
pageFeatureData.editButton = safeCheckEditVisibility(metadata, objectPage.entitySet, log);
|
|
44
40
|
}
|
|
45
41
|
objectPageFeatures.push(pageFeatureData);
|
|
46
42
|
}
|
|
@@ -52,11 +48,11 @@ async function getObjectPageFeatures(objectPages, listReportPageKey, log, metada
|
|
|
52
48
|
* @param applicationModel - The application model containing page definitions.
|
|
53
49
|
* @returns An array of Object Page definitions.
|
|
54
50
|
*/
|
|
55
|
-
function getObjectPages(applicationModel) {
|
|
51
|
+
export function getObjectPages(applicationModel) {
|
|
56
52
|
const objectPages = [];
|
|
57
53
|
for (const pageKey in applicationModel.pages) {
|
|
58
54
|
const page = applicationModel.pages[pageKey];
|
|
59
|
-
if (page.pageType ===
|
|
55
|
+
if (page.pageType === PageTypeV4.ObjectPage) {
|
|
60
56
|
page.name = pageKey; // store page key as name for later identification
|
|
61
57
|
objectPages.push(page);
|
|
62
58
|
}
|
|
@@ -94,9 +90,9 @@ function getObjectPageNavigationParents(targetObjectPageKey, objectPages, listRe
|
|
|
94
90
|
function extractObjectPageHeaderSectionsData(objectPage) {
|
|
95
91
|
const headerSections = [];
|
|
96
92
|
if (objectPage.model) {
|
|
97
|
-
const headerAggregation =
|
|
98
|
-
const sectionsAggregation =
|
|
99
|
-
const sections =
|
|
93
|
+
const headerAggregation = getAggregations(objectPage.model.root)['header'];
|
|
94
|
+
const sectionsAggregation = getAggregations(headerAggregation)['sections'];
|
|
95
|
+
const sections = getAggregations(sectionsAggregation);
|
|
100
96
|
Object.values(sections).forEach((section) => {
|
|
101
97
|
const facetId = getSectionIdentifier(section);
|
|
102
98
|
if (!facetId) {
|
|
@@ -133,8 +129,8 @@ function extractObjectPageHeaderSectionsData(objectPage) {
|
|
|
133
129
|
function extractObjectPageBodySectionsData(objectPage, convertedMetadata, schemaNamespace, metadata, log) {
|
|
134
130
|
const bodySections = [];
|
|
135
131
|
if (objectPage.model) {
|
|
136
|
-
const sectionsAggregation =
|
|
137
|
-
const sections =
|
|
132
|
+
const sectionsAggregation = getAggregations(objectPage.model.root)['sections'];
|
|
133
|
+
const sections = getAggregations(sectionsAggregation);
|
|
138
134
|
Object.entries(sections).forEach(([sectionKey, section]) => {
|
|
139
135
|
const sectionId = getSectionIdentifier(section) ?? sectionKey;
|
|
140
136
|
const subSections = extractBodySubSectionsData(section, sectionId);
|
|
@@ -146,7 +142,7 @@ function extractObjectPageBodySectionsData(objectPage, convertedMetadata, schema
|
|
|
146
142
|
custom: !!section.custom,
|
|
147
143
|
order: section?.order ?? -1,
|
|
148
144
|
fields: section.custom || section.isTable ? [] : extractFormFields(section),
|
|
149
|
-
tableColumns: section.custom || !section.isTable ? {} :
|
|
145
|
+
tableColumns: section.custom || !section.isTable ? {} : extractTableColumnsFromNode(section),
|
|
150
146
|
subSections,
|
|
151
147
|
actions: !section.custom && convertedMetadata && schemaNamespace
|
|
152
148
|
? extractSectionActions(section, convertedMetadata, schemaNamespace)
|
|
@@ -156,7 +152,7 @@ function extractObjectPageBodySectionsData(objectPage, convertedMetadata, schema
|
|
|
156
152
|
if (section.isTable && navigationProperty && metadata && convertedMetadata) {
|
|
157
153
|
const targetEntitySet = resolveNavigationTargetEntitySet(convertedMetadata, objectPage.entitySet, navigationProperty);
|
|
158
154
|
if (targetEntitySet) {
|
|
159
|
-
const buttonVisibility =
|
|
155
|
+
const buttonVisibility = safeCheckButtonVisibility(metadata, targetEntitySet, log);
|
|
160
156
|
sectionData.createButton = buttonVisibility?.create;
|
|
161
157
|
sectionData.deleteButton = buttonVisibility?.delete;
|
|
162
158
|
}
|
|
@@ -178,11 +174,11 @@ function extractHeaderActions(objectPage, convertedMetadata, schemaNamespace) {
|
|
|
178
174
|
if (!objectPage.model) {
|
|
179
175
|
return [];
|
|
180
176
|
}
|
|
181
|
-
const headerAgg =
|
|
182
|
-
const actionsAgg =
|
|
183
|
-
const actionEntries =
|
|
177
|
+
const headerAgg = getAggregations(objectPage.model.root)['header'];
|
|
178
|
+
const actionsAgg = getAggregations(headerAgg)['actions'];
|
|
179
|
+
const actionEntries = getAggregations(actionsAgg);
|
|
184
180
|
return Object.entries(actionEntries)
|
|
185
|
-
.map(([key, item]) =>
|
|
181
|
+
.map(([key, item]) => buildActionStateFromSpecModelKey(key, item.description, convertedMetadata, schemaNamespace))
|
|
186
182
|
.filter((actionState) => actionState !== undefined);
|
|
187
183
|
}
|
|
188
184
|
/**
|
|
@@ -197,20 +193,20 @@ function extractHeaderActions(objectPage, convertedMetadata, schemaNamespace) {
|
|
|
197
193
|
function extractSectionActions(section, convertedMetadata, schemaNamespace) {
|
|
198
194
|
let actionsAgg;
|
|
199
195
|
if (section.isTable) {
|
|
200
|
-
const tableAgg =
|
|
201
|
-
const toolBarAgg =
|
|
202
|
-
actionsAgg =
|
|
196
|
+
const tableAgg = getAggregations(section)['table'];
|
|
197
|
+
const toolBarAgg = getAggregations(tableAgg)['toolBar'];
|
|
198
|
+
actionsAgg = getAggregations(toolBarAgg)['actions'];
|
|
203
199
|
}
|
|
204
200
|
else {
|
|
205
|
-
const formAgg =
|
|
206
|
-
actionsAgg =
|
|
201
|
+
const formAgg = getAggregations(section)['form'];
|
|
202
|
+
actionsAgg = getAggregations(formAgg)['actions'];
|
|
207
203
|
}
|
|
208
204
|
if (!actionsAgg) {
|
|
209
205
|
return [];
|
|
210
206
|
}
|
|
211
|
-
const actionEntries =
|
|
207
|
+
const actionEntries = getAggregations(actionsAgg);
|
|
212
208
|
return Object.entries(actionEntries)
|
|
213
|
-
.map(([key, item]) =>
|
|
209
|
+
.map(([key, item]) => buildActionStateFromSpecModelKey(key, item.description, convertedMetadata, schemaNamespace))
|
|
214
210
|
.filter((actionState) => actionState !== undefined);
|
|
215
211
|
}
|
|
216
212
|
/**
|
|
@@ -222,8 +218,8 @@ function extractSectionActions(section, convertedMetadata, schemaNamespace) {
|
|
|
222
218
|
*/
|
|
223
219
|
function extractBodySubSectionsData(section, parentSectionId) {
|
|
224
220
|
const subSections = [];
|
|
225
|
-
const subSectionsAggregation =
|
|
226
|
-
const subSectionItems =
|
|
221
|
+
const subSectionsAggregation = getAggregations(section)['subSections'];
|
|
222
|
+
const subSectionItems = getAggregations(subSectionsAggregation);
|
|
227
223
|
Object.entries(subSectionItems).forEach(([subSectionKey, subSection]) => {
|
|
228
224
|
const subSectionId = getSectionIdentifier(subSection) ?? `${parentSectionId}_${subSectionKey}`;
|
|
229
225
|
subSections.push({
|
|
@@ -233,7 +229,7 @@ function extractBodySubSectionsData(section, parentSectionId) {
|
|
|
233
229
|
custom: !!subSection.custom,
|
|
234
230
|
order: subSection?.order ?? -1, // put a negative order number to signal that order was not in spec
|
|
235
231
|
fields: subSection.custom || subSection.isTable ? [] : extractFormFields(subSection),
|
|
236
|
-
tableColumns: subSection.custom || !subSection.isTable ? {} :
|
|
232
|
+
tableColumns: subSection.custom || !subSection.isTable ? {} : extractTableColumnsFromNode(subSection)
|
|
237
233
|
});
|
|
238
234
|
});
|
|
239
235
|
return subSections;
|
|
@@ -246,12 +242,12 @@ function extractBodySubSectionsData(section, parentSectionId) {
|
|
|
246
242
|
*/
|
|
247
243
|
function extractFormFields(subSection) {
|
|
248
244
|
const fields = [];
|
|
249
|
-
const formAggregation =
|
|
245
|
+
const formAggregation = getAggregations(subSection)['form'];
|
|
250
246
|
if (!formAggregation) {
|
|
251
247
|
return fields;
|
|
252
248
|
}
|
|
253
|
-
const fieldsAggregation =
|
|
254
|
-
const fieldItems =
|
|
249
|
+
const fieldsAggregation = getAggregations(formAggregation)['fields'];
|
|
250
|
+
const fieldItems = getAggregations(fieldsAggregation);
|
|
255
251
|
Object.values(fieldItems).forEach((field) => {
|
|
256
252
|
const property = field.schema?.keys?.find((key) => key.name === 'Value')?.value;
|
|
257
253
|
if (property) {
|
|
@@ -339,9 +335,9 @@ function getSectionStashedFlag(headerSection) {
|
|
|
339
335
|
*/
|
|
340
336
|
function getHeaderSectionFormFields(section) {
|
|
341
337
|
const formFields = [];
|
|
342
|
-
const formAggregation =
|
|
343
|
-
const fieldsAggregation =
|
|
344
|
-
const fields =
|
|
338
|
+
const formAggregation = getAggregations(section)?.form;
|
|
339
|
+
const fieldsAggregation = getAggregations(formAggregation)?.fields;
|
|
340
|
+
const fields = getAggregations(fieldsAggregation);
|
|
345
341
|
if (fields) {
|
|
346
342
|
Object.keys(fields).forEach((fieldKey) => {
|
|
347
343
|
const field = fields[fieldKey];
|
|
@@ -403,7 +399,7 @@ function isSectionMicroChart(section) {
|
|
|
403
399
|
* @returns true if the section seems to contain a form, false otherwise
|
|
404
400
|
*/
|
|
405
401
|
function isFormSection(section) {
|
|
406
|
-
return
|
|
402
|
+
return getAggregations(section)?.form !== undefined;
|
|
407
403
|
}
|
|
408
404
|
/**
|
|
409
405
|
* Retrieves navigation targets from the given page model.
|
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Utility for reading and updating a generated opaTests.qunit.js file.
|
|
4
3
|
* The file is modified in-place: only the sap.ui.require array is changed;
|
|
5
4
|
* all other content (formatting, comments, whitespace) is preserved exactly.
|
|
6
5
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.addIntegrationOldToGitignore = addIntegrationOldToGitignore;
|
|
11
|
-
exports.addPathsToQUnitJs = addPathsToQUnitJs;
|
|
12
|
-
exports.splicePageIntoJourneyRunner = splicePageIntoJourneyRunner;
|
|
13
|
-
exports.addPagesToJourneyRunner = addPagesToJourneyRunner;
|
|
14
|
-
exports.hasVirtualOPA5 = hasVirtualOPA5;
|
|
15
|
-
exports.addVirtualTestConfig = addVirtualTestConfig;
|
|
16
|
-
const node_path_1 = require("node:path");
|
|
17
|
-
const flpSandboxUtils_1 = require("./flpSandboxUtils");
|
|
18
|
-
const project_access_1 = require("@sap-ux/project-access");
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
import { readHashFromFlpSandbox } from './flpSandboxUtils.js';
|
|
8
|
+
import { getAllUi5YamlFileNames, readUi5Yaml, FileName } from '@sap-ux/project-access';
|
|
19
9
|
/** Relative path from the test output directory to opaTests.qunit.js */
|
|
20
|
-
const OPA_QUNIT_FILE =
|
|
10
|
+
const OPA_QUNIT_FILE = join('integration', 'opaTests.qunit.js');
|
|
21
11
|
/**
|
|
22
12
|
* The regex matches the opening bracket of the sap.ui.require array and
|
|
23
13
|
* captures everything up to (but not including) the closing bracket followed
|
|
@@ -46,7 +36,7 @@ const MAX_FILE_CONTENT_LENGTH = 10000;
|
|
|
46
36
|
* @param moduleNames - module paths to add (e.g. ["myApp/test/integration/SomeJourney"])
|
|
47
37
|
* @returns the updated file content, or the original content unchanged if nothing was added
|
|
48
38
|
*/
|
|
49
|
-
function spliceModulesIntoQUnitContent(fileContent, moduleNames) {
|
|
39
|
+
export function spliceModulesIntoQUnitContent(fileContent, moduleNames) {
|
|
50
40
|
if (fileContent.length > MAX_FILE_CONTENT_LENGTH) {
|
|
51
41
|
return fileContent;
|
|
52
42
|
}
|
|
@@ -100,12 +90,12 @@ const LAUNCH_URL_REGEX = /\.toUrl\s*\([^)]+\)\s*\+\s*'([^']+)'/;
|
|
|
100
90
|
* @param fs - mem-fs-editor instance used to read the file
|
|
101
91
|
* @returns the html target string, or undefined if not found
|
|
102
92
|
*/
|
|
103
|
-
function readHtmlTargetFromQUnitJs(testPath, fs) {
|
|
93
|
+
export function readHtmlTargetFromQUnitJs(testPath, fs) {
|
|
104
94
|
try {
|
|
105
|
-
const integrationOldDir =
|
|
106
|
-
let filePath =
|
|
95
|
+
const integrationOldDir = join(testPath, 'integration_old');
|
|
96
|
+
let filePath = join(integrationOldDir, 'opaTests.qunit.js');
|
|
107
97
|
if (!fs.exists(filePath)) {
|
|
108
|
-
filePath =
|
|
98
|
+
filePath = join(integrationOldDir, 'Opa.qunit.js');
|
|
109
99
|
}
|
|
110
100
|
const content = fs.read(filePath);
|
|
111
101
|
const match = LAUNCH_URL_REGEX.exec(content);
|
|
@@ -120,7 +110,7 @@ function readHtmlTargetFromQUnitJs(testPath, fs) {
|
|
|
120
110
|
// No hash fragment — read the referenced HTML file to extract the
|
|
121
111
|
// application key from the sap-ushell-config applications object
|
|
122
112
|
const htmlPath = launchUrl.split('?')[0];
|
|
123
|
-
const hash =
|
|
113
|
+
const hash = readHashFromFlpSandbox(htmlPath, join(testPath, '..'), fs);
|
|
124
114
|
return hash ? `${launchUrl}#${hash}` : launchUrl;
|
|
125
115
|
}
|
|
126
116
|
catch {
|
|
@@ -136,8 +126,8 @@ const INTEGRATION_OLD_GITIGNORE_ENTRY = '/webapp/test/integration_old';
|
|
|
136
126
|
* @param basePath - project root (contains .gitignore)
|
|
137
127
|
* @param fs - mem-fs-editor instance used to read and write the file
|
|
138
128
|
*/
|
|
139
|
-
async function addIntegrationOldToGitignore(basePath, fs) {
|
|
140
|
-
const filePath =
|
|
129
|
+
export async function addIntegrationOldToGitignore(basePath, fs) {
|
|
130
|
+
const filePath = join(basePath, '.gitignore');
|
|
141
131
|
const existing = fs.exists(filePath) ? fs.read(filePath) : '';
|
|
142
132
|
const lines = existing.split('\n');
|
|
143
133
|
if (lines.some((line) => line.trim() === INTEGRATION_OLD_GITIGNORE_ENTRY)) {
|
|
@@ -158,9 +148,9 @@ async function addIntegrationOldToGitignore(basePath, fs) {
|
|
|
158
148
|
* @param projectPath - path to the test output directory (`.../webapp/test`)
|
|
159
149
|
* @param fs - mem-fs-editor instance used to read and write the file
|
|
160
150
|
*/
|
|
161
|
-
function addPathsToQUnitJs(filePaths, projectPath, fs) {
|
|
151
|
+
export function addPathsToQUnitJs(filePaths, projectPath, fs) {
|
|
162
152
|
try {
|
|
163
|
-
const filePath =
|
|
153
|
+
const filePath = join(projectPath, OPA_QUNIT_FILE);
|
|
164
154
|
const content = fs.read(filePath);
|
|
165
155
|
const updated = spliceModulesIntoQUnitContent(content, filePaths);
|
|
166
156
|
if (updated !== content) {
|
|
@@ -172,7 +162,7 @@ function addPathsToQUnitJs(filePaths, projectPath, fs) {
|
|
|
172
162
|
}
|
|
173
163
|
}
|
|
174
164
|
/** Relative path from the test output directory to JourneyRunner.js */
|
|
175
|
-
const JOURNEY_RUNNER_FILE =
|
|
165
|
+
const JOURNEY_RUNNER_FILE = join('integration', 'pages', 'JourneyRunner.js');
|
|
176
166
|
/**
|
|
177
167
|
* Splices new page entries into the three locations of an existing JourneyRunner.js:
|
|
178
168
|
* - the sap.ui.define dependency array
|
|
@@ -189,7 +179,7 @@ const JOURNEY_RUNNER_FILE = (0, node_path_1.join)('integration', 'pages', 'Journ
|
|
|
189
179
|
* @param pages - pages to add
|
|
190
180
|
* @returns the updated file content, or the original content unchanged if nothing was added
|
|
191
181
|
*/
|
|
192
|
-
function splicePageIntoJourneyRunner(fileContent, pages) {
|
|
182
|
+
export function splicePageIntoJourneyRunner(fileContent, pages) {
|
|
193
183
|
if (fileContent.length > MAX_FILE_CONTENT_LENGTH) {
|
|
194
184
|
return fileContent;
|
|
195
185
|
}
|
|
@@ -264,9 +254,9 @@ function splicePageIntoJourneyRunner(fileContent, pages) {
|
|
|
264
254
|
* @param testOutDirPath - path to the test output directory (`.../webapp/test`)
|
|
265
255
|
* @param fs - mem-fs-editor instance used to read and write the file
|
|
266
256
|
*/
|
|
267
|
-
function addPagesToJourneyRunner(pages, testOutDirPath, fs) {
|
|
257
|
+
export function addPagesToJourneyRunner(pages, testOutDirPath, fs) {
|
|
268
258
|
try {
|
|
269
|
-
const filePath =
|
|
259
|
+
const filePath = join(testOutDirPath, JOURNEY_RUNNER_FILE);
|
|
270
260
|
const content = fs.read(filePath);
|
|
271
261
|
const updated = splicePageIntoJourneyRunner(content, pages);
|
|
272
262
|
if (updated !== content) {
|
|
@@ -284,11 +274,11 @@ function addPagesToJourneyRunner(pages, testOutDirPath, fs) {
|
|
|
284
274
|
* @param basePath - project root directory
|
|
285
275
|
* @returns true when OPA5 is configured in a preview middleware, false otherwise
|
|
286
276
|
*/
|
|
287
|
-
async function hasVirtualOPA5(basePath) {
|
|
288
|
-
const yamlFileNames = await
|
|
277
|
+
export async function hasVirtualOPA5(basePath) {
|
|
278
|
+
const yamlFileNames = await getAllUi5YamlFileNames(basePath);
|
|
289
279
|
for (const fileName of yamlFileNames) {
|
|
290
280
|
try {
|
|
291
|
-
const ui5Config = await
|
|
281
|
+
const ui5Config = await readUi5Yaml(basePath, fileName);
|
|
292
282
|
const previewMiddleware = ui5Config.findCustomMiddleware('fiori-tools-preview');
|
|
293
283
|
const testEntries = previewMiddleware?.configuration?.test;
|
|
294
284
|
if (testEntries?.some((entry) => entry.framework === 'OPA5')) {
|
|
@@ -309,12 +299,12 @@ async function hasVirtualOPA5(basePath) {
|
|
|
309
299
|
* @param testFrameworks - the test framework entries to add to ui5-mock.yaml
|
|
310
300
|
* @param fs - the memfs editor instance
|
|
311
301
|
*/
|
|
312
|
-
async function addVirtualTestConfig(basePath, testFrameworks, fs) {
|
|
313
|
-
const yamlPath =
|
|
302
|
+
export async function addVirtualTestConfig(basePath, testFrameworks, fs) {
|
|
303
|
+
const yamlPath = join(basePath, FileName.Ui5MockYaml);
|
|
314
304
|
if (!fs.exists(yamlPath)) {
|
|
315
305
|
return;
|
|
316
306
|
}
|
|
317
|
-
const yamlConfig = await
|
|
307
|
+
const yamlConfig = await readUi5Yaml(basePath, FileName.Ui5MockYaml, fs);
|
|
318
308
|
const previewMiddleware = yamlConfig.findCustomMiddleware('fiori-tools-preview');
|
|
319
309
|
if (previewMiddleware?.configuration && !previewMiddleware.configuration.test?.length) {
|
|
320
310
|
previewMiddleware.configuration.test = [...testFrameworks];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { TreeAggregation, TreeAggregations } from '@sap/ux-specification/dist/types/src/parser';
|
|
2
|
-
import type { TableColumnFeatureData } from '../types';
|
|
1
|
+
import type { TreeAggregation, TreeAggregations } from '@sap/ux-specification/dist/types/src/parser/index.js';
|
|
2
|
+
import type { TableColumnFeatureData } from '../types.js';
|
|
3
3
|
type ColumnModelItem = {
|
|
4
4
|
custom?: boolean;
|
|
5
5
|
description?: string;
|
package/dist/utils/tableUtils.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getColumnIdentifier = getColumnIdentifier;
|
|
4
|
-
exports.transformTableColumns = transformTableColumns;
|
|
5
|
-
exports.extractTableColumnsFromNode = extractTableColumnsFromNode;
|
|
6
|
-
const modelUtils_1 = require("./modelUtils");
|
|
1
|
+
import { getAggregations } from './modelUtils.js';
|
|
7
2
|
/**
|
|
8
3
|
* Gets the identifier of a column for OPA5 tests.
|
|
9
4
|
* Custom columns use the 'Key' entry; standard columns use the 'Value' entry from the schema keys.
|
|
@@ -11,7 +6,7 @@ const modelUtils_1 = require("./modelUtils");
|
|
|
11
6
|
* @param column - column item from ux specification
|
|
12
7
|
* @returns identifier of the column for OPA5 tests; undefined if no matching key entry is found
|
|
13
8
|
*/
|
|
14
|
-
function getColumnIdentifier(column) {
|
|
9
|
+
export function getColumnIdentifier(column) {
|
|
15
10
|
const key = column.custom ? 'Key' : 'Value';
|
|
16
11
|
return column.schema.keys.find((k) => k.name === key)?.value;
|
|
17
12
|
}
|
|
@@ -22,7 +17,7 @@ function getColumnIdentifier(column) {
|
|
|
22
17
|
* @param columnAggregations - column aggregations from the ux specification model
|
|
23
18
|
* @returns a map of column identifiers to column state objects for use with iCheckColumns()
|
|
24
19
|
*/
|
|
25
|
-
function transformTableColumns(columnAggregations) {
|
|
20
|
+
export function transformTableColumns(columnAggregations) {
|
|
26
21
|
const columns = {};
|
|
27
22
|
Object.values(columnAggregations).forEach((column, index) => {
|
|
28
23
|
const id = getColumnIdentifier(column) ?? String(index);
|
|
@@ -42,16 +37,16 @@ function transformTableColumns(columnAggregations) {
|
|
|
42
37
|
* @param node - tree aggregation node that exposes a 'table' aggregation
|
|
43
38
|
* @returns a map of column identifiers to column state objects for use with iCheckColumns()
|
|
44
39
|
*/
|
|
45
|
-
function extractTableColumnsFromNode(node) {
|
|
46
|
-
const tableAggregation =
|
|
40
|
+
export function extractTableColumnsFromNode(node) {
|
|
41
|
+
const tableAggregation = getAggregations(node)['table'];
|
|
47
42
|
if (!tableAggregation) {
|
|
48
43
|
return {};
|
|
49
44
|
}
|
|
50
|
-
const columnsAggregation =
|
|
45
|
+
const columnsAggregation = getAggregations(tableAggregation)['columns'];
|
|
51
46
|
if (!columnsAggregation) {
|
|
52
47
|
return {};
|
|
53
48
|
}
|
|
54
|
-
const columnItems =
|
|
49
|
+
const columnItems = getAggregations(columnsAggregation);
|
|
55
50
|
return transformTableColumns(columnItems);
|
|
56
51
|
}
|
|
57
52
|
//# sourceMappingURL=tableUtils.js.map
|
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.
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"bugs": {
|
|
11
11
|
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aui5-test-writer"
|
|
12
12
|
},
|
|
13
|
+
"type": "module",
|
|
13
14
|
"license": "Apache-2.0",
|
|
14
15
|
"main": "dist/index.js",
|
|
15
16
|
"files": [
|
|
@@ -27,13 +28,14 @@
|
|
|
27
28
|
"@sap/ux-specification": "1.144.0",
|
|
28
29
|
"@sap-ux/edmx-parser": "0.10.0",
|
|
29
30
|
"@sap-ux/annotation-converter": "0.10.21",
|
|
30
|
-
"@sap-ux/ui5-application-writer": "
|
|
31
|
-
"@sap-ux/
|
|
32
|
-
"@sap-ux/
|
|
33
|
-
"@sap-ux/
|
|
34
|
-
"@sap-ux/
|
|
31
|
+
"@sap-ux/ui5-application-writer": "2.0.0",
|
|
32
|
+
"@sap-ux/logger": "1.0.0",
|
|
33
|
+
"@sap-ux/fiori-generator-shared": "1.0.0",
|
|
34
|
+
"@sap-ux/project-access": "2.0.0",
|
|
35
|
+
"@sap-ux/preview-middleware": "1.0.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
38
|
+
"@jest/globals": "30.3.0",
|
|
37
39
|
"@types/ejs": "3.1.5",
|
|
38
40
|
"@types/fs-extra": "11.0.4",
|
|
39
41
|
"@types/mem-fs": "1.1.2",
|
|
@@ -41,7 +43,7 @@
|
|
|
41
43
|
"rimraf": "6.1.3",
|
|
42
44
|
"fs-extra": "11.3.4",
|
|
43
45
|
"@sap-ux/vocabularies-types": "0.15.0",
|
|
44
|
-
"@sap-ux/jest-file-matchers": "0.
|
|
46
|
+
"@sap-ux/jest-file-matchers": "1.0.0"
|
|
45
47
|
},
|
|
46
48
|
"engines": {
|
|
47
49
|
"node": ">=22.x"
|
|
@@ -53,8 +55,8 @@
|
|
|
53
55
|
"format": "prettier --write '**/*.{js,json,ts,yaml,yml}' --ignore-path ../../.prettierignore",
|
|
54
56
|
"lint": "eslint",
|
|
55
57
|
"lint:fix": "eslint --fix",
|
|
56
|
-
"test": "jest --ci --forceExit --detectOpenHandles --colors",
|
|
57
|
-
"test-u": "jest --ci --forceExit --detectOpenHandles --colors -u",
|
|
58
|
+
"test": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors",
|
|
59
|
+
"test-u": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors -u",
|
|
58
60
|
"link": "pnpm link --global",
|
|
59
61
|
"unlink": "pnpm unlink --global"
|
|
60
62
|
}
|