Skip to content

Commit

Permalink
test: Add fixtures for XML Templating checks
Browse files Browse the repository at this point in the history
  • Loading branch information
matz3 committed Jan 14, 2025
1 parent 16e3f94 commit 8eb3ce4
Show file tree
Hide file tree
Showing 10 changed files with 204 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sap.ui.define(["./BaseController"], function (BaseController) {
"use strict";

const TemplatingMainController = BaseController.extend("com.ui5.troublesome.app.controller.TemplatingMain", {
});
return TemplatingMainController;
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<mvc:View
controllerName="com.ui5.troublesome.app.controller.TemplatingMain"
xmlns="sap.m"
xmlns:core="sap.ui.core"
xmlns:layout="sap.ui.layout"
xmlns:mvc="sap.ui.core.mvc"
xmlns:template="http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1">
<layout:VerticalLayout class="sapUiSmallMarginBottom">
<template:alias name=".formatParts" value="com.ui5.troublesome.app.helpers.Helper.formatParts">
<template:alias name=".id" value="com.ui5.troublesome.app.helpers.Helper.id">
<template:with path="meta>/" var="fieldGroup">
<template:with path="meta>entityType" helper="sap.ui.model.odata.AnnotationHelper.gotoEntityType" var="entityType">
<template:if test="{entityType>com.sap.vocabularies.UI.v1.LineItem}">
<Table headerText="Items" includeItemInSelection="true" mode="SingleSelectMaster"
selectionChange="onSelectionChange" items="{:= '{path:\'/' + ${meta>name} + '\', length: 5}' }">
<template:with path="entityType>com.sap.vocabularies.UI.v1.LineItem" var="target">
<core:Fragment fragmentName="com.ui5.troublesome.app.view.TemplatingTable" type="XML"/>
</template:with>
</Table>
</template:if>
</template:with>
</template:with>
</template:alias>
</template:alias>
</layout:VerticalLayout>
</mvc:View>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<core:FragmentDefinition
xmlns="sap.m"
xmlns:core="sap.ui.core"
xmlns:template="http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1">
<columns>
<template:repeat list="{target>}" var="field">
<template:if test="{field>Value}">
<Column>
<Text text="{path: 'field>Label', formatter: 'sap.ui.model.odata.AnnotationHelper.format'}"/>
</Column>
</template:if>
<template:if test="{field>Action}">
<Column demandPopin="true" minScreenWidth="1800px" popinDisplay="WithoutHeader">
<Text text="{path: 'field>Label', formatter: 'sap.ui.model.odata.AnnotationHelper.format'}"/>
</Column>
</template:if>
</template:repeat>
</columns>
<ColumnListItem>
<template:repeat list="{target>}" var="field">
<template:if test="{field>Value}">
<template:if test="{field>Target}">
<template:then>
<template:with path="field>Target" helper="sap.ui.model.odata.AnnotationHelper.resolvePath" var="entityType">
<Link text="{path: 'field>Value', formatter: 'sap.ui.model.odata.AnnotationHelper.format'}" press="onDetailsPressed">
<dependents>
<template:with path="entityType>com.sap.vocabularies.UI.v1.HeaderInfo" var="headerInfo">
<Popover binding="{path: 'field>Target', formatter: 'sap.ui.model.odata.AnnotationHelper.getNavigationPath'}"
title="{path: 'headerInfo>Title/Value', formatter: 'sap.ui.model.odata.AnnotationHelper.format'}">
</Popover>
</template:with>
</dependents>
</Link>
</template:with>
</template:then>
<template:else>
<Text text="{path: 'field>Value', formatter: 'sap.ui.model.odata.AnnotationHelper.format'}" />
</template:else>
</template:if>
</template:if>
<template:if test="{field>Action}">
<template:with path="field>Action" helper="sap.ui.model.odata.AnnotationHelper.gotoFunctionImport" var="function">
<template:if test="{function>com.sap.vocabularies.Common.v1.IsActionCritical}">
<template:then>
<Button text="{path: 'field>Label', formatter: 'sap.ui.model.odata.AnnotationHelper.format'}"
icon="{= ${function>com.sap.vocabularies.Common.v1.IsActionCritical/Bool} !== 'false' ? 'sap-icon://notification' : ''}" />
</template:then>
<template:else>
<Button text="{path: 'field>Label', formatter: 'sap.ui.model.odata.AnnotationHelper.format'}" />
</template:else>
</template:if>
</template:with>
</template:if>
</template:repeat>
</ColumnListItem>
</core:FragmentDefinition>
36 changes: 36 additions & 0 deletions test/fixtures/linter/rules/NoGlobals/XMLTemplating.view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<mvc:View
controllerName="sap.ui.core.sample.ViewTemplate.scenario.Detail"
template:require="{AH: 'sap/ui/model/odata/AnnotationHelper',
Helper: 'sap/ui/core/sample/ViewTemplate/scenario/Helper'}"
xmlns="sap.m"
xmlns:core="sap.ui.core"
xmlns:layout="sap.ui.layout"
xmlns:mvc="sap.ui.core.mvc"
xmlns:template="http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1">

<!-- Global access of value function -->
<template:alias name=".formatParts" value="sap.ui.core.sample.ViewTemplate.scenario.Helper.formatParts">

<!-- Negative test: Access via local name -->
<template:alias name=".id" value="Helper.id">

<!-- Global access of helper function -->
<template:with path="meta>entityType" helper="sap.ui.model.odata.AnnotationHelper.gotoEntityType" var="entityType">

<!-- Negative test: Access via local name -->
<template:with path="meta>entityType" helper="AH.gotoEntityType" var="entityType2">

<template:if test="{entityType>com.sap.vocabularies.UI.v1.LineItem}">
<Table headerText="Items" includeItemInSelection="true" mode="SingleSelectMaster"
selectionChange="onSelectionChange" items="{:= '{path:\'/' + ${meta>name} + '\', length: 5}' }">
<template:with path="entityType>com.sap.vocabularies.UI.v1.LineItem" var="target">
<core:Fragment fragmentName="sap.ui.core.sample.ViewTemplate.scenario.Table" type="XML"/>
</template:with>
</Table>
</template:if>

</template:with>
</template:with>
</template:alias>
</template:alias>
</mvc:View>
15 changes: 15 additions & 0 deletions test/lib/linter/rules/snapshots/NoGlobals.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,18 @@ Generated by [AVA](https://avajs.dev).
warningCount: 0,
},
]

## General: XMLTemplating.view.xml

> Snapshot 1
[
{
coverageInfo: [],
errorCount: 0,
fatalErrorCount: 0,
filePath: 'XMLTemplating.view.xml',
messages: [],
warningCount: 0,
},
]
Binary file modified test/lib/linter/rules/snapshots/NoGlobals.ts.snap
Binary file not shown.
48 changes: 48 additions & 0 deletions test/lib/linter/snapshots/linter.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,14 @@ Generated by [AVA](https://avajs.dev).
],
warningCount: 0,
},
{
coverageInfo: [],
errorCount: 0,
fatalErrorCount: 0,
filePath: 'webapp/controller/TemplatingMain.controller.js',
messages: [],
warningCount: 0,
},
{
coverageInfo: [],
errorCount: 0,
Expand Down Expand Up @@ -1129,6 +1137,22 @@ Generated by [AVA](https://avajs.dev).
],
warningCount: 0,
},
{
coverageInfo: [],
errorCount: 0,
fatalErrorCount: 0,
filePath: 'webapp/view/TemplatingMain.view.xml',
messages: [],
warningCount: 0,
},
{
coverageInfo: [],
errorCount: 0,
fatalErrorCount: 0,
filePath: 'webapp/view/TemplatingTable.fragment.xml',
messages: [],
warningCount: 0,
},
]

## lint: Some files of com.ui5.troublesome.app (without details / coverage)
Expand Down Expand Up @@ -2889,6 +2913,14 @@ Generated by [AVA](https://avajs.dev).
],
warningCount: 0,
},
{
coverageInfo: [],
errorCount: 0,
fatalErrorCount: 0,
filePath: 'webapp/controller/TemplatingMain.controller.js',
messages: [],
warningCount: 0,
},
{
coverageInfo: [],
errorCount: 0,
Expand Down Expand Up @@ -3141,6 +3173,22 @@ Generated by [AVA](https://avajs.dev).
],
warningCount: 0,
},
{
coverageInfo: [],
errorCount: 0,
fatalErrorCount: 0,
filePath: 'webapp/view/TemplatingMain.view.xml',
messages: [],
warningCount: 0,
},
{
coverageInfo: [],
errorCount: 0,
fatalErrorCount: 0,
filePath: 'webapp/view/TemplatingTable.fragment.xml',
messages: [],
warningCount: 0,
},
]

## lint: com.ui5.troublesome.app with custom UI5 config
Expand Down
Binary file modified test/lib/linter/snapshots/linter.ts.snap
Binary file not shown.
16 changes: 16 additions & 0 deletions test/lib/snapshots/index.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -1628,6 +1628,22 @@ Generated by [AVA](https://avajs.dev).
],
warningCount: 0,
},
{
coverageInfo: [],
errorCount: 0,
fatalErrorCount: 0,
filePath: 'webapp/view/TemplatingMain.view.xml',
messages: [],
warningCount: 0,
},
{
coverageInfo: [],
errorCount: 0,
fatalErrorCount: 0,
filePath: 'webapp/view/TemplatingTable.fragment.xml',
messages: [],
warningCount: 0,
},
]

## ui5lint API: Ignore config file for com.ui5.troublesome.app
Expand Down
Binary file modified test/lib/snapshots/index.ts.snap
Binary file not shown.

0 comments on commit 8eb3ce4

Please sign in to comment.