UNPKG

@sap/generator-fiori

Version:

Create an SAPUI5 application using SAP Fiori elements or a freestyle approach

158 lines (150 loc) 8.67 kB
/****************************************************************************** * ╔═══════════════════════════════════════════════════════════════════════╗ * * ║ ║ * * ║ 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. ║ * * ║ ║ * * ╚═══════════════════════════════════════════════════════════════════════╝ * ******************************************************************************/ sap.ui.define([ "sap/ui/test/opaQunit", "./pages/JourneyRunner" ], function (opaTest, runner) { "use strict"; function journey() { QUnit.module("<%- name%>ObjectPage journey"); opaTest("Navigate to <%- name%>ObjectPage", function (Given, When, Then) { Given.iStartMyApp(); <% if (!hideFilterBar) { %> When.onThe<%- navigationParents.parentLRName%>.onFilterBar().iExecuteSearch(); <% } %> Then.onThe<%- navigationParents.parentLRName%>.onTable().iCheckRows(); When.onThe<%- navigationParents.parentLRName%>.onTable().iPressRow(0); <% if(navigationParents.parentOPName) { %> Then.onThe<%- navigationParents.parentOPName%>.iSeeThisPage(); Then.onThe<%- navigationParents.parentOPName%>.onTable({ property: "<%- navigationParents.parentOPTableSection %>" }).iCheckRows(); When.onThe<%- navigationParents.parentOPName%>.onTable({ property: "<%- navigationParents.parentOPTableSection %>" }).iPressRow(0); <% } %> Then.onThe<%- name%>.iSeeThisPage(); }); <% if (headerActions?.length > 0 && !isStandalone) { -%> opaTest("Check header actions of the Object Page", function (Given, When, Then) { <% if (editButton?.visible) { -%> // Ensure the opened entity is not in Draft state before uncommenting // Then.onThe<%- name%>.onHeader().iCheckEdit({ visible: true }); // When.onThe<%- name%>.onHeader().iPressEdit(); <% } -%> <% headerActions.forEach(function(action) { -%> <% if (action.visible) { -%> <% if (action.enabled === 'dynamic') { -%> Then.onThe<%- name%>.onHeader().iCheckAction("<%- action.label %>" /* , { enabled: true } */); <% } else { -%> Then.onThe<%- name%>.onHeader().iCheckAction("<%- action.label %>", { enabled: <%- action.enabled === true %> }); <% } -%> // When.onThe<%- name%>.onHeader().iPressAction("<%- action.label %>"); <% } -%> <% }); -%> }); <% } -%> <% if (headerSections?.length > 0) { -%> opaTest("Check header facets of the Object Page", function (Given, When, Then) { <% headerSections.forEach(function(section) { -%> <% if (section.microChart) { -%> Then.onThe<%- name%>.onHeader().iCheckMicroChart("<%- section.title %>"); <% } else { -%> Then.onThe<%- name%>.onHeader().iCheckHeaderFacet({ facetId: "<%- section.facetId %>" }); <% if (section.form) { -%> <% section.fields.forEach(function(field) { -%> Then.onThe<%- name%>.onHeader().iCheckFieldInFieldGroup({ fieldGroup: "FieldGroup::<%- field.fieldGroupQualifier %>", field: "<%- field.field %>", targetAnnotation: "<%- field.targetAnnotation %>" }); <% }) -%> <% } -%> <% } -%> <% }) -%> }); <% } -%> <% if (bodySections?.length > 0 && !isStandalone) { -%> opaTest("Check body sections of the Object Page", function (Given, When, Then) { <% if (bodySections?.length > 1) { -%> Then.onThe<%- name%>.iCheckNumberOfSections(<%- bodySections.length %>); <% } -%> <% bodySections.forEach(function(section) { -%> <% if (bodySections.length > 1) { -%> When.onThe<%- name%>.iPressSectionIconTabFilterButton("<%- section.id %>"); <% } -%> Then.onThe<%- name%>.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%>.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction("<%- action.label %>" /* , { enabled: true } */); <% } else { -%> Then.onThe<%- name%>.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction("<%- action.label %>", { enabled: <%- action.enabled === true %> }); <% } -%> // When.onThe<%- name%>.onTable({ property: "<%- section.navigationProperty %>" }).iPressAction("<%- action.label %>"); <% } else { -%> <% if (action.enabled === 'dynamic') { -%> Then.onThe<%- name%>.onForm({ section: "<%- section.id %>" }).iCheckAction("<%- action.label %>" /* , { enabled: true } */); <% } else { -%> Then.onThe<%- name%>.onForm({ section: "<%- section.id %>" }).iCheckAction("<%- action.label %>", { enabled: <%- action.enabled === true %> }); <% } -%> // When.onThe<%- name%>.onForm({ section: "<%- section.id %>" }).iPressAction("<%- action.label %>"); <% } -%> <% } -%> <% }); -%> <% } -%> <% if (section.isTable && section.navigationProperty) { -%> <% if (section.createButton?.visible) { -%> Then.onThe<%- name%>.onTable({ property: "<%- section.navigationProperty %>" }).iCheckCreate({ visible: true }); // When.onThe<%- name%>.onTable({ property: "<%- section.navigationProperty %>" }).iPressCreate(); <% } -%> <% if (section.deleteButton?.visible) { -%> Then.onThe<%- name%>.onTable({ property: "<%- section.navigationProperty %>" }).iCheckDelete({ visible: true }); // When.onThe<%- name%>.onTable({ property: "<%- section.navigationProperty %>" }).iPressDelete(); <% } -%> <% } -%> <% if (section?.subSections?.length > 0) { -%> <% section.subSections.forEach(function(subSection) { -%> //When.onThe<%- name%>.iGoToSection({ section: "<%- section.id %>", subSection: "<%- subSection.id %>" }); Then.onThe<%- name%>.iCheckSubSection({ section: "<%- subSection.id %>" }); <% if (subSection.fields && subSection.fields.length > 0) { -%> <% subSection.fields.forEach(function(field) { -%> Then.onThe<%- name%>.onForm({ section: "<%- subSection.id %>" }).iCheckField({ property: "<%- field.property %>" }); <% }) -%> <% } -%> <% if (subSection.tableColumns && Object.keys(subSection.tableColumns).length > 0 && subSection.navigationProperty) { -%> Then.onThe<%- name%>.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%>.onForm({ section: "<%- section.id %>" }).iCheckField({ property: "<%- field.property %>" }); <% }) -%> <% } -%> <% if (section.tableColumns && Object.keys(section.tableColumns).length > 0 && section.navigationProperty) { -%> Then.onThe<%- name%>.onTable({ property: "<%- section.navigationProperty %>" }).iCheckColumns(<%- JSON.stringify(section.tableColumns) %>); <% } -%> <% } -%> <% }) -%> }); <% } -%> opaTest("Teardown", function (Given, When, Then) { // Cleanup Given.iTearDownMyApp(); }); } runner.run([journey]); });