|
1 | 1 | import ViewSettingsDialog from "../../src/ViewSettingsDialog.js";
|
| 2 | +import GroupItem from "../../src/GroupItem.js"; |
2 | 3 | import SortItem from "../../src/SortItem.js";
|
3 | 4 | import FilterItem from "../../src/FilterItem.js";
|
4 | 5 | import FilterItemOption from "../../src/FilterItemOption.js";
|
5 | 6 |
|
6 |
| -describe("View settings dialog - selection", () => { |
7 |
| - it("tests clicking on sort items (both on the text and radio button)", () => { |
| 7 | +describe("View settings dialog - confirm event", () => { |
| 8 | + it("should throw confirm event after selecting sort options and confirm button", () => { |
8 | 9 | cy.mount(
|
9 | 10 | <ViewSettingsDialog id="vsd" onConfirm={cy.stub().as("confirm")}>
|
10 | 11 | <SortItem slot="sortItems" text="Name" selected={true}></SortItem>
|
@@ -86,7 +87,7 @@ describe("View settings dialog - selection", () => {
|
86 | 87 | .should("equal", "Name");
|
87 | 88 | });
|
88 | 89 |
|
89 |
| - it("tests clicking on filter items, and filter item options (both on the text and checkbox)", () => { |
| 90 | + it("should throw confirm event after selecting filter options and confirm button", () => { |
90 | 91 | cy.mount(
|
91 | 92 | <ViewSettingsDialog id="vsd" onConfirm={cy.stub().as("confirm")}>
|
92 | 93 | <FilterItem slot="filterItems" text="Filter 1">
|
@@ -167,6 +168,61 @@ describe("View settings dialog - selection", () => {
|
167 | 168 | .find("[ui5-dialog]")
|
168 | 169 | .should("not.be.visible");
|
169 | 170 | });
|
| 171 | + |
| 172 | + it("should throw confirm event after selecting group options and confirm button", () => { |
| 173 | + cy.mount( |
| 174 | + <ViewSettingsDialog onConfirm={cy.stub().as("confirm")}> |
| 175 | + <GroupItem slot="groupItems" text="Name"></GroupItem> |
| 176 | + <GroupItem slot="groupItems" text="Position"></GroupItem> |
| 177 | + <GroupItem slot="groupItems" text="(No Group)"></GroupItem> |
| 178 | + </ViewSettingsDialog> |
| 179 | + ); |
| 180 | + |
| 181 | + cy.get("[ui5-view-settings-dialog]") |
| 182 | + .as("vsd") |
| 183 | + .invoke("prop", "open", true); |
| 184 | + |
| 185 | + cy.get("@vsd") |
| 186 | + .shadow() |
| 187 | + .find("[group-order] ui5-li") |
| 188 | + .as("groupOrderItems"); |
| 189 | + |
| 190 | + cy.get("@groupOrderItems") |
| 191 | + .should("have.length", 2); |
| 192 | + |
| 193 | + // Select the group order (Descending) |
| 194 | + cy.get("@groupOrderItems") |
| 195 | + .eq(1) |
| 196 | + .realClick(); |
| 197 | + |
| 198 | + cy.get("@vsd") |
| 199 | + .shadow() |
| 200 | + .find("[group-by] ui5-li") |
| 201 | + .as("groupByItems"); |
| 202 | + |
| 203 | + cy.get("@groupByItems") |
| 204 | + .should("have.length", 3); |
| 205 | + |
| 206 | + // Select the group by (No Group) |
| 207 | + cy.get("@groupByItems") |
| 208 | + .eq(2) |
| 209 | + .realClick(); |
| 210 | + |
| 211 | + // Confirm the selection |
| 212 | + cy.get("@vsd") |
| 213 | + .shadow() |
| 214 | + .find(".ui5-vsd-footer ui5-button") |
| 215 | + .realClick(); |
| 216 | + |
| 217 | + // Check the confirm event for groupOrder and groupBy |
| 218 | + cy.get("@confirm") |
| 219 | + .should("be.calledWithMatch", { |
| 220 | + detail: { |
| 221 | + groupOrder: "Descending", |
| 222 | + groupBy: "(No Group)", |
| 223 | + }, |
| 224 | + }); |
| 225 | + }); |
170 | 226 | });
|
171 | 227 |
|
172 | 228 | describe("ViewSettingsDialog Tests", () => {
|
@@ -371,6 +427,31 @@ describe("ViewSettingsDialog Tests", () => {
|
371 | 427 | .invoke("prop", "open", false);
|
372 | 428 | });
|
373 | 429 |
|
| 430 | + it("should handle group-only mode", () => { |
| 431 | + cy.mount( |
| 432 | + <ViewSettingsDialog id="vsdGroup"> |
| 433 | + <GroupItem slot="groupItems" text="Name"></GroupItem> |
| 434 | + <GroupItem slot="groupItems" text="Position"></GroupItem> |
| 435 | + <GroupItem slot="groupItems" text="Company"></GroupItem> |
| 436 | + <GroupItem slot="groupItems" text="Department"></GroupItem> |
| 437 | + </ViewSettingsDialog> |
| 438 | + ); |
| 439 | + |
| 440 | + cy.get("#vsdGroup") |
| 441 | + .as("vsd"); |
| 442 | + |
| 443 | + cy.get("@vsd") |
| 444 | + .invoke("prop", "open", true); |
| 445 | + |
| 446 | + cy.get("@vsd") |
| 447 | + .shadow() |
| 448 | + .find("[ui5-segmented-button]") |
| 449 | + .should("not.exist"); |
| 450 | + |
| 451 | + cy.get("@vsd") |
| 452 | + .invoke("prop", "open", false); |
| 453 | + }); |
| 454 | + |
374 | 455 | it("should focus first item in filter options", () => {
|
375 | 456 | cy.mount(
|
376 | 457 | <ViewSettingsDialog id="vsdFilter">
|
@@ -407,4 +488,37 @@ describe("ViewSettingsDialog Tests", () => {
|
407 | 488 | .first()
|
408 | 489 | .should("be.focused");
|
409 | 490 | });
|
| 491 | + |
| 492 | + it("should show a split button with all loaded VSD options", () => { |
| 493 | + cy.mount( |
| 494 | + <ViewSettingsDialog id="vsd"> |
| 495 | + <SortItem slot="sortItems" text="Name"></SortItem> |
| 496 | + <FilterItem slot="filterItems" text="Filter 1"> |
| 497 | + <FilterItemOption slot="values" text="Some filter 1"></FilterItemOption> |
| 498 | + <FilterItemOption slot="values" text="Some filter 2"></FilterItemOption> |
| 499 | + <FilterItemOption slot="values" text="Some filter 3"></FilterItemOption> |
| 500 | + </FilterItem> |
| 501 | + <GroupItem slot="groupItems" text="Name"></GroupItem> |
| 502 | + </ViewSettingsDialog> |
| 503 | + ); |
| 504 | + |
| 505 | + cy.get("[ui5-view-settings-dialog]") |
| 506 | + .as("vsd") |
| 507 | + .invoke("prop", "open", true); |
| 508 | + |
| 509 | + cy.get("@vsd") |
| 510 | + .shadow() |
| 511 | + .find("[ui5-segmented-button]") |
| 512 | + .as("segmentedButton"); |
| 513 | + |
| 514 | + cy.get("@segmentedButton") |
| 515 | + .should("be.visible"); |
| 516 | + |
| 517 | + cy.get("@segmentedButton") |
| 518 | + .find("[ui5-segmented-button-item]") |
| 519 | + .as("items"); |
| 520 | + |
| 521 | + cy.get("@items") |
| 522 | + .should("have.length", 3); |
| 523 | + }); |
410 | 524 | });
|
0 commit comments