diff --git a/local_moodleappbehat/tests/behat/behat_app.php b/local_moodleappbehat/tests/behat/behat_app.php index 15e4b0eef..631f938cf 100644 --- a/local_moodleappbehat/tests/behat/behat_app.php +++ b/local_moodleappbehat/tests/behat/behat_app.php @@ -1211,4 +1211,13 @@ class behat_app extends behat_app_helper { $this->resize_app_window($width, $height); } + /** + * Wait until Toast disappears. + * + * @When I wait toast to dismiss in the app + */ + public function i_wait_toast_to_dismiss_in_the_app() { + $this->runtime_js('waitToastDismiss()'); + } + } diff --git a/src/addons/calendar/pages/edit-event/edit-event.html b/src/addons/calendar/pages/edit-event/edit-event.html index fde3faec0..a26e827e9 100644 --- a/src/addons/calendar/pages/edit-event/edit-event.html +++ b/src/addons/calendar/pages/edit-event/edit-event.html @@ -27,12 +27,13 @@ -

{{ 'core.date' | translate }}

+
- + - + {{'core.date' | translate}} @@ -146,16 +147,16 @@
-

{{ 'addon.calendar.durationuntil' | translate }}

+

- + + presentation="date-time" [showDefaultButtons]="true"> {{'addon.calendar.durationuntil' | translate}} @@ -163,11 +164,11 @@ -

{{ 'addon.calendar.durationminutes' | translate }}

+

- diff --git a/src/addons/calendar/tests/behat/create_events.feature b/src/addons/calendar/tests/behat/create_events.feature index 88dd50205..7f05af69b 100755 --- a/src/addons/calendar/tests/behat/create_events.feature +++ b/src/addons/calendar/tests/behat/create_events.feature @@ -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. diff --git a/src/addons/mod/data/fields/date/component/addon-mod-data-field-date.html b/src/addons/mod/data/fields/date/component/addon-mod-data-field-date.html index 9e9378121..b5ac0ad6e 100644 --- a/src/addons/mod/data/fields/date/component/addon-mod-data-field-date.html +++ b/src/addons/mod/data/fields/date/component/addon-mod-data-field-date.html @@ -5,7 +5,7 @@ + [disabled]="searchMode && !searchFields['f_'+field.id+'_z']" presentation="date" [showDefaultButtons]="true" /> diff --git a/src/addons/userprofilefield/datetime/component/addon-user-profile-field-datetime.html b/src/addons/userprofilefield/datetime/component/addon-user-profile-field-datetime.html index 43341f2e6..5c4aaaa70 100644 --- a/src/addons/userprofilefield/datetime/component/addon-user-profile-field-datetime.html +++ b/src/addons/userprofilefield/datetime/component/addon-user-profile-field-datetime.html @@ -13,16 +13,22 @@ - + + - + + + {{ 'core.choosedots' | translate }} + {{ 'core.choosedots' | translate }} + + - + diff --git a/src/addons/userprofilefield/datetime/component/datetime.ts b/src/addons/userprofilefield/datetime/component/datetime.ts index 17e28354a..af78bef7e 100644 --- a/src/addons/userprofilefield/datetime/component/datetime.ts +++ b/src/addons/userprofilefield/datetime/component/datetime.ts @@ -86,7 +86,7 @@ export class AddonUserProfileFieldDatetimeComponent extends CoreUserProfileField */ protected createFormControl(field: AuthEmailSignupProfileField): FormControl { const formData = { - value: field.defaultdata != '0' ? field.defaultdata : undefined, + value: field.defaultdata && field.defaultdata !== '0' ? field.defaultdata : undefined, disabled: this.disabled, }; diff --git a/src/core/features/reminders/tests/behat/course_reminders.feature b/src/core/features/reminders/tests/behat/course_reminders.feature index b14edb89b..6c9aeee2d 100644 --- a/src/core/features/reminders/tests/behat/course_reminders.feature +++ b/src/core/features/reminders/tests/behat/course_reminders.feature @@ -23,19 +23,19 @@ Feature: Set a new reminder on course # Default set When I press "Set a reminder for \"Course 1\" (Course end date)" in the app Then I should find "Reminder set for " in the app - And I should find "Reminder set for" in the app # Set from list - When I press "Set a reminder for \"Course 1\" (Course end date)" in the app + When I wait toast to dismiss in the app + And I press "Set a reminder for \"Course 1\" (Course end date)" in the app Then I should find "Set a reminder" in the app And "At the time of the event" should be selected in the app But "12 hours before" should not be selected in the app When I press "12 hours before" in the app Then I should find "Reminder set for " in the app - And I should find "Reminder set for" in the app # Custom set - When I press "Set a reminder for \"Course 1\" (Course end date)" in the app + When I wait toast to dismiss in the app + And I press "Set a reminder for \"Course 1\" (Course end date)" in the app Then I should find "Set a reminder" in the app And "At the time of the event" should not be selected in the app But "12 hours before" should be selected in the app @@ -46,10 +46,10 @@ Feature: Set a new reminder on course | Units | hours | And I press "Set reminder" in the app Then I should find "Reminder set for " in the app - And I should find "Reminder set for" in the app # Remove - When I press "Set a reminder for \"Course 1\" (Course end date)" in the app + When I wait toast to dismiss in the app + And I press "Set a reminder for \"Course 1\" (Course end date)" in the app Then "2 hours before" should be selected in the app When I press "Delete reminder" in the app Then I should find "Reminder deleted" in the app diff --git a/src/testing/services/behat-dom.ts b/src/testing/services/behat-dom.ts index 8d8fff76a..27a97bed3 100644 --- a/src/testing/services/behat-dom.ts +++ b/src/testing/services/behat-dom.ts @@ -376,6 +376,11 @@ export class TestingBehatDomUtilsService { containers = containers .filter(container => { + if (!this.isElementVisible(container)) { + // Ignore containers not visible. + return false; + } + if (container.tagName === 'ION-ALERT') { // For some reason, in Behat sometimes alerts aren't removed from DOM, the close animation doesn't finish. // Filter alerts with pointer-events none since that style is set before the close animation starts. @@ -453,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 = ( element).datetime; + const datetime = document.querySelector(`ion-datetime#${datetimeId}`); + + return datetime || undefined; } input = this.getShadowDOMHost(label) || undefined; @@ -477,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]; } diff --git a/src/testing/services/behat-runtime.ts b/src/testing/services/behat-runtime.ts index 17078b0af..d4a39c5d5 100644 --- a/src/testing/services/behat-runtime.ts +++ b/src/testing/services/behat-runtime.ts @@ -18,7 +18,7 @@ import { CoreCustomURLSchemes, CoreCustomURLSchemesProvider } from '@services/ur import { ONBOARDING_DONE } from '@features/login/constants'; import { CoreConfig } from '@services/config'; import { EnvironmentConfig } from '@/types/config'; -import { LocalNotifications, makeSingleton, NgZone } from '@singletons'; +import { LocalNotifications, makeSingleton, NgZone, ToastController } from '@singletons'; import { CoreNetwork, CoreNetworkService } from '@services/network'; import { CorePushNotifications, CorePushNotificationsProvider } from '@features/pushnotifications/services/pushnotifications'; import { CoreCronDelegate, CoreCronDelegateService } from '@services/cron'; @@ -33,6 +33,7 @@ import { Swiper } from 'swiper'; import { LocalNotificationsMock } from '@features/emulator/services/local-notifications'; import { GetClosureArgs } from '@/core/utils/types'; import { CoreIframeComponent } from '@components/iframe/iframe'; +import { CoreUtils } from '@services/utils/utils'; /** * Behat runtime servive with public API. @@ -745,6 +746,15 @@ export class TestingBehatRuntimeService { return 'OK'; } + /** + * Wait for toast to be dismissed in the app. + * + * @returns Promise resolved when toast has been dismissed. + */ + async waitToastDismiss(): Promise { + await CoreUtils.ignoreErrors(ToastController.dismiss()); + } + } export const TestingBehatRuntime = makeSingleton(TestingBehatRuntimeService); diff --git a/src/theme/theme.base.scss b/src/theme/theme.base.scss index c83994d66..25b28b996 100644 --- a/src/theme/theme.base.scss +++ b/src/theme/theme.base.scss @@ -2015,6 +2015,11 @@ ion-item.item-label-stacked ion-datetime-button { align-self: self-end; } +ion-datetime-button p { + margin-top: 4px; + margin-bottom: 4px; +} + // Table App styles table.core-table { border-collapse: collapse;