@sapui5/sap.fe.test 1.104.1 → 1.105.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.
- package/package.json +3 -3
- package/src/sap/fe/test/.library +1 -1
- package/src/sap/fe/test/CollaborationClient.js +1 -1
- package/src/sap/fe/test/FeMocks.js +1 -3
- package/src/sap/fe/test/FeMocks.ts +0 -4
- package/src/sap/fe/test/JestTemplatingHelper.js +99 -9
- package/src/sap/fe/test/JestTemplatingHelper.ts +82 -4
- package/src/sap/fe/test/ListReport.js +21 -0
- package/src/sap/fe/test/ObjectPage.js +8 -0
- package/src/sap/fe/test/UI5MockHelper.js +373 -326
- package/src/sap/fe/test/UI5MockHelper.ts +395 -258
- package/src/sap/fe/test/api/CollaborationAPI.js +1 -1
- package/src/sap/fe/test/api/FormActions.js +9 -0
- package/src/sap/fe/test/api/HeaderAssertions.js +16 -7
- package/src/sap/fe/test/internal/ConsoleErrorChecker.js +1 -1
- package/src/sap/fe/test/library.js +2 -2
|
@@ -6,6 +6,7 @@ import type { RequiredOptions } from "prettier";
|
|
|
6
6
|
import { format } from "prettier";
|
|
7
7
|
import Log from "sap/base/Log";
|
|
8
8
|
import merge from "sap/base/util/merge";
|
|
9
|
+
import AppComponent from "sap/fe/core/AppComponent";
|
|
9
10
|
import { registerBuildingBlock } from "sap/fe/core/buildingBlocks/BuildingBlockRuntime";
|
|
10
11
|
import ConverterContext from "sap/fe/core/converters/ConverterContext";
|
|
11
12
|
import type { IssueCategory, IssueSeverity } from "sap/fe/core/converters/helpers/IssueManager";
|
|
@@ -16,12 +17,18 @@ import TemplateModel from "sap/fe/core/TemplateModel";
|
|
|
16
17
|
import type { DataModelObjectPath } from "sap/fe/core/templating/DataModelPathHelper";
|
|
17
18
|
import BindingParser from "sap/ui/base/BindingParser";
|
|
18
19
|
import ManagedObject from "sap/ui/base/ManagedObject";
|
|
20
|
+
import Component from "sap/ui/core/Component";
|
|
19
21
|
import Control from "sap/ui/core/Control";
|
|
20
22
|
import InvisibleText from "sap/ui/core/InvisibleText";
|
|
21
23
|
import Serializer from "sap/ui/core/util/serializer/Serializer";
|
|
22
24
|
import XMLPreprocessor from "sap/ui/core/util/XMLPreprocessor";
|
|
25
|
+
import FlexState from "sap/ui/fl/apply/_internal/flexState/FlexState";
|
|
26
|
+
import XmlPreprocessor from "sap/ui/fl/apply/_internal/preprocessors/XmlPreprocessor";
|
|
27
|
+
import AppStorage from "sap/ui/fl/initial/_internal/Storage";
|
|
28
|
+
import Utils from "sap/ui/fl/Utils";
|
|
23
29
|
import type Context from "sap/ui/model/Context";
|
|
24
30
|
import JSONModel from "sap/ui/model/json/JSONModel";
|
|
31
|
+
import MetaModel from "sap/ui/model/MetaModel";
|
|
25
32
|
import _MetadataRequestor from "sap/ui/model/odata/v4/lib/_MetadataRequestor";
|
|
26
33
|
import ODataMetaModel from "sap/ui/model/odata/v4/ODataMetaModel";
|
|
27
34
|
import xpath from "xpath";
|
|
@@ -288,11 +295,60 @@ export function evaluateBindingWithModel(
|
|
|
288
295
|
return text.getText();
|
|
289
296
|
}
|
|
290
297
|
|
|
298
|
+
const TESTVIEWID = "testViewId";
|
|
299
|
+
|
|
300
|
+
export const applyFlexChanges = async function (
|
|
301
|
+
aVariantDependentControlChanges: any[],
|
|
302
|
+
oMetaModel: MetaModel,
|
|
303
|
+
resultXML: any,
|
|
304
|
+
createChangesObject: Function
|
|
305
|
+
) {
|
|
306
|
+
const changes = createChangesObject(TESTVIEWID, aVariantDependentControlChanges);
|
|
307
|
+
const appId = "someComponent";
|
|
308
|
+
const oManifest = {
|
|
309
|
+
"sap.app": {
|
|
310
|
+
id: appId,
|
|
311
|
+
type: "application",
|
|
312
|
+
crossNavigation: {
|
|
313
|
+
outbounds: []
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
const oAppComponent: AppComponent = {
|
|
318
|
+
getDiagnostics: jest.fn().mockReturnValue(getFakeDiagnostics()),
|
|
319
|
+
getModel: jest.fn().mockReturnValue({
|
|
320
|
+
getMetaModel: jest.fn().mockReturnValue(oMetaModel)
|
|
321
|
+
}),
|
|
322
|
+
getComponentData: jest.fn().mockReturnValue({}),
|
|
323
|
+
getManifestObject: jest.fn().mockReturnValue({
|
|
324
|
+
getEntry: function (name: string) {
|
|
325
|
+
return (oManifest as any)[name];
|
|
326
|
+
}
|
|
327
|
+
})
|
|
328
|
+
} as unknown as AppComponent;
|
|
329
|
+
//fake changes
|
|
330
|
+
jest.spyOn(AppStorage, "loadFlexData").mockReturnValue(Promise.resolve(changes));
|
|
331
|
+
jest.spyOn(Component, "get").mockReturnValue(oAppComponent);
|
|
332
|
+
jest.spyOn(Utils, "getAppComponentForControl").mockReturnValue(oAppComponent);
|
|
333
|
+
await FlexState.initialize({
|
|
334
|
+
componentId: appId
|
|
335
|
+
});
|
|
336
|
+
resultXML = await XmlPreprocessor.process(resultXML, { name: "Test Fragment", componentId: appId, id: TESTVIEWID });
|
|
337
|
+
return resultXML;
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
export const getChangesFromXML = (xml: any) =>
|
|
341
|
+
[...xml.querySelectorAll("*")]
|
|
342
|
+
.flatMap((e) => [...e.attributes].map((a) => a.name))
|
|
343
|
+
.filter((attr) => attr.includes("sap.ui.fl.appliedChanges"));
|
|
344
|
+
|
|
291
345
|
export const getTemplatingResult = async function (
|
|
292
346
|
xmlInput: string,
|
|
293
347
|
sMetadataUrl: string,
|
|
294
348
|
mBindingContexts: { [x: string]: any; entitySet?: string },
|
|
295
|
-
mModels: { [x: string]: any }
|
|
349
|
+
mModels: { [x: string]: any },
|
|
350
|
+
aVariantDependentControlChanges?: any[],
|
|
351
|
+
createChangesObject?: Function
|
|
296
352
|
) {
|
|
297
353
|
const templatedXml = `<root>${xmlInput}</root>`;
|
|
298
354
|
const parser = new window.DOMParser();
|
|
@@ -335,16 +391,38 @@ export const getTemplatingResult = async function (
|
|
|
335
391
|
oPreprocessorSettings.bindingContexts["this"] = oPreprocessorSettings.models["this"].createBindingContext("/");
|
|
336
392
|
}
|
|
337
393
|
|
|
338
|
-
|
|
394
|
+
let resultXML = await XMLPreprocessor.process(xmlDoc.firstElementChild!, { name: "Test Fragment" }, oPreprocessorSettings);
|
|
395
|
+
|
|
396
|
+
if (aVariantDependentControlChanges && createChangesObject) {
|
|
397
|
+
// prefix Ids
|
|
398
|
+
[...resultXML.querySelectorAll("[id]")].forEach((node) => {
|
|
399
|
+
node.id = `${TESTVIEWID}--${node.id}`;
|
|
400
|
+
});
|
|
401
|
+
// apply flex changes
|
|
402
|
+
resultXML = await applyFlexChanges(aVariantDependentControlChanges, oMetaModel, resultXML, createChangesObject);
|
|
403
|
+
//Assert that all changes have been applied
|
|
404
|
+
const changesApplied = getChangesFromXML(resultXML);
|
|
405
|
+
expect(changesApplied.length).toBe(aVariantDependentControlChanges.length);
|
|
406
|
+
}
|
|
407
|
+
return resultXML;
|
|
339
408
|
};
|
|
340
409
|
|
|
341
410
|
export const getTemplatedXML = async function (
|
|
342
411
|
xmlInput: string,
|
|
343
412
|
sMetadataUrl: string,
|
|
344
413
|
mBindingContexts: { [x: string]: any; entitySet?: string },
|
|
345
|
-
mModels: { [x: string]: any }
|
|
414
|
+
mModels: { [x: string]: any },
|
|
415
|
+
aVariantDependentControlChanges?: any[],
|
|
416
|
+
createChangesObject?: Function
|
|
346
417
|
) {
|
|
347
|
-
const templatedXML = await getTemplatingResult(
|
|
418
|
+
const templatedXML = await getTemplatingResult(
|
|
419
|
+
xmlInput,
|
|
420
|
+
sMetadataUrl,
|
|
421
|
+
mBindingContexts,
|
|
422
|
+
mModels,
|
|
423
|
+
aVariantDependentControlChanges,
|
|
424
|
+
createChangesObject
|
|
425
|
+
);
|
|
348
426
|
return serializeXML(templatedXML);
|
|
349
427
|
};
|
|
350
428
|
|
|
@@ -179,6 +179,27 @@ sap.ui.define(
|
|
|
179
179
|
.description("Pressing dialog button '" + sText + "'")
|
|
180
180
|
.execute();
|
|
181
181
|
},
|
|
182
|
+
iCheckLinksCount: function (count) {
|
|
183
|
+
return OpaBuilder.create(this)
|
|
184
|
+
.hasType("sap.m.ColumnListItem")
|
|
185
|
+
.check(function (targets) {
|
|
186
|
+
if (targets.length === count) {
|
|
187
|
+
return true;
|
|
188
|
+
} else {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
}, true)
|
|
192
|
+
.description("Seeing QuickView Card with " + count + " target applications in ObjectPage")
|
|
193
|
+
.execute();
|
|
194
|
+
},
|
|
195
|
+
iClickQuickViewMoreLinksButton: function () {
|
|
196
|
+
return OpaBuilder.create(this)
|
|
197
|
+
.hasType("sap.m.Button")
|
|
198
|
+
.has(OpaBuilder.Matchers.resourceBundle("text", "sap.ui.mdc", "info.POPOVER_DEFINE_LINKS"))
|
|
199
|
+
.doPress()
|
|
200
|
+
.description("Pressing 'More Links' button")
|
|
201
|
+
.execute();
|
|
202
|
+
},
|
|
182
203
|
iClickLinkWithText: function (sText) {
|
|
183
204
|
return OpaBuilder.create(this)
|
|
184
205
|
.hasType("sap.m.Link")
|
|
@@ -293,6 +293,14 @@ sap.ui.define(
|
|
|
293
293
|
.description("Navigating via link '" + sText + "'")
|
|
294
294
|
.execute();
|
|
295
295
|
},
|
|
296
|
+
iClickObjectStatus: function (sText) {
|
|
297
|
+
return OpaBuilder.create(this)
|
|
298
|
+
.hasType("sap.m.ObjectStatus")
|
|
299
|
+
.hasProperties({ text: sText })
|
|
300
|
+
.doPress()
|
|
301
|
+
.description("Press Object Status '" + sText + "'")
|
|
302
|
+
.execute();
|
|
303
|
+
},
|
|
296
304
|
iCheckLinksCount: function (count) {
|
|
297
305
|
return OpaBuilder.create(this)
|
|
298
306
|
.hasType("sap.m.ColumnListItem")
|