Skip to content

Commit 6bf7b05

Browse files
fix(OpenUI5Support): stabilize popups tests (#12830)
fix(OpenUI5Support): stabilize tests
1 parent dee55cf commit 6bf7b05

File tree

1 file changed

+40
-15
lines changed

1 file changed

+40
-15
lines changed

packages/main/cypress/specs/OpenUI5andWebCPopups.cy.tsx

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,20 @@ import ComboBox from "../../src/ComboBox.js";
77
import ComboBoxItem from "../../src/ComboBoxItem.js";
88
import ResponsivePopover from "../../src/ResponsivePopover.js";
99

10+
let OpenUI5Element;
11+
1012
function onOpenUI5InitMethod(win) {
11-
(win as any).sap.ui.require(["sap/ui/core/HTML", "sap/m/Button", "sap/m/Dialog", "sap/m/Popover", "sap/m/Input"], async (HTML, Button, Dialog, Popover, Input) => {
13+
(win as any).sap.ui.require([
14+
"sap/ui/core/Element",
15+
"sap/ui/core/HTML",
16+
"sap/m/Button",
17+
"sap/m/Dialog",
18+
"sap/m/Popover",
19+
"sap/m/Input"
20+
], async (Element, HTML, Button, Dialog, Popover, Input) => {
1221

1322
await OpenUI5Support.init();
14-
23+
OpenUI5Element = Element;
1524
new Button("openUI5Button", {
1625
text: "Open OpenUI5 Dialog",
1726
press: function () {
@@ -21,7 +30,7 @@ function onOpenUI5InitMethod(win) {
2130
content: [
2231
new HTML({
2332
content:
24-
`<ui5-select id="webCSelect1">
33+
`<ui5-select id="webCSelect1">
2534
<ui5-option>Option 1</ui5-option>
2635
<ui5-option>Option 2</ui5-option>
2736
<ui5-option>Option 3</ui5-option>
@@ -206,6 +215,15 @@ function openUI5Popover(win, opener) {
206215
});
207216
}
208217

218+
function isOpenUI5DialogOpen($dialog) {
219+
expect(OpenUI5Element).to.exist;
220+
221+
const dialogInstance = OpenUI5Element.getElementById($dialog.attr("id"));
222+
223+
expect(dialogInstance).to.exist
224+
expect(dialogInstance.isOpen()).to.be.true;
225+
};
226+
209227
describe("ui5 and web components integration", () => {
210228
beforeEach(() => {
211229
// mount the components
@@ -480,6 +498,10 @@ describe("ui5 and web components integration", () => {
480498
.find('input')
481499
.focus();
482500

501+
cy.get("#openUI5Combobox1")
502+
.find('input')
503+
.should('be.focused');
504+
483505
cy.realPress("Escape");
484506

485507
cy.get('#dialog1')
@@ -518,12 +540,11 @@ describe("ui5 and web components integration", () => {
518540
.should('be.visible')
519541
.realClick();
520542

521-
cy.get<Dialog>("#respPopover").ui5DialogOpened();
543+
cy.get<ResponsivePopover>("#respPopover").ui5ResponsivePopoverOpened();
522544

523545
cy.realPress("Escape");
524546

525-
cy.get("#respPopover")
526-
.should('not.be.visible');
547+
cy.get<ResponsivePopover>("#respPopover").ui5ResponsivePopoverClosed();
527548

528549
cy.get("#openUI5Dialog1")
529550
.should('be.visible');
@@ -549,12 +570,12 @@ describe("ui5 and web components integration", () => {
549570
.should('be.visible')
550571
.realClick();
551572

552-
cy.get<Dialog>("#respPopoverNoInitialFocus").ui5DialogOpened();
573+
cy.get<ResponsivePopover>("#respPopoverNoInitialFocus").ui5ResponsivePopoverOpened();
553574

554575
cy.realPress("Escape");
555576

556-
cy.get("#respPopoverNoInitialFocus")
557-
.should('not.be.visible');
577+
cy.get<ResponsivePopover>("#respPopoverNoInitialFocus")
578+
.ui5ResponsivePopoverClosed();
558579

559580
cy.get("#openResPopoverNoInitialFocusButton")
560581
.should('be.focused');
@@ -591,8 +612,8 @@ describe("ui5 and web components integration", () => {
591612

592613
cy.get("#webCSelect1")
593614
.shadow()
594-
.find("[ui5-responsive-popover]")
595-
.should('not.be.visible');
615+
.find<ResponsivePopover>("[ui5-responsive-popover]")
616+
.ui5ResponsivePopoverClosed();
596617

597618
cy.get("#openUI5Dialog1")
598619
.should('be.visible');
@@ -631,8 +652,8 @@ describe("ui5 and web components integration", () => {
631652

632653
cy.get("#webCComboBox1")
633654
.shadow()
634-
.find("[ui5-responsive-popover]")
635-
.should('not.be.visible');
655+
.find<ResponsivePopover>("[ui5-responsive-popover]")
656+
.ui5ResponsivePopoverClosed();
636657

637658
cy.get("#openUI5Dialog1")
638659
.should('be.visible');
@@ -688,7 +709,9 @@ describe("ui5 and web components integration", () => {
688709
.realClick();
689710

690711
cy.get("#openUI5DialogFinal")
691-
.should('be.visible');
712+
.should('be.visible')
713+
.should(isOpenUI5DialogOpen);
714+
cy.wait(1000);
692715

693716
cy.get("#openUI5Dialog1")
694717
.should('not.be.visible');
@@ -706,7 +729,9 @@ describe("ui5 and web components integration", () => {
706729
.should('not.exist');
707730

708731
cy.get("#openUI5DialogWithButtons")
709-
.should('be.visible');
732+
.should('be.visible')
733+
.should(isOpenUI5DialogOpen);
734+
cy.wait(100);
710735

711736
cy.realPress("Escape");
712737

0 commit comments

Comments
 (0)