MOBILE-3947 behat: Fix Datetime value
parent
036e932350
commit
210b3a75a3
|
@ -20,13 +20,14 @@ Feature: Test creation of calendar events in app
|
||||||
| teacher1 | C1 | editingteacher |
|
| teacher1 | C1 | editingteacher |
|
||||||
| student1 | C1 | student |
|
| student1 | C1 | student |
|
||||||
|
|
||||||
@ionic7_failure
|
# This test is flaky due to timestamp.
|
||||||
Scenario: Create user event as student from monthly view
|
Scenario: Create user event as student from monthly view
|
||||||
Given I entered the app as "student1"
|
Given I entered the app as "student1"
|
||||||
When I press "More" in the app
|
When I press "More" in the app
|
||||||
And I press "Calendar" in the app
|
And I press "Calendar" in the app
|
||||||
And I press "New event" in the app
|
And I press "New event" in the app
|
||||||
Then the field "Date" matches value "## now ##%d/%m/%y, %H:%M##" in the app
|
# Flaky step, sometimes it fails due to minute change when checking.
|
||||||
|
Then the field "Date" matches value "## now ##%Y-%m-%dT%H:%M##" in the app
|
||||||
And I should not be able to press "Save" in the app
|
And I should not be able to press "Save" in the app
|
||||||
|
|
||||||
# Check that student can only create User events.
|
# Check that student can only create User events.
|
||||||
|
@ -36,7 +37,7 @@ Feature: Test creation of calendar events in app
|
||||||
|
|
||||||
# Create the event.
|
# Create the event.
|
||||||
When I set the field "Event title" to "User Event 01" in the app
|
When I set the field "Event title" to "User Event 01" in the app
|
||||||
And I set the field "Date" to "2025-04-11T09:00+08:00" in the app
|
And I set the field "Date" to "2025-04-11T09:00" in the app
|
||||||
And I press "Without duration" in the app
|
And I press "Without duration" in the app
|
||||||
And I set the field "Description" to "This is User Event 01 description." in the app
|
And I set the field "Description" to "This is User Event 01 description." in the app
|
||||||
And I set the field "Location" to "Barcelona" in the app
|
And I set the field "Location" to "Barcelona" in the app
|
||||||
|
|
|
@ -401,7 +401,7 @@ export class TestingBehatDomUtilsService {
|
||||||
*/
|
*/
|
||||||
findField(field: string): HTMLElement | HTMLInputElement | undefined {
|
findField(field: string): HTMLElement | HTMLInputElement | undefined {
|
||||||
const input = this.findElementBasedOnText(
|
const input = this.findElementBasedOnText(
|
||||||
{ text: field, selector: 'input, textarea, [contenteditable="true"], ion-select, ion-datetime' },
|
{ text: field, selector: 'input, textarea, [contenteditable="true"], ion-select, ion-datetime-button, ion-datetime' },
|
||||||
{ onlyClickable: false, containerName: '' },
|
{ onlyClickable: false, containerName: '' },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -508,12 +508,15 @@ export class TestingBehatRuntimeService {
|
||||||
* @returns Value.
|
* @returns Value.
|
||||||
*/
|
*/
|
||||||
protected getFieldValue(element: HTMLElement | HTMLInputElement): string {
|
protected getFieldValue(element: HTMLElement | HTMLInputElement): string {
|
||||||
if (element.tagName === 'ION-DATETIME') {
|
if (element.tagName === 'ION-DATETIME-BUTTON' && element.shadowRoot) {
|
||||||
// ion-datetime's value is a timestamp in ISO format. Use the text displayed to the user instead.
|
return Array.from(element.shadowRoot.querySelectorAll('button')).map(button => button.innerText).join(' ');
|
||||||
const dateTimeTextElement = element.shadowRoot?.querySelector<HTMLElement>('.datetime-text');
|
|
||||||
if (dateTimeTextElement) {
|
|
||||||
return dateTimeTextElement.innerText;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (element.tagName === 'ION-DATETIME') {
|
||||||
|
const value = 'value' in element ? element.value : element.innerText;
|
||||||
|
|
||||||
|
// Remove seconds from the value to ensure stability on tests. It could be improved using moment parsing if needed.
|
||||||
|
return value.substring(0, value.length - 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'value' in element ? element.value : element.innerText;
|
return 'value' in element ? element.value : element.innerText;
|
||||||
|
|
Loading…
Reference in New Issue