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
6 changes: 3 additions & 3 deletions packages/main/cypress/specs/ColorPalette.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ describe("Color Palette tests", () => {
cy.mount(<ColorPaletteSample/>);

cy.ui5ColorPaletteNavigateAndCheckSelectedColor("#cp1", 0, "ArrowRight", "pink");
cy.ui5ColorPaletteNavigateAndCheckSelectedColor("#cp1", 0, "ArrowLeft", "orange");
cy.ui5ColorPaletteNavigateAndCheckSelectedColor("#cp1", 0, "ArrowUp", "orange");
cy.ui5ColorPaletteNavigateAndCheckSelectedColor("#cp1", 9, "ArrowDown", "darkblue");
cy.ui5ColorPaletteNavigateAndCheckSelectedColor("#cp1", 0, "ArrowLeft", "darkblue");
cy.ui5ColorPaletteNavigateAndCheckSelectedColor("#cp1", 0, "ArrowUp", "darkblue");
cy.ui5ColorPaletteNavigateAndCheckSelectedColor("#cp1", 9, "ArrowDown", "orange");
});

it("Tests show-recent-colors functionality", () => {
Expand Down
211 changes: 83 additions & 128 deletions packages/main/cypress/specs/ColorPalettePopover.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ describe("Color Popover Palette events tests", () => {
});

describe("Color Popover Palette arrow keys navigation", () => {
it("should navigate with Arrow right", () => {
it("should navigate with Arrow Down from last swatch to More Colors", () => {
cy.mount(
<SimplePalettePopover showMoreColors={true} />
);
Expand All @@ -322,13 +322,13 @@ describe("Color Popover Palette arrow keys navigation", () => {
.and("include", "red");

cy.focused()
.realPress("ArrowRight");
.realPress("ArrowDown");

cy.focused()
.should("have.attr", "aria-label", "More Colors...");

cy.focused()
.realPress("ArrowLeft");
.realPress("ArrowUp");

cy.focused()
.should("have.attr", "aria-label")
Expand Down Expand Up @@ -366,7 +366,7 @@ describe("Color Popover Palette arrow keys navigation", () => {
.should("have.attr", "_selected-color", "hotpink");
});

it("should navigate with Arrow left", () => {
it("should navigate with Arrow Down and Arrow Up between Default Color and swatches", () => {
cy.mount(
<SimplePalettePopover showDefaultColor={true} />
);
Expand All @@ -389,19 +389,16 @@ describe("Color Popover Palette arrow keys navigation", () => {
cy.get("@defaultColorButton")
.should("have.focus");

// Navigate right to first color item
// Navigate down to first color item
cy.get("@defaultColorButton")
.realPress("ArrowRight");
.realPress("ArrowDown");

cy.get("[ui5-color-palette-popover]")
.ui5GetColorPaletteItem(0)
.as("firstColorItem")
.should("be.visible")
.and("have.attr", "value", "cyan");

cy.get("@firstColorItem")
.should("have.attr", "value", "cyan");

cy.get("@firstColorItem")
.should("have.focus")
.shadow()
Expand All @@ -411,7 +408,7 @@ describe("Color Popover Palette arrow keys navigation", () => {
.and("include", "cyan");

cy.focused()
.realPress("ArrowLeft");
.realPress("ArrowUp");

cy.focused()
.should("have.attr", "aria-label", "Default Color");
Expand All @@ -420,7 +417,7 @@ describe("Color Popover Palette arrow keys navigation", () => {
.should("have.focus");
});

it("should cycle through colors horizontally with left/right arrows", () => {
it("should stay at boundary when navigating horizontally past edges", () => {
cy.mount(
<SimplePalettePopover />
);
Expand Down Expand Up @@ -450,20 +447,33 @@ describe("Color Popover Palette arrow keys navigation", () => {
.should("have.attr", "aria-label")
.and("include", "red");

// At last item, ArrowRight stays (no sections to escape to)
cy.focused()
.realPress("ArrowRight");
cy.focused()
.should("have.attr", "aria-label")
.and("include", "red");

// Navigate back to first
cy.focused()
.realPress("ArrowLeft");
cy.focused()
.realPress("ArrowLeft");
cy.focused()
.realPress("ArrowLeft");
cy.focused()
.should("have.attr", "aria-label")
.and("include", "cyan");

// At first item, ArrowLeft stays (no sections to escape to)
cy.focused()
.realPress("ArrowLeft");
cy.focused()
.should("have.attr", "aria-label")
.and("include", "red");
.and("include", "cyan");
});

it("should cycle through colors vertically with up/down arrows", () => {
it("should navigate vertically with up/down arrows", () => {
cy.mount(
<MultiRowPalettePopover />
);
Expand All @@ -481,17 +491,11 @@ describe("Color Popover Palette arrow keys navigation", () => {
.should("have.attr", "aria-label")
.and("include", "yellow");

cy.focused()
.realPress("ArrowDown");
cy.focused()
.should("have.attr", "aria-label")
.and("include", "orange");

cy.focused()
.realPress("ArrowUp");
cy.focused()
.should("have.attr", "aria-label")
.and("include", "yellow");
.and("include", "cyan");
});

it("should navigate to More Colors from colors grid", () => {
Expand All @@ -502,19 +506,24 @@ describe("Color Popover Palette arrow keys navigation", () => {
cy.get("[ui5-color-palette-popover]")
.ui5ColorPalettePopoverOpen({ opener: "btnPalette" });

// Navigate to last item in second (incomplete) row
cy.focused()
.realPress("End");
cy.focused()
.realPress("End");
cy.focused()
.should("have.attr", "aria-label")
.and("include", "green");
.and("include", "purple");

// ArrowDown from last row goes to More Colors
cy.focused()
.realPress("ArrowDown");
cy.focused()
.should("have.attr", "aria-label", "More Colors...");

// ArrowUp from More Colors restores column back into grid
cy.focused()
.realPress("ArrowLeft");
.realPress("ArrowUp");
cy.focused()
.should("have.attr", "aria-label")
.and("include", "purple");
Expand All @@ -528,91 +537,55 @@ describe("Color Popover Palette arrow keys navigation", () => {
cy.get("[ui5-color-palette-popover]")
.ui5ColorPalettePopoverOpen({ opener: "btnPalette" });

// Navigate to second row item
cy.focused()
.realPress("End");
.realPress("ArrowDown");
cy.focused()
.should("have.attr", "aria-label")
.and("include", "yellow");

// Navigate right within incomplete row
cy.focused()
.realPress("ArrowRight");
cy.focused()
.should("have.attr", "aria-label")
.and("include", "green");
.and("include", "purple");

// ArrowUp from column 1 in last row goes to column 1 in first row
cy.focused()
.realPress("ArrowUp");
cy.focused()
.should("have.attr", "aria-label")
.and("include", "red");
.and("include", "orange");
});
});

describe("Color Popover Palette Home and End keyboard navigation", () => {
it.skip("should navigate with Home/End when showDefaultColor is set", () => {
cy.mount(
<SimplePalettePopover showDefaultColor={true} />
);

cy.get("[ui5-color-palette-popover]")
.ui5ColorPalettePopoverOpen({ opener: "btnPalette" });

cy.get("[ui5-color-palette-popover]")
.should("have.attr", "open");

cy.get("[ui5-color-palette-popover]")
.ui5GetColorPaletteInPopover()
.as("colorPalette");

cy.get("@colorPalette")
.ui5GetColorPaletteDefaultButton()
.as("defaultColorButton")
.should("be.visible")
.and("have.focus");

cy.get("@defaultColorButton")
.should("have.focus")
.shadow()
.find("button[data-sap-focus-ref]")
.should("have.focus");

cy.get("@defaultColorButton")
.realPress("End");

cy.get("[ui5-color-palette-popover]")
.ui5GetColorPaletteItem(3)
.as("lastColorPaletteItem")
.should("be.visible")
.and("have.attr", "value", "red");

cy.get("@lastColorPaletteItem")
.should("have.focus")
.shadow()
.find(".ui5-cp-item")
.should("have.attr", "tabindex", "0")
.and("have.attr", "aria-label")
.and("include", "red");

cy.focused()
.realPress("Home");

cy.get("[ui5-color-palette-popover]")
.ui5GetColorPaletteItem(0)
.as("firstColorPaletteItem")
.should("be.visible")
.and("have.attr", "value", "cyan");

cy.get("@firstColorPaletteItem")
.should("have.focus")
.shadow()
.find(".ui5-cp-item")
.should("have.attr", "tabindex", "0")
.and("have.attr", "aria-label")
.and("include", "cyan");

cy.focused()
.realPress("Home");

cy.focused()
.should("have.attr", "aria-label", "Default Color");

cy.get("@defaultColorButton")
.should("have.focus");
});
it("should navigate with Home/End when showDefaultColor is set", () => {
cy.mount(
<SimplePalettePopover showDefaultColor={true} />
);

cy.get("[ui5-color-palette-popover]")
.ui5ColorPalettePopoverOpen({ opener: "btnPalette" });

cy.focused()
.should("have.attr", "aria-label", "Default Color")
.realPress("End");

cy.focused()
.should("have.attr", "aria-label")
.and("include", "red")
.realPress("Home");

cy.focused()
.should("have.attr", "aria-label")
.and("include", "cyan")
.realPress("Home");

cy.focused()
.should("have.attr", "aria-label", "Default Color");
});

it("should navigate with Home/End keys when showMoreColors is set", () => {
cy.mount(
Expand Down Expand Up @@ -640,43 +613,25 @@ describe("Color Popover Palette Home and End keyboard navigation", () => {
.should("have.attr", "aria-label", "More Colors...");
});

it.skip("should navigate with Home/End when showDefaultColor & showMoreColors are set", () => {
cy.mount(
<SimplePalettePopover showDefaultColor={true} showMoreColors={true} />
);

cy.get<ColorPalettePopover>("[ui5-color-palette-popover]")
.as("colorPalettePopover")
.ui5ColorPalettePopoverOpen({ opener: "btnPalette" });

cy.get<ColorPalette>("@colorPalettePopover")
.ui5GetColorPaletteInPopover()
.as("colorPalette");

cy.get("@colorPalette")
.ui5GetColorPaletteDefaultButton()
.as("defaultColorButton");

cy.get("@defaultColorButton")
.should("have.focus")
.realPress("End");
it("should navigate with Home/End when showDefaultColor and showMoreColors are set", () => {
cy.mount(
<SimplePalettePopover showDefaultColor={true} showMoreColors={true} />
);

cy.get("@colorPalette")
.ui5GetColorPaletteMoreColorsButton()
.as("moreColorsButton")
.should("be.visible");
cy.get("[ui5-color-palette-popover]")
.ui5ColorPalettePopoverOpen({ opener: "btnPalette" });

cy.get("@moreColorsButton")
.should("exist")
.and("be.visible")
.and("have.focus");
cy.focused()
.should("have.attr", "aria-label", "Default Color")
.realPress("End");

cy.get("@moreColorsButton")
.realPress("Home");
cy.focused()
.should("have.attr", "aria-label", "More Colors...")
.realPress("Home");

cy.get("@defaultColorButton")
.should("have.focus");
});
cy.focused()
.should("have.attr", "aria-label", "Default Color");
});

it("should navigate with End key", () => {
cy.mount(
Expand Down
Loading
Loading