Skip to content
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
a82ff0f
feat: add samples
GDamyanov Aug 25, 2025
80a5144
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Aug 25, 2025
5b7bacf
refactor: refactor tests
GDamyanov Aug 25, 2025
16d76ac
refactor: refactor tests
GDamyanov Aug 25, 2025
4594bba
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Aug 27, 2025
a86b4e4
feat: extend formValidity
GDamyanov Aug 27, 2025
f3d457e
Merge branch 'controls-check-form-validity-samples' of https://github…
GDamyanov Aug 27, 2025
fef162a
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Aug 28, 2025
ca2dc95
feat: implement controls formValidity
GDamyanov Aug 28, 2025
3210e54
test: add test suites
GDamyanov Aug 28, 2025
a230b74
test: add tests
GDamyanov Aug 28, 2025
63e706c
test: add tests
GDamyanov Aug 29, 2025
a2f4ac6
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Aug 29, 2025
1ed9145
feat: add form validity for ui5-file-uploader
GDamyanov Aug 29, 2025
da81009
feat: add validation messages
GDamyanov Sep 1, 2025
1e0c4eb
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Sep 1, 2025
e5021e4
test: test
GDamyanov Sep 4, 2025
95f8595
test: fix tests
GDamyanov Sep 4, 2025
1e87f8c
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Sep 4, 2025
1483322
refactor: edin param as optional
GDamyanov Sep 4, 2025
81fbcdc
Merge branch 'controls-check-form-validity-samples' of https://github…
GDamyanov Sep 4, 2025
f4f87bf
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Sep 9, 2025
beaca0f
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Sep 9, 2025
495cdee
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Sep 11, 2025
caca4fe
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Sep 11, 2025
bb7718b
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Sep 12, 2025
5847e1c
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Sep 12, 2025
d2795b6
test: extract formValidity in Cypress function
GDamyanov Sep 12, 2025
574e6cc
fix: update value on input and fix tests
GDamyanov Sep 23, 2025
0728b63
test: added tests
GDamyanov Sep 23, 2025
14611a9
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Sep 24, 2025
3aa8cf0
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Sep 24, 2025
968120b
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Sep 24, 2025
bf996aa
fix: update value only on change
GDamyanov Sep 24, 2025
392f618
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Sep 24, 2025
c99775b
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Sep 25, 2025
51f62d1
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Sep 26, 2025
e5832b9
chore: clear spaces
GDamyanov Sep 26, 2025
7df0faf
test: refactor tests
GDamyanov Sep 26, 2025
77434ea
Merge branch 'main' into controls-check-form-validity-samples
ilhan007 Sep 26, 2025
54bf18f
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Sep 29, 2025
f6a0f0d
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Oct 2, 2025
9ec1583
refactor: remove comment
GDamyanov Oct 2, 2025
a627574
fix: optimization single use of filter instead of twice
GDamyanov Oct 2, 2025
8300ada
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Oct 9, 2025
0dd91d0
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Oct 14, 2025
815b9fe
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Oct 14, 2025
9b1f504
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Oct 15, 2025
663fee0
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Oct 17, 2025
ca75d08
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Oct 21, 2025
0bac2c2
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Oct 21, 2025
5f9c9f3
refactor: refactor samples
GDamyanov Oct 21, 2025
8e7ed76
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Oct 22, 2025
44f5de6
fix: refactor samples
GDamyanov Oct 22, 2025
468a36f
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Oct 23, 2025
42c26e2
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Oct 23, 2025
b0a0026
Merge branch 'main' into controls-check-form-validity-samples
GDamyanov Oct 23, 2025
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
269 changes: 187 additions & 82 deletions packages/main/cypress/specs/DatePicker.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1644,6 +1644,192 @@ describe("Date Picker Tests", () => {
});


describe("Validation inside a form ", () => {
it("has correct validity for valueMissing", () => {
cy.mount(
<form>
<DatePicker id="datePicker1" required={true}></DatePicker>
<button type="submit" id="submitBtn">Submits forms</button>
</form>
);

cy.get("form")
.then($item => {
$item.get(0).addEventListener("submit", (e) => e.preventDefault());
$item.get(0).addEventListener("submit", cy.stub().as("submit"));
});

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

cy.get("@submit")
.should("have.not.been.called");

cy.get("[ui5-date-picker]")
.as("datePicker")
.ui5AssertValidityState({
formValidity: { valueMissing: true },
validity: { valueMissing: true, valid: false },
checkValidity: false,
reportValidity: false
});

cy.get("#datePicker1:invalid")
.should("exist", "Required DatePicker without value should have :invalid CSS class");

cy.get("@datePicker")
.ui5DatePickerTypeDate("Apr 12, 2024");

cy.get("@datePicker")
.ui5AssertValidityState({
formValidity: { valueMissing: false },
validity: { valueMissing: false, valid: true },
checkValidity: true,
reportValidity: true
});

cy.get("#datePicker1:invalid").should("not.exist", "Required DatePicker with value should not have :invalid CSS class");
});

it("has correct validity for patternMismatch", () => {
cy.mount(
<form>
<DatePicker id="datePicker2" required={true} valueFormat="MMM d, y"></DatePicker>
<button type="submit" id="submitBtn">Submits forms</button>
</form>
);

cy.get("form")
.then($item => {
$item.get(0).addEventListener("submit", (e) => e.preventDefault());
$item.get(0).addEventListener("submit", cy.stub().as("submit"));
});

cy.get("#datePicker2")
.as("datePicker")
.ui5DatePickerTypeDate("Test 33, 2024");

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

cy.get("@submit")
.should("have.not.been.called");

cy.get("@datePicker")
.ui5AssertValidityState({
formValidity: { patternMismatch: true },
validity: { patternMismatch: true, valid: false },
checkValidity: false,
reportValidity: false
});

cy.get("#datePicker2:invalid")
.should("exist", "DatePicker without correct formatted value should have :invalid CSS class");

cy.get("@datePicker")
.ui5DatePickerTypeDate("Apr 12, 2024");

cy.get("@datePicker")
.ui5AssertValidityState({
formValidity: { patternMismatch: false },
validity: { patternMismatch: false, valid: true },
checkValidity: true,
reportValidity: true
});

cy.get("#datePicker2:invalid")
.should("not.exist", "DatePicker with correct formatted value should not have :invalid CSS class");
});

it("has correct validity for rangeUnderflow", () => {
cy.mount(
<form method="get">
<DatePicker id="datePicker3" minDate="Jan 10, 2024" valueFormat="MMM d, y"></DatePicker>
<button type="submit" id="submitBtn">Submits forms</button>
</form>
);

cy.get("form")
.then($item => {
$item.get(0).addEventListener("submit", (e) => e.preventDefault());
$item.get(0).addEventListener("submit", cy.stub().as("submit"));
});

cy.get("#datePicker3")
.as("datePicker")
.ui5DatePickerTypeDate("Apr 10, 2020");

cy.get("@datePicker")
.ui5AssertValidityState({
formValidity: { rangeUnderflow: true },
validity: { rangeUnderflow: true, valid: false },
checkValidity: false,
reportValidity: false
});

cy.get("#datePicker3:invalid")
.should("exist", "DatePicker with value below minDate should have :invalid CSS class");

cy.get("@datePicker")
.ui5DatePickerTypeDate("Jan 20, 2024");

cy.get("@datePicker")
.ui5AssertValidityState({
formValidity: { rangeUnderflow: false },
validity: { rangeUnderflow: false, valid: true },
checkValidity: true,
reportValidity: true
});

cy.get("#datePicker3:invalid")
.should("not.exist", "DatePicker with value above minDate should not have :invalid CSS class");
});


it("has correct validity for rangeOverflow", () => {
cy.mount(
<form>
<DatePicker id="datePicker3" maxDate="Jan 10, 2024" valueFormat="MMM d, y"></DatePicker>
<button type="submit" id="submitBtn">Submits forms</button>
</form>
);

cy.get("form")
.then($item => {
$item.get(0).addEventListener("submit", (e) => e.preventDefault());
$item.get(0).addEventListener("submit", cy.stub().as("submit"));
});

cy.get("#datePicker3")
.ui5DatePickerTypeDate("Jan 14, 2024");

cy.get("@datePicker")
.ui5AssertValidityState({
formValidity: { rangeOverflow: true },
validity: { rangeOverflow: true, valid: false },
checkValidity: false,
reportValidity: false
});

cy.get("#datePicker3:invalid")
.should("exist", "DatePicker with value above maxDate should have :invalid CSS class");

cy.get("@datePicker")
.ui5DatePickerTypeDate("Jan 5, 2024");

cy.get("@datePicker")
.ui5AssertValidityState({
formValidity: { rangeOverflow: false },
validity: { rangeOverflow: false, valid: true },
checkValidity: true,
reportValidity: true
});

cy.get("#datePicker3:invalid")
.should("not.exist", "DatePicker with value below maxDate should not have :invalid CSS class");
});
});

describe("Accessibility", () => {
it("picker popover accessible name with external label", () => {
const LABEL = "Deadline";
Expand Down Expand Up @@ -1723,85 +1909,4 @@ describe("Accessibility", () => {
.find("span#descr")
.should("have.text", DESCRIPTION);
});

describe("Accessibility - ariaValueStateHiddenText", () => {
it("should correctly extract text from nested slot structure in value state messages", () => {
const ERROR_MESSAGE = "Invalid date format";

cy.mount(
<DatePicker valueState="Negative">
<div slot="valueStateMessage">{ERROR_MESSAGE}</div>
</DatePicker>
);

cy.get("[ui5-date-picker]")
.as("datePicker");

// Get the inner datetime input
cy.get<DatePicker>("@datePicker")
.shadow()
.find("[ui5-datetime-input]")
.as("datetimeInput");

// Verify the input has proper value state
cy.get("@datetimeInput")
.should("have.attr", "value-state", "Negative");

// Test the ariaValueStateHiddenText getter directly
cy.get("@datetimeInput")
.then(($input) => {
const datetimeInput = $input[0] as any;
const ariaText = datetimeInput.ariaValueStateHiddenText;

// Should contain both the value state type and the custom message
expect(ariaText).to.include("Error");
expect(ariaText).to.include(ERROR_MESSAGE);
});

// Verify the aria-describedby points to an element with the correct text
cy.get("@datetimeInput")
.shadow()
.find("input")
.should("have.attr", "aria-describedby")
.then((describedBy) => {
cy.get("@datetimeInput")
.shadow()
.find(`#${describedBy}`)
.should("contain.text", "Error")
.and("contain.text", ERROR_MESSAGE);
});
});

it("should handle complex nested slot structure from DatePicker forwarding", () => {
const CUSTOM_ERROR = "Please select a valid date";

cy.mount(
<DatePicker valueState="Critical">
<div slot="valueStateMessage">
<span>{CUSTOM_ERROR}</span>
</div>
</DatePicker>
);

cy.get("[ui5-date-picker]")
.as("datePicker");

cy.get<DatePicker>("@datePicker")
.shadow()
.find("[ui5-datetime-input]")
.as("datetimeInput");

// Test nested slot content extraction
cy.get("@datetimeInput")
.then(($input) => {
const datetimeInput = $input[0] as any;
const ariaText = datetimeInput.ariaValueStateHiddenText;

// Should extract text from nested structure
expect(ariaText).to.include("Warning");
expect(ariaText).to.include(CUSTOM_ERROR);
expect(ariaText.trim()).to.not.be.empty;
});
});
});
});
});
Loading
Loading