/****************************************************************************** * ╔═══════════════════════════════════════════════════════════════════════╗ * * ║ ║ * * ║ 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.gen"; <%_ 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.iResetMockData({ ServiceUri: <%- JSON.stringify(serviceUri) %> }); Given.iResetTestData(); Given.iStartMyApp(); <% if(navigationParents.parentLRName) { -%> <% const parentTableId = navigationParents.parentLRViewKey ? '"' + navigationParents.parentLRViewKey + '"' : '""'; -%> <% if (!hideFilterBar) { -%> When.onThe<%- navigationParents.parentLRName%>Generated.onFilterBar().iExecuteSearch(); <% } -%> <% if (navigationParents.parentLRViewKey && !navigationParents.parentLRViewIsDefault) { -%> When.onThe<%- navigationParents.parentLRName%>Generated.iGoToView({ key: "<%- navigationParents.parentLRViewKey %>" }); <% } -%> Then.onThe<%- navigationParents.parentLRName%>Generated.onTable(<%- parentTableId %>).iCheckRows(); When.onThe<%- navigationParents.parentLRName%>Generated.onTable(<%- parentTableId %>).iPressRow(0); <% } -%> <% navigationParents.parentOPs.forEach(function(parent) { %> Then.onThe<%- parent.name %>Generated.iSeeThisPage(); Then.onThe<%- parent.name %>Generated.onTable({ property: "<%- parent.navigationProperty %>" }).iCheckRows(); When.onThe<%- parent.name %>Generated.onTable({ property: "<%- parent.navigationProperty %>" }).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({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> } /* , { enabled: true } */); <% } else { -%> Then.onThe<%- name%>Generated.onHeader().iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }, { enabled: <%- action.enabled === true %> }); <% } -%> // When.onThe<%- name%>Generated.onHeader().iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }); <% } -%> <% }); -%> }); <% } -%> <% 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 > 1) { -%> opaTest("Check the number of sections of the Object Page", function (_Given: Given, _When: When, Then: Then) { Then.onThe<%- name%>Generated.iCheckNumberOfSections(<%- bodySections.length %>); }); <% } -%> <% if (bodySections?.length > 0) { -%> <% bodySections.forEach(function(section) { -%> opaTest("Check the <%- section.id %> section of the Object Page", function (_Given: Given, <% if (bodySections.length > 1) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) { <% 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({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> } /* , { enabled: true } */); <% } else { -%> Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }, { enabled: <%- action.enabled === true %> }); <% } -%> // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }); <% } else { -%> <% if (action.enabled === 'dynamic') { -%> Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> } /* , { enabled: true } */); <% } else { -%> Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }, { enabled: <%- action.enabled === true %> }); <% } -%> // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }); <% } -%> <% } -%> <% }); -%> <% } -%> <% 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) { -%> <% if (section.subSections.length > 1) { -%> //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 (field.connectedFields) { %>, connectedFields: "<%- field.connectedFields %>"<% } %><% if (field.fieldGroup) { %>, fieldGroup: "<%- field.fieldGroup %>"<% } %> }); <% }) -%> <% } -%> <% if (subSection.tableColumns && Object.keys(subSection.tableColumns).length > 0 && subSection.navigationProperty) { -%> Then.onThe<%- name%>Generated.onTable({ property: "<%- subSection.navigationProperty %>" }).iCheckColumns(undefined, <%- 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 (field.connectedFields) { %>, connectedFields: "<%- field.connectedFields %>"<% } %><% if (field.fieldGroup) { %>, fieldGroup: "<%- field.fieldGroup %>"<% } %> }); <% }) -%> <% } -%> <% if (section.tableColumns && Object.keys(section.tableColumns).length > 0 && section.navigationProperty) { -%> Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckColumns(undefined, <%- JSON.stringify(section.tableColumns) %>); <% } -%> <% } -%> }); <% }) -%> <% } -%> opaTest("Teardown", function (Given: Given) { // Cleanup Given.iTearDownMyApp(); }); } runner.run([journey]);