Commit 537e2c7d authored by vignan lavu's avatar vignan lavu Committed by Joseph Nuthalapati

mediawiki: Enable SVG support for MediaWiki

- Changed configuration file FreedomBoxSettings.php to enable SVG extension.
- Added functional test for upload and viewing of svg file.
- Modified the existing functional test with image file name as parameter.

Closes #1354Signed-off-by: vignan lavu's avatarVignan Lavu <vignan.lavu@gmail.com>
Reviewed-by: Joseph Nuthalapati's avatarJoseph Nuthalapati <njoseph@thoughtworks.com>
Signed-off-by: Joseph Nuthalapati's avatarJoseph Nuthalapati <njoseph@thoughtworks.com>
parent aa90564c
Pipeline #17889 passed with stages
in 11 minutes and 54 seconds
......@@ -19,3 +19,8 @@ $wgUsePathInfo = true;
# Instant Commons
$wgUseInstantCommons = true;
# SVG Enablement
$wgFileExtensions[] = 'svg';
$wgAllowTitlesInSVG = true;
$wgSVGConverter = 'ImageMagick';
......@@ -75,5 +75,10 @@ Scenario: Logged in user can see upload files option
Scenario: Upload images
Given the mediawiki application is enabled
When I upload an image to mediawiki with credentials admin and whatever123
Then there should be 1 uploaded images
When I upload an image named FreedomBox-logo-lineart.png to mediawiki with credentials admin and whatever123
Then there should be FreedomBox-logo-lineart.png image
Scenario: Upload SVG image
Given the mediawiki application is enabled
When I upload an image named FreedomBox-logo-grayscale.svg to mediawiki with credentials admin and whatever123
Then there should be FreedomBox-logo-grayscale.svg image
......@@ -37,16 +37,16 @@ def access_application(browser, app_name):
@when(
parsers.parse(
'I upload an image to mediawiki with credentials {username:w} and {password:w}'
))
def upload_image(browser, username, password):
site.upload_image_mediawiki(browser, username, password)
'I upload an image named {image:S} to mediawiki with credentials {username:w} and '
'{password:w}'))
def upload_image(browser, username, password, image):
site.upload_image_mediawiki(browser, username, password, image)
@then(parsers.parse('there should be {count:d} uploaded images'))
def uploaded_image_should_be_available(browser, count):
num_images = site.get_number_of_uploaded_images_in_mediawiki(browser)
assert count == num_images
@then(parsers.parse('there should be {image:S} image'))
def uploaded_image_should_be_available(browser, image):
uploaded_image = site.get_uploaded_image_in_mediawiki(browser, image)
assert image.lower() == uploaded_image.lower()
@then(
......@@ -82,7 +82,7 @@ def mediawiki_does_not_allow__account_creation_anonymous_reads_edits(browser):
@then(
parsers.parse(
'I should see the Upload File option in the side pane when logged in with credentials {username:w} and {password:w}'
))
'I should see the Upload File option in the side pane when logged in '
'with credentials {username:w} and {password:w}'))
def login_to_mediawiki_with_credentials(browser, username, password):
site.login_to_mediawiki_with_credentials(browser, username, password)
......@@ -101,7 +101,7 @@ def login_to_mediawiki_with_credentials(browser, username, password):
assert eventually(browser.is_element_present_by_id, args=['t-upload'])
def upload_image_mediawiki(browser, username, password):
def upload_image_mediawiki(browser, username, password, image):
"""Upload an image to MediaWiki. Idempotent."""
browser.visit(config['DEFAULT']['url'] + '/mediawiki')
_login_to_mediawiki(browser, username, password)
......@@ -109,7 +109,7 @@ def upload_image_mediawiki(browser, username, password):
# Upload file
browser.visit(config['DEFAULT']['url'] + '/mediawiki/Special:Upload')
file_path = os.path.realpath(
'../static/themes/default/img/freedombox-logo-32px.png')
'../static/themes/default/img/' + image)
browser.attach_file('wpUploadFile', file_path)
interface.submit(browser, element=browser.find_by_name('wpUpload')[0])
......@@ -117,3 +117,9 @@ def upload_image_mediawiki(browser, username, password):
def get_number_of_uploaded_images_in_mediawiki(browser):
browser.visit(config['DEFAULT']['url'] + '/mediawiki/Special:ListFiles')
return len(browser.find_by_css('.TablePager_col_img_timestamp'))
def get_uploaded_image_in_mediawiki(browser, image):
browser.visit(config['DEFAULT']['url'] + '/mediawiki/Special:ListFiles')
elements = browser.find_link_by_partial_href(image)
return elements[0].value
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment