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

email reminder times settings hooked up to backend

ulferts27f925d6d719
diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb
index 8873cce0e07..5f50beab7c2 100644
--- a/app/models/user_preference.rb
+++ b/app/models/user_preference.rb
@@ -118,6 +118,10 @@ class UserPreference < ApplicationRecord
super.presence || Setting.user_default_timezone.presence
end
+ def daily_reminders
+ super.presence || { enabled: true, times: ["08:00:00+00:00"] }.with_indifferent_access
+ end
+
def canonical_time_zone
return if time_zone.nil?
diff --git a/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.html b/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.html
index 5cb11bff6ba..94336a4b0d9 100644
--- a/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.html
+++ b/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.html
@@ -4,8 +4,8 @@
<form>
<section class="form--section">
- <h3 [textContent]="text.daily.title"></h3>
- <span [textContent]="text.daily.explanation"></span>
+ <h2 [textContent]="text.daily.title"></h2>
+ <p [textContent]="text.daily.explanation"></p>
<op-reminder-settings-daily-time>
</op-reminder-settings-daily-time>
diff --git a/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.ts b/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.ts
index ab31d0ad393..717190a6ddf 100644
--- a/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.ts
+++ b/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.ts
@@ -37,12 +37,13 @@ export class ReminderSettingsPageComponent implements OnInit {
}
ngOnInit():void {
+ this.userId = (this.userId || this.uiRouterGlobals.params.userId) as string;// || user.id!;
this
.currentUserService
.user$
.pipe(take(1))
.subscribe((user) => {
- this.userId = (this.userId || this.uiRouterGlobals.params.userId) as string || user.id!;
+ this.userId = this.userId || user?.id as string;
this.stateService.get(this.userId);
});
}
diff --git a/frontend/src/app/features/user-preferences/reminder-settings/reminder-time/reminder-settings-daily-time.component.html b/frontend/src/app/features/user-preferences/reminder-settings/reminder-time/reminder-settings-daily-time.component.html
index fc7a28e5a7e..82afd6fc268 100644
--- a/frontend/src/app/features/user-preferences/reminder-settings/reminder-time/reminder-settings-daily-time.component.html
+++ b/frontend/src/app/features/user-preferences/reminder-settings/reminder-time/reminder-settings-daily-time.component.html
@@ -1,54 +1,62 @@
-<div
- class="op-reminder-settings-daily-time--enable">
- <input
- [(ngModel)]="enabled"
- type="checkbox"
- id="op-reminder-settings-daily-time--enable">
- <label
- for="op-reminder-settings-daily-time--enable"
- [textContent]="text.enable">
- </label>
-</div>
+<ng-container
+ *ngIf="(dailyReminders$ | async) && (selectedTimes$ | async) as selectedTimes">
+ <!-- TODO: use checkbox component for the enabled input -->
+ <div
+ class="op-reminder-settings-daily-time--enable">
+ <input
+ [ngModel]="enabled$ | async"
+ (ngModelChange)="toggleEnabled($event)"
+ type="checkbox"
+ id="op-reminder-settings-daily-time--enable">
+ <label
+ for="op-reminder-settings-daily-time--enable"
+ [textContent]="text.enable">
+ </label>
+ </div>
+
+ <div *ngFor="let time of selectedTimes; index as i; trackBy: index"
+ class="op-reminder-settings-daily-time--row">
+ <input
+ type="checkbox"
+ [ngModel]="isActive(time)"
+ (ngModelChange)="toggleActive($event, i, selectedTimes)"
+ [disabled]="(activeTimes$ | async).length === 0 || (activeTimes$ | async).length === 1 && (activeTimes$ | async)[0] === time"
+ class="op-reminder-settings-daily-time--active"
+ attr.data-qa-selector="op-settings-daily-time--active-{{i + 1}}">
+ <label
+ class="op-reminder-settings-daily-time--label"
+ [textContent]="text.timeLabel(i + 1)"
+ attr.for="op-reminder-settings-daily-time-{{i + 1}}--time">
+ </label>
+ <select
+ [ngModel]="time"
+ (ngModelChange)="changeTime($event, selectedTimes, i)"
+ [disabled]="(enabled$ | async) === false"
+ class="op-reminder-settings-daily-time--time form--select -narrow"
+ attr.id="op-reminder-settings-daily-time-{{i + 1}}--time"
+ required="true">
+ <option
+ *ngFor="let availableTime of availableTimes"
+ [value]="availableTime"
+ [disabled]="time !== availableTime && selectedTimes.includes(availableTime)">
+ {{timeLabel(availableTime)}}
+ </option>
+ </select>
+ <button
+ class="op-link op-reminder-settings-daily-time--remove"
+ type="button"
+ *ngIf="timeRemovable$ | async"
+ (click)="removeTime(selectedTimes, i)"
+ attr.data-qa-selector="op-settings-daily-time--remove-{{i + 1}}">
+ <op-icon icon-classes="icon-small icon-remove icon4"></op-icon>
+ </button>
+ </div>
-<div *ngFor="let time of selectedTimes; index as i; trackBy: indexTracker"
- class="op-reminder-settings-daily-time--row">
- <input
- type="checkbox"
- [(ngModel)]="selectedTimes[i].active"
- [disabled]="isActiveDisabled"
- class="op-reminder-settings-daily-time--active"
- attr.data-qa-selector="op-settings-daily-time--active-{{i + 1}}">
- <label
- class="op-reminder-settings-daily-time--label"
- [textContent]="text.timeLabel(i + 1)"
- attr.for="op-reminder-settings-daily-time-{{i + 1}}--time">
- </label>
- <select
- [(ngModel)]="selectedTimes[i]"
- [disabled]="!enabled"
- class="op-reminder-settings-daily-time--time form--select -narrow"
- attr.id="op-reminder-settings-daily-time-{{i + 1}}--time"
- required="true">
- <option
- *ngFor="let time of availableTimes"
- [ngValue]="time"
- [disabled]="isOptionDisabled(time, selectedTimes[i])">
- {{time.label}}
- </option>
- </select>
<button
- class="op-link op-reminder-settings-daily-time--remove"
- type="button"
- *ngIf="isRemovable"
- (click)="removeTime(i)">
- <op-icon icon-classes="icon-small icon-remove icon4"></op-icon>
+ class="button op-reminder-settings-daily-time--add"
+ [disabled]="nonAddable$ | async"
+ (click)="addTime(selectedTimes)">
+ <i class="button--icon icon-add"></i>
+ <span class="button--text">{{text.addTime}}</span>
</button>
-</div>
-
-<button
- class="button op-reminder-settings-daily-time--add"
- [disabled]="nonAddable"
- (click)="addTime()">
- <i class="button--icon icon-add"></i>
- <span class="button--text">{{text.addTime}}</span>
-</button>
+</ng-container>
\ No newline at end of file
diff --git a/frontend/src/app/features/user-preferences/reminder-settings/reminder-time/reminder-settings-daily-time.component.ts b/frontend/src/app/features/user-preferences/reminder-settings/reminder-time/reminder-settings-daily-time.component.ts
index 22794e54151..567631c7bef 100644
--- a/frontend/src/app/features/user-preferences/reminder-settings/reminder-time/reminder-settings-daily-time.component.ts
+++ b/frontend/src/app/features/user-preferences/reminder-settings/reminder-time/reminder-settings-daily-time.component.ts
@@ -1,12 +1,11 @@
import { Component, ChangeDetectionStrategy } from '@angular/core';
import { I18nService } from 'core-app/core/i18n/i18n.service';
-
-interface ReminderTime {
- label:string
- time:string
- active:boolean,
- suggested:boolean
-}
+import { UserPreferencesQuery } from 'core-app/features/user-preferences/state/user-preferences.query';
+import {
+ map, skip,
+} from 'rxjs/operators';
+import { UserPreferencesStore } from 'core-app/features/user-preferences/state/user-preferences.store';
+import { combineLatest } from 'rxjs';
@Component({
selector: 'op-reminder-settings-daily-time',
@@ -15,11 +14,64 @@ interface ReminderTime {
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ReminderSettingsDailyTimeComponent {
- public selectedTimes:Array<ReminderTime> = [];
+ // All times that are available in a day with a 1 hour gap between each.
+ // ['00:00', '01:00', ..., '24:00']
+ public availableTimes:string[] = ReminderSettingsDailyTimeComponent.setupAvailableTimes();
+
+ // The times (hours) that the user deactivated. Those are only stored within the component
+ // as the inactive hours are not persisted. This list is then interleaved with the list
+ // of times stored in the backend. As the order of the times should be kept,
+ // the position needs to be maintained.
+ // Upon a reload of the page, it is accepted to loose this information.
+ public inactiveTimes:Array<{ position:number, time:string }> = [];
+
+ // Hours suggested if a new time is added by a user.
+ public suggestedTimes = ['08:00', '12:00', '15:00', '18:00'];
+
+ // The daily reminders with the first value skipped. Only used
+ // for that skipping as the first value is produced by the front end (default value).
+ public dailyReminders$ = this.query.dailyReminders$.pipe(skip(1));
+
+ // Whether the reminder are active at all.
+ public enabled$ = this.query.dailyRemindersEnabled$;
+
+ // The active times as present in the store interleaved with the inactive
+ // times.
+ public selectedTimes$ = this
+ .query
+ .dailyRemindersTimes$
+ .pipe(map((times) => {
+ const activeTimes = Array(...times);
- public availableTimes:Array<ReminderTime> = [];
-
- public enabled = true;
+ this
+ .inactiveTimes
+ .sort((a, b) => a.position - b.position)
+ .forEach((inactiveTime) => {
+ activeTimes.splice(inactiveTime.position, 0, inactiveTime.time);
+ });
+
+ return activeTimes;
+ }));
+
+ // Times that are truly active:
+ // * the reminders are not disabled completely
+ // * the times are not inactive individually.
+ public activeTimes$ = combineLatest(
+ this.query.dailyRemindersEnabled$,
+ this.query.dailyRemindersTimes$,
+ ).pipe(map(([enabled, times]) => (enabled ? times : [])));
+
+ // Times can only be removed if the element is active and if there is more than one time present.
+ public timeRemovable$ = combineLatest(
+ this.query.dailyRemindersEnabled$,
+ this.selectedTimes$,
+ ).pipe(map(([enabled, selectedTimes]) => enabled && selectedTimes.length > 1));
+
+ // Times can not be added if the element is disabled or if all the possible times have already been added (active or not).
+ public nonAddable$ = combineLatest(
+ this.query.dailyRemindersEnabled$,
+ this.selectedTimes$,
+ ).pipe(map(([enabled, selectedTimes]) => !enabled || selectedTimes.length === this.availableTimes.length));
text = {
timeLabel: (counter:number):string => this.I18n.t('js.reminders.settings.daily.time_label', { counter }),
@@ -29,76 +81,104 @@ export class ReminderSettingsDailyTimeComponent {
constructor(
private I18n:I18nService,
- ) {
- this.setupAvailableTimes();
- this.setupSelectedTimes();
+ private query:UserPreferencesQuery,
+ private store:UserPreferencesStore,
+ ) { }
+
+ addTime(selectedTimes:string[]):void {
+ const time = this.firstAvailableSuggested(selectedTimes) || this.firstAfterSelected(selectedTimes);
+
+ if (time) {
+ this.storeTimes(selectedTimes.concat(time));
+ }
}
- get nonAddable():boolean {
- return !this.enabled || this.selectedTimes.length === this.availableTimes.length;
+ changeTime(newTime:string, selectedTimes:string[], index:number):void {
+ selectedTimes.splice(index, 1, newTime);
+
+ this.storeTimes(selectedTimes);
}
- indexTracker(index:number):number {
- return index;
+ isActive(time:string):boolean {
+ return !this.inactiveTimes.find((inactive) => inactive.time === time);
}
- addTime():void {
- if (this.nonAddable) {
- return;
- }
+ removeTime(selectedTimes:string[], index:number):void {
+ this.inactiveTimes = this
+ .inactiveTimes
+ .filter((inactiveTime) => inactiveTime.time !== selectedTimes[index]);
- const time = this.firstAvailableSuggested() || this.firstAfterSelected();
+ this.inactiveTimes
+ .forEach((inactiveTime) => {
+ if (inactiveTime.position > index) {
+ // eslint-disable-next-line no-param-reassign
+ inactiveTime.position -= 1;
+ }
+ });
- if (time) {
- this
- .selectedTimes
- .push(time);
+ selectedTimes.splice(index, 1);
+
+ if (selectedTimes.length === 1) {
+ this.inactiveTimes = [];
}
- }
- isOptionDisabled(time:ReminderTime, self:ReminderTime):boolean {
- return time !== self && this.selectedTimes.includes(time);
- }
+ // Activate the first time if none is active.
+ if (selectedTimes.length === this.inactiveTimes.length) {
+ this.inactiveTimes.shift();
+ }
- get isActiveDisabled():boolean {
- return !this.enabled || this.selectedTimes.length === 1;
+ this.storeTimes(selectedTimes);
}
- get isRemovable():boolean {
- return this.enabled && this.selectedTimes.length > 1;
+ toggleEnabled(enabled:boolean):void {
+ this.store.update(({ dailyReminders }) => (
+ {
+ dailyReminders: {
+ ...dailyReminders,
+ enabled,
+ },
+ }
+ ));
}
- removeTime(index:number):void {
- this.selectedTimes.splice(index, 1);
-
- if (this.selectedTimes.length === 1) {
- this.selectedTimes[0].active = true;
+ toggleActive(active:boolean, index:number, selectedTimes:string[]):void {
+ if (!active) {
+ this.inactiveTimes.push({ position: index, time: selectedTimes[index] });
+ } else {
+ this.inactiveTimes = this.inactiveTimes.filter((inactiveTime) => inactiveTime.time !== selectedTimes[index]);
}
- }
- private setupAvailableTimes() {
- const date = new Date();
+ this.storeTimes(selectedTimes);
+ }
- for (let i = 0; i < 24; i++) {
- date.setTime(1000 * 60 * 60 * (i - 1));
- this.availableTimes.push(this.toAvailableTime(date));
- }
+ timeLabel(time:string):string {
+ return this
+ .I18n
+ .toTime(
+ 'time.formats.time',
+ ReminderSettingsDailyTimeComponent.dateForHour(parseInt(time.split(':')[0], 10)),
+ );
}
- private setupSelectedTimes() {
- // TODO: fetch selectedTimes from user preferences
- this.selectedTimes = [this.availableTimes[8]];
+ private storeTimes(selectedTimes:string[]) {
+ this.store.update(({ dailyReminders }) => (
+ {
+ dailyReminders: {
+ ...dailyReminders,
+ times: selectedTimes.filter((selected) => !this.inactiveTimes.map((inactive) => inactive.time).includes(selected)), // .map((selected) => selected.time),
+ },
+ }));
}
- private firstAvailableSuggested() {
- return this.availableTimes.filter((v) => v.suggested && !this.selectedTimes.includes(v))[0];
+ private firstAvailableSuggested(selectedTimes:string[]) {
+ return this.availableTimes.find((v) => this.suggestedTimes.includes(v) && !selectedTimes.includes(v));
}
- private firstAfterSelected() {
- const indexLastSelected = this.availableTimes.indexOf(this.selectedTimes[this.selectedTimes.length - 1]);
+ private firstAfterSelected(selectedTimes:string[]) {
+ const indexLastSelected = this.availableTimes.indexOf(selectedTimes[selectedTimes.length - 1]);
for (let i = indexLastSelected; i < 24 + indexLastSelected; i++) {
- if (!this.selectedTimes.includes(this.availableTimes[i % 24])) {
+ if (!selectedTimes.includes(this.availableTimes[i % 24])) {
return this.availableTimes[i % 24];
}
}
@@ -106,14 +186,16 @@ export class ReminderSettingsDailyTimeComponent {
return null;
}
- private toAvailableTime(date:Date) {
- const time = date.toLocaleTimeString('en-US', { hour12: false, hour: 'numeric', minute: 'numeric' });
+ private static setupAvailableTimes() {
+ return Array.from({ length: 24 }, (v, i) => ReminderSettingsDailyTimeComponent
+ .dateForHour(i)
+ .toLocaleTimeString('en-US', { hour12: false, hour: 'numeric', minute: 'numeric' }));
+ }
+
+ private static dateForHour(hour:number) {
+ const date = new Date();
+ date.setTime(1000 * 60 * 60 * (hour - 1));
- return {
- label: this.I18n.toTime('time.formats.time', date),
- time,
- active: true,
- suggested: ['08:00', '12:00', '15:00', '18:00'].includes(time),
- };
+ return date;
}
}
diff --git a/frontend/src/app/features/user-preferences/state/user-preferences.model.ts b/frontend/src/app/features/user-preferences/state/user-preferences.model.ts
index 954ba83a521..9db5a9b4a8d 100644
--- a/frontend/src/app/features/user-preferences/state/user-preferences.model.ts
+++ b/frontend/src/app/features/user-preferences/state/user-preferences.model.ts
@@ -1,5 +1,10 @@
import { NotificationSetting } from 'core-app/features/user-preferences/state/notification-setting.model';
+export interface DailyRemindersSettings {
+ enabled:boolean;
+ times:string[];
+}
+
export interface UserPreferencesModel {
autoHidePopups:boolean;
commentSortDescending:boolean;
@@ -7,4 +12,5 @@ export interface UserPreferencesModel {
timeZone:string|null;
warnOnLeavingUnsaved:boolean;
notifications:NotificationSetting[];
+ dailyReminders:DailyRemindersSettings;
}
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.ts
index 7cf0f1d62b7..fb1bad78bfe 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
@@ -34,6 +34,21 @@ export class UserPreferencesQuery extends Query<UserPreferencesModel> {
)),
);
+ /** All daily reminders settings */
+ dailyReminders$ = this.select('dailyReminders');
+
+ dailyRemindersEnabled$ = this
+ .dailyReminders$
+ .pipe(
+ map((reminders) => reminders.enabled),
+ );
+
+ dailyRemindersTimes$ = this
+ .dailyReminders$
+ .pipe(
+ map((reminders) => reminders.times),
+ );
+
preferences$ = this.select();
constructor(protected store:UserPreferencesStore) {
diff --git a/frontend/src/app/features/user-preferences/state/user-preferences.store.ts b/frontend/src/app/features/user-preferences/state/user-preferences.store.ts
index 54177ec6b9f..e4e91e6d4de 100644
--- a/frontend/src/app/features/user-preferences/state/user-preferences.store.ts
+++ b/frontend/src/app/features/user-preferences/state/user-preferences.store.ts
@@ -38,6 +38,10 @@ function createInitialState():UserPreferencesModel {
timeZone: null,
warnOnLeavingUnsaved: true,
notifications: [],
+ dailyReminders: {
+ enabled: true,
+ times: ['08:00'],
+ },
};
}
diff --git a/spec/features/notifications/reminder_mail_spec.rb b/spec/features/notifications/reminder_mail_spec.rb
index 226cb1257fb..65581bfb608 100644
--- a/spec/features/notifications/reminder_mail_spec.rb
+++ b/spec/features/notifications/reminder_mail_spec.rb
@@ -46,5 +46,29 @@ describe "Reminder email", type: :feature, js: true do
# The next suggested time is taken: 12:00
reminders_settings_page.expect_active_daily_times("08:00 am", "12:00 pm")
+
+ reminders_settings_page.set_time "Time 2", "03:00 pm"
+
+ reminders_settings_page.expect_active_daily_times("08:00 am", "03:00 pm")
+
+ reminders_settings_page.save
+
+ reminders_settings_page.expect_and_dismiss_notification(message: I18n.t('js.notice_successful_update'))
+
+ reminders_settings_page.reload!
+
+ # Deactivate the second time but then remove the first one will activate the second (then only) one
+ # so that one time is always enabled.
+ reminders_settings_page.expect_active_daily_times("08:00 am", "03:00 pm")
+ reminders_settings_page.deactivate_time("Time 2")
+ reminders_settings_page.remove_time("Time 1")
+
+ reminders_settings_page.save
+
+ reminders_settings_page.expect_and_dismiss_notification(message: I18n.t('js.notice_successful_update'))
+
+ reminders_settings_page.reload!
+
+ reminders_settings_page.expect_active_daily_times("03:00 pm")
end
end
diff --git a/spec/models/user_preference_spec.rb b/spec/models/user_preference_spec.rb
index 9383751ddd2..f9aec0eb4bf 100644
--- a/spec/models/user_preference_spec.rb
+++ b/spec/models/user_preference_spec.rb
@@ -29,27 +29,15 @@
require 'spec_helper'
describe UserPreference do
- subject(:preference) { FactoryBot.build(:user_preference, user: user) }
-
- let(:user) { FactoryBot.build_stubbed(:user) }
-
- describe 'default settings' do
- it 'hides the email address' do
- expect(subject.hide_mail).to eql(true)
- end
+ subject(:preference) do
+ FactoryBot.build(:user_preference,
+ user: user,
+ settings: settings)
+ end
- context 'with default setting auto_hide_popups to false', with_settings: { default_auto_hide_popups: false } do
- it 'disables auto hide popups' do
- expect(subject.auto_hide_popups).to be_falsey
- end
- end
+ let(:settings) { {} }
- context 'with default setting auto_hide_popups to true', with_settings: { default_auto_hide_popups: true } do
- it 'disables auto hide popups' do
- expect(subject.auto_hide_popups).to be_truthy
- end
- end
- end
+ let(:user) { FactoryBot.build_stubbed(:user) }
shared_examples 'accepts real and false booleans' do |setter, getter|
it 'accepts true boolean' do
@@ -115,6 +103,20 @@ describe UserPreference do
it_behaves_like 'accepts real and false booleans',
:auto_hide_popups=,
:auto_hide_popups?
+
+ describe 'without a value being stored and with default setting auto_hide_popups to false',
+ with_settings: { default_auto_hide_popups: false } do
+ it 'disables auto hide popups' do
+ expect(subject.auto_hide_popups).to be_falsey
+ end
+ end
+
+ context 'without a value being stored and with default setting auto_hide_popups to true',
+ with_settings: { default_auto_hide_popups: true } do
+ it 'disables auto hide popups' do
+ expect(subject.auto_hide_popups).to be_truthy
+ end
+ end
end
describe 'hide_mail' do
@@ -138,6 +140,31 @@ describe UserPreference do
end
end
+ describe '#daily_reminders' do
+ context 'without reminders being stored' do
+ it 'uses the defaults' do
+ expect(subject.daily_reminders)
+ .to eql("enabled" => true, "times" => ["08:00:00+00:00"])
+ end
+ end
+
+ context 'with reminders being stored' do
+ let(:settings) do
+ {
+ "daily_reminders" => {
+ "enabled" => false,
+ "times" => %w[12:00:00+00:00 18:00:00+00:00 09:00:00+00:00]
+ }
+ }
+ end
+
+ it 'uses the defaults' do
+ expect(subject.daily_reminders)
+ .to eql(settings["daily_reminders"])
+ end
+ end
+ end
+
describe 'time_zone' do
it 'allows to save short time zones' do
subject.time_zone = 'Berlin'
@@ -155,22 +182,20 @@ describe UserPreference do
describe '[]=' do
let(:user) { FactoryBot.create(:user) }
- context 'with attributes stored in "others"' do
- it 'will save the values on sending "save"' do
- subject.save
+ it 'will save the values on sending "save"' do
+ subject.save
- value_warn_on_leaving_unsaved = !subject[:warn_on_leaving_unsaved]
- value_auto_hide_popups = !subject[:auto_hide_popups]
+ value_warn_on_leaving_unsaved = !subject[:warn_on_leaving_unsaved]
+ value_auto_hide_popups = !subject[:auto_hide_popups]
- subject[:warn_on_leaving_unsaved] = value_warn_on_leaving_unsaved
- subject[:auto_hide_popups] = value_auto_hide_popups
+ subject[:warn_on_leaving_unsaved] = value_warn_on_leaving_unsaved
+ subject[:auto_hide_popups] = value_auto_hide_popups
- subject.save
- subject.reload
+ subject.save
+ subject.reload
- expect(subject[:warn_on_leaving_unsaved]).to eql(value_warn_on_leaving_unsaved)
- expect(subject[:auto_hide_popups]).to eql(value_auto_hide_popups)
- end
+ expect(subject[:warn_on_leaving_unsaved]).to eql(value_warn_on_leaving_unsaved)
+ expect(subject[:auto_hide_popups]).to eql(value_auto_hide_popups)
end
end
end
diff --git a/spec/support/pages/page.rb b/spec/support/pages/page.rb
index 1c50fdeac22..a55d9455f08 100644
--- a/spec/support/pages/page.rb
+++ b/spec/support/pages/page.rb
@@ -44,6 +44,10 @@ module Pages
self
end
+ def reload!
+ page.driver.browser.navigate.refresh
+ end
+
def accept_alert_dialog!
alert_dialog.accept if selenium_driver?
end
diff --git a/spec/support/pages/reminders/settings.rb b/spec/support/pages/reminders/settings.rb
index b317a74d72a..b2c46636592 100644
--- a/spec/support/pages/reminders/settings.rb
+++ b/spec/support/pages/reminders/settings.rb
@@ -43,8 +43,19 @@ module Pages
end
def add_time
- page
- .click_button 'Add time'
+ click_button 'Add time'
+ end
+
+ def set_time(label, time)
+ select time, from: label
+ end
+
+ def deactivate_time(label)
+ find("[data-qa-selector='op-settings-daily-time--active-#{label.split[1]}']").click
+ end
+
+ def remove_time(label)
+ find("[data-qa-selector='op-settings-daily-time--remove-#{label.split[1]}']").click
end
def expect_active_daily_times(*times)