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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Specs are working for notification settings page
Benjamin Bädorfc439e11eb3c2
diff --git a/config/locales/js-en.yml b/config/locales/js-en.ymlindex cef93364866..96fbe742369 100644--- a/config/locales/js-en.yml+++ b/config/locales/js-en.yml@@ -563,10 +563,6 @@ en:title: "Notifications"channel: "Channel"no_unread: "No unread notifications"- channels:- in_app: "In-app"- mail: "Email"- mail_digest: "Daily email summary"reasons:mentioned: 'mentioned'watched: 'watched'@@ -580,20 +576,32 @@ en:text_update_date: "%{date} by"total_count_warning: "Showing the %{newest_count} most recent notifications. %{more_count} more are not displayed."settings:- default_all_projects: 'Default for all projects'- involved: 'I am involved'- mentioned: 'I was mentioned'- watched: 'I am watching'- work_package_commented: 'Work package commented'- work_package_created: 'Work package created'- work_package_processed: 'Work package status changed'- work_package_prioritized: 'Work package priority changed'- work_package_scheduled: 'Work package scheduled'- all: 'All events'- add: 'Add setting for project'- already_selected: 'This project is already selected'- remove_projects: 'Remove notifications for projects'title: "Notification settings"+ reasons:+ mentioned:+ title: 'I am @mentioned'+ description: 'Receive a notification every time someone mentions me anywhere'+ involved:+ title: 'Assigned to me or accountable'+ description: 'Receive notifications for all activities on work packages for which I am assignee or accountable.'+ watched: 'Updates on watched items'+ work_package_commented: 'All new comments'+ work_package_created: 'New work packages'+ work_package_processed: 'All status changes'+ work_package_prioritized: 'all priority changes'+ work_package_scheduled: 'All date changes'+ global:+ immediately:+ title: 'Notify me immediately'+ description: 'These settings apply to all projects. You can create project-specific exceptions below.'+ delayed:+ title: 'Also notify me for'+ description: 'Receive notifications for these activities on work packages in all projects:'+ project_specific:+ title: 'Project-specific notification settings'+ description: 'These project-specific settings override default settings above'+ add: 'Add setting for project'+ already_selected: 'This project is already selected'password_confirmation:field_description: 'You need to enter your account password to confirm this change.'diff --git a/frontend/src/app/features/user-preferences/notifications-settings/inline-create/notification-setting-inline-create.component.ts b/frontend/src/app/features/user-preferences/notifications-settings/inline-create/notification-setting-inline-create.component.tsindex 60c699080eb..396e97a4760 100644--- a/frontend/src/app/features/user-preferences/notifications-settings/inline-create/notification-setting-inline-create.component.ts+++ b/frontend/src/app/features/user-preferences/notifications-settings/inline-create/notification-setting-inline-create.component.ts@@ -35,9 +35,9 @@ export class NotificationSettingInlineCreateComponent {active = false;text = {- add_setting: this.I18n.t('js.notifications.settings.add'),+ add_setting: this.I18n.t('js.notifications.settings.project_specific.add'),please_select: this.I18n.t('js.placeholders.selection'),- already_selected: this.I18n.t('js.notifications.settings.already_selected'),+ already_selected: this.I18n.t('js.notifications.settings.project_specific.already_selected'),};public autocompleterOptions = {diff --git a/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.html b/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.htmlindex 507d3867a11..7a876f35660 100644--- a/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.html+++ b/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.html@@ -3,35 +3,34 @@[formGroup]="form"(ngSubmit)="saveChanges()">- <h2>Notify me immediately</h2>- <p>These settings apply to all projects. You can create project-specific exceptions below.</p>+ <h2>{{ text.saveImmediately.title }}</h2>+ <p>{{ text.saveImmediately.description }}</p>- <op-checkbox-field label="I am @Mentioned">+ <op-checkbox-field [label]="text.mentioned.title"><inputdisabledcheckedtype="checkbox"slot="input"/>- <p slot="description">Receive a notification every time someone mentions me anywhere</p>+ <p slot="description">{{ text.mentioned.description }}</p></op-checkbox-field><op-checkbox-field- label="Assigned to me or accountable"- [control]="form.get('assignedToMeOrAccountable')"+ [label]="text.involved.title"+ [control]="form.get('involved')"><inputslot="input"type="checkbox"- formControlName="assignedToMeOrAccountable"+ formControlName="involved"+ data-qa-global-notification-type="involved"/>- <p slot="description">- Receive notifications for all activities on work packages for which I am assignee or accountable.- </p>+ <p slot="description">{{ text.mentioned.title }}</p></op-checkbox-field>- <h2>Also notify me for</h2>- <p>Receive notifications for these activities on work packages in all projects:</p>+ <h2>{{ text.alsoNotifyFor.title }}</h2>+ <p>{{ text.alsoNotifyFor.description }}</p><op-checkbox-field><input@@ -40,52 +39,57 @@type="checkbox"slot="input"/>- <p slot="description">Updates on watched items</p>+ <p slot="description">{{ text.watched }}</p></op-checkbox-field>- <op-checkbox-field [control]="form.get('newWorkPackages')">+ <op-checkbox-field [control]="form.get('workPackageCreated')"><inputslot="input"type="checkbox"- formControlName="newWorkPackages"+ formControlName="workPackageCreated"+ data-qa-global-notification-type="work_package_created"/>- <p slot="description">New work packages</p>+ <p slot="description">{{ text.work_package_created }}</p></op-checkbox-field>- <op-checkbox-field [control]="form.get('allStatusChanges')">+ <op-checkbox-field [control]="form.get('workPackageProcessed')"><inputslot="input"type="checkbox"- formControlName="allStatusChanges"+ formControlName="workPackageProcessed"+ data-qa-global-notification-type="work_package_processed"/>- <p slot="description">All status changes</p>+ <p slot="description">{{ text.work_package_processed }}</p></op-checkbox-field>- <op-checkbox-field [control]="form.get('allDateChanges')">+ <op-checkbox-field [control]="form.get('workPackageScheduled')"><inputslot="input"type="checkbox"- formControlName="allDateChanges"+ formControlName="workPackageScheduled"+ data-qa-global-notification-type="work_package_scheduled"/>- <p slot="description">All date changes</p>+ <p slot="description">{{ text.work_package_scheduled }}</p></op-checkbox-field>- <op-checkbox-field [control]="form.get('allPriorityChanges')">+ <op-checkbox-field [control]="form.get('workPackagePrioritized')"><inputslot="input"type="checkbox"- formControlName="allPriorityChanges"+ formControlName="workPackagePrioritized"+ data-qa-global-notification-type="work_package_prioritized"/>- <p slot="description">All priority changes</p>+ <p slot="description">{{ text.work_package_prioritized }}</p></op-checkbox-field>- <op-checkbox-field [control]="form.get('allNewComments')">+ <op-checkbox-field [control]="form.get('workPackageCommented')"><inputslot="input"type="checkbox"- formControlName="allNewComments"+ formControlName="workPackageCommented"+ data-qa-global-notification-type="work_package_commented"/>- <p slot="description">All new comments</p>+ <p slot="description">{{ text.work_package_commented }}</p></op-checkbox-field><hr />diff --git a/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.ts b/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.tsindex 2f9e65e0b26..81595f69b20 100644--- a/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.ts+++ b/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.ts@@ -7,14 +7,17 @@ import {import {FormGroup,FormControl,- Validators,} from '@angular/forms';-import { I18nService } from 'core-app/core/i18n/i18n.service';-import { CurrentUserService } from 'core-app/core/current-user/current-user.service';+import { arrayUpdate } from '@datorama/akita';import { take } from 'rxjs/internal/operators/take';import { UIRouterGlobals } from '@uirouter/core';+import { I18nService } from 'core-app/core/i18n/i18n.service';+import { CurrentUserService } from 'core-app/core/current-user/current-user.service';+import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';import { UserPreferencesService } from 'core-app/features/user-preferences/state/user-preferences.service';+import { UserPreferencesStore } from 'core-app/features/user-preferences/state/user-preferences.store';import { UserPreferencesQuery } from 'core-app/features/user-preferences/state/user-preferences.query';+import { NotificationSetting } from 'core-app/features/user-preferences/state/notification-setting.model';export const myNotificationsPageComponentSelector = 'op-notifications-page';@@ -23,32 +26,58 @@ export const myNotificationsPageComponentSelector = 'op-notifications-page';templateUrl: './notifications-settings-page.component.html',changeDetection: ChangeDetectionStrategy.OnPush,})-export class NotificationsSettingsPageComponent implements OnInit {+export class NotificationsSettingsPageComponent extends UntilDestroyedMixin implements OnInit {@Input() userId:string;public form = new FormGroup({- assignedToMeOrAccountable: new FormControl(false, []),- newWorkPackages: new FormControl(false, []),- allStatusChanges: new FormControl(false, []),- allDateChanges: new FormControl(false, []),- allPriorityChanges: new FormControl(false, []),- allNewComments: new FormControl(false, []),+ involved: new FormControl(false, []),+ workPackageCreated: new FormControl(false, []),+ workPackageProcessed: new FormControl(false, []),+ workPackageScheduled: new FormControl(false, []),+ workPackagePrioritized: new FormControl(false, []),+ workPackageCommented: new FormControl(false, []),});text = {+ saveImmediately: {+ title: this.I18n.t('js.notifications.settings.global.immediately.title'),+ description: this.I18n.t('js.notifications.settings.global.immediately.description'),+ },+ alsoNotifyFor: {+ title: this.I18n.t('js.notifications.settings.global.delayed.title'),+ description: this.I18n.t('js.notifications.settings.global.delayed.description'),+ },+ mentioned: {+ title: this.I18n.t('js.notifications.settings.reasons.mentioned.title'),+ description: this.I18n.t('js.notifications.settings.reasons.mentioned.description'),+ },+ involved: {+ title: this.I18n.t('js.notifications.settings.reasons.involved.title'),+ description: this.I18n.t('js.notifications.settings.reasons.involved.description'),+ },+ watched: this.I18n.t('js.notifications.settings.reasons.watched'),+ work_package_commented: this.I18n.t('js.notifications.settings.reasons.work_package_commented'),+ work_package_created: this.I18n.t('js.notifications.settings.reasons.work_package_created'),+ work_package_processed: this.I18n.t('js.notifications.settings.reasons.work_package_processed'),+ work_package_prioritized: this.I18n.t('js.notifications.settings.reasons.work_package_prioritized'),+ work_package_scheduled: this.I18n.t('js.notifications.settings.reasons.work_package_scheduled'),save: this.I18n.t('js.button_save'),- email: this.I18n.t('js.notifications.email'),- inApp: this.I18n.t('js.notifications.in_app'),- default_all_projects: this.I18n.t('js.notifications.settings.default_all_projects'),+ projectSpecific: {+ title: this.I18n.t('js.notifications.settings.project_specific.title'),+ description: this.I18n.t('js.notifications.settings.project_specific.description'),+ },};constructor(private I18n:I18nService,private stateService:UserPreferencesService,private query:UserPreferencesQuery,+ private store:UserPreferencesStore,private currentUserService:CurrentUserService,private uiRouterGlobals:UIRouterGlobals,- ) {}+ ) {+ super();+ }ngOnInit():void {this.userId = this.userId || this.uiRouterGlobals.params.userId;@@ -60,10 +89,45 @@ export class NotificationsSettingsPageComponent implements OnInit {this.userId = this.userId || user.id!;this.stateService.get(this.userId);});++ this.query.notificationsForGlobal$+ .pipe(this.untilDestroyed())+ .subscribe((settings) => {+ if (!settings) {+ return;+ }++ this.form.get('involved')?.setValue(settings.involved);+ this.form.get('workPackageCreated')?.setValue(settings.workPackageCreated);+ this.form.get('workPackageProcessed')?.setValue(settings.workPackageProcessed);+ this.form.get('workPackageScheduled')?.setValue(settings.workPackageScheduled);+ this.form.get('workPackagePrioritized')?.setValue(settings.workPackagePrioritized);+ this.form.get('workPackageCommented')?.setValue(settings.workPackageCommented);+ });}public saveChanges():void {+ this.update(this.form.value);const prefs = this.query.getValue();+ console.log(prefs);this.stateService.update(this.userId, prefs);}++ private update(delta:Partial<NotificationSetting>) {+ this.store.update(+ ({ notifications }) => ({+ notifications: arrayUpdate(+ notifications,+ (notification:NotificationSetting) => {+ return notification._links.project.href === null;+ },+ {+ ...delta,+ mentioned: true,+ watched: true,+ },+ ),+ }),+ );+ }}diff --git a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.html b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.htmlindex 8ea68f858e6..7b8a9ee0b9d 100644--- a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.html+++ b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.html@@ -5,9 +5,7 @@<thead><tr><th class="op-table--cell op-table--cell_heading"></th>- <ng-container- *ngFor="let item of (groupedNotificationSettings$ | async) | keyvalue"- >+ <ng-container *ngFor="let item of (groupedNotificationSettings$ | async) | keyvalue"><th class="op-table--cell op-table--cell_heading">{{ item.key }}</th></ng-container></tr>@@ -27,6 +25,8 @@type="checkbox"[checked]="item.value[0].involved"(change)="update({ involved: $event.target.checked }, item.value[0]._links.project.href)"+ data-qa-project-notification-type="involved"+ [attr.data-qa-project]="item.key"/></td></ng-container>@@ -45,6 +45,8 @@type="checkbox"[checked]="item.value[0].workPackageCreated"(change)="update({ workPackageCreated: $event.target.checked }, item.value[0]._links.project.href)"+ data-qa-project-notification-type="work_package_created"+ [attr.data-qa-project]="item.key"/></td></ng-container>@@ -57,6 +59,8 @@type="checkbox"[checked]="item.value[0].workPackageProcessed"(change)="update({ workPackageProcessed: $event.target.checked }, item.value[0]._links.project.href)"+ data-qa-project-notification-type="work_package_processed"+ [attr.data-qa-project]="item.key"/></td></ng-container>@@ -69,6 +73,8 @@type="checkbox"[checked]="item.value[0].workPackageScheduled"(change)="update({ workPackageScheduled: $event.target.checked }, item.value[0]._links.project.href)"+ data-qa-project-notification-type="work_package_scheduled"+ [attr.data-qa-project]="item.key"/></td></ng-container>@@ -81,6 +87,8 @@type="checkbox"[checked]="item.value[0].workPackagePrioritized"(change)="update({ workPackagePrioritized: $event.target.checked }, item.value[0]._links.project.href)"+ data-qa-project-notification-type="work_package_prioritized"+ [attr.data-qa-project]="item.key"/></td></ng-container>@@ -93,6 +101,8 @@type="checkbox"[checked]="item.value[0].workPackageCommented"(change)="update({ workPackageCommented: $event.target.checked }, item.value[0]._links.project.href)"+ data-qa-project-notification-type="work_package_commented"+ [attr.data-qa-project]="item.key"/></td></ng-container>diff --git a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.ts b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.tsindex cc178186802..02133b77759 100644--- a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.ts+++ b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.ts@@ -9,7 +9,6 @@ import { map } from 'rxjs/operators';import { KeyValue } from '@angular/common';import { arrayAdd, arrayUpdate, arrayRemove } from '@datorama/akita';import { I18nService } from 'core-app/core/i18n/i18n.service';-import { UserPreferencesService } from 'core-app/features/user-preferences/state/user-preferences.service';import { UserPreferencesStore } from 'core-app/features/user-preferences/state/user-preferences.store';import { UserPreferencesQuery } from 'core-app/features/user-preferences/state/user-preferences.query';import { HalSourceLink } from 'core-app/features/hal/resources/hal-resource';@@ -33,17 +32,15 @@ export class NotificationSettingsTableComponent {text = {save: this.I18n.t('js.button_save'),- involved_header: this.I18n.t('js.notifications.settings.involved'),- channel_header: this.I18n.t('js.notifications.channel'),- mentioned_header: this.I18n.t('js.notifications.settings.mentioned'),- watched_header: this.I18n.t('js.notifications.settings.watched'),- work_package_commented_header: this.I18n.t('js.notifications.settings.work_package_commented'),- work_package_created_header: this.I18n.t('js.notifications.settings.work_package_created'),- work_package_processed_header: this.I18n.t('js.notifications.settings.work_package_processed'),- work_package_prioritized_header: this.I18n.t('js.notifications.settings.work_package_prioritized'),- work_package_scheduled_header: this.I18n.t('js.notifications.settings.work_package_scheduled'),- any_event_header: this.I18n.t('js.notifications.settings.all'),- default_all_projects: this.I18n.t('js.notifications.settings.default_all_projects'),++ mentioned_header: this.I18n.t('js.notifications.settings.reasons.mentioned.title'),+ involved_header: this.I18n.t('js.notifications.settings.reasons.involved.title'),+ watched_header: this.I18n.t('js.notifications.settings.reasons.watched'),+ work_package_commented_header: this.I18n.t('js.notifications.settings.reasons.work_package_commented'),+ work_package_created_header: this.I18n.t('js.notifications.settings.reasons.work_package_created'),+ work_package_processed_header: this.I18n.t('js.notifications.settings.reasons.work_package_processed'),+ work_package_prioritized_header: this.I18n.t('js.notifications.settings.reasons.work_package_prioritized'),+ work_package_scheduled_header: this.I18n.t('js.notifications.settings.reasons.work_package_scheduled'),};projectOrder = (a:KeyValue<string, unknown>, b:KeyValue<string, unknown>):number => {@@ -76,10 +73,7 @@ export class NotificationSettingsTableComponent {({ notifications }) => ({notifications: arrayUpdate(notifications,- (notification:NotificationSetting) => {- return notification._links.project.href === projectHref- && notification.channel === 'in_app';- },+ (notification:NotificationSetting) => notification._links.project.href === projectHref,delta,),}),diff --git a/frontend/src/app/features/user-preferences/notifications-settings/toolbar/notifications-settings-toolbar.component.html b/frontend/src/app/features/user-preferences/notifications-settings/toolbar/notifications-settings-toolbar.component.htmlindex 88677c7b463..91ec548e193 100644--- a/frontend/src/app/features/user-preferences/notifications-settings/toolbar/notifications-settings-toolbar.component.html+++ b/frontend/src/app/features/user-preferences/notifications-settings/toolbar/notifications-settings-toolbar.component.html@@ -3,18 +3,5 @@<div class="title-container"><h2 [textContent]="text.title"></h2></div>- <ul class="toolbar-items">- <li- *ngIf="(projectSettings$ | async).length > 0"- class="toolbar-item"- >- <button- class="button"- (click)="removeAll()"- >- <span [textContent]="text.remove_projects"></span>- </button>- </li>- </ul></div></div>diff --git a/frontend/src/app/features/user-preferences/notifications-settings/toolbar/notifications-settings-toolbar.component.ts b/frontend/src/app/features/user-preferences/notifications-settings/toolbar/notifications-settings-toolbar.component.tsindex 127d875cdd3..a5710b09057 100644--- a/frontend/src/app/features/user-preferences/notifications-settings/toolbar/notifications-settings-toolbar.component.ts+++ b/frontend/src/app/features/user-preferences/notifications-settings/toolbar/notifications-settings-toolbar.component.ts@@ -1,7 +1,5 @@import { ChangeDetectionStrategy, Component } from '@angular/core';-import { UserPreferencesQuery } from 'core-app/features/user-preferences/state/user-preferences.query';import { I18nService } from 'core-app/core/i18n/i18n.service';-import { UserPreferencesStore } from 'core-app/features/user-preferences/state/user-preferences.store';@Component({selector: 'op-notifications-settings-toolbar',@@ -9,25 +7,11 @@ import { UserPreferencesStore } from 'core-app/features/user-preferences/state/uchangeDetection: ChangeDetectionStrategy.OnPush,})export class NotificationsSettingsToolbarComponent {- projectSettings$ = this.query.projectNotifications$;-text = {title: this.I18n.t('js.notifications.settings.title'),- remove_projects: this.I18n.t('js.notifications.settings.remove_projects'),};constructor(- private query:UserPreferencesQuery,- private store:UserPreferencesStore,private I18n:I18nService,- ) {- }-- removeAll():void {- this.store.update(- ({ notifications }) => ({- notifications: notifications.filter((notification) => notification._links.project.href === null),- }),- );- }+ ) { }}diff --git a/frontend/src/app/features/user-preferences/state/user-preferences.query.ts b/frontend/src/app/features/user-preferences/state/user-preferences.query.tsindex 6778a184121..9306d5975e9 100644--- a/frontend/src/app/features/user-preferences/state/user-preferences.query.ts+++ b/frontend/src/app/features/user-preferences/state/user-preferences.query.ts@@ -9,17 +9,22 @@ import { NotificationSetting } from 'core-app/features/user-preferences/state/no@Injectable()export class UserPreferencesQuery extends Query<UserPreferencesModel> {- /** All notification settings */notificationSettings$ = this.select('notifications');- /** Notification settings grouped by Project */notificationsGroupedByProject$:Observable<{ [key:string]:NotificationSetting[] }> = this.notificationSettings$.pipe(- map((notifications) => notifications.filter((setting) => setting.channel === 'in_app' && setting._links.project.title)),+ map((notifications) => notifications.filter((setting) => setting.channel === 'in_app' && setting._links.project.href)),map((notifications) => _.groupBy(notifications, (setting) => setting._links.project.title)),);+ /** Notification settings grouped by Project */+ notificationsForGlobal$:Observable<NotificationSetting|undefined> = this+ .notificationSettings$+ .pipe(+ map((notifications) => notifications.find((setting) => setting.channel === 'in_app' && setting._links.project.href === null)),+ );+projectNotifications$ = this.notificationSettings$.pipe(diff --git a/spec/features/users/notifications/shared_examples.rb b/spec/features/users/notifications/shared_examples.rbindex 3048462fde6..7ca328a3848 100644--- a/spec/features/users/notifications/shared_examples.rb+++ b/spec/features/users/notifications/shared_examples.rb@@ -1,67 +1,47 @@shared_examples 'notification settings workflow' dodescribe 'with another project the user can see' dolet!(:project) { FactoryBot.create :project }+ let!(:project_alt) { FactoryBot.create :project }let!(:role) { FactoryBot.create :role, permissions: %i[view_project] }let!(:member) { FactoryBot.create :member, user: user, project: project, roles: [role] }+ let!(:member_2) { FactoryBot.create :member, user: user, project: project_alt, roles: [role] }it 'allows to control notification settings' do# Expect default settingssettings_page.expect_represented- # Add setting for the project- settings_page.add_row project+ # Add projects columns+ settings_page.add_project project+ settings_page.add_project project_alt# Set settings for project email- settings_page.configure_channel :mail,- project: project,- involved: true,- mentioned: true,- watched: true,- work_package_commented: true,- work_package_created: true,- work_package_processed: true,- work_package_prioritized: true,- work_package_scheduled: true,- all: false+ settings_page.configure_global involved: true,+ work_package_commented: true,+ work_package_created: true,+ work_package_processed: true,+ work_package_prioritized: true,+ work_package_scheduled: true# Set settings for project email- settings_page.configure_channel :in_app,- project: project,+ settings_page.configure_project project: project,involved: true,- mentioned: true,- watched: false,work_package_commented: false,work_package_created: false,work_package_processed: false,work_package_prioritized: false,- work_package_scheduled: false,- all: false-- # Set settings for project email digest- settings_page.configure_channel :mail_digest,- project: project,- involved: false,- mentioned: true,- watched: false,- work_package_commented: true,- work_package_created: true,- work_package_processed: true,- work_package_prioritized: true,- work_package_scheduled: true,- all: true+ work_package_scheduled: falsesettings_page.saveuser.reloadnotification_settings = user.notification_settings- expect(notification_settings.count).to eq 6+ expect(notification_settings.count).to eq 9expect(notification_settings.where(project: project).count).to eq 3in_app = notification_settings.find_by(project: project, channel: :in_app)expect(in_app.involved).to be_truthyexpect(in_app.mentioned).to be_truthy- expect(in_app.watched).to be_falsey- expect(in_app.all).to be_falsey+ expect(in_app.watched).to be_truthyexpect(in_app.work_package_commented).to be_falseyexpect(in_app.work_package_created).to be_falseyexpect(in_app.work_package_processed).to be_falsey@@ -72,23 +52,21 @@ shared_examples 'notification settings workflow' doexpect(mail.involved).to be_truthyexpect(mail.mentioned).to be_truthyexpect(mail.watched).to be_truthy- expect(mail.all).to be_falsey- expect(mail.work_package_commented).to be_truthy- expect(mail.work_package_created).to be_truthy- expect(mail.work_package_processed).to be_truthy- expect(mail.work_package_prioritized).to be_truthy- expect(mail.work_package_scheduled).to be_truthy+ expect(mail.work_package_commented).to be_falsey+ expect(mail.work_package_created).to be_falsey+ expect(mail.work_package_processed).to be_falsey+ expect(mail.work_package_prioritized).to be_falsey+ expect(mail.work_package_scheduled).to be_falseymail_digest = notification_settings.find_by(project: project, channel: :mail_digest)- expect(mail_digest.involved).to be_falsey+ expect(mail_digest.involved).to be_truthyexpect(mail_digest.mentioned).to be_truthy- expect(mail_digest.watched).to be_falsey- expect(mail_digest.all).to be_truthy- expect(mail_digest.work_package_commented).to be_truthy- expect(mail_digest.work_package_created).to be_truthy- expect(mail_digest.work_package_processed).to be_truthy- expect(mail_digest.work_package_prioritized).to be_truthy- expect(mail_digest.work_package_scheduled).to be_truthy+ expect(mail_digest.watched).to be_truthy+ expect(mail_digest.work_package_commented).to be_falsey+ expect(mail_digest.work_package_created).to be_falsey+ expect(mail_digest.work_package_processed).to be_falsey+ expect(mail_digest.work_package_prioritized).to be_falsey+ expect(mail_digest.work_package_scheduled).to be_falsey# Trying to add the same project again will not be possible (Regression #38072)click_button 'Add setting for project'diff --git a/spec/support/pages/notifications/settings.rb b/spec/support/pages/notifications/settings.rbindex fafd667621a..9e89ad5137d 100644--- a/spec/support/pages/notifications/settings.rb+++ b/spec/support/pages/notifications/settings.rb@@ -45,62 +45,60 @@ module Pagesdef expect_representeduser.notification_settings.each do |setting|- within_channel(setting.channel, project: setting.project&.name) do- expect_setting setting.attributes.symbolize_keys- end+ expect_global_represented(setting)+ # expect_project_represented(setting)endend- def expect_setting(setting)- channel_name = I18n.t("js.notifications.channels.#{setting[:channel]}")- expect(page).to have_selector('td', text: channel_name)-- %i[involved mentioned watched all].each do |type|- expect(page).to have_selector("input[type='checkbox'][data-qa-notification-type='#{type}']") do |checkbox|- if setting[:all] && type != :all- checkbox.disabled?- else- checkbox.checked? == setting[type]- end+ def expect_global_represented(setting)+ %i[+ involved+ work_package_commented+ work_package_created+ work_package_processed+ work_package_prioritized+ work_package_scheduled+ ].each do |type|+ expect(page).to have_selector("input[type='checkbox'][data-qa-global-notification-type='#{type}']") do |checkbox|+ checkbox.checked? == setting[type]endendenddef expect_project(project)- expect(page).to have_selector('td', text: project.name)+ expect(page).to have_selector('th', text: project.name)end- def add_row(project)+ def add_project(project)click_button 'Add setting for project'container = page.find('[data-qa-selector="notification-setting-inline-create"] ng-select')select_autocomplete container, query: project.name, results_selector: 'body'expect_project projectend- def configure_channel(channel, project: nil, **types)- within_channel(channel, project: project) do- types.each(&method(:set_option))- end+ def configure_global(**types)+ types.each(&method(:set_global_option))end- def set_option(type, checked)- checkbox = page.find "input[type='checkbox'][data-qa-notification-type='#{type}']"+ def set_global_option(type, checked)+ checkbox = page.find "input[type='checkbox'][data-qa-global-notification-type='#{type}']"checked ? checkbox.check : checkbox.uncheckend- def save- click_button 'Save'- expect_notification message: 'Successful update.'+ def configure_project(project: nil, **types)+ types.each { |type|+ set_project_option(*type, project);+ }end- def within_channel(channel, project: nil, &block)- raise(ArgumentError, "Invalid channel") unless NotificationSetting.channels.include?(channel.to_sym)+ def set_project_option(type, checked, project)+ checkbox = page.find "input[type='checkbox'][data-qa-project='#{project}'][data-qa-project-notification-type='#{type}']"+ checked ? checkbox.check : checkbox.uncheck+ end- project = 'global' if project.nil?- page.within(- "[data-qa-notification-project='#{project}'][data-qa-notification-channel='#{channel}']",- &block- )+ def save+ click_button 'Save'+ expect_notification message: 'Successful update.'endendend