Skip to content

Commit 527ded6

Browse files
committed
Add happy path for collaborative editing
1 parent 9c8bea6 commit 527ded6

File tree

3 files changed

+86
-1
lines changed

3 files changed

+86
-1
lines changed

modules/documents/app/components/documents/show_edit_view/page_header/info_line_component.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
<%=
3333
component_wrapper do
34-
flex_layout(tag: :div, align_items: :center) do |flex|
34+
flex_layout(tag: :div, align_items: :center, test_selector: "document-info-line") do |flex|
3535
flex.with_column(hide: :sm, mr: 2) do
3636
render(Primer::Alpha::ActionMenu.new(select_variant: :single)) do |menu|
3737
menu.with_show_button do |button|
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# frozen_string_literal: true
2+
3+
#-- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See COPYRIGHT and LICENSE files for more details.
29+
#++
30+
31+
require "spec_helper"
32+
require_module_spec_helper
33+
34+
RSpec.describe "Show/Edit Document View",
35+
:js,
36+
:selenium,
37+
with_flag: { block_note_editor: true } do
38+
shared_let(:project) { create(:project) }
39+
shared_let(:member_role) { create(:existing_project_role, permissions: %i[view_documents manage_documents]) }
40+
shared_let(:member) { create(:user, member_with_roles: { project => member_role }) }
41+
42+
let(:document_types) do
43+
%w[Specification Report].map { create(:document_type, name: it) }
44+
end
45+
let(:document) { create(:document, project:, title: "Collaborative document", type: document_types.first) }
46+
47+
current_user { member }
48+
49+
it "renders a collaborative document" do
50+
visit document_path(document)
51+
52+
expect(page).to have_content("Collaborative document")
53+
54+
aggregate_failures "can change document type" do
55+
within_test_selector("document-info-line") do
56+
click_button "Specification"
57+
click_on "Report"
58+
expect(page).to have_button("Report")
59+
end
60+
expect(document.reload.type).to eq(document_types[1])
61+
end
62+
63+
aggregate_failures "can edit document content" do
64+
editor = FormFields::Primerized::BlockNoteEditorInput.new
65+
editor.fill_in_with_content("This is the new **content**.")
66+
67+
expect(page).to have_content("This is the new content.")
68+
end
69+
end
70+
71+
context "without view documents permission" do
72+
let(:user) { create(:user) }
73+
74+
current_user { user }
75+
76+
it "renders a not authorized message" do
77+
visit document_path(document)
78+
expect(page).to have_text("[Error 403] You are not authorized to access this page.")
79+
end
80+
end
81+
end

spec/support/form_fields/primerized/block_note_editor_input.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ def fill_in_with_content(content)
1919
editor = find_editor
2020
editor.send_keys(content)
2121
end
22+
23+
def find_editor
24+
page.find("div[role='textbox']")
25+
end
2226
end
2327
end
2428
end

0 commit comments

Comments
 (0)