diff --git a/packages/main/cypress/specs/RatingIndicator.cy.ts b/packages/main/cypress/specs/RatingIndicator.cy.ts new file mode 100644 index 000000000000..83150cfdd07c --- /dev/null +++ b/packages/main/cypress/specs/RatingIndicator.cy.ts @@ -0,0 +1,39 @@ +import { html } from "lit"; +import "../../src/RatingIndicator.js"; + +describe("RatingIndicator", () => { + describe("Half Icon appearance", () => { + it("Half icon should be filled when rating indicator is disabled", () => { + const attributeValue = "favorite"; + + cy.mount(html``); + + cy.get("[ui5-rating-indicator]") + .shadow() + .find(".ui5-rating-indicator-item-half [ui5-icon]") + .should("have.attr", "name", attributeValue); + }); + + it("Half icon should be filled when rating indicator is readonly", () => { + const attributeValue = "favorite"; + + cy.mount(html``); + + cy.get("[ui5-rating-indicator]") + .shadow() + .find(".ui5-rating-indicator-item-half [ui5-icon]") + .should("have.attr", "name", attributeValue); + }); + + it("Half icon should be border only when rating indicator is regular", () => { + const attributeValue = "unfavorite"; + + cy.mount(html``); + + cy.get("[ui5-rating-indicator]") + .shadow() + .find(".ui5-rating-indicator-item-half [ui5-icon]") + .should("have.attr", "name", attributeValue); + }); + }); +}); diff --git a/packages/main/src/RatingIndicator.hbs b/packages/main/src/RatingIndicator.hbs index 29c1d3fda23b..e016ed38e150 100644 --- a/packages/main/src/RatingIndicator.hbs +++ b/packages/main/src/RatingIndicator.hbs @@ -27,7 +27,7 @@ {{else if this.halfStar}}
  • - +
    diff --git a/packages/main/src/RatingIndicator.ts b/packages/main/src/RatingIndicator.ts index aa989847ce76..bdd191175b11 100644 --- a/packages/main/src/RatingIndicator.ts +++ b/packages/main/src/RatingIndicator.ts @@ -289,6 +289,10 @@ class RatingIndicator extends UI5Element { this._focused = false; } + get halfStarIconName() { + return this.disabled || this.readonly ? "favorite" : "unfavorite"; + } + get effectiveTabIndex() { const tabindex = this.getAttribute("tabindex"); return this.disabled ? "-1" : tabindex || "0";