MOBILE-4569 behat: Fix some behat tests

main
Pau Ferrer Ocaña 2024-07-09 10:49:06 +02:00
parent 4427f91b63
commit 339212435d
14 changed files with 39 additions and 10 deletions

View File

@ -153,7 +153,7 @@ jobs:
- name: Initialise moodle-plugin-ci
run: |
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4.4
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4.5
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
sudo locale-gen en_AU.UTF-8

View File

@ -3,8 +3,7 @@
<ion-list>
<ion-item>
<ion-label position="floating">What is the answer to the Ultimate Question of Life, The Universe, and Everything?</ion-label>
<ion-input [(ngModel)]="CONTENT_OTHERDATA.answer"></ion-input>
<ion-input labelPlacement="floating" [(ngModel)]="CONTENT_OTHERDATA.answer" label="What is the answer to the Ultimate Question of Life, The Universe, and Everything?"></ion-input>
</ion-item>
<ion-item *ngIf="CONTENT_OTHERDATA.answer === '42'">
<ion-label>That is correct!</ion-label>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -449,7 +449,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
this.feedback,
this.submitId,
);
} catch (error) {
} catch {
// Error ocurred, consider there are no changes.
return false;
}

View File

@ -100,6 +100,7 @@ Feature: Test marking workflow in assignment activity in app
And I press "Grade" in the app
When I set the field "Grade out of 100" to "60" in the app
And I press "Done" in the app
And I wait loading to finish in the app
And I press "Student1" in the app
And I press "Grade" in the app
Then I should find "60 / 100" within "Current grade in assignment" "ion-item" in the app
@ -112,6 +113,7 @@ Feature: Test marking workflow in assignment activity in app
And I press "Grade" in the app
When I set the field "Grade out of 100" to "80" in the app
And I press "Done" in the app
And I wait loading to finish in the app
And I press "Student3" in the app
And I press "Grade" in the app
Then I should find "80" within "Current grade in gradebook" "ion-item" in the app

View File

@ -49,6 +49,8 @@ Feature: Test basic usage of BBB activity in app
And I should be able to press "Join session" in the app
When I press "Join session" in the app
# TODO: This step will make behat github actions work but we should find a better way to wait for the room to start.
And I wait "3" seconds
And I wait for the BigBlueButton room to start
And I switch back to the app
Then I should find "The session is in progress." in the app
@ -68,6 +70,8 @@ Feature: Test basic usage of BBB activity in app
And I should be able to press "Join session" in the app
When I press "Join session" in the app
# TODO: This step will make behat github actions work but we should find a better way to wait for the room to start.
And I wait "3" seconds
And I wait for the BigBlueButton room to start
And I switch back to the app
Then I should find "The session is in progress." in the app

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -167,12 +167,16 @@ Feature: Attempt a quiz in app
And I press "Three" in the app
And I set the field "Answer" to "Berlin" in the app
And I press "Next" in the app
And I wait loading to finish in the app
And I set the field "Answer" to "testing" in the app
And I press "Next" in the app
And I wait loading to finish in the app
And I set the field "Answer" to "5" in the app
And I press "Next" in the app
And I wait loading to finish in the app
And I set the field "Answer" to "Testing an essay" in the app
And I press "Next" "ion-button" in the app
And I wait loading to finish in the app
And I press "quick" ".drag" in the app
And I click on ".place1.drop" "css"
And I press "fox" ".drag" in the app
@ -180,26 +184,33 @@ Feature: Attempt a quiz in app
And I press "lazy" ".drag" in the app
And I click on ".place3.drop" "css"
And I press "Next" in the app
And I wait loading to finish in the app
And I press "True" in the app
And I press "Next" in the app
And I wait loading to finish in the app
And I set the field "frog" to "amphibian" in the app
And I set the field "newt" to "insect" in the app
And I set the field "cat" to "mammal" in the app
And I press "Next" in the app
And I wait loading to finish in the app
Then I should find "Text of the eighth question" in the app
When I press "Next" in the app
And I wait loading to finish in the app
And I set the field "Blank 1" to "cat" in the app
And I set the field "Blank 2" to "mat" in the app
And I press "Next" in the app
And I wait loading to finish in the app
And I press "abyssal" ".drag" in the app
And I click on ".place6.dropzone" "css"
And I press "trench" ".drag" in the app
And I click on ".place3.dropzone" "css"
And I press "Next" in the app
And I wait loading to finish in the app
And I press "Railway station" ".marker" in the app
And I click on "img.dropbackground" "css"
And I press "Submit" in the app
And I wait loading to finish in the app
Then I should find "Answer saved" in the app
And I should find "Incomplete answer" within "10" "ion-item" in the app
But I should not find "Not yet answered" in the app
@ -224,8 +235,10 @@ Feature: Attempt a quiz in app
When I press "True" in the app
And I press "Next" in the app
And I wait loading to finish in the app
And I press "False" in the app
And I press "Submit" in the app
And I wait loading to finish in the app
And I press "Submit all and finish" in the app
Then I should find "Once you submit" in the app
But I should not find "Questions without a response" in the app

View File

@ -1185,7 +1185,7 @@ export class CoreUtilsProvider {
if (options.showBrowserWarning || options.showBrowserWarning === undefined) {
try {
await CoreWindow.confirmOpenBrowserIfNeeded(originaUrl);
} catch (error) {
} catch {
return; // Cancelled, stop.
}
}

View File

@ -196,10 +196,13 @@ export class TestingBehatBlockingService {
await CoreUtils.nextTick();
const blockingElements = Array.from(
document.querySelectorAll<HTMLElement>('div.core-loading-container, ion-loading, .click-block-active'),
document.querySelectorAll<HTMLElement>('div.core-loading-container, ion-loading'),
);
const isBlocked = blockingElements.some(element => {
// @TODO Fix ion-loading present check with CoreDom.isElementVisible.
// ion-loading never has offsetParent since position is fixed.
// Using isElementVisible solve the problem but will block behats (like BBB).
if (!element.offsetParent) {
return false;
}

View File

@ -159,11 +159,19 @@ export class TestingBehatRuntimeService {
*/
async waitLoadingToFinish(): Promise<void> {
await NgZone.run(async () => {
const elements = Array.from(document.body.querySelectorAll<HTMLElement>('core-loading'))
.filter((element) => CoreDom.isElementVisible(element));
const coreLoadingsPromises: Promise<unknown>[] =
Array.from(document.body.querySelectorAll<HTMLElement>('core-loading'))
.filter((element) => CoreDom.isElementVisible(element))
.map(element => CoreDirectivesRegistry.waitDirectiveReady(element, CoreLoadingComponent));
await Promise.all(elements.map(element =>
CoreDirectivesRegistry.waitDirectiveReady(element, CoreLoadingComponent)));
const ionLoadingsPromises: Promise<unknown>[] =
Array.from(document.body.querySelectorAll<HTMLIonLoadingElement>('ion-loading'))
.filter((element) => CoreDom.isElementVisible(element))
.map(element => element.onDidDismiss());
const promises = coreLoadingsPromises.concat(ionLoadingsPromises);
await Promise.all(promises);
});
}