From aed72f9f8e8f31eabf6cc86b91405add466aa069 Mon Sep 17 00:00:00 2001 From: Dombi Attila <83396+dombesz@users.noreply.github.com> Date: Tue, 18 Jul 2023 14:38:55 +0300 Subject: [PATCH] [#45011] No info about changes in activity when use checkbox in the custom field https://community.openproject.org/work_packages/45011 --- .../user/user-activity.component.ts | 4 +-- .../work_packages/tabs/activity_tab_spec.rb | 32 +++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/features/work-packages/components/wp-activity/user/user-activity.component.ts b/frontend/src/app/features/work-packages/components/wp-activity/user/user-activity.component.ts index 8d5f9fc1aff3..7e4815434175 100644 --- a/frontend/src/app/features/work-packages/components/wp-activity/user/user-activity.component.ts +++ b/frontend/src/app/features/work-packages/components/wp-activity/user/user-activity.component.ts @@ -132,8 +132,8 @@ export class UserActivityComponent extends WorkPackageCommentFieldHandler implem this.$element.bind('focusin', this.focus.bind(this)); this.$element.bind('focusout', this.blur.bind(this)); - _.each(this.activity.details, (detail:any) => { - this.details.push(detail.html); + _.each(this.activity.details, (detail:{ html:string }) => { + this.details.push(this.sanitization.bypassSecurityTrustHtml(detail.html)); }); this diff --git a/spec/features/work_packages/tabs/activity_tab_spec.rb b/spec/features/work_packages/tabs/activity_tab_spec.rb index 8f6354211759..69b284706a71 100644 --- a/spec/features/work_packages/tabs/activity_tab_spec.rb +++ b/spec/features/work_packages/tabs/activity_tab_spec.rb @@ -35,13 +35,26 @@ js: true, selenium: true do def alter_work_package_at(work_package, attributes:, at:, user: User.current) + work_package.custom_field_values = attributes.delete(:custom_field_values) work_package.update(attributes.merge(updated_at: at)) note_journal = work_package.journals.last note_journal.update(created_at: at, updated_at: at, user:) end - let(:project) { create(:project_with_types, public: true) } + let(:string_cf) { create(:text_wp_custom_field) } + + let(:type_with_cf) do + create(:type, custom_fields: [string_cf]) + end + + let(:project) do + create(:project_with_types, + types: [type_with_cf], + work_package_custom_fields: [string_cf], + public: true) + end + let!(:work_package) do work_package = create(:work_package, project:, @@ -65,7 +78,13 @@ def alter_work_package_at(work_package, attributes:, at:, user: User.current) end let!(:note1) do - attributes = { subject: 'New subject', description: 'Some not so long description.' } + attributes = { + subject: 'New subject', + description: 'Some not so long description.', + custom_field_values: { + string_cf.id => "* [x] Task 1\n* [ ] Task 2" + } + } alter_work_package_at(work_package, attributes:, @@ -208,6 +227,15 @@ def alter_work_package_at(work_package, attributes:, at:, user: User.current) expect(page).to have_selector('.user-comment > .message', count: 3) expect(page).to have_selector('.user-comment > .message blockquote') end + + it 'can render checkboxes as part of the activity' do + task_list = page.all('[data-qa-activity-number="2"] ul.op-uc-list_task-list li.op-uc-list--item') + expect(task_list.size).to eq(2) + expect(task_list[0]).to have_text('Task 1') + expect(task_list[0]).to have_checked_field(disabled: true) + expect(task_list[1]).to have_text('Task 2') + expect(task_list[1]).to have_unchecked_field(disabled: true) + end end context 'with no permission' do