-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ui5-view-settings-dialog): clicking on the radio button/checkbox works #10706
Merged
Merged
Changes from 6 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
975019c
fix(ui5-view-settings-dialog): clicking on the radio button works
vladitasev 20c576d
chore: test
vladitasev a253649
chore: change some back
vladitasev 5f8fdc6
chore: add test
vladitasev c6f5f75
chore: lint
vladitasev ecc9fe1
chore: restore test page
vladitasev a457bd9
chore: comments
vladitasev a9f2391
Merge remote-tracking branch 'origin/main' into vsd-radio-fix
vladitasev 0508801
Merge remote-tracking branch 'origin/main' into vsd-radio-fix
vladitasev d24c417
chore: change tests to TSX
vladitasev 33ca6df
chore: eslint
vladitasev 247beb0
chore: fix
vladitasev 5432973
Merge remote-tracking branch 'origin/main' into vsd-radio-fix
vladitasev d69a384
chore: fix test
vladitasev 8922769
chore: improve
vladitasev de0ef6f
chore: improve
vladitasev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
import { html } from "lit"; | ||
import "../../src/ViewSettingsDialog.js"; | ||
import "../../src/SortItem.js"; | ||
import "../../src/FilterItem.js"; | ||
import "../../src/FilterItemOption.js"; | ||
|
||
describe("View settings dialog - selection", () => { | ||
it("tests clicking on sort items (both on the text and radio button)", () => { | ||
cy.mount(html` | ||
<ui5-view-settings-dialog id="vsd" sort-ascending> | ||
<ui5-sort-item slot="sortItems" text="Name" selected></ui5-sort-item> | ||
<ui5-sort-item slot="sortItems" text="Position"></ui5-sort-item> | ||
</ui5-view-settings-dialog> | ||
`); | ||
|
||
// Bind the "confirm" event - it will be called twice (first with Position, then with Name) | ||
cy.get("[ui5-view-settings-dialog]") | ||
.as("vsd") | ||
.then(vsd => { | ||
vsd.get(0).addEventListener("ui5-confirm", cy.stub().as("confirm")); | ||
}); | ||
|
||
// Open the dialog and wait until it's visible | ||
cy.get("@vsd") | ||
.invoke("prop", "open", true) | ||
.shadow() | ||
.find("[ui5-dialog]") | ||
.should("be.visible"); | ||
|
||
// There should be 4 list items in the dialog - Ascending, Descending, Name, Position | ||
cy.get("@vsd") | ||
.shadow() | ||
.find("[ui5-li]") | ||
.should("have.length", 4); | ||
|
||
// Click the TEXT of the 4th item (Position) | ||
cy.get("@vsd") | ||
.shadow() | ||
.find("[ui5-li]") | ||
.eq(3) | ||
.shadow() | ||
.find("span[part=title]") // we click the text itself first | ||
.realClick(); | ||
|
||
// Click the OK button of the dialog | ||
cy.get("@vsd") | ||
.shadow() | ||
.find("ui5-button[design=Emphasized]") | ||
.realClick(); | ||
|
||
// Check if the confirm event was fired with sortBy = "Position" | ||
cy.get("@confirm") | ||
.should("be.called") | ||
.its("firstCall.args.0.detail.sortBy") | ||
.should("equal", "Position"); | ||
|
||
// Wait until the dialog is closed | ||
cy.get("@vsd") | ||
.shadow() | ||
.find("[ui5-dialog]") | ||
.should("not.be.visible"); | ||
|
||
// Open the dialog again and wait until it's visible | ||
cy.get("@vsd") | ||
.invoke("prop", "open", true) | ||
.shadow() | ||
.find("[ui5-dialog]") | ||
.should("be.visible"); | ||
|
||
// Click the RADIO BUTTON of the 3th item (Name) instead of the text this time | ||
cy.get("@vsd") | ||
.shadow() | ||
.find("[ui5-li]") | ||
.eq(2) | ||
.shadow() | ||
.find("[ui5-radio-button]") | ||
.realClick(); | ||
|
||
// Click the OK button of the dialog again | ||
cy.get("@vsd") | ||
.shadow() | ||
.find("ui5-button[design=Emphasized]") | ||
.realClick(); | ||
|
||
// Check if the confirm event was fired for a second time, now with sortBy = "Name" | ||
cy.get("@confirm") | ||
.should("be.called") | ||
.its("secondCall.args.0.detail.sortBy") | ||
.should("equal", "Name"); | ||
}); | ||
|
||
it("tests clicking on filter items, and filter item options (both on the text and checkbox)", () => { | ||
cy.mount(html` | ||
<ui5-view-settings-dialog id="vsd"> | ||
<ui5-filter-item slot="filterItems" text="Filter 1"> | ||
<ui5-filter-item-option slot="values" text="Some filter 1"></ui5-filter-item-option> | ||
<ui5-filter-item-option slot="values" text="Some filter 2"></ui5-filter-item-option> | ||
<ui5-filter-item-option slot="values" text="Some filter 3"></ui5-filter-item-option> | ||
</ui5-filter-item> | ||
<ui5-filter-item slot="filterItems" text="Filter 2"> | ||
<ui5-filter-item-option slot="values" text="Some filter 4"></ui5-filter-item-option> | ||
<ui5-filter-item-option slot="values" text="Some filter 5"></ui5-filter-item-option> | ||
<ui5-filter-item-option slot="values" text="Some filter 6"></ui5-filter-item-option> | ||
</ui5-filter-item> | ||
</ui5-view-settings-dialog> | ||
`); | ||
|
||
// Bind the "confirm" event - it will be called once with filters = [{"Filter 1":["Some filter 1","Some filter 3"]}] | ||
cy.get("[ui5-view-settings-dialog]") | ||
.as("vsd") | ||
.then(vsd => { | ||
vsd.get(0).addEventListener("ui5-confirm", cy.stub().as("confirm")); | ||
}); | ||
|
||
// Open the dialog and wait until it's visible | ||
cy.get("@vsd") | ||
.invoke("prop", "open", true) | ||
.shadow() | ||
.find("[ui5-dialog]") | ||
.should("be.visible"); | ||
|
||
// There should be 2 list items in the dialog - Filter 1 and Filter 2 | ||
cy.get("@vsd") | ||
.shadow() | ||
.find("[ui5-li]") | ||
.should("have.length", 2); | ||
|
||
// Click the "Filter 1" item | ||
cy.get("@vsd") | ||
.shadow() | ||
.find("[ui5-li]") | ||
.eq(0) | ||
.shadow() | ||
.find("span[part=title]") | ||
.realClick(); | ||
|
||
// There should be 3 list items in the dialog - Some filter 1, Some filter 2, Some filter 3 | ||
cy.get("@vsd") | ||
.shadow() | ||
.find("[ui5-li]") | ||
.should("have.length", 3); | ||
|
||
// Click on the text of the first list item (Some filter 1) | ||
cy.get("@vsd") | ||
.shadow() | ||
.find("[ui5-li]") | ||
.eq(0) | ||
.shadow() | ||
.find("span[part=title]") | ||
.realClick(); | ||
|
||
// Click on the checkbox of the third list item (Some filter 3) | ||
cy.get("@vsd") | ||
.shadow() | ||
.find("[ui5-li]") | ||
.eq(2) | ||
.shadow() | ||
.find("[ui5-checkbox]") | ||
.realClick(); | ||
|
||
// Click the OK button of the dialog | ||
cy.get("@vsd") | ||
.shadow() | ||
.find("ui5-button[design=Emphasized]") | ||
.realClick(); | ||
|
||
// Check if the confirm event was fired with: filters = [{"Filter 1":["Some filter 1","Some filter 3"]}] | ||
cy.get("@confirm") | ||
.should("be.called") | ||
.its("firstCall.args.0.detail.filters") | ||
.should("deep.equal", [{ "Filter 1": ["Some filter 1", "Some filter 3"] }]); | ||
|
||
// Wait until the dialog is closed | ||
cy.get("@vsd") | ||
.shadow() | ||
.find("[ui5-dialog]") | ||
.should("not.be.visible"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separate invoke from other commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done