SAP / ui5-webcomponents

UI5 Web Components - the enterprise-flavored sugar on top of native APIs! Build SAP Fiori user interfaces with the technology of your choice.
https://sap.github.io/ui5-webcomponents/
Apache License 2.0
1.51k stars 260 forks source link

[Radio Button]: Unit tests involving radio button fails after upgrading ui5-webcomponents version #7608

Closed chiragSAP closed 10 months ago

chiragSAP commented 12 months ago

Bug Description

When ui5-webcomponents version is upgraded to 1.17.0 all the unit tests involving radio button starts failing with the error "TypeError: this.attachInternals is not a function".

Affected Component

Radio Button

Expected Behaviour

Unit tests should pass.

Isolated Example

https://codesandbox.io/p/sandbox/cocky-feynman-kd2t5f?file=/src/App.tsx:8,41

Steps to Reproduce

  1. write a unit test for a program involving radio button

Log Output, Stack Trace or Screenshots

MicrosoftTeams-image (1)

Priority

High

UI5 Web Components Version

1.17.0

Browser

Chrome

Operating System

Windows

Additional Context

Need to upgrade the version to resolve https://github.com/SAP/ui5-webcomponents/issues/6895 and https://github.com/SAP/ui5-webcomponents-react/issues/4397

Organization

No response

Declaration

MFel0123 commented 12 months ago

Hello, thank you very much for this message. It seems we face exactly the same issue when we want to upgrade ui5-webComponents from 1.16.0 to 1.17.0. Some of our unit tests written in JEST fail. We are using the web components in angular. And from what we see the RadioButton causes the problem (at least also the RadioButton). I attach a little picture from the error log as well: image

We hope for a quick fix as well 👍 Thanks for bringing this up.

plamenivanov91 commented 12 months ago

Hello @SAP/ui5-webcomponents-topic-rd,

It seems like a regression in the RadioButton is causing some tests to fail.

Could you please look into it?

Regards, Plamen

georgimkv commented 11 months ago

The issue is being reported for Chrome browser but the environment these tests are being ran on is actually JSDom, which doesn't yet support attachInternals. See https://github.com/jsdom/jsdom/issues/3444

At the moment JSDom is not present in the support matrix https://github.com/SAP/ui5-webcomponents#browser-support

Lukas742 commented 11 months ago

Hi @chiragSAP

until attachInternals is supported by JSDom you can probably use the element-internals-polyfill. Just install it and then import it in your Jest setup-file.

georgimkv commented 10 months ago

Hi @chiragSAP Does the above suggestion to use elements-internals-polyfill solve your problem with running your tests on JSDom?

chiragSAP commented 10 months ago

Hi @gmkv After implementing the above mentioned fix, I was able to resolve the issue. Thanks for the support.