diff --git a/data/etc/mediawiki/FreedomBoxSettings.php b/data/etc/mediawiki/FreedomBoxSettings.php index d4fa5dd51..f33f4a6e3 100644 --- a/data/etc/mediawiki/FreedomBoxSettings.php +++ b/data/etc/mediawiki/FreedomBoxSettings.php @@ -19,3 +19,8 @@ $wgUsePathInfo = true; # Instant Commons $wgUseInstantCommons = true; + +# SVG Enablement +$wgFileExtensions[] = 'svg'; +$wgAllowTitlesInSVG = true; +$wgSVGConverter = 'ImageMagick'; diff --git a/functional_tests/features/mediawiki.feature b/functional_tests/features/mediawiki.feature index 3d0f70e0e..6c39cccd7 100644 --- a/functional_tests/features/mediawiki.feature +++ b/functional_tests/features/mediawiki.feature @@ -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 diff --git a/functional_tests/step_definitions/site.py b/functional_tests/step_definitions/site.py index b97cdca90..6e2cbdd88 100644 --- a/functional_tests/step_definitions/site.py +++ b/functional_tests/step_definitions/site.py @@ -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) diff --git a/functional_tests/support/site.py b/functional_tests/support/site.py index 9dddd87f5..8b6a7e40e 100644 --- a/functional_tests/support/site.py +++ b/functional_tests/support/site.py @@ -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