fix specs

This commit is contained in:
Bruno Pagno
2025-11-19 13:28:57 +01:00
parent a2bb5423f4
commit 7a1112eea8
6 changed files with 30 additions and 6 deletions
@@ -42,28 +42,31 @@ export default class extends Controller {
'blockNoteInputField',
];
declare readonly blockNoteEditorTarget:HTMLElement;
declare readonly blockNoteInputFieldTarget:HTMLInputElement;
static values = {
inputText: String,
activeUser: Object,
openProjectUrl: String,
attachmentsUploadUrl: String,
attachmentsCollectionKey: String,
collaborationEnabled: Boolean,
};
declare readonly blockNoteEditorTarget:HTMLElement;
declare readonly blockNoteInputFieldTarget:HTMLInputElement;
declare readonly inputTextValue:string;
declare readonly activeUserValue:User;
declare readonly openProjectUrlValue:string;
declare readonly attachmentsUploadUrlValue:string;
declare readonly attachmentsCollectionKeyValue:string;
declare readonly collaborationEnabledValue:string;
connect() {
const root = createRoot(this.blockNoteEditorTarget);
// this should be a system wide configuration
const collaborationEnabled = true;
if (collaborationEnabled) {
if (this.collaborationEnabledValue) {
LiveCollaborationManager.onReady((hocuspocusProvider) => {
root.render(this.BlockNoteReactContainer(hocuspocusProvider));
});
@@ -39,6 +39,7 @@
block_note_active_user_value: active_user,
block_note_attachments_upload_url_value: attachments_upload_url,
block_note_attachments_collection_key_value: attachments_collection_key,
block_note_collaboration_enabled_value: collaboration_enabled,
test_selector: "blocknote-document-description"
}
) do
@@ -39,7 +39,8 @@ module Primer
:value,
:active_user,
:attachments_upload_url,
:attachments_collection_key
:attachments_collection_key,
:collaboration_enabled
delegate :name, to: :@input
@@ -53,6 +54,8 @@ module Primer
}
@attachments_upload_url = attachments_upload_url
@attachments_collection_key = attachments_collection_key
@collaboration_enabled = true
end
end
end
@@ -55,6 +55,11 @@ RSpec.describe "Upload attachment to documents",
before do
login_as(user)
# This is here while we don't have a setting defined for enabling/disabling collaboration
# rubocop:disable RSpec/AnyInstance
allow_any_instance_of(Primer::OpenProject::Forms::BlockNoteEditor).to receive(:collaboration_enabled).and_return(false)
# rubocop:enable RSpec/AnyInstance
end
shared_examples "can upload an image in CKEditor" do
@@ -38,6 +38,11 @@ RSpec.describe "BlockNote editor rendering", :js, with_flag: { block_note_editor
before do
login_as(admin)
# This is here while we don't have a setting defined for enabling/disabling collaboration
# rubocop:disable RSpec/AnyInstance
allow_any_instance_of(Primer::OpenProject::Forms::BlockNoteEditor).to receive(:collaboration_enabled).and_return(false)
# rubocop:enable RSpec/AnyInstance
end
it "renders the BlockNote editor in the users locale" do
@@ -46,6 +46,13 @@ RSpec.describe "Show/Edit Document View",
current_user { member }
before do
# This is here while we don't have a setting defined for enabling/disabling collaboration
# rubocop:disable RSpec/AnyInstance
allow_any_instance_of(Primer::OpenProject::Forms::BlockNoteEditor).to receive(:collaboration_enabled).and_return(false)
# rubocop:enable RSpec/AnyInstance
end
it "renders a collaborative document" do
visit document_path(document)