/****************************************************************************** * ╔═══════════════════════════════════════════════════════════════════════╗ * * ║ ║ * * ║ 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; }); const usesWhenInBody = (bodySections || []).length > 1 || (bodySections || []).some(function(section) { return (section.subSections && section.subSections.length > 1) || (section.contactCardFields && section.contactCardFields.length > 0) || (section.contactCardColumns && section.contactCardColumns.length > 0) || (section.subSections || []).some(function(sub) { return (sub.contactCardFields && sub.contactCardFields.length > 0) || (sub.contactCardColumns && sub.contactCardColumns.length > 0); }) || (section.actions || []).some(function(action) { return action.visible && action.menuActions && !action.splitButton; }) || (section.actions || []).some(function(action) { return action.visible && ((action.isCritical && action.enabled !== 'dynamic') || action.menuActions); }); }); const headerHasMenu = (headerActions || []).some(function(action) { return action.visible && action.menuActions && !action.splitButton; }); -%> <% 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, <% if (headerHasMenu || headerActions.some(function(action) { return action.visible && action.isCritical && action.enabled !== 'dynamic'; })) { %>When: When<% } else { %>_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().iExecuteEdit(); <% } -%> <% headerActions.forEach(function(action) { -%> <% if (action.visible) { -%> <% if (action.menuActions) { -%> <% if (action.splitButton) { -%> // <%- JSON.stringify(action.label) %> is a split menu button (has a default action); its drop-down cannot be opened via the test API, so its menu items are not checked. Pressing it triggers the default action: Then.onThe<%- name%>Generated.onHeader().iCheckAction(<%- JSON.stringify(action.label) %>); // When.onThe<%- name%>Generated.onHeader().iExecuteAction(<%- JSON.stringify(action.label) %>); <% } else { -%> Then.onThe<%- name%>Generated.onHeader().iCheckAction(<%- JSON.stringify(action.label) %>); When.onThe<%- name%>Generated.onHeader().iExecuteAction(<%- JSON.stringify(action.label) %>); <% action.menuActions.forEach(function(menuAction) { -%> <% if (menuAction.visible) { -%> Then.onThe<%- name%>Generated.onHeader().iCheckMenuAction(<%- JSON.stringify(menuAction.label) %>); // When.onThe<%- name%>Generated.onHeader().iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>); <% } -%> <% }); -%> <% } -%> <% } else if (action.custom) { -%> <% if (action.labelUnresolved) { -%> // TODO: label is an unresolved i18n key; replace with the rendered action text <% } -%> Then.onThe<%- name%>Generated.onHeader().iCheckAction(<%- JSON.stringify(action.label) %>, { visible: true }); // When.onThe<%- name%>Generated.onHeader().iExecuteAction(<%- JSON.stringify(action.label) %>); <% } else 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 %> }); <% } -%> <% if (action.isCritical && action.enabled === 'dynamic') { -%> // "<%- action.label || action.action %>" is critical but conditionally enabled (Core.OperationAvailable path); it may be disabled for the opened entity. Uncomment when the entity state enables it to test the confirmation dialog. // When.onThe<%- name%>Generated.onHeader().iExecuteAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }); // Then.onThe<%- name%>Generated.onMessageDialog().iCheckState(); // When.onThe<%- name%>Generated.onMessageDialog().iCancel(); <% } else if (action.isCritical) { -%> When.onThe<%- name%>Generated.onHeader().iExecuteAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }); Then.onThe<%- name%>Generated.onMessageDialog().iCheckState(); When.onThe<%- name%>Generated.onMessageDialog().iCancel(); <% } else if (!action.custom && !action.menuActions) { -%> // When.onThe<%- name%>Generated.onHeader().iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }); <% } -%> <% } -%> <% }); -%> }); <% } -%> <% if (headerTitle) { -%> opaTest("Check header title of the Object Page", function (_Given: Given, _When: When, Then: Then) { Then.onThe<%- name%>Generated.onHeader().iCheckTitlePath(<%- JSON.stringify(headerTitle) %>); }); <% } -%> <% if (headerSections?.length > 0) { -%> opaTest("Check header facets of the Object Page", function (_Given: Given, <% if (headerSections.some(function(section) { return section.contactCardFields?.length > 0; })) { %>When: When<% } else { %>_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); <% }) -%> <% section.contactCardFields.forEach(function(field) { -%> When.onThe<%- name%>Generated.onHeader().iClickLink({ property: "<%- field.property %>" } as unknown as FieldIdentifier); Then.onThe<%- name%>Generated.onDialog().iCheckContactDialog({ controlType: "sap.ui.mdc.link.Panel" }); <% }) -%> <% } -%> <% } -%> <% }) -%> }); <% } -%> <% 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 (usesWhenInBody) { %>When: When<% } else { %>_When: When<% } %>, Then: Then) { <% if (bodySections.length > 1) { -%> When.onThe<%- name%>Generated.iGoToSection({ section: "<%- 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.menuActions) { -%> <% if (action.splitButton) { -%> // <%- JSON.stringify(action.label) %> is a split menu button (has a default action); its drop-down cannot be opened via the test API, so its menu items are not checked. Pressing it triggers the default action: Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction(<%- JSON.stringify(action.label) %>); // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteAction(<%- JSON.stringify(action.label) %>); <% } else { -%> Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction(<%- JSON.stringify(action.label) %>); When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteAction(<%- JSON.stringify(action.label) %>); <% action.menuActions.forEach(function(menuAction) { -%> <% if (menuAction.visible) { -%> Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckMenuAction(<%- JSON.stringify(menuAction.label) %>); // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>); <% } -%> <% }); -%> <% } -%> <% } else if (action.custom) { -%> <% if (action.labelUnresolved) { -%> // TODO: label is an unresolved i18n key; replace with the rendered action text <% } -%> Then.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iCheckAction(<%- JSON.stringify(action.label) %>, { visible: true }); // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteAction(<%- JSON.stringify(action.label) %>); <% } else 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 %> }); <% } -%> <% if (action.isCritical && action.enabled === 'dynamic') { -%> // "<%- action.label || action.action %>" is critical but conditionally enabled (Core.OperationAvailable path); it may be disabled for the selected row. Uncomment and select a row that enables it to test the confirmation dialog. // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iSelectRows(0); // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }); // Then.onThe<%- name%>Generated.onMessageDialog().iCheckState(); // When.onThe<%- name%>Generated.onMessageDialog().iCancel(); <% } else if (action.isCritical) { -%> // Critical action (Common.IsActionCritical): select a row, press it, assert the confirmation dialog opens, then cancel so it is not executed. When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iSelectRows(0); When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iExecuteAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }); Then.onThe<%- name%>Generated.onMessageDialog().iCheckState(); When.onThe<%- name%>Generated.onMessageDialog().iCancel(); // Deselect the row so the following actions start with an empty selection. When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iSelectRows(0); <% } else if (!action.custom && !action.menuActions) { -%> // When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iPressAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }); <% } -%> <% } else { -%> <% if (action.menuActions) { -%> <% if (action.splitButton) { -%> // <%- JSON.stringify(action.label) %> is a split menu button (has a default action); its drop-down cannot be opened via the test API, so its menu items are not checked. Pressing it triggers the default action: Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckAction(<%- JSON.stringify(action.label) %>); // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iExecuteAction(<%- JSON.stringify(action.label) %>); <% } else { -%> Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckAction(<%- JSON.stringify(action.label) %>); When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iExecuteAction(<%- JSON.stringify(action.label) %>); <% action.menuActions.forEach(function(menuAction) { -%> <% if (menuAction.visible) { -%> Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckMenuAction(<%- JSON.stringify(menuAction.label) %>); // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iExecuteMenuAction(<%- JSON.stringify(menuAction.label) %>); <% } -%> <% }); -%> <% } -%> <% } else if (action.custom) { -%> <% if (action.labelUnresolved) { -%> // TODO: label is an unresolved i18n key; replace with the rendered action text <% } -%> Then.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iCheckAction(<%- JSON.stringify(action.label) %>, { visible: true }); // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iExecuteAction(<%- JSON.stringify(action.label) %>); <% } 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 %> }); <% } -%> <% if (action.isCritical && action.enabled === 'dynamic') { -%> // "<%- action.label || action.action %>" is critical but conditionally enabled (Core.OperationAvailable path); it may be disabled for the opened entity. Uncomment when the entity state enables it to test the confirmation dialog. // When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iExecuteAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }); // Then.onThe<%- name%>Generated.onMessageDialog().iCheckState(); // When.onThe<%- name%>Generated.onMessageDialog().iCancel(); <% } else if (action.isCritical) { -%> // Critical action (Common.IsActionCritical): press it, assert the confirmation dialog opens, then cancel so it is not executed. When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iExecuteAction({ service: "<%- action.service %>", action: "<%- action.action %>", unbound: <%- action.unbound === true %> }); Then.onThe<%- name%>Generated.onMessageDialog().iCheckState(); When.onThe<%- name%>Generated.onMessageDialog().iCancel(); <% } else if (!action.custom && !action.menuActions) { -%> // 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(); <% } -%> <% section.contactCardColumns.forEach(function(column) { -%> When.onThe<%- name%>Generated.onTable({ property: "<%- section.navigationProperty %>" }).iClickLink(0, "<%- column.property %>"); Then.onThe<%- name%>Generated.onDialog().iCheckContactDialog({ controlType: "sap.ui.mdc.link.Panel" }); <% }) -%> <% } -%> <% 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 %>"<% } %> }); <% }) -%> <% } -%> <% subSection.contactCardFields.forEach(function(field) { -%> When.onThe<%- name%>Generated.onForm({ section: "<%- subSection.id %>" } as unknown as FormIdentifier).iClickLink({ property: "<%- field.property %>" }); Then.onThe<%- name%>Generated.onDialog().iCheckContactDialog({ controlType: "sap.ui.mdc.link.Panel" }); <% }) -%> <% 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) %>); <% } -%> <% if (subSection.navigationProperty) { -%> <% subSection.contactCardColumns.forEach(function(column) { -%> When.onThe<%- name%>Generated.onTable({ property: "<%- subSection.navigationProperty %>" }).iClickLink(0, "<%- column.property %>"); Then.onThe<%- name%>Generated.onDialog().iCheckContactDialog({ controlType: "sap.ui.mdc.link.Panel" }); <% }) -%> <% } -%> <% }) -%> <% } 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 %>"<% } %> }); <% }) -%> <% } -%> <% section.contactCardFields.forEach(function(field) { -%> When.onThe<%- name%>Generated.onForm({ section: "<%- section.id %>" } as unknown as FormIdentifier).iClickLink({ property: "<%- field.property %>" }); Then.onThe<%- name%>Generated.onDialog().iCheckContactDialog({ controlType: "sap.ui.mdc.link.Panel" }); <% }) -%> <% 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]);