Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Feature/38933 new notification banner (#9762)

Benjamin Bädorfe7042d53f149
diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml
index c6b64f26242..0058e53a319 100644
--- a/config/locales/js-en.yml
+++ b/config/locales/js-en.yml
@@ -583,6 +583,9 @@ en:
no_notification: "Looks like you're all caught up."
no_notification_with_current_filter: "Change of involvement or go back to the Inbox to view notifications"
no_selection: "Click on a notification to view all activity details."
+ new_notifications:
+ message: 'There are new notifications.'
+ link_text: 'Click here to load them'
menu:
accountable: 'Accountable'
assigned: 'Assigned'
diff --git a/frontend/src/app/core/state/collection-store.ts b/frontend/src/app/core/state/collection-store.ts
index d837c152255..5f3f351a4b8 100644
--- a/frontend/src/app/core/state/collection-store.ts
+++ b/frontend/src/app/core/state/collection-store.ts
@@ -3,6 +3,7 @@ import {
ID,
QueryEntity,
} from '@datorama/akita';
+import { IHALCollection } from 'core-app/core/apiv3/types/hal-collection.type';
import {
Apiv3ListParameters,
listParamsString,
@@ -10,7 +11,6 @@ import {
import { Observable } from 'rxjs';
import {
filter,
- map,
} from 'rxjs/operators';
export interface CollectionResponse {
@@ -30,6 +30,12 @@ export interface CollectionItem {
id:ID;
}
+export function mapHALCollectionToIDCollection<T extends CollectionItem>(collection:IHALCollection<T>):CollectionResponse {
+ return {
+ ids: collection._embedded.elements.map((el) => el.id),
+ };
+}
+
/**
* Initialize the collection part of the entity store
*/
@@ -66,6 +72,20 @@ export function selectCollectionAsHrefs$<T extends CollectionItem>(service:Colle
);
}
+/**
+ * Retrieve the entities from the collection a given the ID collection
+ *
+ * @param service
+ * @param collection
+ */
+export function selectEntitiesFromIDCollection<T extends CollectionItem>(service:CollectionService<T>, collection:CollectionResponse):T[] {
+ const ids = collection?.ids || [];
+
+ return ids
+ .map((id) => service.query.getEntity(id))
+ .filter((item) => !!item) as T[];
+}
+
/**
* Retrieve the entities from the collection a given parameter set produces.
*
@@ -76,9 +96,6 @@ export function selectCollectionAsHrefs$<T extends CollectionItem>(service:Colle
export function selectCollectionAsEntities$<T extends CollectionItem>(service:CollectionService<T>, state:CollectionState<T>, params:Apiv3ListParameters):T[] {
const key = collectionKey(params);
const collection = state.collections[key];
- const ids = collection?.ids || [];
- return ids
- .map((id:string) => service.query.getEntity(id))
- .filter((item) => !!item) as T[];
+ return selectEntitiesFromIDCollection(service, collection);
}
diff --git a/frontend/src/app/core/state/in-app-notifications/in-app-notification.model.ts b/frontend/src/app/core/state/in-app-notifications/in-app-notification.model.ts
index f3bc3d24d2a..b5b85c79516 100644
--- a/frontend/src/app/core/state/in-app-notifications/in-app-notification.model.ts
+++ b/frontend/src/app/core/state/in-app-notifications/in-app-notification.model.ts
@@ -2,7 +2,6 @@ import { ID } from '@datorama/akita';
import {
HalResourceLink,
HalResourceLinks,
- Formattable,
} from 'core-app/core/state/hal-resource';
export const NOTIFICATIONS_MAX_SIZE = 100;
diff --git a/frontend/src/app/core/state/in-app-notifications/in-app-notifications.actions.ts b/frontend/src/app/core/state/in-app-notifications/in-app-notifications.actions.ts
index be2fa86cb59..1aeda581f9e 100644
--- a/frontend/src/app/core/state/in-app-notifications/in-app-notifications.actions.ts
+++ b/frontend/src/app/core/state/in-app-notifications/in-app-notifications.actions.ts
@@ -13,3 +13,8 @@ export const notificationsMarkedRead = action(
'[IAN] Notifications were marked as read',
props<{ origin:string, notifications:ID[] }>(),
);
+
+export const notificationCountIncreased = action(
+ '[IAN] The backend sent a notification count that was higher than the last known',
+ props<{ origin:string, count:number }>(),
+);
diff --git a/frontend/src/app/core/state/in-app-notifications/in-app-notifications.service.ts b/frontend/src/app/core/state/in-app-notifications/in-app-notifications.service.ts
index 355419c6b01..c81f585956f 100644
--- a/frontend/src/app/core/state/in-app-notifications/in-app-notifications.service.ts
+++ b/frontend/src/app/core/state/in-app-notifications/in-app-notifications.service.ts
@@ -10,8 +10,6 @@ import {
} from '@datorama/akita';
import { APIV3Service } from 'core-app/core/apiv3/api-v3.service';
import { NotificationsService } from 'core-app/shared/components/notifications/notifications.service';
-import { InAppNotificationsStore } from './in-app-notifications.store';
-import { InAppNotification } from './in-app-notification.model';
import { IHALCollection } from 'core-app/core/apiv3/types/hal-collection.type';
import { HttpClient } from '@angular/common/http';
import { InAppNotificationsQuery } from 'core-app/core/state/in-app-notifications/in-app-notifications.query';
@@ -26,6 +24,8 @@ import {
EffectHandler,
} from 'core-app/core/state/effects/effect-handler.decorator';
import { ActionsService } from 'core-app/core/state/actions/actions.service';
+import { InAppNotificationsStore } from './in-app-notifications.store';
+import { InAppNotification } from './in-app-notification.model';
@EffectHandler
@Injectable()
@@ -64,6 +64,7 @@ export class InAppNotificationsResourceService {
collections: {
...collections,
[collectionURL]: {
+ ...collections[collectionURL],
ids: events._embedded.elements.map((el) => el.id),
},
},
diff --git a/frontend/src/app/features/in-app-notifications/bell/state/ian-bell.query.ts b/frontend/src/app/features/in-app-notifications/bell/state/ian-bell.query.ts
index 38e48b3a1dc..6748f4f7be9 100644
--- a/frontend/src/app/features/in-app-notifications/bell/state/ian-bell.query.ts
+++ b/frontend/src/app/features/in-app-notifications/bell/state/ian-bell.query.ts
@@ -1,3 +1,4 @@
+import { pairwise, filter, map } from 'rxjs/operators';
import { Query } from '@datorama/akita';
import {
IanBellState,
@@ -5,6 +6,14 @@ import {
} from 'core-app/features/in-app-notifications/bell/state/ian-bell.store';
export class IanBellQuery extends Query<IanBellState> {
+ unread$ = this.select('totalUnread');
+
+ unreadCountIncreased$ = this.unread$.pipe(
+ pairwise(),
+ filter(([last, curr]) => curr > last),
+ map(([, curr]) => curr),
+ );
+
constructor(protected store:IanBellStore) {
super(store);
}
diff --git a/frontend/src/app/features/in-app-notifications/bell/state/ian-bell.service.ts b/frontend/src/app/features/in-app-notifications/bell/state/ian-bell.service.ts
index 706ed568722..49559103432 100644
--- a/frontend/src/app/features/in-app-notifications/bell/state/ian-bell.service.ts
+++ b/frontend/src/app/features/in-app-notifications/bell/state/ian-bell.service.ts
@@ -5,6 +5,7 @@ import { IAN_FACET_FILTERS } from 'core-app/features/in-app-notifications/center
import {
map,
tap,
+ skip,
} from 'rxjs/operators';
import { Observable } from 'rxjs';
import { IanBellQuery } from 'core-app/features/in-app-notifications/bell/state/ian-bell.query';
@@ -12,7 +13,7 @@ import {
EffectCallback,
EffectHandler,
} from 'core-app/core/state/effects/effect-handler.decorator';
-import { notificationsMarkedRead } from 'core-app/core/state/in-app-notifications/in-app-notifications.actions';
+import { notificationsMarkedRead, notificationCountIncreased } from 'core-app/core/state/in-app-notifications/in-app-notifications.actions';
import { ActionsService } from 'core-app/core/state/actions/actions.service';
/**
@@ -23,18 +24,21 @@ import { ActionsService } from 'core-app/core/state/actions/actions.service';
@Injectable({ providedIn: 'root' })
@EffectHandler
export class IanBellService {
- readonly id = 'ian-center';
+ readonly id = 'ian-bell';
readonly store = new IanBellStore();
readonly query = new IanBellQuery(this.store);
- unread$ = this.query.select('totalUnread');
+ unread$ = this.query.unread$;
constructor(
readonly actions$:ActionsService,
readonly resourceService:InAppNotificationsResourceService,
) {
+ this.query.unreadCountIncreased$.pipe(skip(1)).subscribe((count) => {
+ this.actions$.dispatch(notificationCountIncreased({ origin: this.id, count }));
+ });
}
fetchUnread():Observable<number> {
diff --git a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.html b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.html
index e71d2210dbe..8ee520dd9cf 100644
--- a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.html
+++ b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.html
@@ -5,7 +5,7 @@
</op-content-loader>
</div>
<div class="op-ian-center--content">
- <ng-container *ngIf="(hasNotifications$ | async) as notifications; else noResults">
+ <ng-container *ngIf="(hasNotifications$ | async); else noResults">
<cdk-virtual-scroll-viewport
itemSize="100"
class="op-ian-center--viewport"
diff --git a/frontend/src/app/features/in-app-notifications/center/menu/state/ian-menu.service.ts b/frontend/src/app/features/in-app-notifications/center/menu/state/ian-menu.service.ts
index 8a29dc1f0c6..d6f9073697d 100644
--- a/frontend/src/app/features/in-app-notifications/center/menu/state/ian-menu.service.ts
+++ b/frontend/src/app/features/in-app-notifications/center/menu/state/ian-menu.service.ts
@@ -2,7 +2,10 @@ import {
Injectable,
Injector,
} from '@angular/core';
-import { notificationsMarkedRead } from 'core-app/core/state/in-app-notifications/in-app-notifications.actions';
+import {
+ notificationsMarkedRead,
+ notificationCountIncreased,
+} from 'core-app/core/state/in-app-notifications/in-app-notifications.actions';
import {
EffectCallback,
EffectHandler,
@@ -38,6 +41,14 @@ export class IanMenuService {
) {
}
+ /**
+ * Check for updates after bell count increased
+ */
+ @EffectCallback(notificationCountIncreased)
+ private checkForNewNotifications() {
+ this.reload();
+ }
+
/**
* Reload after notifications were successfully marked as read
*/
diff --git a/frontend/src/app/features/in-app-notifications/center/state/ian-center.query.ts b/frontend/src/app/features/in-app-notifications/center/state/ian-center.query.ts
index cde83dc10ee..1a84e5b0826 100644
--- a/frontend/src/app/features/in-app-notifications/center/state/ian-center.query.ts
+++ b/frontend/src/app/features/in-app-notifications/center/state/ian-center.query.ts
@@ -3,7 +3,6 @@ import {
distinctUntilChanged,
map,
} from 'rxjs/operators';
-import { combineLatest } from 'rxjs';
import {
IAN_FACET_FILTERS,
IanCenterState,
@@ -14,8 +13,7 @@ import {
Apiv3ListParameters,
} from 'core-app/core/apiv3/paths/apiv3-list-resource.interface';
import { InAppNotificationsResourceService } from 'core-app/core/state/in-app-notifications/in-app-notifications.service';
-import { InAppNotification } from 'core-app/core/state/in-app-notifications/in-app-notification.model';
-import { selectCollectionAsEntities$ } from 'core-app/core/state/collection-store';
+import { selectEntitiesFromIDCollection } from 'core-app/core/state/collection-store';
export class IanCenterQuery extends Query<IanCenterState> {
activeFacet$ = this.select('activeFacet');
@@ -24,12 +22,14 @@ export class IanCenterQuery extends Query<IanCenterState> {
paramsChanges$ = this.select(['params', 'activeFacet']);
- selectNotifications$ = combineLatest([
- this.paramsChanges$,
- this.resourceService.query.select(),
- ]).pipe(
- map(([, state]) => selectCollectionAsEntities$<InAppNotification>(this.resourceService, state, this.params)),
- );
+ activeCollection$ = this.select('activeCollection');
+
+ selectNotifications$ = this
+ .activeCollection$
+ .pipe(
+ map((collection) => selectEntitiesFromIDCollection(this.resourceService, collection)),
+ distinctUntilChanged(),
+ );
aggregatedCenterNotifications$ = this
.selectNotifications$
@@ -37,12 +37,14 @@ export class IanCenterQuery extends Query<IanCenterState> {
map((notifications) => (
_.groupBy(notifications, (notification) => notification._links.resource?.href || 'none')
)),
+ distinctUntilChanged(),
);
notifications$ = this
.aggregatedCenterNotifications$
.pipe(
map((items) => Object.values(items)),
+ distinctUntilChanged(),
);
hasNotifications$ = this
@@ -50,12 +52,14 @@ export class IanCenterQuery extends Query<IanCenterState> {
.pipe(
distinctUntilChanged(),
map((items) => items.length > 0),
+ distinctUntilChanged(),
);
hasMoreThanPageSize$ = this
.notLoaded$
.pipe(
map((notLoaded) => notLoaded > 0),
+ distinctUntilChanged(),
);
get params():Apiv3ListParameters {
diff --git a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts
index 304c86be0a6..011d09947b3 100644
--- a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts
+++ b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts
@@ -5,19 +5,24 @@ import {
import {
distinctUntilChanged,
map,
+ mapTo,
pluck,
share,
switchMap,
take,
+ debounceTime,
} from 'rxjs/operators';
-import { from } from 'rxjs';
+import { Subject, from } from 'rxjs';
import {
ID,
setLoading,
} from '@datorama/akita';
+import { I18nService } from 'core-app/core/i18n/i18n.service';
+import { NotificationsService } from 'core-app/shared/components/notifications/notifications.service';
import {
markNotificationsAsRead,
notificationsMarkedRead,
+ notificationCountIncreased,
} from 'core-app/core/state/in-app-notifications/in-app-notifications.actions';
import { InAppNotification } from 'core-app/core/state/in-app-notifications/in-app-notification.model';
import { IanCenterQuery } from 'core-app/features/in-app-notifications/center/state/ian-center.query';
@@ -29,7 +34,7 @@ import { ActionsService } from 'core-app/core/state/actions/actions.service';
import { HalResource } from 'core-app/features/hal/resources/hal-resource';
import { APIV3Service } from 'core-app/core/apiv3/api-v3.service';
import { InAppNotificationsResourceService } from 'core-app/core/state/in-app-notifications/in-app-notifications.service';
-import { selectCollectionAsHrefs$ } from 'core-app/core/state/collection-store';
+import { mapHALCollectionToIDCollection, selectCollectionAsHrefs$ } from 'core-app/core/state/collection-store';
import { INotificationPageQueryParameters } from 'core-app/features/in-app-notifications/in-app-notifications.routes';
import {
IanCenterStore,
@@ -49,6 +54,24 @@ export class IanCenterService extends UntilDestroyedMixin {
readonly query = new IanCenterQuery(this.store, this.resourceService);
+ private reload = new Subject();
+
+ private onReload = this.reload.pipe(
+ debounceTime(0),
+ switchMap((setToLoading) => this.resourceService
+ .fetchNotifications(this.query.params)
+ .pipe(
+ // We don't want to set loading if the request is sent in the background
+ setToLoading ? setLoading(this.store) : map((res) => res),
+ switchMap(
+ (results) => from(this.sideLoadInvolvedWorkPackages(results._embedded.elements))
+ .pipe(
+ mapTo(mapHALCollectionToIDCollection(results)),
+ ),
+ ),
+ )),
+ );
+
public selectedNotificationIndex = 0;
stateChanged$ = this.uiRouterGlobals.params$?.pipe(
@@ -60,14 +83,17 @@ export class IanCenterService extends UntilDestroyedMixin {
);
constructor(
+ readonly I18n:I18nService,
readonly injector:Injector,
readonly resourceService:InAppNotificationsResourceService,
readonly actions$:ActionsService,
readonly apiV3Service:APIV3Service,
+ readonly notificationsService:NotificationsService,
readonly uiRouterGlobals:UIRouterGlobals,
readonly state:StateService,
) {
super();
+ this.reload.subscribe();
if (this.stateChanged$) {
this.stateChanged$.subscribe(() => {
@@ -78,12 +104,18 @@ export class IanCenterService extends UntilDestroyedMixin {
setFilters(filters:INotificationPageQueryParameters):void {
this.store.update({ filters });
- this.debouncedReload();
+ this.onReload.pipe(take(1)).subscribe((collection) => {
+ this.store.update({ activeCollection: collection });
+ });
+ this.reload.next(true);
}
setFacet(facet:InAppNotificationFacet):void {
this.store.update({ activeFacet: facet });
- this.debouncedReload();
+ this.onReload.pipe(take(1)).subscribe((collection) => {
+ this.store.update({ activeCollection: collection });
+ });
+ this.reload.next(true);
}
markAsRead(notifications:ID[]):void {
@@ -131,30 +163,50 @@ export class IanCenterService extends UntilDestroyedMixin {
});
}
+ /**
+ * Check for updates after bell count increased
+ */
+ @EffectCallback(notificationCountIncreased)
+ private checkForNewNotifications() {
+ this.onReload.pipe(take(1)).subscribe((collection) => {
+ const { activeCollection } = this.query.getValue();
+ const hasNewNotifications = !collection.ids.reduce(
+ (allInOldCollection, id) => allInOldCollection && activeCollection.ids.includes(id),
+ true,
+ );
+
+ if (!hasNewNotifications) {
+ return;
+ }
+
+ this.notificationsService.add({
+ type: 'info',
+ message: this.I18n.t('js.notifications.center.new_notifications.message'),
+ link: {
+ text: this.I18n.t('js.notifications.center.new_notifications.link_text'),
+ target: () => {
+ this.store.update({ activeCollection: collection });
+ },
+ },
+ });
+ });
+ this.reload.next(false);
+ }
+
/**
* Reload after notifications were successfully marked as read
*/
@EffectCallback(notificationsMarkedRead)
private reloadOnNotificationRead(action:ReturnType<typeof notificationsMarkedRead>) {
- this
- .resourceService
- .removeFromCollection(this.query.params, action.notifications);
+ const { activeCollection } = this.query.getValue();
+ this.store.update({
+ activeCollection: {
+ ids: activeCollection.ids.filter((activeID) => !action.notifications.includes(activeID)),
+ },
+ });
this.showNextNotification();
}
- private debouncedReload = _.debounce(() => { this.reload().subscribe(); });
-
- private reload() {
- return this.resourceService
- .fetchNotifications(this.query.params)
- .pipe(
- setLoading(this.store),
- switchMap((results) => from(this.sideLoadInvolvedWorkPackages(results._embedded.elements))),
- switchMap(() => this.query.notifications$),
- take(1),
- );
- }
-
private sideLoadInvolvedWorkPackages(elements:InAppNotification[]):Promise<unknown> {
const { cache } = this.apiV3Service.work_packages;
const wpIds = elements
diff --git a/frontend/src/app/features/in-app-notifications/center/state/ian-center.store.ts b/frontend/src/app/features/in-app-notifications/center/state/ian-center.store.ts
index 8644fd55457..d3d258fc9d1 100644
--- a/frontend/src/app/features/in-app-notifications/center/state/ian-center.store.ts
+++ b/frontend/src/app/features/in-app-notifications/center/state/ian-center.store.ts
@@ -1,4 +1,5 @@
import { Store, StoreConfig } from '@datorama/akita';
+import { CollectionResponse } from 'core-app/core/state/collection-store';
import { ApiV3ListFilter } from 'core-app/core/apiv3/paths/apiv3-list-resource.interface';
import { NOTIFICATIONS_MAX_SIZE } from 'core-app/core/state/in-app-notifications/in-app-notification.model';
import { INotificationPageQueryParameters } from 'core-app/features/in-app-notifications/in-app-notifications.routes';
@@ -11,6 +12,8 @@ export interface IanCenterState {
activeFacet:InAppNotificationFacet;
filters:INotificationPageQueryParameters;
+ activeCollection:CollectionResponse;
+
/** Number of elements not showing after max values loaded */
notLoaded:number;
}
@@ -29,6 +32,7 @@ export function createInitialState():IanCenterState {
page: 1,
},
filters: {},
+ activeCollection: { ids: [] },
activeFacet: 'unread',
notLoaded: 0,
};
diff --git a/spec/features/notifications/notification_center/notification_center_spec.rb b/spec/features/notifications/notification_center/notification_center_spec.rb
index d4cdaf11812..64bab5dc131 100644
--- a/spec/features/notifications/notification_center/notification_center_spec.rb
+++ b/spec/features/notifications/notification_center/notification_center_spec.rb
@@ -3,21 +3,22 @@ require 'spec_helper'
describe "Notification center", type: :feature, js: true, with_settings: { journal_aggregation_time_minutes: 0 } do
# Notice that the setup in this file here is not following the normal rules as
# it also tests notification creation.
- let!(:project) { FactoryBot.create :project }
+ let!(:project1) { FactoryBot.create :project }
+ let!(:project2) { FactoryBot.create :project }
let!(:recipient) do
# Needs to take place before the work package is created so that the notification listener is set up
FactoryBot.create :user,
- member_in_project: project,
+ member_in_projects: [project1, project2],
member_with_permissions: %i[view_work_packages]
end
let!(:other_user) do
FactoryBot.create(:user)
end
let(:work_package) do
- FactoryBot.create :work_package, project: project, author: other_user
+ FactoryBot.create :work_package, project: project1, author: other_user
end
let(:work_package2) do
- FactoryBot.create :work_package, project: project, author: other_user
+ FactoryBot.create :work_package, project: project2, author: other_user
end
let(:notification) do
# Will have been created via the JOURNAL_CREATED event listeners
@@ -29,6 +30,7 @@ describe "Notification center", type: :feature, js: true, with_settings: { journ
end
let(:center) { ::Pages::Notifications::Center.new }
+ let(:side_menu) { ::Components::Notifications::Sidemenu.new }
let(:activity_tab) { ::Components::WorkPackages::Activities.new(work_package) }
let(:split_screen) { ::Pages::SplitWorkPackage.new work_package }
let(:split_screen2) { ::Pages::SplitWorkPackage.new work_package2 }
@@ -115,6 +117,46 @@ describe "Notification center", type: :feature, js: true, with_settings: { journ
center.expect_work_package_item notification2
end
+ context "with a new notification" do
+ let(:notification3) do
+ FactoryBot.create :notification,
+ reason: :commented,
+ recipient: recipient,
+ project: project1,
+ actor: other_user,
+ read_ian: true
+ end
+
+ it "opens a toaster if the notification is part of the current filters" do
+ visit home_path
+ center.open
+ center.expect_bell_count 2
+ center.expect_work_package_item notification
+ center.expect_work_package_item notification2
+ center.expect_no_toaster
+ notification3.update(read_ian: false)
+ center.expect_toaster
+ center.update_via_toaster
+ center.expect_no_toaster
+ center.expect_work_package_item notification
+ center.expect_work_package_item notification2
+ center.expect_work_package_item notification3
+ end
+
+ it "does not open a toaster if the notification is not part of the current filters" do
+ visit home_path
+ center.open
+ center.expect_bell_count 2
+ side_menu.click_item '@mentioned'
+ side_menu.finished_loading
+ center.expect_no_toaster
+ notification3.update(read_ian: false)
+ # We need to wait for the bell to poll for updates
+ sleep 15
+ center.expect_no_toaster
+ end
+ end
+
it 'opens the next notification after marking one as read' do
visit home_path
center.expect_bell_count 2
diff --git a/spec/support/pages/notifications/center.rb b/spec/support/pages/notifications/center.rb
index 18d214a7374..33f44410448 100644
--- a/spec/support/pages/notifications/center.rb
+++ b/spec/support/pages/notifications/center.rb
@@ -118,7 +118,7 @@ module Pages
if count == 0
expect(page).to have_no_selector('[data-qa-selector^="op-ian-notification-item-"]')
else
- expect(page).to have_selector('[data-qa-selector^="op-ian-notification-item-"]', count: count, wait: 20)
+ expect(page).to have_selector('[data-qa-selector^="op-ian-notification-item-"]', count: count, wait: 10)
end
end
@@ -126,13 +126,25 @@ module Pages
if count == 0
expect(page).to have_no_selector('[data-qa-selector="op-ian-notifications-count"]')
else
- expect(page).to have_selector('[data-qa-selector="op-ian-notifications-count"]', text: count, wait: 20)
+ expect(page).to have_selector('[data-qa-selector="op-ian-notifications-count"]', text: count, wait: 10)
end
end
def bell_element
page.find('op-in-app-notification-bell [data-qa-selector="op-ian-bell"]')
end
+
+ def expect_no_toaster
+ expect(page).to have_no_selector('.notification-box.-info', wait: 10)
+ end
+
+ def expect_toaster
+ expect(page).to have_selector('.notification-box.-info', wait: 10)
+ end
+
+ def update_via_toaster
+ page.find('.notification-box.-info a', wait: 10).click
+ end
end
end
end