openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

Global sap.ui.test.OpaBuilder returns undefined

Open mauriciolauffer opened this issue 1 year ago • 3 comments

For whatever reason, I'm trying to access global sap.ui.test.OpaBuilder and it returns undefined.

OpenUI5 version: All.

Browser/version (+device/version): Any browser.

URL (minimal example if possible): https://openui5.hana.ondemand.com/test-resources/sap/m/demokit/cart/webapp/test/integration/opaTestsComponent.qunit.html

Steps to reproduce the problem:

  1. Open DevTools
  2. Go to console
  3. Type sap.ui.test.OpaBuilder and press enter

What is the expected result? Should see sap.ui.test.OpaBuilder object.

What happens instead? It returns undefined

Any other information? (attach screenshot if possible) It doesn't matter what you do, OpaBuilder doesn't show up in the library sap.ui.test. Even if you load it, like the following example:

sap.ui.require([
	"sap/ui/test/OpaBuilder"
], function (OpaBuilder) {
	console.dir(sap.ui.test.Opa); //OK
	console.dir(sap.ui.test.Opa5); //OK
	console.dir(sap.ui.test.OpaBuilder); //undefined
	console.dir(OpaBuilder); //OK
});

mauriciolauffer avatar Mar 12 '23 07:03 mauriciolauffer

Thanks for bringing this up!

This is kind of a documentation issue.

As you might know, we slowly transition from global names as APIs to import-based APIs (using sap.ui.define/AMD in standard JavaScript or using ES6 imports when working with TypeScript). In line with this transition, newer APIs often no longer provide a global name and only export their API from the sap.ui.define call. That's the case for the OpaBuilder.

But unfortunately, the OpaBuilder documents a global name sap.ui.test.OpaBuilder and that's highly misleading. Other modules that don't have global exports, use JSDoc's module name syntax, e.g. module:sap/base/Log. The OpaBuilder should IMO do the same.

codeworrior avatar Mar 13 '23 06:03 codeworrior

@codeworrior for the first time, I have a use case for globals and you tell me OpaBuilder isn't global... Oh, the irony 😆

Thanks for the response.

mauriciolauffer avatar Mar 13 '23 23:03 mauriciolauffer

Hello @mauriciolauffer , Thank you for sharing this finding. I've created an internal incident 2370018538. The status of the issue will be updated here in GitHub.

i556484 avatar Mar 17 '23 08:03 i556484

Hello, I would rather close this item due to internal discussion inactivity. The general direction is to use modules and avoid exposing globals. If there is an important use case for exposing global here perhaps we can think of another approach but please do share with us. Best regards, Jordan

jdichev avatar Mar 22 '24 11:03 jdichev