@sap/generator-fiori
Version:
Create an SAPUI5 application using SAP Fiori elements or a freestyle approach
177 lines (168 loc) • 10.1 kB
text/typescript
/******************************************************************************
* ╔═══════════════════════════════════════════════════════════════════════╗ *
* ║ ║ *
* ║ WARNING: AUTO-GENERATED FILE ║ *
* ║ ║ *
* ║ This file is automatically generated by SAP Fiori tools and is ║ *
* ║ overwritten when you run the OPA test generator again. ║ *
* ║ ║ *
* ║ To add your own custom tests: ║ *
* ║ - Create a new journey test file in this directory. ║ *
* ║ - Follow the same pattern as this file. ║ *
* ║ - Add the new file to the opaTests.qunit.js config file. ║ *
* ║ - Custom journey files are not overwritten. ║ *
* ║ ║ *
* ╚═══════════════════════════════════════════════════════════════════════╝ *
******************************************************************************/
import opaTest from "sap/ui/test/opaQunit";
import type { Given, When, Then } from "./types/OpaJourneyTypes";
<%_
const usesFieldIdentifier = (headerSections || []).some(function(section) {
return section.form && section.fields && section.fields.length > 0;
});
const usesFormIdentifier = (bodySections || []).some(function(section) {
const subSectionsHaveForm = (section.subSections || []).some(function(sub) {
return sub.fields && sub.fields.length > 0;
});
const sectionHasFormFields = !(section.subSections && section.subSections.length > 0) && section.fields && section.fields.length > 0;
const hasFormAction = (section.actions || []).some(function(action) {
return action.visible && !(section.isTable && section.navigationProperty);
});
return subSectionsHaveForm || sectionHasFormFields || hasFormAction;
});
-%>
<% if (usesFieldIdentifier) { -%>
import type { FieldIdentifier } from "sap/fe/test/api/BaseAPI";
<% } -%>
<% if (usesFormIdentifier) { -%>
import type { FormIdentifier } from "sap/fe/test/api/FormAPI";
<% } -%>
import runner from "./pages/JourneyRunner";
function journey() {
QUnit.module("<%- name%>ObjectPage journey");
opaTest("Navigate to <%- name%>ObjectPage", function (Given: Given, When: When, Then: Then) {
Given.iStartMyApp();
<% if (!hideFilterBar) { %>
When.onThe<%- navigationParents.parentLRName%>Generated.onFilterBar().iExecuteSearch();
<% } %>
Then.onThe<%- navigationParents.parentLRName%>Generated.onTable("").iCheckRows();
When.onThe<%- navigationParents.parentLRName%>Generated.onTable("").iPressRow(0);
<% if(navigationParents.parentOPName) { %>
Then.onThe<%- navigationParents.parentOPName%>Generated.iSeeThisPage();
Then.onThe<%- navigationParents.parentOPName%>Generated.onTable({ property: "<%- navigationParents.parentOPTableSection %>" }).iCheckRows();
When.onThe<%- navigationParents.parentOPName%>Generated.onTable({ property: "<%- navigationParents.parentOPTableSection %>" }).iPressRow(0);
<% } %>
Then.onThe<%- name%>Generated.iSeeThisPage();
});
<% if (headerActions?.length > 0) { -%>
opaTest("Check header actions of the Object Page", function (_Given: Given, _When: When, Then: Then) {
<% if (editButton?.visible) { -%>
// Ensure the opened entity is not in Draft state before uncommenting
// Then.onThe<%- name%>Generated.onHeader().iCheckEdit({ visible: true });
// When.onThe<%- name%>Generated.onHeader().iPressEdit();
<% } -%>
<% headerActions.forEach(function(action) { -%>
<% if (action.visible) { -%>
<% if (action.enabled === 'dynamic') { -%>
Then.onThe<%- name%>Generated.onHeader().iCheckAction("<%- action.label %>" /* , { enabled: true } */);
<% } else { -%>
Then.onThe<%- name%>Generated.onHeader().iCheckAction("<%- action.label %>", { enabled: <%- action.enabled === true %> });
<% } -%>
// When.onThe<%- name%>Generated.onHeader().iPressAction("<%- action.label %>");
<% } -%>
<% }); -%>
});
<% } -%>
<% if (headerSections?.length > 0) { -%>
opaTest("Check header facets of the Object Page", function (_Given: Given, _When: When, Then: Then) {
<% headerSections.forEach(function(section) { -%>
<% if (section.microChart) { -%>
Then.onThe<%- name%>Generated.onHeader().iCheckMicroChart("<%- section.title %>", "");
<% } else { -%>
Then.onThe<%- name%>Generated.onHeader().iCheckHeaderFacet({ facetId: "<%- section.facetId %>"<% if (section.custom) { %>, custom: true<% } %> });
<% if (section.form) { -%>
<% section.fields.forEach(function(field) { -%>
Then.onThe<%- name%>Generated.onHeader().iCheckFieldInFieldGroup({
fieldGroup: "<%- field.fieldGroupQualifier %>",
field: "<%- field.field %>",
targetAnnotation: "<%- field.targetAnnotation %>"
} as unknown as FieldIdentifier);
<% }) -%>
<% } -%>
<% } -%>
<% }) -%>
});
<% } -%>
<% if (bodySections?.length > 0) { -%>
opaTest("Check body sections of the Object Page", function (_Given: Given, <% if (bodySections?.length > 1) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) {
<% if (bodySections?.length > 1) { -%>
Then.onThe<%- name%>Generated.iCheckNumberOfSections(<%- bodySections.length %>);
<% } -%>
<% bodySections.forEach(function(section) { -%>
<% if (bodySections.length > 1) { -%>
When.onThe<%- name%>Generated.iPressSectionIconTabFilterButton("<%- section.id %>");
<% } -%>
Then.onThe<%- name%>Generated.iCheckSection({ section: "<%- section.id %>" }, {});
<% if (section.actions && section.actions.length > 0) { -%>
<% section.actions.forEach(function(action) { -%>
<% if (action.visible) { -%>
<% if (section.isTable && section.navigationProperty) { -%>
<% if (action.enabled === 'dynamic') { -%>
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction("<%- action.label %>" /* , { enabled: true } */);
<% } else { -%>
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction("<%- action.label %>", { enabled: <%- action.enabled === true %> });
<% } -%>
// When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iPressAction("<%- action.label %>");
<% } else { -%>
<% if (action.enabled === 'dynamic') { -%>
Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckAction("<%- action.label %>" /* , { enabled: true } */);
<% } else { -%>
Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckAction("<%- action.label %>", { enabled: <%- action.enabled === true %> });
<% } -%>
// When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iPressAction("<%- action.label %>");
<% } -%>
<% } -%>
<% }); -%>
<% } -%>
<% if (section.isTable && section.navigationProperty) { -%>
<% if (section.createButton?.visible) { -%>
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckCreate({ visible: true });
// When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iPressCreate();
<% } -%>
<% if (section.deleteButton?.visible) { -%>
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckDelete({ visible: true });
// When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iPressDelete();
<% } -%>
<% } -%>
<% if (section?.subSections?.length > 0) { -%>
<% section.subSections.forEach(function(subSection) { -%>
//When.onThe<%- name%>Generated.iGoToSection({ section: "<%- section.id %>", subSection: "<%- subSection.id %>" });
Then.onThe<%- name%>Generated.iCheckSubSection({ section: "<%- subSection.id %>" });
<% if (subSection.fields && subSection.fields.length > 0) { -%>
<% subSection.fields.forEach(function(field) { -%>
Then.onThe<%- name%>Generated.onForm({ section: "<%- subSection.id %>" } as unknown as FormIdentifier).iCheckField({ property: "<%- field.property %>" });
<% }) -%>
<% } -%>
<% if (subSection.tableColumns && Object.keys(subSection.tableColumns).length > 0 && subSection.navigationProperty) { -%>
Then.onThe<%- name%>Generated.onTable({ property: "<%- subSection.navigationProperty %>" }).iCheckColumns(<%- JSON.stringify(subSection.tableColumns) %>);
<% } -%>
<% }) -%>
<% } else { -%>
<% if (section.fields && section.fields.length > 0) { -%>
<% section.fields.forEach(function(field) { -%>
Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckField({ property: "<%- field.property %>" });
<% }) -%>
<% } -%>
<% if (section.tableColumns && Object.keys(section.tableColumns).length > 0 && section.navigationProperty) { -%>
Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckColumns(<%- JSON.stringify(section.tableColumns) %>);
<% } -%>
<% } -%>
<% }) -%>
});
<% } -%>
opaTest("Teardown", function (Given: Given) {
// Cleanup
Given.iTearDownMyApp();
});
}
runner.run([journey]);