Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 53 additions & 1 deletion packages/main/cypress/specs/Input.mobile.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import Input from "../../src/Input.js";
import "../../src/features/InputSuggestions.js";
import type ResponsivePopover from "../../src/ResponsivePopover.js";
import SuggestionItem from "../../src/SuggestionItem.js";
import { INPUT_SUGGESTIONS_OK_BUTTON, INPUT_SUGGESTIONS_CANCEL_BUTTON } from "../../src/generated/i18n/i18n-defaults.js";
import { INPUT_SUGGESTIONS_OK_BUTTON, INPUT_SUGGESTIONS_CANCEL_BUTTON, INPUT_SUGGESTIONS_TITLE } from "../../src/generated/i18n/i18n-defaults.js";
import Label from "../../src/Label.js";

describe("Input on mobile device", () => {
beforeEach(() => {
Expand Down Expand Up @@ -442,3 +443,54 @@ describe("Property open", () => {
.ui5ResponsivePopoverClosed();
});
});

describe("Dialog header title", () => {
beforeEach(() => {
cy.ui5SimulateDevice("phone");
});

it("Should display label text as dialog header title when label for is used", () => {
cy.mount(
<>
<Label for="myInput">Country</Label>
<Input id="myInput" showSuggestions>
<SuggestionItem text="Item 1" />
<SuggestionItem text="Item 2" />
</Input>
</>
);

cy.get("#myInput").realClick();

cy.get("#myInput")
.shadow()
.find<ResponsivePopover>("[ui5-responsive-popover]")
.ui5ResponsivePopoverOpened();

cy.get("#myInput")
.shadow()
.find("[ui5-responsive-popover] .ui5-responsive-popover-header-text")
.should("have.text", "Country");
});

it("Should fallback to 'All Items' when no label is associated", () => {
cy.mount(
<Input id="myInput" showSuggestions>
<SuggestionItem text="Item 1" />
<SuggestionItem text="Item 2" />
</Input>
);

cy.get("#myInput").realClick();

cy.get("#myInput")
.shadow()
.find<ResponsivePopover>("[ui5-responsive-popover]")
.ui5ResponsivePopoverOpened();

cy.get("#myInput")
.shadow()
.find("[ui5-responsive-popover] .ui5-responsive-popover-header-text")
.should("have.text", INPUT_SUGGESTIONS_TITLE.defaultText);
});
});
59 changes: 59 additions & 0 deletions packages/main/cypress/specs/MultiInput.mobile.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import SuggestionItem from "../../src/SuggestionItem.js";
import Button from "../../src/Button.js";
import "../../src/features/InputSuggestions.js";
import type ResponsivePopover from "@ui5/webcomponents/dist/ResponsivePopover.js";
import { INPUT_SUGGESTIONS_TITLE } from "../../src/generated/i18n/i18n-defaults.js";
import Label from "../../src/Label.js";

const createTokenFromText = (text: string): HTMLElement => {
const token = document.createElement("ui5-token");
Expand Down Expand Up @@ -213,3 +215,60 @@ describe("Multi Input on mobile device", () => {
});
});
});

describe("Dialog header title", () => {
beforeEach(() => {
cy.ui5SimulateDevice("phone");
});

it("Should display label text as dialog header title when label for is used", () => {
cy.mount(
<>
<Label for="myMultiInput">Tags</Label>
<MultiInput id="myMultiInput" showSuggestions>
<SuggestionItem text="Item 1" />
<SuggestionItem text="Item 2" />
</MultiInput>
</>
);

cy.get("#myMultiInput")
.shadow()
.find(".ui5-input-inner")
.realClick();

cy.get("#myMultiInput")
.shadow()
.find<ResponsivePopover>("[ui5-responsive-popover]")
.ui5ResponsivePopoverOpened();

cy.get("#myMultiInput")
.shadow()
.find("[ui5-responsive-popover] .ui5-responsive-popover-header-text")
.should("have.text", "Tags");
});

it("Should fallback to 'All Items' when no label is associated", () => {
cy.mount(
<MultiInput id="myMultiInput" showSuggestions>
<SuggestionItem text="Item 1" />
<SuggestionItem text="Item 2" />
</MultiInput>
);

cy.get("#myMultiInput")
.shadow()
.find(".ui5-input-inner")
.realClick();

cy.get("#myMultiInput")
.shadow()
.find<ResponsivePopover>("[ui5-responsive-popover]")
.ui5ResponsivePopoverOpened();

cy.get("#myMultiInput")
.shadow()
.find("[ui5-responsive-popover] .ui5-responsive-popover-header-text")
.should("have.text", INPUT_SUGGESTIONS_TITLE.defaultText);
});
});
2 changes: 1 addition & 1 deletion packages/main/src/Input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1760,7 +1760,7 @@ class Input extends UI5Element implements SuggestionComponent, IFormInputElement
}

get _headerTitleText() {
return Input.i18nBundle.getText(INPUT_SUGGESTIONS_TITLE);
return this._associatedLabelsTexts || Input.i18nBundle.getText(INPUT_SUGGESTIONS_TITLE);
}

get _suggestionsOkButtonText() {
Expand Down
Loading