Merge pull request #3764 from NoelDeMartin/MOBILE-4362

MOBILE-4362 timeline: Fix empty searches
main
Dani Palou 2023-08-01 10:46:48 +02:00 committed by GitHub
commit ad3245136e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 21 deletions

View File

@ -252,9 +252,7 @@ export class AddonBlockTimelineComponent implements OnInit, ICoreBlockComponent
const courseIds = courses.map(course => course.id); const courseIds = courses.map(course => course.id);
const gracePeriod = await this.getCoursesGracePeriod(); const gracePeriod = await this.getCoursesGracePeriod();
const courseEvents = await AddonBlockTimeline.getActionEventsByCourses(courseIds, search ?? ''); const courseEvents = await AddonBlockTimeline.getActionEventsByCourses(courseIds, search ?? '');
const sectionObservables = courses
return combineLatest(
courses
.filter( .filter(
course => course =>
!course.hidden && !course.hidden &&
@ -273,8 +271,13 @@ export class AddonBlockTimelineComponent implements OnInit, ICoreBlockComponent
); );
return section.data$.pipe(map(({ events }) => events.length > 0 ? section : null)); return section.data$.pipe(map(({ events }) => events.length > 0 ? section : null));
}), });
).pipe(
if (sectionObservables.length === 0) {
return of([]);
}
return combineLatest(sectionObservables).pipe(
map(sections => sections.filter( map(sections => sections.filter(
(section: AddonBlockTimelineSection | null): section is AddonBlockTimelineSection => !!section, (section: AddonBlockTimelineSection | null): section is AddonBlockTimelineSection => !!section,
)), )),

View File

@ -91,3 +91,27 @@ Feature: Timeline block.
| assign | C1 | newassign | New Assignment | ##tomorrow## | | assign | C1 | newassign | New Assignment | ##tomorrow## |
And I pull to refresh in the app And I pull to refresh in the app
Then I should find "New Assignment" in the app Then I should find "New Assignment" in the app
@lms_from4.0
Scenario: Search
Given I entered the app as "student1"
Then I should find "Assignment 00" within "Timeline" "ion-card" in the app
When I set the field "Search by activity type or name" to "thisdoesntexist" in the app
And I press "Search" in the app
Then I should find "No activities require action" in the app
But I should not find "Assignment 00" within "Timeline" "ion-card" in the app
When I press "Clear search" in the app
Then I should find "Assignment 00" within "Timeline" "ion-card" in the app
When I press "Sort by" in the app
And I press "Sort by courses" in the app
Then I should find "Course 1" in the app
And I should find "Assignment 02" within "Timeline" "ion-card" in the app
When I set the field "Search by activity type or name" to "thisdoesntexist" in the app
And I press "Search" in the app
Then I should find "No activities require action" in the app
But I should not find "Course 1" in the app
And I should not find "Assignment 02" within "Timeline" "ion-card" in the app