2019-07-25 05:27:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-10-17 15:47:05 +00:00
|
|
|
module WikiHelpers
|
|
|
|
extend self
|
|
|
|
|
2020-09-11 18:08:42 +00:00
|
|
|
def stub_group_wikis(enabled)
|
|
|
|
stub_feature_flags(group_wikis_feature_flag: enabled)
|
|
|
|
stub_licensed_features(group_wikis: enabled)
|
|
|
|
end
|
|
|
|
|
2020-02-26 18:09:24 +00:00
|
|
|
def wait_for_svg_to_be_loaded(example = nil)
|
|
|
|
# Ensure the SVG is loaded first before clicking the button
|
|
|
|
find('.svg-content .js-lazy-loaded') if example.nil? || example.metadata.key?(:js)
|
|
|
|
end
|
|
|
|
|
2020-06-04 00:08:17 +00:00
|
|
|
def upload_file_to_wiki(container, user, file_name)
|
2018-10-17 15:47:05 +00:00
|
|
|
opts = {
|
|
|
|
file_name: file_name,
|
|
|
|
file_content: File.read(expand_fixture_path(file_name))
|
|
|
|
}
|
|
|
|
|
2020-05-13 18:08:47 +00:00
|
|
|
::Wikis::CreateAttachmentService.new(
|
2020-06-04 00:08:17 +00:00
|
|
|
container: container,
|
2020-05-13 18:08:47 +00:00
|
|
|
current_user: user,
|
|
|
|
params: opts
|
|
|
|
).execute[:result][:file_path]
|
2018-10-17 15:47:05 +00:00
|
|
|
end
|
|
|
|
end
|