@sap_oss/wdio-qmate-service 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +3 -0
- package/.eslintrc.yml +33 -0
- package/.reuse/dep5 +29 -0
- package/LICENSE +201 -0
- package/LICENSES/Apache-2.0.txt +73 -0
- package/README.md +20 -0
- package/docs/contact.md +10 -0
- package/docs/doc.md +5188 -0
- package/docs/gettingStarted/selectors.md +168 -0
- package/docs/gettingStarted/setup.md +8 -0
- package/docs/index.md +14 -0
- package/docs/style/custom.css +24 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +171 -0
- package/lib/index.js.map +1 -0
- package/lib/reuse/authenticator/authConfig.d.ts +54 -0
- package/lib/reuse/authenticator/authConfig.js +55 -0
- package/lib/reuse/authenticator/authConfig.js.map +1 -0
- package/lib/reuse/authenticator/authHandler.d.ts +6 -0
- package/lib/reuse/authenticator/authHandler.js +37 -0
- package/lib/reuse/authenticator/authHandler.js.map +1 -0
- package/lib/reuse/authenticator/basicUrlAuthenticator.d.ts +2 -0
- package/lib/reuse/authenticator/basicUrlAuthenticator.js +36 -0
- package/lib/reuse/authenticator/basicUrlAuthenticator.js.map +1 -0
- package/lib/reuse/authenticator/customAuthenticator.d.ts +2 -0
- package/lib/reuse/authenticator/customAuthenticator.js +60 -0
- package/lib/reuse/authenticator/customAuthenticator.js.map +1 -0
- package/lib/reuse/authenticator/formAuthenticator.d.ts +2 -0
- package/lib/reuse/authenticator/formAuthenticator.js +57 -0
- package/lib/reuse/authenticator/formAuthenticator.js.map +1 -0
- package/lib/reuse/authenticator/plainAuthenticator.d.ts +2 -0
- package/lib/reuse/authenticator/plainAuthenticator.js +20 -0
- package/lib/reuse/authenticator/plainAuthenticator.js.map +1 -0
- package/lib/reuse/data/authenticators.json +16 -0
- package/lib/reuse/helper/clientsideUI5scripts.d.ts +1 -0
- package/lib/reuse/helper/clientsideUI5scripts.js +388 -0
- package/lib/reuse/helper/clientsideUI5scripts.js.map +1 -0
- package/lib/reuse/helper/jsDocGen.d.ts +1 -0
- package/lib/reuse/helper/jsDocGen.js +45 -0
- package/lib/reuse/helper/jsDocGen.js.map +1 -0
- package/lib/reuse/index.d.ts +5 -0
- package/lib/reuse/index.js +89 -0
- package/lib/reuse/index.js.map +1 -0
- package/lib/reuse/modules/common/Common.d.ts +12 -0
- package/lib/reuse/modules/common/Common.js +21 -0
- package/lib/reuse/modules/common/Common.js.map +1 -0
- package/lib/reuse/modules/common/assertion.d.ts +65 -0
- package/lib/reuse/modules/common/assertion.js +91 -0
- package/lib/reuse/modules/common/assertion.js.map +1 -0
- package/lib/reuse/modules/common/constants/date.constants.d.ts +8 -0
- package/lib/reuse/modules/common/constants/date.constants.js +13 -0
- package/lib/reuse/modules/common/constants/date.constants.js.map +1 -0
- package/lib/reuse/modules/common/constants/userInteraction.constants.d.ts +9 -0
- package/lib/reuse/modules/common/constants/userInteraction.constants.js +14 -0
- package/lib/reuse/modules/common/constants/userInteraction.constants.js.map +1 -0
- package/lib/reuse/modules/common/date.d.ts +84 -0
- package/lib/reuse/modules/common/date.js +164 -0
- package/lib/reuse/modules/common/date.js.map +1 -0
- package/lib/reuse/modules/common/navigation.d.ts +26 -0
- package/lib/reuse/modules/common/navigation.js +56 -0
- package/lib/reuse/modules/common/navigation.js.map +1 -0
- package/lib/reuse/modules/common/types/date.types.d.ts +2 -0
- package/lib/reuse/modules/common/types/date.types.js +3 -0
- package/lib/reuse/modules/common/types/date.types.js.map +1 -0
- package/lib/reuse/modules/common/userInteraction.d.ts +104 -0
- package/lib/reuse/modules/common/userInteraction.js +199 -0
- package/lib/reuse/modules/common/userInteraction.js.map +1 -0
- package/lib/reuse/modules/nonUi5/NonUi5.d.ts +12 -0
- package/lib/reuse/modules/nonUi5/NonUi5.js +21 -0
- package/lib/reuse/modules/nonUi5/NonUi5.js.map +1 -0
- package/lib/reuse/modules/nonUi5/assertion.d.ts +62 -0
- package/lib/reuse/modules/nonUi5/assertion.js +127 -0
- package/lib/reuse/modules/nonUi5/assertion.js.map +1 -0
- package/lib/reuse/modules/nonUi5/constants/userInteraction.constants.d.ts +6 -0
- package/lib/reuse/modules/nonUi5/constants/userInteraction.constants.js +11 -0
- package/lib/reuse/modules/nonUi5/constants/userInteraction.constants.js.map +1 -0
- package/lib/reuse/modules/nonUi5/element.d.ts +286 -0
- package/lib/reuse/modules/nonUi5/element.js +639 -0
- package/lib/reuse/modules/nonUi5/element.js.map +1 -0
- package/lib/reuse/modules/nonUi5/navigation.d.ts +17 -0
- package/lib/reuse/modules/nonUi5/navigation.js +44 -0
- package/lib/reuse/modules/nonUi5/navigation.js.map +1 -0
- package/lib/reuse/modules/nonUi5/userInteraction.d.ts +170 -0
- package/lib/reuse/modules/nonUi5/userInteraction.js +415 -0
- package/lib/reuse/modules/nonUi5/userInteraction.js.map +1 -0
- package/lib/reuse/modules/service/Service.d.ts +8 -0
- package/lib/reuse/modules/service/Service.js +17 -0
- package/lib/reuse/modules/service/Service.js.map +1 -0
- package/lib/reuse/modules/service/odata.d.ts +177 -0
- package/lib/reuse/modules/service/odata.js +347 -0
- package/lib/reuse/modules/service/odata.js.map +1 -0
- package/lib/reuse/modules/service/rest.d.ts +66 -0
- package/lib/reuse/modules/service/rest.js +168 -0
- package/lib/reuse/modules/service/rest.js.map +1 -0
- package/lib/reuse/modules/service/soap.d.ts +0 -0
- package/lib/reuse/modules/service/soap.js +2 -0
- package/lib/reuse/modules/service/soap.js.map +1 -0
- package/lib/reuse/modules/ui5/Ui5.d.ts +34 -0
- package/lib/reuse/modules/ui5/Ui5.js +41 -0
- package/lib/reuse/modules/ui5/Ui5.js.map +1 -0
- package/lib/reuse/modules/ui5/assertion.d.ts +183 -0
- package/lib/reuse/modules/ui5/assertion.js +493 -0
- package/lib/reuse/modules/ui5/assertion.js.map +1 -0
- package/lib/reuse/modules/ui5/confirmationDialog.d.ts +86 -0
- package/lib/reuse/modules/ui5/confirmationDialog.js +145 -0
- package/lib/reuse/modules/ui5/confirmationDialog.js.map +1 -0
- package/lib/reuse/modules/ui5/constants/mockserver.constants.d.ts +4 -0
- package/lib/reuse/modules/ui5/constants/mockserver.constants.js +9 -0
- package/lib/reuse/modules/ui5/constants/mockserver.constants.js.map +1 -0
- package/lib/reuse/modules/ui5/control.d.ts +84 -0
- package/lib/reuse/modules/ui5/control.js +132 -0
- package/lib/reuse/modules/ui5/control.js.map +1 -0
- package/lib/reuse/modules/ui5/date.d.ts +48 -0
- package/lib/reuse/modules/ui5/date.js +153 -0
- package/lib/reuse/modules/ui5/date.js.map +1 -0
- package/lib/reuse/modules/ui5/element.d.ts +160 -0
- package/lib/reuse/modules/ui5/element.js +349 -0
- package/lib/reuse/modules/ui5/element.js.map +1 -0
- package/lib/reuse/modules/ui5/errorDialog.d.ts +39 -0
- package/lib/reuse/modules/ui5/errorDialog.js +65 -0
- package/lib/reuse/modules/ui5/errorDialog.js.map +1 -0
- package/lib/reuse/modules/ui5/footerBar.d.ts +153 -0
- package/lib/reuse/modules/ui5/footerBar.js +240 -0
- package/lib/reuse/modules/ui5/footerBar.js.map +1 -0
- package/lib/reuse/modules/ui5/mockserver.d.ts +154 -0
- package/lib/reuse/modules/ui5/mockserver.js +665 -0
- package/lib/reuse/modules/ui5/mockserver.js.map +1 -0
- package/lib/reuse/modules/ui5/navigation.d.ts +103 -0
- package/lib/reuse/modules/ui5/navigation.js +275 -0
- package/lib/reuse/modules/ui5/navigation.js.map +1 -0
- package/lib/reuse/modules/ui5/navigationBar.d.ts +48 -0
- package/lib/reuse/modules/ui5/navigationBar.js +141 -0
- package/lib/reuse/modules/ui5/navigationBar.js.map +1 -0
- package/lib/reuse/modules/ui5/qunit.d.ts +17 -0
- package/lib/reuse/modules/ui5/qunit.js +52 -0
- package/lib/reuse/modules/ui5/qunit.js.map +1 -0
- package/lib/reuse/modules/ui5/session.d.ts +117 -0
- package/lib/reuse/modules/ui5/session.js +374 -0
- package/lib/reuse/modules/ui5/session.js.map +1 -0
- package/lib/reuse/modules/ui5/table.d.ts +61 -0
- package/lib/reuse/modules/ui5/table.js +188 -0
- package/lib/reuse/modules/ui5/table.js.map +1 -0
- package/lib/reuse/modules/ui5/types/mockserver.types.d.ts +2 -0
- package/lib/reuse/modules/ui5/types/mockserver.types.js +3 -0
- package/lib/reuse/modules/ui5/types/mockserver.types.js.map +1 -0
- package/lib/reuse/modules/ui5/userInteraction.d.ts +304 -0
- package/lib/reuse/modules/ui5/userInteraction.js +690 -0
- package/lib/reuse/modules/ui5/userInteraction.js.map +1 -0
- package/lib/reuse/modules/util/Util.d.ts +22 -0
- package/lib/reuse/modules/util/Util.js +27 -0
- package/lib/reuse/modules/util/Util.js.map +1 -0
- package/lib/reuse/modules/util/browser.d.ts +167 -0
- package/lib/reuse/modules/util/browser.js +367 -0
- package/lib/reuse/modules/util/browser.js.map +1 -0
- package/lib/reuse/modules/util/console.d.ts +56 -0
- package/lib/reuse/modules/util/console.js +152 -0
- package/lib/reuse/modules/util/console.js.map +1 -0
- package/lib/reuse/modules/util/constants/formatter.constants.d.ts +11 -0
- package/lib/reuse/modules/util/constants/formatter.constants.js +16 -0
- package/lib/reuse/modules/util/constants/formatter.constants.js.map +1 -0
- package/lib/reuse/modules/util/data.d.ts +36 -0
- package/lib/reuse/modules/util/data.js +87 -0
- package/lib/reuse/modules/util/data.js.map +1 -0
- package/lib/reuse/modules/util/file.d.ts +55 -0
- package/lib/reuse/modules/util/file.js +159 -0
- package/lib/reuse/modules/util/file.js.map +1 -0
- package/lib/reuse/modules/util/formatter.d.ts +90 -0
- package/lib/reuse/modules/util/formatter.js +210 -0
- package/lib/reuse/modules/util/formatter.js.map +1 -0
- package/lib/reuse/modules/util/function.d.ts +48 -0
- package/lib/reuse/modules/util/function.js +161 -0
- package/lib/reuse/modules/util/function.js.map +1 -0
- package/lib/reuse/modules/util/system.d.ts +17 -0
- package/lib/reuse/modules/util/system.js +58 -0
- package/lib/reuse/modules/util/system.js.map +1 -0
- package/lib/reuse/modules/util/types/formatter.types.d.ts +2 -0
- package/lib/reuse/modules/util/types/formatter.types.js +3 -0
- package/lib/reuse/modules/util/types/formatter.types.js.map +1 -0
- package/lib/scripts/clientsideUI5scripts.d.ts +1 -0
- package/lib/scripts/clientsideUI5scripts.js +315 -0
- package/lib/scripts/clientsideUI5scripts.js.map +1 -0
- package/lib/scripts/dataExchange/dataExchange.d.ts +1 -0
- package/lib/scripts/dataExchange/dataExchange.js +224 -0
- package/lib/scripts/dataExchange/dataExchange.js.map +1 -0
- package/lib/scripts/dataExchange/dataExchangeUtil.d.ts +63 -0
- package/lib/scripts/dataExchange/dataExchangeUtil.js +211 -0
- package/lib/scripts/dataExchange/dataExchangeUtil.js.map +1 -0
- package/lib/scripts/hooks/after.d.ts +8 -0
- package/lib/scripts/hooks/after.js +30 -0
- package/lib/scripts/hooks/after.js.map +1 -0
- package/lib/scripts/hooks/before.d.ts +8 -0
- package/lib/scripts/hooks/before.js +38 -0
- package/lib/scripts/hooks/before.js.map +1 -0
- package/lib/scripts/hooks/beforeSession.d.ts +8 -0
- package/lib/scripts/hooks/beforeSession.js +37 -0
- package/lib/scripts/hooks/beforeSession.js.map +1 -0
- package/lib/scripts/hooks/onComplete.d.ts +9 -0
- package/lib/scripts/hooks/onComplete.js +31 -0
- package/lib/scripts/hooks/onComplete.js.map +1 -0
- package/lib/scripts/hooks/onPrepare.d.ts +6 -0
- package/lib/scripts/hooks/onPrepare.js +36 -0
- package/lib/scripts/hooks/onPrepare.js.map +1 -0
- package/lib/scripts/hooks/utils/addLocatorCommands.d.ts +2 -0
- package/lib/scripts/hooks/utils/addLocatorCommands.js +193 -0
- package/lib/scripts/hooks/utils/addLocatorCommands.js.map +1 -0
- package/lib/scripts/hooks/utils/browserLog.d.ts +2 -0
- package/lib/scripts/hooks/utils/browserLog.js +39 -0
- package/lib/scripts/hooks/utils/browserLog.js.map +1 -0
- package/lib/scripts/hooks/utils/dataExchangeCommands.d.ts +9 -0
- package/lib/scripts/hooks/utils/dataExchangeCommands.js +46 -0
- package/lib/scripts/hooks/utils/dataExchangeCommands.js.map +1 -0
- package/lib/scripts/hooks/utils/decryption.d.ts +13 -0
- package/lib/scripts/hooks/utils/decryption.js +90 -0
- package/lib/scripts/hooks/utils/decryption.js.map +1 -0
- package/lib/scripts/hooks/utils/lib.d.ts +4 -0
- package/lib/scripts/hooks/utils/lib.js +330 -0
- package/lib/scripts/hooks/utils/lib.js.map +1 -0
- package/lib/scripts/hooks/utils/locatorCommands.d.ts +10 -0
- package/lib/scripts/hooks/utils/locatorCommands.js +216 -0
- package/lib/scripts/hooks/utils/locatorCommands.js.map +1 -0
- package/lib/scripts/locators/qmateLocator.d.ts +1 -0
- package/lib/scripts/locators/qmateLocator.js +1384 -0
- package/lib/scripts/locators/qmateLocator.js.map +1 -0
- package/lib/scripts/locators/uiveri5Locator.d.ts +1 -0
- package/lib/scripts/locators/uiveri5Locator.js +21 -0
- package/lib/scripts/locators/uiveri5Locator.js.map +1 -0
- package/mkdocs.yml +53 -0
- package/package.json +152 -0
- package/test/.eslintrc.yml +6 -0
- package/test/authenticator/package.json +13 -0
- package/test/authenticator/staticLogin/configCustom.js +22 -0
- package/test/authenticator/staticLogin/configCustomViaConfig.js +20 -0
- package/test/authenticator/staticLogin/configFiori.js +19 -0
- package/test/authenticator/staticLogin/configPlain.js +17 -0
- package/test/authenticator/staticLogin/configSapCloud.js +18 -0
- package/test/authenticator/staticLogin/html/custom.html +10 -0
- package/test/authenticator/staticLogin/html/fiori.html +10 -0
- package/test/authenticator/staticLogin/html/home.html +7 -0
- package/test/authenticator/staticLogin/html/sapCloud.html +10 -0
- package/test/authenticator/staticLogin/specs/custom.spec.js +6 -0
- package/test/authenticator/staticLogin/specs/customViaConfig.spec.js +10 -0
- package/test/authenticator/staticLogin/specs/fiori.spec.js +6 -0
- package/test/authenticator/staticLogin/specs/plain.spec.js +64 -0
- package/test/authenticator/staticLogin/specs/sapCloud.spec.js +6 -0
- package/test/authenticator/staticLogin/staticServerConfig.js +20 -0
- package/test/authenticator/systemLogin/configCustom.js +26 -0
- package/test/authenticator/systemLogin/configFiori.js +24 -0
- package/test/authenticator/systemLogin/configPlain.js +22 -0
- package/test/authenticator/systemLogin/configSapCloud.js +24 -0
- package/test/authenticator/systemLogin/specs/custom.spec.js +13 -0
- package/test/authenticator/systemLogin/specs/fiori.spec.js +12 -0
- package/test/authenticator/systemLogin/specs/plain.spec.js +21 -0
- package/test/authenticator/systemLogin/specs/sapCloud.spec.js +13 -0
- package/test/core/README.md +17 -0
- package/test/core/dataExchange/config.export.js +56 -0
- package/test/core/dataExchange/config.import.js +47 -0
- package/test/core/dataExchange/config.js +52 -0
- package/test/core/dataExchange/config.parallel.group.js +61 -0
- package/test/core/dataExchange/config.parallel.js +58 -0
- package/test/core/dataExchange/data/another/folder/data/anotherFolder/dummy1.txt +0 -0
- package/test/core/dataExchange/data/another/folder/data/anotherFolder/purchase-orders/Limit-Purchase-Order.json +29 -0
- package/test/core/dataExchange/data/another/folder/data/anotherFolder/purchase-orders/ServicePurchaseOrder.2Items.json +67 -0
- package/test/core/dataExchange/data/another/folder/data/anotherFolder/purchaseRequisition_HI.json +31 -0
- package/test/core/dataExchange/data/another/folder/data/anotherFolder/subfolder/LimitPurchaseOrder.json +29 -0
- package/test/core/dataExchange/data/another/folder/data/anotherFolder/subfolder/PurchaseOrderItems.json +58 -0
- package/test/core/dataExchange/data/another/folder/data/anotherFolder/subfolder/PurchaseOrderWithScheduline.json +27 -0
- package/test/core/dataExchange/data/another/folder/data/anotherFolder/subfolder/ServiceAndMaterialPurchaseOrder.json +65 -0
- package/test/core/dataExchange/data/another/folder/data/anotherFolder/subfolder/ServicePurchaseOrder.json +39 -0
- package/test/core/dataExchange/data/another/folder/data/anotherFolder/subfolder/ServicePurchaseOrder2Items.json +67 -0
- package/test/core/dataExchange/data/my/folder/data/qs9/data.json +5 -0
- package/test/core/dataExchange/data/my/folder/data/qs9/dummy1.txt +0 -0
- package/test/core/dataExchange/data/my/folder/data/qs9/dummy2.txt +0 -0
- package/test/core/dataExchange/data/my/folder/data/qs9/empty.json +0 -0
- package/test/core/dataExchange/data/my/folder/data/qs9/purchaseRequisition.json +31 -0
- package/test/core/dataExchange/data/my/folder/data/qs9/supplierInvoice.json +17 -0
- package/test/core/dataExchange/data/my/folder/data/qs9/webUser.json +6 -0
- package/test/core/dataExchange/data/ui/moreDataFolder/anotherUser.json +6 -0
- package/test/core/dataExchange/data/ui/user.json +6 -0
- package/test/core/dataExchange/data/ui/webUser.json +6 -0
- package/test/core/dataExchange/specs/export.fast.spec.js +48 -0
- package/test/core/dataExchange/specs/export.slow.spec.js +50 -0
- package/test/core/dataExchange/specs/export.spec.js +103 -0
- package/test/core/dataExchange/specs/import.spec.js +144 -0
- package/test/core/dataExchange/specs/importExport.spec.js +196 -0
- package/test/core/dataExchange/utils.js +160 -0
- package/test/core/functional/README.md +30 -0
- package/test/core/functional/chaining/chaining.test.js +137 -0
- package/test/core/functional/chaining/test.conf.js +31 -0
- package/test/core/functional/locators/ancestorProperties.test.js +99 -0
- package/test/core/functional/locators/childProperties.test.js +40 -0
- package/test/core/functional/locators/descendantProperties.test.js +107 -0
- package/test/core/functional/locators/domProperties.test.js +60 -0
- package/test/core/functional/locators/elementProperties.test.js +114 -0
- package/test/core/functional/locators/mixedProperties.test.js +170 -0
- package/test/core/functional/locators/parentProperties.test.js +47 -0
- package/test/core/functional/locators/siblingProperties.test.js +120 -0
- package/test/core/functional/locators/test.locator.conf.js +38 -0
- package/test/core/functional/locators/utils.js +6 -0
- package/test/core/functional/nativeBrowser/runInBrowser.test.js +111 -0
- package/test/core/functional/nativeBrowser/test.conf.js +31 -0
- package/test/core/functional/nonUi5/basic.test.js +10 -0
- package/test/core/functional/nonUi5/getWithDomElement.test.js +51 -0
- package/test/core/functional/nonUi5/getWithDomElements.test.js +141 -0
- package/test/core/functional/nonUi5/test.conf.js +32 -0
- package/test/core/functional/ui5Properties/getAggregations.test.js +102 -0
- package/test/core/functional/ui5Properties/getAssociations.test.js +24 -0
- package/test/core/functional/ui5Properties/getBindingInfos.test.js +71 -0
- package/test/core/functional/ui5Properties/getProperties.test.js +226 -0
- package/test/core/functional/ui5Properties/test.conf.js +16 -0
- package/test/core/functional/uiveri5/sample.test.js +61 -0
- package/test/core/functional/uiveri5/test.conf.js +31 -0
- package/test/core/package-lock.json +0 -0
- package/test/core/package.json +12 -0
- package/test/core/testIntegration/config.js +17 -0
- package/test/core/testIntegration/configMultiCombo.js +17 -0
- package/test/core/testIntegration/configTable.js +18 -0
- package/test/core/testIntegration/filters1.spec.js +1849 -0
- package/test/core/testIntegration/multicombobox.spec.js +134 -0
- package/test/core/testIntegration/table.spec.js +80 -0
- package/test/helper/configurations/base.conf.js +43 -0
- package/test/helper/configurations/chrome.conf.js +47 -0
- package/test/helper/configurations/chrome.headless.conf.js +45 -0
- package/test/helper/configurations/sauce.labs.conf.js +37 -0
- package/test/helper/configurations/sauce.labs.tunnel.conf.js +39 -0
- package/test/helper/sleeper.js +19 -0
- package/test/helper/utils.js +15 -0
- package/test/helper/website/buttons.html +85 -0
- package/test/helper/website/checkBox.html +83 -0
- package/test/helper/website/dragAndDropFailing.html +83 -0
- package/test/helper/website/dragAndDropWdioExample.html +41 -0
- package/test/helper/website/dropdown.html +78 -0
- package/test/helper/website/forms.html +82 -0
- package/test/helper/website/hiddenAndVisible.html +60 -0
- package/test/helper/website/main.css +36 -0
- package/test/helper/website/scrollPage.html +261 -0
- package/test/helper/website/style.css +52 -0
- package/test/helper/website/tables.html +140 -0
- package/test/helper/website/waitForElements.html +73 -0
- package/test/reuse/common/assertion/expectDefined.spec.js +11 -0
- package/test/reuse/common/assertion/expectEqual.spec.js +52 -0
- package/test/reuse/common/assertion/expectFalse.spec.js +9 -0
- package/test/reuse/common/assertion/expectTrue.spec.js +9 -0
- package/test/reuse/common/assertion/expectUndefined.spec.js +11 -0
- package/test/reuse/common/assertion/expectUnequal.spec.js +25 -0
- package/test/reuse/common/assertion/expectUrlToBe.spec.js +27 -0
- package/test/reuse/common/assertion/test.assertion.conf.js +59 -0
- package/test/reuse/common/date/calculate.spec.js +163 -0
- package/test/reuse/common/date/getNextMonth.spec.js +105 -0
- package/test/reuse/common/date/getNextYear.spec.js +72 -0
- package/test/reuse/common/date/getPreviousMonth.spec.js +71 -0
- package/test/reuse/common/date/getPreviousYear.spec.js +72 -0
- package/test/reuse/common/date/getSpecific.spec.js +63 -0
- package/test/reuse/common/date/getToday.spec.js +78 -0
- package/test/reuse/common/date/getTomorrow.spec.js +72 -0
- package/test/reuse/common/date/test.date.conf.js +19 -0
- package/test/reuse/common/date/utils.js +6 -0
- package/test/reuse/common/navigation/navigateToUrl.spec.js +28 -0
- package/test/reuse/common/navigation/navigateToUrlAndRetry.spec.js +27 -0
- package/test/reuse/common/navigation/test.navigation.conf.js +25 -0
- package/test/reuse/common/userInteraction/clearAndFillActive.spec.js +100 -0
- package/test/reuse/common/userInteraction/clearAndFillActiveAndRetry.spec.js +106 -0
- package/test/reuse/common/userInteraction/fillActive.spec.js +230 -0
- package/test/reuse/common/userInteraction/fillActiveAndRetry.spec.js +172 -0
- package/test/reuse/common/userInteraction/pressKey.spec.js +105 -0
- package/test/reuse/common/userInteraction/test.userInteraction.conf.js +53 -0
- package/test/reuse/nonUi5/assertion/expectAttributeToBe.spec.js +45 -0
- package/test/reuse/nonUi5/assertion/expectAttributeToContain.spec.js +43 -0
- package/test/reuse/nonUi5/assertion/expectToBeNotVisible.spec.js +37 -0
- package/test/reuse/nonUi5/assertion/expectToBeVisible.spec.js +63 -0
- package/test/reuse/nonUi5/assertion/expectValueToBe.spec.js +25 -0
- package/test/reuse/nonUi5/assertion/test.assertion.conf.js +60 -0
- package/test/reuse/nonUi5/assertion/test.assertion.sauceLabs.conf.js +64 -0
- package/test/reuse/nonUi5/element/getAllDisplayed.spec.js +39 -0
- package/test/reuse/nonUi5/element/getAttributeValue.spec.js +58 -0
- package/test/reuse/nonUi5/element/getByChild.spec.js +70 -0
- package/test/reuse/nonUi5/element/getByClass.spec.js +64 -0
- package/test/reuse/nonUi5/element/getByCss.spec.js +65 -0
- package/test/reuse/nonUi5/element/getByCssContainingText.spec.js +83 -0
- package/test/reuse/nonUi5/element/getById.spec.js +35 -0
- package/test/reuse/nonUi5/element/getByName.spec.js +30 -0
- package/test/reuse/nonUi5/element/getByParent.spec.js +71 -0
- package/test/reuse/nonUi5/element/getByXPath.spec.js +30 -0
- package/test/reuse/nonUi5/element/getValue.spec.js +51 -0
- package/test/reuse/nonUi5/element/highlight.spec.js +18 -0
- package/test/reuse/nonUi5/element/isPresent.spec.js +39 -0
- package/test/reuse/nonUi5/element/isPresentByCss.spec.js +73 -0
- package/test/reuse/nonUi5/element/isPresentByXPath.spec.js +31 -0
- package/test/reuse/nonUi5/element/setInnerHTML.spec.js +23 -0
- package/test/reuse/nonUi5/element/test.element.conf.js +55 -0
- package/test/reuse/nonUi5/element/test.element.sauceLabs.conf.js +58 -0
- package/test/reuse/nonUi5/element/waitForAll.spec.js +24 -0
- package/test/reuse/nonUi5/element/waitToBeClickable.spec.js +24 -0
- package/test/reuse/nonUi5/element/waitToBePresent.spec.js +32 -0
- package/test/reuse/nonUi5/element/waitToBeVisible.spec.js +36 -0
- package/test/reuse/nonUi5/navigation/navigateToApplication.spec.js +13 -0
- package/test/reuse/nonUi5/navigation/test.navigation.conf.js +14 -0
- package/test/reuse/nonUi5/userInteraction/checkAttributeAndValue.spec.js +135 -0
- package/test/reuse/nonUi5/userInteraction/clear.spec.js +43 -0
- package/test/reuse/nonUi5/userInteraction/clearAndFill.spec.js +51 -0
- package/test/reuse/nonUi5/userInteraction/clearAndFillAndRetry.spec.js +58 -0
- package/test/reuse/nonUi5/userInteraction/clearAndRetry.spec.js +43 -0
- package/test/reuse/nonUi5/userInteraction/click.spec.js +60 -0
- package/test/reuse/nonUi5/userInteraction/clickAndRetry.spec.js +60 -0
- package/test/reuse/nonUi5/userInteraction/clickElementInSvg.spec.js +24 -0
- package/test/reuse/nonUi5/userInteraction/doubleClick.spec.js +22 -0
- package/test/reuse/nonUi5/userInteraction/dragAndDrop.spec.js +40 -0
- package/test/reuse/nonUi5/userInteraction/fill.spec.js +37 -0
- package/test/reuse/nonUi5/userInteraction/fillAndRetry.spec.js +39 -0
- package/test/reuse/nonUi5/userInteraction/mouseOverElement.spec.js +36 -0
- package/test/reuse/nonUi5/userInteraction/moveCursorAndClick.spec.js +24 -0
- package/test/reuse/nonUi5/userInteraction/rightClick.spec.js +13 -0
- package/test/reuse/nonUi5/userInteraction/scrollToElement.spec.js +35 -0
- package/test/reuse/nonUi5/userInteraction/test.userInteraction.conf.js +72 -0
- package/test/reuse/nonUi5/userInteraction/test.userInteraction.sauceLabs.conf.js +78 -0
- package/test/reuse/service/rest/db.json +8 -0
- package/test/reuse/service/rest/delete.spec.js +20 -0
- package/test/reuse/service/rest/get.spec.js +19 -0
- package/test/reuse/service/rest/init.spec.js +35 -0
- package/test/reuse/service/rest/patch.spec.js +29 -0
- package/test/reuse/service/rest/post.spec.js +37 -0
- package/test/reuse/service/rest/test.rest.conf.js +18 -0
- package/test/reuse/ui5/assertion/expectAttributeToBe.spec.js +106 -0
- package/test/reuse/ui5/assertion/expectAttributeToContain.spec.js +78 -0
- package/test/reuse/ui5/assertion/expectBindingContextPathToBe.spec.js +103 -0
- package/test/reuse/ui5/assertion/expectBindingPathToBe.spec.js +164 -0
- package/test/reuse/ui5/assertion/expectMessageToastTextToBe.spec.js +43 -0
- package/test/reuse/ui5/assertion/expectTextToBe.spec.js +39 -0
- package/test/reuse/ui5/assertion/expectToBeEnabled.spec.js +90 -0
- package/test/reuse/ui5/assertion/expectToBeNotEnabled.spec.js +62 -0
- package/test/reuse/ui5/assertion/expectToBeNotVisible.spec.js +52 -0
- package/test/reuse/ui5/assertion/expectToBeVisible.spec.js +69 -0
- package/test/reuse/ui5/assertion/expectToBeVisibleInViewport.spec.js +49 -0
- package/test/reuse/ui5/assertion/expectValidationError.spec.js +54 -0
- package/test/reuse/ui5/assertion/expectValidationSuccess.spec.js +53 -0
- package/test/reuse/ui5/assertion/expectValueToBe.spec.js +57 -0
- package/test/reuse/ui5/assertion/expectValueToBeDefined.spec.js +35 -0
- package/test/reuse/ui5/assertion/test.assertion.conf.js +28 -0
- package/test/reuse/ui5/assertion/test.assertion.sauceLab.conf.js +37 -0
- package/test/reuse/ui5/confirmationDialog/clickCancel.spec.js +88 -0
- package/test/reuse/ui5/confirmationDialog/clickCreate.spec.js +3 -0
- package/test/reuse/ui5/confirmationDialog/clickDelete.spec.js +89 -0
- package/test/reuse/ui5/confirmationDialog/clickNo.spec.js +96 -0
- package/test/reuse/ui5/confirmationDialog/clickOk.spec.js +66 -0
- package/test/reuse/ui5/confirmationDialog/clickRevokeApproval.spec.js +3 -0
- package/test/reuse/ui5/confirmationDialog/clickYes.spec.js +70 -0
- package/test/reuse/ui5/confirmationDialog/test.confirmationDialog.conf.js +20 -0
- package/test/reuse/ui5/confirmationDialog/test.confirmationDialog.sauceLab.conf.js +29 -0
- package/test/reuse/ui5/control/execute.spec.js +29 -0
- package/test/reuse/ui5/control/getAggregationProperty.spec.js +29 -0
- package/test/reuse/ui5/control/getAssociationProperty.spec.js +1 -0
- package/test/reuse/ui5/control/getBindingContextPathProperty.spec.js +30 -0
- package/test/reuse/ui5/control/getProperty.spec.js +30 -0
- package/test/reuse/ui5/control/getPropertyBinding.spec.js +30 -0
- package/test/reuse/ui5/control/test.control.conf.js +19 -0
- package/test/reuse/ui5/control/test.control.sauceLab.conf.js +30 -0
- package/test/reuse/ui5/date/fillRange.spec.js +53 -0
- package/test/reuse/ui5/date/pick.spec.js +136 -0
- package/test/reuse/ui5/date/pickRange.spec.js +143 -0
- package/test/reuse/ui5/date/test.date.conf.js +14 -0
- package/test/reuse/ui5/date/test.date.sauceLab.conf.js +26 -0
- package/test/reuse/ui5/element/getAllDisplayed.spec.js +71 -0
- package/test/reuse/ui5/element/getBindingValue.spec.js +78 -0
- package/test/reuse/ui5/element/getByChild.spec.js +124 -0
- package/test/reuse/ui5/element/getByParent.spec.js +134 -0
- package/test/reuse/ui5/element/getByText.spec.js +67 -0
- package/test/reuse/ui5/element/getDisplayed.spec.js +82 -0
- package/test/reuse/ui5/element/getId.spec.js +72 -0
- package/test/reuse/ui5/element/getPropertyValue.spec.js +91 -0
- package/test/reuse/ui5/element/highlight.spec.js +46 -0
- package/test/reuse/ui5/element/isVisible.spec.js +68 -0
- package/test/reuse/ui5/element/test.element.conf.js +22 -0
- package/test/reuse/ui5/element/test.element.sauceLab.conf.js +33 -0
- package/test/reuse/ui5/errorDialog/clickClose.spec.js +31 -0
- package/test/reuse/ui5/errorDialog/expectToBeVisible.spec.js +30 -0
- package/test/reuse/ui5/errorDialog/test.errorDialog.conf.js +13 -0
- package/test/reuse/ui5/errorDialog/test.errorDialog.sauceLab.conf.js +26 -0
- package/test/reuse/ui5/formatter/addRemoveLeadingZeros.spec.js +18 -0
- package/test/reuse/ui5/formatter/extractNumberFromString.spec.js +34 -0
- package/test/reuse/ui5/formatter/formatDate.spec.js +103 -0
- package/test/reuse/ui5/formatter/test.formatter.conf.js +14 -0
- package/test/reuse/ui5/formatter/test.formatter.sauceLab.conf.js +24 -0
- package/test/reuse/ui5/mockserver_qunit/Component.js +23 -0
- package/test/reuse/ui5/mockserver_qunit/LICENSE.txt +957 -0
- package/test/reuse/ui5/mockserver_qunit/NOTICE.txt +1 -0
- package/test/reuse/ui5/mockserver_qunit/controller/App.controller.js +37 -0
- package/test/reuse/ui5/mockserver_qunit/controller/BaseController.js +30 -0
- package/test/reuse/ui5/mockserver_qunit/controller/Home.controller.js +27 -0
- package/test/reuse/ui5/mockserver_qunit/controller/NotFound.controller.js +34 -0
- package/test/reuse/ui5/mockserver_qunit/controller/employee/Employee.controller.js +64 -0
- package/test/reuse/ui5/mockserver_qunit/controller/employee/EmployeeList.controller.js +22 -0
- package/test/reuse/ui5/mockserver_qunit/controller/employee/Resume.controller.js +83 -0
- package/test/reuse/ui5/mockserver_qunit/controller/employee/overview/EmployeeOverview.controller.js +11 -0
- package/test/reuse/ui5/mockserver_qunit/controller/employee/overview/EmployeeOverviewContent.controller.js +192 -0
- package/test/reuse/ui5/mockserver_qunit/i18n/i18n.properties +42 -0
- package/test/reuse/ui5/mockserver_qunit/index.html +21 -0
- package/test/reuse/ui5/mockserver_qunit/initMockServer.js +16 -0
- package/test/reuse/ui5/mockserver_qunit/localService/metadata.xml +61 -0
- package/test/reuse/ui5/mockserver_qunit/localService/mockdata/Employees.json +155 -0
- package/test/reuse/ui5/mockserver_qunit/localService/mockdata/Resumes.json +65 -0
- package/test/reuse/ui5/mockserver_qunit/localService/mockserver.js +146 -0
- package/test/reuse/ui5/mockserver_qunit/localService/mockserverLoadAllData.js +75 -0
- package/test/reuse/ui5/mockserver_qunit/manifest.json +169 -0
- package/test/reuse/ui5/mockserver_qunit/test/flpSandboxMockServer.html +63 -0
- package/test/reuse/ui5/mockserver_qunit/test/flpSandboxMockServerAllData.html +68 -0
- package/test/reuse/ui5/mockserver_qunit/test/qmate/ui/config.js +92 -0
- package/test/reuse/ui5/mockserver_qunit/test/qmate/ui/qunitExecution/specs/runQUnitTests.spec.js +14 -0
- package/test/reuse/ui5/mockserver_qunit/test/qmate/ui/testDisplayNotFound/data/setup.json +11 -0
- package/test/reuse/ui5/mockserver_qunit/test/qmate/ui/testDisplayNotFound/specs/testDisplayNotFound.spec.js +71 -0
- package/test/reuse/ui5/mockserver_qunit/test/qmate/ui/testShowEmployeeList/data/mock/Employees.json +204 -0
- package/test/reuse/ui5/mockserver_qunit/test/qmate/ui/testShowEmployeeList/data/mock/Resumes.json +114 -0
- package/test/reuse/ui5/mockserver_qunit/test/qmate/ui/testShowEmployeeList/data/setup.json +11 -0
- package/test/reuse/ui5/mockserver_qunit/test/qmate/ui/testShowEmployeeList/data/testShowEmployeeList.json +1 -0
- package/test/reuse/ui5/mockserver_qunit/test/qmate/ui/testShowEmployeeList/specs/testShowEmployeeList.spec.js +118 -0
- package/test/reuse/ui5/mockserver_qunit/test/qmate/ui/utils/constants.js +25 -0
- package/test/reuse/ui5/mockserver_qunit/test/qmate/ui/utils/mockDataMapper.js +23 -0
- package/test/reuse/ui5/mockserver_qunit/test/qmate/ui/utils/mockHelper.js +222 -0
- package/test/reuse/ui5/mockserver_qunit/test/unit/allTests.js +6 -0
- package/test/reuse/ui5/mockserver_qunit/test/unit/unitTests.qunit.html +38 -0
- package/test/reuse/ui5/mockserver_qunit/test/unit/utils/Conversions.js +13 -0
- package/test/reuse/ui5/mockserver_qunit/view/App.view.xml +9 -0
- package/test/reuse/ui5/mockserver_qunit/view/Home.view.xml +12 -0
- package/test/reuse/ui5/mockserver_qunit/view/NotFound.view.xml +11 -0
- package/test/reuse/ui5/mockserver_qunit/view/employee/Employee.view.xml +52 -0
- package/test/reuse/ui5/mockserver_qunit/view/employee/EmployeeList.view.xml +24 -0
- package/test/reuse/ui5/mockserver_qunit/view/employee/Resume.view.xml +35 -0
- package/test/reuse/ui5/mockserver_qunit/view/employee/ResumeHobbies.view.xml +3 -0
- package/test/reuse/ui5/mockserver_qunit/view/employee/ResumeNotes.view.xml +3 -0
- package/test/reuse/ui5/mockserver_qunit/view/employee/ResumeProjects.view.xml +3 -0
- package/test/reuse/ui5/mockserver_qunit/view/employee/overview/EmployeeOverview.view.xml +13 -0
- package/test/reuse/ui5/mockserver_qunit/view/employee/overview/EmployeeOverviewContent.view.xml +43 -0
- package/test/reuse/ui5/mockserver_qunit/view/employee/overview/EmployeeOverviewTop.view.xml +3 -0
- package/test/reuse/ui5/navigation/closePopups.spec.js +16 -0
- package/test/reuse/ui5/navigation/expectUnsupportedNavigationPopup.spec.js +81 -0
- package/test/reuse/ui5/navigation/navigateToApplication.spec.js +148 -0
- package/test/reuse/ui5/navigation/navigateToApplicationAndRetry.spec.js +153 -0
- package/test/reuse/ui5/navigation/navigateToApplicationWithQueryParams.spec.js +63 -0
- package/test/reuse/ui5/navigation/navigateToApplicationWithQueryParamsAndRetry.spec.js +64 -0
- package/test/reuse/ui5/navigation/navigateToSystemAndApplication.spec.js +45 -0
- package/test/reuse/ui5/navigation/navigateToSystemAndApplicationAndRetry.spec.js +43 -0
- package/test/reuse/ui5/navigation/test.navigation.conf.js +17 -0
- package/test/reuse/ui5/navigation/test.navigation.sauceLab.conf.js +33 -0
- package/test/reuse/ui5/navigation/test.navigation.static.conf.js +34 -0
- package/test/reuse/ui5/navigation/test.navigation.static.sauceLab.conf.js +41 -0
- package/test/reuse/ui5/navigation/website/main.css +36 -0
- package/test/reuse/ui5/navigation/website/main.html +50 -0
- package/test/reuse/ui5/navigationBar/clickBack.spec.js +38 -0
- package/test/reuse/ui5/navigationBar/clickUserIcon.spec.js +36 -0
- package/test/reuse/ui5/navigationBar/expectPageTitle.spec.js +22 -0
- package/test/reuse/ui5/navigationBar/expectShellHeader.spec.js +22 -0
- package/test/reuse/ui5/navigationBar/test.navigationBar.conf.js +17 -0
- package/test/reuse/ui5/navigationBar/test.navigationBar.sauceLab.conf.js +28 -0
- package/test/reuse/ui5/session/login.spec.js +78 -0
- package/test/reuse/ui5/session/loginFiori.spec.js +52 -0
- package/test/reuse/ui5/session/loginSapCloud.spec.js +51 -0
- package/test/reuse/ui5/session/logout.spec.js +48 -0
- package/test/reuse/ui5/session/switchUser.spec.js +48 -0
- package/test/reuse/ui5/session/test.session.conf.js +20 -0
- package/test/reuse/ui5/session/test.session.sauceLab.conf.js +29 -0
- package/test/reuse/ui5/table/clickSettingsButton.spec.js +58 -0
- package/test/reuse/ui5/table/sortColumnAscending.spec.js +84 -0
- package/test/reuse/ui5/table/sortColumnDescending.spec.js +84 -0
- package/test/reuse/ui5/table/test.table.conf.js +14 -0
- package/test/reuse/ui5/table/test.table.sauceLab.conf.js +25 -0
- package/test/reuse/ui5/table/test.table.sauceLab.tunnel.conf.js +25 -0
- package/test/reuse/ui5/userInteraction/clear.spec.js +75 -0
- package/test/reuse/ui5/userInteraction/clearAndFill.spec.js +157 -0
- package/test/reuse/ui5/userInteraction/clearAndFillAndRetry.spec.js +132 -0
- package/test/reuse/ui5/userInteraction/clearAndFillSmartFieldInput.spec.js +73 -0
- package/test/reuse/ui5/userInteraction/clearAndRetry.spec.js +57 -0
- package/test/reuse/ui5/userInteraction/click.spec.js +73 -0
- package/test/reuse/ui5/userInteraction/clickAndRetry.spec.js +52 -0
- package/test/reuse/ui5/userInteraction/clickSelectArrow.spec.js +87 -0
- package/test/reuse/ui5/userInteraction/clickSelectArrowAndRetry.spec.js +147 -0
- package/test/reuse/ui5/userInteraction/clickTab.spec.js +59 -0
- package/test/reuse/ui5/userInteraction/doubleClick.spec.js +73 -0
- package/test/reuse/ui5/userInteraction/dragAndDrop.spec.js +34 -0
- package/test/reuse/ui5/userInteraction/fill.spec.js +114 -0
- package/test/reuse/ui5/userInteraction/fillAndRetry.spec.js +120 -0
- package/test/reuse/ui5/userInteraction/mouseOverElement.spec.js +55 -0
- package/test/reuse/ui5/userInteraction/openF4Help.spec.js +56 -0
- package/test/reuse/ui5/userInteraction/rightClick.spec.js +72 -0
- package/test/reuse/ui5/userInteraction/scrollToElement.spec.js +89 -0
- package/test/reuse/ui5/userInteraction/searchFor.spec.js +155 -0
- package/test/reuse/ui5/userInteraction/selectBox.spec.js +128 -0
- package/test/reuse/ui5/userInteraction/selectCombobox.spec.js +115 -0
- package/test/reuse/ui5/userInteraction/selectMultiComboBox.spec.js +155 -0
- package/test/reuse/ui5/userInteraction/test.userInteraction.conf.js +35 -0
- package/test/reuse/ui5/userInteraction/test.userInteraction.sauceLab.conf.js +46 -0
- package/test/reuse/util/browser/back.spec.js +32 -0
- package/test/reuse/util/browser/clearBrowser.spec.js +35 -0
- package/test/reuse/util/browser/executeScript.spec.js +49 -0
- package/test/reuse/util/browser/getBaseUrl.spec.js +13 -0
- package/test/reuse/util/browser/getBrowserName.spec.js +18 -0
- package/test/reuse/util/browser/getCurrentUrl.spec.js +34 -0
- package/test/reuse/util/browser/getCurrentWindow.spec.js +42 -0
- package/test/reuse/util/browser/getUI5Version.spec.js +31 -0
- package/test/reuse/util/browser/logCurrentUrl.spec.js +23 -0
- package/test/reuse/util/browser/refresh.spec.js +52 -0
- package/test/reuse/util/browser/setBaseUrl.spec.js +13 -0
- package/test/reuse/util/browser/switchToDefaultContent.spec.js +34 -0
- package/test/reuse/util/browser/switchToIframe.spec.js +29 -0
- package/test/reuse/util/browser/switchToNewWindow.spec.js +142 -0
- package/test/reuse/util/browser/switchToWindow.spec.js +57 -0
- package/test/reuse/util/browser/test.browser.conf.js +27 -0
- package/test/reuse/util/data/data/test.json +3 -0
- package/test/reuse/util/data/data/test.secure.json +11 -0
- package/test/reuse/util/data/decrypt.spec.js +15 -0
- package/test/reuse/util/data/getData.spec.js +15 -0
- package/test/reuse/util/data/getSecureData.spec.js +57 -0
- package/test/reuse/util/data/test.data.conf.js +22 -0
- package/test/reuse/util/file/file.spec.js +90 -0
- package/test/reuse/util/file/pdfParser.spec.js +55 -0
- package/test/reuse/util/file/test.file.conf.js +15 -0
- package/test/reuse/util/file/testFiles/sample.pdf +198 -0
- package/test/reuse/util/file/testFiles/test.txt +5 -0
- package/test/reuse/util/file/testFiles/test2.txt +2 -0
- package/test/reuse/util/formatter/addRemoveLeadingZeros.spec.js +38 -0
- package/test/reuse/util/formatter/extractNumberFromString.spec.js +67 -0
- package/test/reuse/util/formatter/formatDate.spec.js +150 -0
- package/test/reuse/util/formatter/sliceStringAfter.spec.js +62 -0
- package/test/reuse/util/formatter/sliceStringAt.spec.js +62 -0
- package/test/reuse/util/formatter/stringifyJSON.spec.js +24 -0
- package/test/reuse/util/formatter/test.formatter.conf.js +20 -0
- package/test/reuse/util/formatter/trimString.spec.js +37 -0
- package/tsconfig.json +26 -0
|
@@ -0,0 +1,665 @@
|
|
|
1
|
+
/* eslint-disable no-return-await */
|
|
2
|
+
/* eslint-disable no-useless-escape */
|
|
3
|
+
// Note: functions to be executed in browser need to be stringified (fn.toString()).
|
|
4
|
+
// E.g. `await lib.mockServerActionInBrowser(function (mockserver, method, fnAfterCallbackAsString, oParams, done){...})`
|
|
5
|
+
// It is not required to check the type (function or string) - toString() function can be applied to a string too.
|
|
6
|
+
"use strict";
|
|
7
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Mockserver = void 0;
|
|
18
|
+
/**
|
|
19
|
+
* @class mockserver
|
|
20
|
+
* @memberof ui5
|
|
21
|
+
*/
|
|
22
|
+
class Mockserver {
|
|
23
|
+
constructor() {
|
|
24
|
+
this.lib = require("../../../scripts/hooks/utils/lib.js");
|
|
25
|
+
}
|
|
26
|
+
// =================================== MAIN ===================================
|
|
27
|
+
/**
|
|
28
|
+
* @function waitForUi5ApplicationLoad
|
|
29
|
+
* @memberOf ui5.mockserver
|
|
30
|
+
* @description Waits for the UI5 framework to load and makes sure XHR request finished und busy indicators are not visible anymore.
|
|
31
|
+
* @param {Integer} interval - The intervals to use when waiting UI5 to load.
|
|
32
|
+
* @example await ui5.mockserver.waitForUi5ApplicationLoad(100);
|
|
33
|
+
*/
|
|
34
|
+
waitForUi5ApplicationLoad(interval = 100) {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
yield this.lib.waitUI5ToStabilize(); // Note: interval is hardcoded in lib.js
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
;
|
|
40
|
+
/**
|
|
41
|
+
* @function interactWithMockServer
|
|
42
|
+
* @memberOf ui5.mockserver
|
|
43
|
+
* @description Execute client script function to enable interaction with mockserver instance [you can write code in ui5 app context]
|
|
44
|
+
* @param {String} mockServerPath - The full path to your mockserver instance
|
|
45
|
+
* @param {String | Object} fnCallback - The client script function that you can use to interact with your mockserver instance.
|
|
46
|
+
* [Caution] The first and last parameter is reserved (1st param is the mockserver instance and last parameter the promise resolve function - done)
|
|
47
|
+
* @param {String} oParams - Additional parameters you would like to inject in your client script function
|
|
48
|
+
* @example await ui5.mockserver.interactWithMockServer("path/to/project/localService/main/mockserver", fnCallback, oParams);
|
|
49
|
+
*/
|
|
50
|
+
interactWithMockServer(mockServerPath, fnCallback, oParams) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
// fnCallback-> function(mockServerInstance, oParams, done){...}
|
|
53
|
+
yield this.lib.mockServerActionInBrowser(fnCallback, mockServerPath, oParams);
|
|
54
|
+
return yield ui5.mockserver.waitForUi5ApplicationLoad();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
;
|
|
58
|
+
/**
|
|
59
|
+
* @function attachFunctionBefore
|
|
60
|
+
* @memberOf ui5.mockserver
|
|
61
|
+
* @description Attaches a callback function in mockserver attachBefore event to be executed
|
|
62
|
+
* @param {String} method - The attachAfter http method [GET or POST].
|
|
63
|
+
* @param {String} mockServerPath - The full path to your mockserver file [make sure you implemented getMockServer method so the mockserver instance can be consumed].
|
|
64
|
+
* @param {String | Object} fnBeforeCallback - The callback function to be used in the native attachBefore method as described (https://sapui5.hana.ondemand.com/#/api/sap.ui.core.ui5.mockserver%23methods/Summary)
|
|
65
|
+
* @param {Object} oParams - Additional parameters you would like to inject in your client script function
|
|
66
|
+
* @example await ui5.mockserver.attachFunctionBefore("GET", "path/to/project/localService/main/mockserver", fnBeforeCallback, oParams);
|
|
67
|
+
*/
|
|
68
|
+
attachFunctionBefore(method, mockServerPath, fnBeforeCallback, oParams) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const fnBeforeCallbackString = fnBeforeCallback.toString();
|
|
71
|
+
yield this.lib.mockServerActionInBrowser(function (mockserver, method, fnBeforeCallbackString, oParams, done) {
|
|
72
|
+
const mockServerInst = mockserver.getMockServer();
|
|
73
|
+
if (!mockServerInst) {
|
|
74
|
+
console.error("Mockserver not yet initialized or method getMockServer is missing");
|
|
75
|
+
done();
|
|
76
|
+
}
|
|
77
|
+
const beforeCallback = "beforeCallback = " + fnBeforeCallbackString;
|
|
78
|
+
const fnFunction = eval(beforeCallback);
|
|
79
|
+
mockServerInst.attachBefore(method, fnFunction);
|
|
80
|
+
done();
|
|
81
|
+
}, mockServerPath, method, fnBeforeCallbackString, oParams);
|
|
82
|
+
return yield ui5.mockserver.waitForUi5ApplicationLoad();
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
;
|
|
86
|
+
/**
|
|
87
|
+
* @function attachFunctionAfter
|
|
88
|
+
* @memberOf ui5.mockserver
|
|
89
|
+
* @description Attaches a callback function in mockserver attachAfter event to be executed
|
|
90
|
+
* @param {String} method - The attachAfter http method [GET or POST].
|
|
91
|
+
* @param {String} mockServerPath - The full path to your mockserver file [make sure you implemented getMockServer method so the mockserver instance can be consumed].
|
|
92
|
+
* @param {String|Object} fnAfterCallback - The callback function to be used in the native attachAfter method as described (https://sapui5.hana.ondemand.com/#/api/sap.ui.core.ui5.mockserver%23methods/Summary)
|
|
93
|
+
* @param {Object} oParams - Additional parameters you would like to inject in your client script function
|
|
94
|
+
* @example await ui5.mockserver.attachFunctionAfter("GET", "path/to/project/localService/main/mockserver", fnAfterCallback);
|
|
95
|
+
*/
|
|
96
|
+
attachFunctionAfter(method, mockServerPath, fnAfterCallback, oParams) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
const fnAfterCallbackString = fnAfterCallback.toString();
|
|
99
|
+
yield this.lib.mockServerActionInBrowser(function (mockserver, method, fnAfterCallbackString, oParams, done) {
|
|
100
|
+
var mockServerInst = mockserver.getMockServer();
|
|
101
|
+
if (!mockServerInst) {
|
|
102
|
+
console.error("Mockserver not yet initialized or method getMockServer is missing");
|
|
103
|
+
done();
|
|
104
|
+
}
|
|
105
|
+
var afterCallback = "afterCallback = " + fnAfterCallbackString;
|
|
106
|
+
var fnFunction = eval(afterCallback);
|
|
107
|
+
mockServerInst.attachAfter(method, fnFunction);
|
|
108
|
+
done();
|
|
109
|
+
}, mockServerPath, method, fnAfterCallbackString, oParams);
|
|
110
|
+
return yield ui5.mockserver.waitForUi5ApplicationLoad();
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
;
|
|
114
|
+
/**
|
|
115
|
+
* @function addNewRequest
|
|
116
|
+
* @memberOf ui5.mockserver
|
|
117
|
+
* @description Adds new mock request
|
|
118
|
+
* @param {String} method - The http method [GET,POST..].
|
|
119
|
+
* @param {String} mockServerPath - The full path to your mockserver file [make sure you implemented getMockServer method in this file to return the mockserver instance].
|
|
120
|
+
* @param {String} urlPathRegex - The url path regex to filter the requests
|
|
121
|
+
* @param {String} responseJsonPath - The json object or the path to your json file to be used as response [use relative path from the html page started].
|
|
122
|
+
* @param {Integer} returnCode - The http response code to simulate for this mock request.
|
|
123
|
+
* @param {Boolean} isText - If true then content type is text/plain otherwise application/json.
|
|
124
|
+
* @param {String} responseMessages - Mocks the gw sap-message response messages [Don't forget to stringify your json before: JSON.stringify(msg)]
|
|
125
|
+
* @param {String} responseLocation - Mocks the location response messages header
|
|
126
|
+
* @example await ui5.mockserver.addNewRequest("GET","path/to/project/localService/main/mockserver", "*.Headers.*", "path/to/project/localService/main/mockdata/test.json", 200, true, JSON.stringify(msg));
|
|
127
|
+
*/
|
|
128
|
+
addNewRequest(method, mockServerPath, urlPathRegex, responseJsonPath, returnCode, isText, responseMessages, responseLocation) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
var responseData = responseJsonPath;
|
|
131
|
+
try {
|
|
132
|
+
if (typeof responseJsonPath !== "string" && typeof responseJsonPath === "object") {
|
|
133
|
+
responseData = JSON.stringify(responseJsonPath);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
throw new Error("Something went wrong with the conversion" + error);
|
|
138
|
+
}
|
|
139
|
+
// If undefined dont add any messages
|
|
140
|
+
if (!responseMessages) {
|
|
141
|
+
responseMessages = false;
|
|
142
|
+
}
|
|
143
|
+
// If undefined dont add any location
|
|
144
|
+
if (!responseLocation) {
|
|
145
|
+
responseLocation = false;
|
|
146
|
+
}
|
|
147
|
+
yield this.lib.mockServerActionInBrowser(function (mockserver, method, urlPathRegex, responseJsonPath, responseMessages, responseLocation, returnCode, isText, done) {
|
|
148
|
+
var mockServerInst = mockserver.getMockServer();
|
|
149
|
+
if (!mockServerInst)
|
|
150
|
+
throw new Error("Mockserver not yet initialized or method getMockServer is missing");
|
|
151
|
+
var fnResponse = function (oXhr) {
|
|
152
|
+
// If connection close dont redo response
|
|
153
|
+
if (oXhr.readyState && oXhr.readyState === 4)
|
|
154
|
+
return true;
|
|
155
|
+
var oData = null;
|
|
156
|
+
try {
|
|
157
|
+
if (isText && isText !== "false") {
|
|
158
|
+
oData = responseJsonPath;
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
oData = JSON.parse(responseJsonPath);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
catch (e) {
|
|
165
|
+
if (typeof responseJsonPath === "string" && !RegExp(".?([^\/\s]+\/)(.*)").test(responseJsonPath)) {
|
|
166
|
+
oData = responseJsonPath;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
if (isText && isText !== "false") {
|
|
170
|
+
// @ts-ignore
|
|
171
|
+
var oResponse = jQuery.sap.sjax({
|
|
172
|
+
url: responseJsonPath,
|
|
173
|
+
dataType: "text"
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
// @ts-ignore
|
|
178
|
+
oResponse = jQuery.sap.sjax({
|
|
179
|
+
url: responseJsonPath,
|
|
180
|
+
dataType: "json"
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
if (oResponse.success) {
|
|
184
|
+
if (isText && isText !== "false" && oResponse.data) {
|
|
185
|
+
oData = oResponse.data;
|
|
186
|
+
}
|
|
187
|
+
else if (oResponse.data.d) {
|
|
188
|
+
if (oResponse.data.d.results) {
|
|
189
|
+
oData = oResponse.data;
|
|
190
|
+
}
|
|
191
|
+
else if (oResponse.data.d) {
|
|
192
|
+
// Function Import or single data
|
|
193
|
+
oData = oResponse.data;
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
console.error("The mock data are invalid");
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
if (Array.isArray(oResponse.data)) {
|
|
201
|
+
oData = oResponse.data;
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
console.error("The mock data could not be loaded due to wrong format!");
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
var resHeader = {};
|
|
211
|
+
resHeader["content-encoding"] = "identity";
|
|
212
|
+
// @ts-ignore
|
|
213
|
+
let parsedReturnCode = parseInt(returnCode);
|
|
214
|
+
if (isNaN(parsedReturnCode)) {
|
|
215
|
+
parsedReturnCode = 200;
|
|
216
|
+
}
|
|
217
|
+
if (isText && isText !== "false") {
|
|
218
|
+
if (responseMessages && responseMessages !== "false") {
|
|
219
|
+
resHeader["sap-message"] = responseMessages;
|
|
220
|
+
}
|
|
221
|
+
if (responseLocation && responseLocation !== "false") {
|
|
222
|
+
resHeader["location"] = responseLocation;
|
|
223
|
+
}
|
|
224
|
+
resHeader["Content-Type"] = "text/plain;charset=utf-8";
|
|
225
|
+
oXhr.respond(parsedReturnCode, resHeader, oData);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
if (responseMessages && responseMessages !== "false") {
|
|
229
|
+
resHeader["sap-message"] = responseMessages;
|
|
230
|
+
}
|
|
231
|
+
if (responseLocation && responseLocation !== "false") {
|
|
232
|
+
resHeader["location"] = responseLocation;
|
|
233
|
+
}
|
|
234
|
+
resHeader["Content-Type"] = "application/json;charset=utf-8";
|
|
235
|
+
oXhr.respond(parsedReturnCode, resHeader, JSON.stringify(oData));
|
|
236
|
+
}
|
|
237
|
+
return true;
|
|
238
|
+
};
|
|
239
|
+
var aRequests = mockServerInst.getRequests();
|
|
240
|
+
const isOverride = false;
|
|
241
|
+
if (!isOverride) {
|
|
242
|
+
if (!urlPathRegex) {
|
|
243
|
+
console.error("path regex wasn't provided");
|
|
244
|
+
done();
|
|
245
|
+
}
|
|
246
|
+
//Remove regexp slashes so we read them if needed
|
|
247
|
+
var urlPathEscRegex = urlPathRegex.substring(1, urlPathRegex.length - 1);
|
|
248
|
+
aRequests.push({
|
|
249
|
+
method: method,
|
|
250
|
+
path: new RegExp(urlPathEscRegex),
|
|
251
|
+
response: fnResponse
|
|
252
|
+
});
|
|
253
|
+
mockServerInst.setRequests(aRequests);
|
|
254
|
+
}
|
|
255
|
+
done();
|
|
256
|
+
}, mockServerPath, method, urlPathRegex, responseData, responseMessages, responseLocation, returnCode, isText);
|
|
257
|
+
return yield ui5.mockserver.waitForUi5ApplicationLoad();
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
;
|
|
261
|
+
/**
|
|
262
|
+
* @function removeRequest
|
|
263
|
+
* @memberOf ui5.mockserver
|
|
264
|
+
* @description Removes request mock [Doesn't work currently - Mockserver bug]
|
|
265
|
+
* @param {String} method - The http method [GET,POST..].
|
|
266
|
+
* @param {String} mockServerPath - The full path to your mockserver file [make sure you implemented getMockServer method in this file to return the mockserver instance].
|
|
267
|
+
* @param {String} urlPathRegex - The url path regex to filter the requests
|
|
268
|
+
* @example await ui5.mockserver.removeRequest("GET","path/to/project/localService/main/mockserver", "*.Headers.*");
|
|
269
|
+
*/
|
|
270
|
+
removeRequest(method, mockServerPath, urlPathRegex) {
|
|
271
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
272
|
+
yield this.lib.mockServerActionInBrowser(function (mockserver, method, urlPathRegex, done) {
|
|
273
|
+
var mockServerInst = mockserver.getMockServer();
|
|
274
|
+
if (!mockServerInst) {
|
|
275
|
+
console.error("Mockserver not yet initialized or method getMockServer is missing");
|
|
276
|
+
done();
|
|
277
|
+
}
|
|
278
|
+
var aExistingRequests = mockServerInst.getRequests();
|
|
279
|
+
var aRequests = [].concat(aExistingRequests);
|
|
280
|
+
var elemDeleted = false;
|
|
281
|
+
if (urlPathRegex && method && aExistingRequests) {
|
|
282
|
+
//var urlRegEsc = RegExp(urlPathRegex).source.replace(/\\/g, "");
|
|
283
|
+
for (let index = 0; index < aExistingRequests.length; index++) {
|
|
284
|
+
const mockRequest = aExistingRequests[index];
|
|
285
|
+
var regExpPath = mockRequest.path.toString();
|
|
286
|
+
if (mockRequest.method === method && urlPathRegex === regExpPath) {
|
|
287
|
+
aRequests.splice(index, 1);
|
|
288
|
+
elemDeleted = true;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
mockServerInst.setRequests(aRequests);
|
|
293
|
+
done(elemDeleted);
|
|
294
|
+
}, mockServerPath, method, urlPathRegex);
|
|
295
|
+
return yield ui5.mockserver.waitForUi5ApplicationLoad();
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
;
|
|
299
|
+
/**
|
|
300
|
+
* @function addOrOverrideRequest
|
|
301
|
+
* @memberOf ui5.mockserver
|
|
302
|
+
* @description Adds new or overrides an existing mock request
|
|
303
|
+
* @param {String} method - The http method [GET,POST..].
|
|
304
|
+
* @param {String} mockServerPath - The full path to your mockserver file [make sure you implemented getMockServer method in this file to return the mockserver instance].
|
|
305
|
+
* @param {String} urlPathRegex - The url path regex to filter the requests
|
|
306
|
+
* @param {String} responseJsonPath - The json object or the path to your json file to be used as response [use relative path from the html page started].
|
|
307
|
+
* @param {Integer} returnCode - The http response code to simulate for this mock request.
|
|
308
|
+
* @param {Boolean} isText - If true then content type is text/plain otherwise application/json.
|
|
309
|
+
* @param {String} responseMessages - Mocks the gw sap-message response messages [Don't forget to stringify your json before: JSON.stringify(msg)]
|
|
310
|
+
* @param {String} responseLocation - Mocks the location response messages header
|
|
311
|
+
* @example await ui5.mockserver.addOrOverrideRequest("GET","path/to/project/localService/main/mockserver", "*.Headers.*", "path/to/project/localService/main/mockdata/test.json", 200, true, JSON.stringify(msg));
|
|
312
|
+
*/
|
|
313
|
+
addOrOverrideRequest(method, mockServerPath, urlPathRegex, responseJsonPath, returnCode, isText, responseMessages, responseLocation) {
|
|
314
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
315
|
+
var responseData = responseJsonPath;
|
|
316
|
+
try {
|
|
317
|
+
if (typeof responseJsonPath !== "string" && typeof responseJsonPath === "object") {
|
|
318
|
+
responseData = JSON.stringify(responseJsonPath);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
catch (error) {
|
|
322
|
+
throw new Error("Something went wrong with the conversion" + error);
|
|
323
|
+
}
|
|
324
|
+
// If undefined dont add any messages
|
|
325
|
+
if (!responseMessages) {
|
|
326
|
+
responseMessages = false;
|
|
327
|
+
}
|
|
328
|
+
// If undefined dont add any location
|
|
329
|
+
if (!responseLocation) {
|
|
330
|
+
responseLocation = false;
|
|
331
|
+
}
|
|
332
|
+
yield this.lib.mockServerActionInBrowser(function (mockserver, method, urlPathRegex, responseJsonPath, responseMessages, responseLocation, returnCode, isText, done) {
|
|
333
|
+
var mockServerInst = mockserver.getMockServer();
|
|
334
|
+
if (!mockServerInst)
|
|
335
|
+
throw new Error("Mockserver not yet initialized or method getMockServer is missing");
|
|
336
|
+
var fnResponse = function (oXhr) {
|
|
337
|
+
// If connection close dont redo response
|
|
338
|
+
if (oXhr.readyState && oXhr.readyState === 4)
|
|
339
|
+
return true;
|
|
340
|
+
var oData = null;
|
|
341
|
+
try {
|
|
342
|
+
if (isText && isText !== "false") {
|
|
343
|
+
oData = responseJsonPath;
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
oData = JSON.parse(responseJsonPath);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
catch (e) {
|
|
350
|
+
if (typeof responseJsonPath === "string" && !RegExp(".?([^\/\s]+\/)(.*)").test(responseJsonPath)) {
|
|
351
|
+
oData = responseJsonPath;
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
if (isText && isText !== "false") {
|
|
355
|
+
// @ts-ignore
|
|
356
|
+
var oResponse = jQuery.sap.sjax({
|
|
357
|
+
url: responseJsonPath,
|
|
358
|
+
dataType: "text"
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
// @ts-ignore
|
|
363
|
+
oResponse = jQuery.sap.sjax({
|
|
364
|
+
url: responseJsonPath,
|
|
365
|
+
dataType: "json"
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
if (oResponse.success) {
|
|
369
|
+
if (isText && isText !== "false" && oResponse.data) {
|
|
370
|
+
oData = oResponse.data;
|
|
371
|
+
}
|
|
372
|
+
else if (oResponse.data.d) {
|
|
373
|
+
if (oResponse.data.d.results) {
|
|
374
|
+
oData = oResponse.data;
|
|
375
|
+
}
|
|
376
|
+
else if (oResponse.data.d) {
|
|
377
|
+
// Function Import or single data
|
|
378
|
+
oData = oResponse.data;
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
console.error("The mock data are invalid");
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
if (Array.isArray(oResponse.data)) {
|
|
386
|
+
oData = oResponse.data;
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
console.error("The mock data could not be loaded due to wrong format!");
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
var resHeader = {};
|
|
396
|
+
resHeader["content-encoding"] = "identity";
|
|
397
|
+
let parsedReturnCode = parseInt(returnCode);
|
|
398
|
+
if (isNaN(parsedReturnCode)) {
|
|
399
|
+
parsedReturnCode = 200;
|
|
400
|
+
}
|
|
401
|
+
if (isText && isText !== "false") {
|
|
402
|
+
if (responseMessages && responseMessages !== "false") {
|
|
403
|
+
resHeader["sap-message"] = responseMessages;
|
|
404
|
+
}
|
|
405
|
+
if (responseLocation && responseLocation !== "false") {
|
|
406
|
+
resHeader["location"] = responseLocation;
|
|
407
|
+
}
|
|
408
|
+
resHeader["Content-Type"] = "text/plain;charset=utf-8";
|
|
409
|
+
oXhr.respond(parsedReturnCode, resHeader, oData);
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
if (responseMessages && responseMessages !== "false") {
|
|
413
|
+
resHeader["sap-message"] = responseMessages;
|
|
414
|
+
}
|
|
415
|
+
if (responseLocation && responseLocation !== "false") {
|
|
416
|
+
resHeader["location"] = responseLocation;
|
|
417
|
+
}
|
|
418
|
+
resHeader["Content-Type"] = "application/json;charset=utf-8";
|
|
419
|
+
oXhr.respond(parsedReturnCode, resHeader, JSON.stringify(oData));
|
|
420
|
+
}
|
|
421
|
+
return true;
|
|
422
|
+
};
|
|
423
|
+
var aRequests = mockServerInst.getRequests();
|
|
424
|
+
const isOverride = false;
|
|
425
|
+
if (!isOverride) {
|
|
426
|
+
if (!urlPathRegex) {
|
|
427
|
+
console.error("path regex wasnt provided");
|
|
428
|
+
done();
|
|
429
|
+
}
|
|
430
|
+
//Remove regexp slashes so we read them if needed
|
|
431
|
+
var urlPathEscRegex = urlPathRegex.substring(1, urlPathRegex.length - 1);
|
|
432
|
+
aRequests.push({
|
|
433
|
+
method: method,
|
|
434
|
+
path: new RegExp(urlPathEscRegex),
|
|
435
|
+
response: fnResponse
|
|
436
|
+
});
|
|
437
|
+
mockServerInst.setRequests(aRequests);
|
|
438
|
+
}
|
|
439
|
+
done();
|
|
440
|
+
}, mockServerPath, method, urlPathRegex, responseData, responseMessages, responseLocation, returnCode, isText);
|
|
441
|
+
return yield ui5.mockserver.waitForUi5ApplicationLoad();
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
;
|
|
445
|
+
/**
|
|
446
|
+
* @function startMockServer
|
|
447
|
+
* @memberOf ui5.mockserver
|
|
448
|
+
* @description (Re-)Starts mock server instance
|
|
449
|
+
* @param {String} mockServerPath - The full path to your mockserver file [make sure you implemented getMockServer method in this file to return the mockserver instance].
|
|
450
|
+
* @example await ui5.mockserver.startMockServer("path/to/project/localService/main/mockserver");
|
|
451
|
+
*/
|
|
452
|
+
startMockServer(mockServerPath) {
|
|
453
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
454
|
+
yield this.lib.mockServerActionInBrowser(function (mockserver, done) {
|
|
455
|
+
var mockServerInst = mockserver.getMockServer();
|
|
456
|
+
if (!mockServerInst) {
|
|
457
|
+
console.error("Mockserver not yet initialized or method getMockServer is missing");
|
|
458
|
+
done();
|
|
459
|
+
}
|
|
460
|
+
mockServerInst.start();
|
|
461
|
+
done();
|
|
462
|
+
}, mockServerPath);
|
|
463
|
+
return yield ui5.mockserver.waitForUi5ApplicationLoad();
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
;
|
|
467
|
+
/**
|
|
468
|
+
* @function initMockServer
|
|
469
|
+
* @memberOf ui5.mockserver
|
|
470
|
+
* @description Initializes the provide mockserver instance on the fly
|
|
471
|
+
* @param {String} mockServerPath - The full path to your mockserver file [make sure you implemented getMockServer method in this file to return the mockserver instance].
|
|
472
|
+
* @param {String} mockServerOptions - The mock server options
|
|
473
|
+
* @example await ui5.mockserver.initMockServer("path/to/project/localService/main/mockserver", mockServerOptions);
|
|
474
|
+
*/
|
|
475
|
+
initMockServer(mockServerPath, mockServerOptions) {
|
|
476
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
477
|
+
var mockServerOpts = JSON.stringify(mockServerOptions);
|
|
478
|
+
return yield this.lib.mockServerActionInBrowser(function (mockserver, mockServerOpts, done) {
|
|
479
|
+
if (!mockserver) {
|
|
480
|
+
console.error("Mockserver file not yet loaded or is missing");
|
|
481
|
+
done();
|
|
482
|
+
}
|
|
483
|
+
mockserver.init(JSON.parse(mockServerOpts)).catch(function (oError) {
|
|
484
|
+
// load MessageBox only when needed as it otherwise bypasses the preload of sap.m
|
|
485
|
+
// eslint-disable-next-line no-undef
|
|
486
|
+
sap.ui.require(["sap/m/MessageBox"], function (MessageBox) {
|
|
487
|
+
MessageBox.error(oError.message);
|
|
488
|
+
});
|
|
489
|
+
}).finally(function () {
|
|
490
|
+
// initialize the embedded component on the HTML page
|
|
491
|
+
// eslint-disable-next-line no-undef
|
|
492
|
+
sap.ui.require(["sap/ui/core/ComponentSupport"]);
|
|
493
|
+
done();
|
|
494
|
+
});
|
|
495
|
+
}, mockServerPath, mockServerOpts);
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
;
|
|
499
|
+
/**
|
|
500
|
+
* @function initApplication
|
|
501
|
+
* @memberOf ui5.mockserver
|
|
502
|
+
* @description Initializes the application [Used in the beggining of script, once the mockserver is fully initialized and request mocking is done]
|
|
503
|
+
* @param {String} mockServerPath - The full path to your mockserver file [make sure you implemented getMockServer method in this file to return the mockserver instance].
|
|
504
|
+
* @example await ui5.mockserver.initApplication("path/to/project/localService/main/mockserver");
|
|
505
|
+
*/
|
|
506
|
+
initApplication(mockServerPath) {
|
|
507
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
508
|
+
yield this.lib.mockServerActionInBrowser(function (mockserver, done) {
|
|
509
|
+
if (!mockserver) {
|
|
510
|
+
console.error("Mockserver file not yet loaded or is missing");
|
|
511
|
+
done();
|
|
512
|
+
}
|
|
513
|
+
// eslint-disable-next-line no-undef
|
|
514
|
+
sap.ushell.Container.createRenderer().placeAt("content");
|
|
515
|
+
done();
|
|
516
|
+
}, mockServerPath);
|
|
517
|
+
return yield ui5.mockserver.waitForUi5ApplicationLoad();
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
;
|
|
521
|
+
/**
|
|
522
|
+
* @function stopMockServer
|
|
523
|
+
* @memberOf ui5.mockserver
|
|
524
|
+
* @description Stops the mockserver instance
|
|
525
|
+
* @param {String} mockServerPath - The full path to your mockserver file [make sure you implemented getMockServer method in this file to return the mockserver instance].
|
|
526
|
+
* @example await ui5.mockserver.stopMockServer("path/to/project/localService/main/mockserver");
|
|
527
|
+
*/
|
|
528
|
+
stopMockServer(mockServerPath) {
|
|
529
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
530
|
+
return yield this.lib.mockServerActionInBrowser(function (mockserver, done) {
|
|
531
|
+
var mockServerInst = mockserver.getMockServer();
|
|
532
|
+
if (!mockServerInst) {
|
|
533
|
+
console.error("Mockserver not yet initialized or method getMockServer is missing");
|
|
534
|
+
done();
|
|
535
|
+
}
|
|
536
|
+
mockServerInst.stop();
|
|
537
|
+
done();
|
|
538
|
+
}, mockServerPath);
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
;
|
|
542
|
+
/**
|
|
543
|
+
* @function loadMockDataFile
|
|
544
|
+
* @memberOf ui5.mockserver
|
|
545
|
+
* @description Loads a mock data file
|
|
546
|
+
* @param {String} filePath - The full path to your mockserver file [make sure you implemented getMockServer method in this file to return the mockserver instance].
|
|
547
|
+
* @param {Boolean} isText - If true then content type is text/plain otherwise application/json.
|
|
548
|
+
* @returns {String} The json object
|
|
549
|
+
* @example await ui5.mockserver.loadMockDataFile("path/to/project/mockData/myData.json", true);
|
|
550
|
+
*/
|
|
551
|
+
loadMockDataFile(filePath, isText) {
|
|
552
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
553
|
+
return yield this.lib.loadMockData(filePath, isText);
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
;
|
|
557
|
+
/**
|
|
558
|
+
* @function getEntitySetData
|
|
559
|
+
* @memberOf ui5.mockserver
|
|
560
|
+
* @description Retrieves entity data
|
|
561
|
+
* @param {String} mockServerPath - The full path to your mockserver file [make sure you implemented getMockServer method in this file to return the mockserver instance].
|
|
562
|
+
* @param {String} entitySetName - The entity set name
|
|
563
|
+
* @returns {Array} An array of json objects
|
|
564
|
+
* @example await ui5.mockserver.getEntitySetData("path/to/project/localService/main/mockserver", "Headers");
|
|
565
|
+
*/
|
|
566
|
+
getEntitySetData(mockServerPath, entitySetName) {
|
|
567
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
568
|
+
return yield this.lib.mockServerActionInBrowser(function (mockserver, entitySetName, done) {
|
|
569
|
+
var mockServerInst = mockserver.getMockServer();
|
|
570
|
+
if (!mockServerInst) {
|
|
571
|
+
console.error("Mockserver not yet initialized or method getMockServer is missing");
|
|
572
|
+
done();
|
|
573
|
+
}
|
|
574
|
+
const oData = mockServerInst.getEntitySetData(entitySetName);
|
|
575
|
+
done(oData);
|
|
576
|
+
}, mockServerPath, entitySetName);
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
;
|
|
580
|
+
/**
|
|
581
|
+
* @function setEntitySetData
|
|
582
|
+
* @memberOf ui5.mockserver
|
|
583
|
+
* @description Override entity data entries
|
|
584
|
+
* @param {String} mockServerPath - The full path to your mockserver file [make sure you implemented getMockServer method in this file to return the mockserver instance].
|
|
585
|
+
* @param {String} entitySetName - The entity name
|
|
586
|
+
* @param {String} entries - The json object to be used as data to be inserted [use relative path from the html page started].
|
|
587
|
+
* @example await ui5.mockserver.setEntitySetData("path/to/project/localService/main/mockserver", "Headers", entries);
|
|
588
|
+
*/
|
|
589
|
+
setEntitySetData(mockServerPath, entitySetName, entries) {
|
|
590
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
591
|
+
var responseData = entries;
|
|
592
|
+
try {
|
|
593
|
+
if (typeof entries !== "string" && typeof entries === "object") {
|
|
594
|
+
responseData = JSON.stringify(entries);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
catch (error) {
|
|
598
|
+
throw new Error("Something went wrong with the conversion" + error);
|
|
599
|
+
}
|
|
600
|
+
return yield this.lib.mockServerActionInBrowser(function (mockserver, entitySetName, entries, done) {
|
|
601
|
+
var mockServerInst = mockserver.getMockServer();
|
|
602
|
+
if (!mockServerInst) {
|
|
603
|
+
console.error("Mockserver not yet initialized or method getMockServer is missing");
|
|
604
|
+
done();
|
|
605
|
+
}
|
|
606
|
+
var oData = [];
|
|
607
|
+
try {
|
|
608
|
+
var tempOData = JSON.parse(entries);
|
|
609
|
+
if (!Array.isArray(tempOData)) {
|
|
610
|
+
if (tempOData.d.results)
|
|
611
|
+
oData = [].concat(tempOData.d.results);
|
|
612
|
+
else if (tempOData.d)
|
|
613
|
+
oData = [].concat(tempOData.d);
|
|
614
|
+
else
|
|
615
|
+
oData = [].concat(tempOData);
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
// @ts-ignore
|
|
619
|
+
oData = [].concat(tempOData);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
catch (e) {
|
|
623
|
+
// @ts-ignore
|
|
624
|
+
var oResponse = jQuery.sap.sjax({
|
|
625
|
+
url: entries,
|
|
626
|
+
dataType: "json"
|
|
627
|
+
});
|
|
628
|
+
if (oResponse.success) {
|
|
629
|
+
if (oResponse.data.d) {
|
|
630
|
+
if (oResponse.data.d.results) {
|
|
631
|
+
oData = oResponse.data.d.results;
|
|
632
|
+
}
|
|
633
|
+
else if (oResponse.data.d) {
|
|
634
|
+
// Single data
|
|
635
|
+
oData.push(oResponse.data.d);
|
|
636
|
+
}
|
|
637
|
+
else if (oResponse.data) {
|
|
638
|
+
// Fallback Single data
|
|
639
|
+
oData.push(oResponse.data);
|
|
640
|
+
}
|
|
641
|
+
else {
|
|
642
|
+
console.error("The mock data are invalid");
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
else {
|
|
646
|
+
if (Array.isArray(oResponse.data)) {
|
|
647
|
+
oData = [].concat(oResponse.data);
|
|
648
|
+
}
|
|
649
|
+
else {
|
|
650
|
+
console.error("The mock data could not be loaded due to wrong format!");
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
mockServerInst.setEntitySetData(entitySetName, oData);
|
|
656
|
+
done(oData);
|
|
657
|
+
}, mockServerPath, entitySetName, responseData);
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
;
|
|
661
|
+
}
|
|
662
|
+
exports.Mockserver = Mockserver;
|
|
663
|
+
;
|
|
664
|
+
exports.default = new Mockserver();
|
|
665
|
+
//# sourceMappingURL=mockserver.js.map
|