MOBILE-3947 behat: Fix datetime behat tests
parent
69fca2f269
commit
864087c52a
|
@ -26,8 +26,9 @@ Feature: Test creation of calendar events in app
|
|||
When I press "More" in the app
|
||||
And I press "Calendar" in the app
|
||||
And I press "New event" in the app
|
||||
Then I should find "## now ##%b %e, %Y##" 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 find "## now ##%l:%M %p##" in the app
|
||||
And I should not be able to press "Save" in the app
|
||||
|
||||
# Check that student can only create User events.
|
||||
|
|
|
@ -86,7 +86,7 @@ export class AddonUserProfileFieldDatetimeComponent extends CoreUserProfileField
|
|||
*/
|
||||
protected createFormControl(field: AuthEmailSignupProfileField): FormControl<string | undefined> {
|
||||
const formData = {
|
||||
value: field.defaultdata != '0' ? field.defaultdata : undefined,
|
||||
value: field.defaultdata && field.defaultdata !== '0' ? field.defaultdata : undefined,
|
||||
disabled: this.disabled,
|
||||
};
|
||||
|
||||
|
|
|
@ -458,7 +458,16 @@ export class TestingBehatDomUtilsService {
|
|||
const inputId = label.getAttribute('for');
|
||||
|
||||
if (inputId) {
|
||||
return document.getElementById(inputId) || undefined;
|
||||
const element = document.getElementById(inputId) || undefined;
|
||||
if (element?.tagName !== 'ION-DATETIME-BUTTON') {
|
||||
return element;
|
||||
}
|
||||
|
||||
// Search the ion-datetime associated with the button.
|
||||
const datetimeId = (<HTMLIonDatetimeButtonElement> element).datetime;
|
||||
const datetime = document.querySelector<HTMLElement>(`ion-datetime#${datetimeId}`);
|
||||
|
||||
return datetime || undefined;
|
||||
}
|
||||
|
||||
input = this.getShadowDOMHost(label) || undefined;
|
||||
|
@ -482,6 +491,19 @@ export class TestingBehatDomUtilsService {
|
|||
locator: TestingBehatElementLocator,
|
||||
options: TestingBehatFindOptions = {},
|
||||
): HTMLElement | undefined {
|
||||
// Remove extra spaces.
|
||||
const treatedText = locator.text.trim().replace(/\s\s+/g, ' ');
|
||||
if (treatedText !== locator.text) {
|
||||
const element = this.findElementsBasedOnText({
|
||||
...locator,
|
||||
text: treatedText,
|
||||
}, options)[0];
|
||||
|
||||
if (element) {
|
||||
return element;
|
||||
}
|
||||
}
|
||||
|
||||
return this.findElementsBasedOnText(locator, options)[0];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue