Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui5-tooling-modules): seamless web components support phase 1 #1051

Merged
merged 60 commits into from
Aug 25, 2024

Conversation

petermuessig
Copy link
Member

@petermuessig petermuessig commented Jul 26, 2024

This change enables the direct consumption of UI5 Web Components in OpenUI5/SAPUI5 applications without any change in the OpenUI5/SAPUI5 runtime. UI5 Web Components can be directly accessed declaratively in the XMLView and imperatively in the JavaScript/TypeScript code.

Declarative Usage:

<mvc:View xmlns:mvc="sap.ui.core.mvc" ...
  xmlns:webc="@ui5/webcomponents"
  core:require="{
    iconActivities: '@ui5/webcomponents-icons/dist/activities'
  }">

          <webc:Button id="webcBtn" text="Don't change this text!" click="onBoo" />
          <webc:Input value="Don't change this text!" change="onChange">
            <webc:icon>
              <webc:Icon name="activities" />
            </webc:icon>
          </webc:Input>

</mvc:View>

Imperative Usage:

sap.ui.require(["@ui5/webcomponents/Button"], function(Button) {

  new Button({
    text: "Hello World"
  }).placeAt("content");

});

To use the UI5 Web Components seamlessly in OpenUI5/SAPUI5 as UI5 Controls, you need to use the tooling extension ui5-tooling-modules and then import your preferred UI5 Web Components npm package, e.g. @ui5/webcomponents in your package.json.

📢 The change also introduces a new showcase of seamless UI5 Web Components in showcases/ui5-tsapp-webc which can be started with pnpm dev-webc:ts.

@petermuessig petermuessig force-pushed the feat/SeamlessWebComponents branch from bbeb7d0 to ce85746 Compare July 26, 2024 12:57
@petermuessig petermuessig changed the title Feat/seamless web components SEAMLESS WEB COMPONENTS Jul 26, 2024
petermuessig and others added 27 commits July 30, 2024 09:09
- add aliasing for classes to prevent searching for a class every time
@vobu
Copy link
Contributor

vobu commented Aug 24, 2024

I almost don’t dare to say….but…would you eventually need a hand with „the wdi5 issues“?! 😬😅

@petermuessig
Copy link
Member Author

petermuessig commented Aug 24, 2024

I almost don’t dare to say….but…would you eventually need a hand with „the wdi5 issues“?! 😬😅

@vobu oh well, yes - I have no clue why in the binding test the list is not available and it states "element is not interactable" - strange that with my change I somehow introduced it, but the initial page of the app is not really changed. Really weird. The shorthand API doesn't work, because of the list is not detected properly on the other view. Grml...

And the stupid thing is that locally all works fine - only centrally the issue exists - so I assume it is a race condition...

@petermuessig
Copy link
Member Author

petermuessig commented Aug 24, 2024

@vobu: by moving the code into one line into the page object all works fine - now I'm checking when it starts to fail.

	async iShouldSeeListItems() {
		// ui5 api + high-speed aggregation retrieval: https://ui5-community.github.io/wdi5/#/usage?id=getshorthand-conveniences
		return (await browser.asControl(this._listPeople).getItems()).length > 0;
	}

@petermuessig
Copy link
Member Author

@vobu: the not interactable issue is always present - this is not the root cause of the issue. This lead me into the wrong direction - the getItems for the list wasn't available as the lookup for the people list doesn't work. Maybe it has to do when looking up the list two times in one test. Checking now...

@petermuessig
Copy link
Member Author

@vobu: this here somehow doesn't work anymore
https://github.com/ui5-community/ui5-ecosystem-showcase/blob/main/showcases/ui5-app/webapp/test/e2e/binding.test.js#L21-L23

But if I put it into a page object, it works again - what is the difference here? maybe that expect doesn't get a Promise?

The following issue occured with my last code change:

	it("Other view: PeopleList: items aggregation + amount of items", async function () {
		await MainPage.iPressTheNavButton();
		expect(onTheOtherPage.iShouldSeeTheList()).toBeTruthy();
		expect(onTheOtherPage.iShouldSeeListItems()).toBeTruthy();

		// ui5 api + high-speed aggregation retrieval: https://ui5-community.github.io/wdi5/#/usage?id=getshorthand-conveniences
		const oList = await browser.asControl(this._listPeople);
		const aListItems = await oList.getItems(true);
		expect(aListItems.length).toBeGreaterThanOrEqual(1);
	});

and in the page object:

	async iShouldSeeListItems() {
		// ui5 api + high-speed aggregation retrieval: https://ui5-community.github.io/wdi5/#/usage?id=getshorthand-conveniences
		const oList = await browser.asControl(this._listPeople);
		return (await oList.getItems(true)).length > 0;
	}

the following issue occurs with the code above when the list lookup is made in the test.

[chrome 128.0.6613.84 Linux #0-0] Cannot read properties of undefined (reading 'hasOwnProperty')
[chrome 128.0.6613.84 Linux #0-0] TypeError: Cannot read properties of undefined (reading 'hasOwnProperty')
[chrome 128.0.6613.84 Linux #0-0]     at _verifySelector (file:///home/runner/work/ui5-ecosystem-showcase/ui5-ecosystem-showcase/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]__@w_m5i5wntlxcgoyk2dj374hdswia/node_modules/wdio-ui5-service/esm/lib/wdi5-bridge.js:192:22)
[chrome 128.0.6613.84 Linux #0-0]     at Browser.<anonymous> (file:///home/runner/work/ui5-ecosystem-showcase/ui5-ecosystem-showcase/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]__@w_m5i5wntlxcgoyk2dj374hdswia/node_modules/wdio-ui5-service/esm/lib/wdi5-bridge.js:214:14)
[chrome 128.0.6613.84 Linux #0-0]     at browserInstance.asControl (file:///home/runner/work/ui5-ecosystem-showcase/ui5-ecosystem-showcase/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]__@w_m5i5wntlxcgoyk2dj374hdswia/node_modules/wdio-ui5-service/esm/lib/wdi5-bridge.js:416:47)
[chrome 128.0.6613.84 Linux #0-0]     at Context.<anonymous> (/home/runner/work/ui5-ecosystem-showcase/ui5-ecosystem-showcase/showcases/ui5-app/webapp/test/e2e/binding.test.js:24:31)

@petermuessig
Copy link
Member Author

for now, I'll keep the variant with the page object - this here is the diff which fixes the test issue by moving all lookup calls into an async page object function and using this for the expect as parameter.

0730363

@petermuessig
Copy link
Member Author

@vobu: as discussed the testing issue was related to the screensize and the height 100% of the VBox which rendered the Button which should be clicked outside of the visible area which finally led to the issue resolving the list with browser.asControl.

@petermuessig petermuessig marked this pull request as ready for review August 25, 2024 07:56
@petermuessig petermuessig changed the title SEAMLESS WEB COMPONENTS feat(ui5-tooling-modules): seamless web components support phase 1 Aug 25, 2024
@petermuessig petermuessig merged commit f2cc93e into main Aug 25, 2024
4 of 5 checks passed
@petermuessig petermuessig deleted the feat/SeamlessWebComponents branch August 25, 2024 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants