diff --git a/tests/features/ui/ui_admin.feature b/tests/features/ui/ui_admin.feature index cb51ef7af..28c6bebf4 100644 --- a/tests/features/ui/ui_admin.feature +++ b/tests/features/ui/ui_admin.feature @@ -112,3 +112,28 @@ Feature: Admin UI Examples: | user | text | | functionaladminpriv | TemporaryTerms | + + + Scenario Outline: Admin user deletes file format + Given user is logged in + When module "admin" is shown + And the user selects the file format list to delete + And the user clicks the Delete file format list button + Then the success message for deleting the file format list is shown + + Examples: + | user | filename | + | functionaladminpriv | 4TU.json | + | functionaladminpriv | DANS.json | + + + Scenario Outline: Admin user uploads new file format + Given user is logged in + When module "admin" is shown + And the user clicks the Upload file format list + Then the success message of uploading a file format list is shown + + Examples: + | user | filename | + | functionaladminpriv | 4TU.json | + | functionaladminpriv | DANS.json | diff --git a/tests/files/file_formats/4TU.json b/tests/files/file_formats/4TU.json new file mode 100644 index 000000000..80686335f --- /dev/null +++ b/tests/files/file_formats/4TU.json @@ -0,0 +1,35 @@ +{ + "name": "4TU Preferred formats", + "help": "Checks if the files in the data folder and subfolders comply with the 4TU Centre for Research Data guidelines for preferred file formats as per 1-Aug-2019. Their guidelines states that usage of the preferred file formats is of essential importance in order to ensure that the research data will remain usable in the future. For more information see https://researchdata.4tu.nl/. Disclaimer: Please note that Yoda currently deducts the file format from the filename. It does not inspect the file content.", + "advice": "For files that do not comply with preferred formats, we recommend that you include in the data package a specification of the file format. Should you want to reference an external specification document then try to find a sustainable link, ideally use a DOI. If feasible, also include in a separate folder of your data package a copy of the file transformed into of the preferred formats. Please consult a datamanager or consult the Research Support desk (see https://www.uu.nl/rdm) in case you need any assistance.", + "formats": [ + "txt", + "xml", + "html", + "pdf", + "json", + "pdb", + "ent", + "brk", + "xyz", + "csv", + "jpg", + "jpeg", + "tif", + "tiff", + "png", + "svg", + "gml", + "kml", + "kmz", + "shp", + "shx", + "dbf", + "nc", + "wav", + "zip", + "tar", + "gzip", + "7z" + ] +} diff --git a/tests/files/file_formats/DANS.json b/tests/files/file_formats/DANS.json new file mode 100644 index 000000000..31a274f40 --- /dev/null +++ b/tests/files/file_formats/DANS.json @@ -0,0 +1,49 @@ +{ + "name": "DANS Preferred formats", + "help": "Checks if the files in the data folder and subfolders comply with the DANS guidelines for preferred file formats as per 1-Aug-2019. Their guidelines states that the preferred file formats offer the best long-term guarantees in terms of usability, accessibility and sustainability. For more information see https://dans.knaw.nl/. Disclaimer: Please note that Yoda currently deducts the file format from the filename. It does not inspect the file content.", + "advice": "For files that do not comply with preferred formats, we recommend that you include in the data package a specification of the file format. Should you want to reference an external specification document then try to find a sustainable link, ideally use a DOI. If feasible, also include in a separate folder of your data package a copy of the file transformed into of the preferred formats. Please consult a datamanager or consult the Research Support desk (see https://www.uu.nl/rdm) in case you need any assistance.", + "formats": [ + "pdf", + "odt", + "txt", + "xml", + "html", + "css", + "xslt", + "js", + "es", + "ods", + "csv", + "sql", + "siard", + "por", + "dta", + "jpg", + "jpeg", + "tif", + "tiff", + "png", + "jp2", + "dcm", + "svg", + "bwf", + "mxf", + "mka", + "flac", + "mxf", + "mkv", + "dxf", + "gml", + "mif", + "mid", + "asc", + "obj", + "ply", + "x3d", + "dae", + "rdf", + "trig", + "ttl", + "nt" + ] +} diff --git a/tests/step_defs/ui/test_ui_admin.py b/tests/step_defs/ui/test_ui_admin.py index 1c45870ae..5e3f3d7ab 100644 --- a/tests/step_defs/ui/test_ui_admin.py +++ b/tests/step_defs/ui/test_ui_admin.py @@ -4,6 +4,7 @@ __copyright__ = "Copyright (c) 2024, Utrecht University" __license__ = "GPLv3, see LICENSE" +import os import time from pytest_bdd import ( @@ -182,3 +183,41 @@ def ui_admin_removed_text_not_displayed(browser, text): time.sleep(1) terms = browser.find_by_id('admin-publication-terms').first.value assert text not in terms + + +@when(parsers.parse('the user clicks the Upload file format list {filename}')) +def ui_admin_clicks_upload_file_format_button(browser, filename): + browser.execute_script("document.getElementById('upload-button').scrollIntoView();") + browser.find_by_css("#upload-button") + + cwd = os.getcwd() + if os.name == 'nt': + browser.find_by_css('input[type="file"]')[0].fill("{}\\files\\file_formats\\{}".format(cwd, filename)) + else: + browser.find_by_css('input[type="file"]')[0].fill("{}/files/file_formats/{}".format(cwd, filename)) + + +@then(parsers.parse('the success message of uploading a file format list {filename} is shown')) +def ui_admin_upload_file_format_success(browser, filename): + assert browser.is_text_present(f"File format list '{filename}' uploaded successfully.") + + +@when(parsers.parse('the user selects the file format list {filename} to delete')) +def ui_admin_select_file_format(browser, filename): + browser.execute_script("document.getElementById('file-formats-list').scrollIntoView();") + browser.find_by_css('#file-formats-list').click() + options = browser.find_by_css('#file-formats-list option') + for option in options: + if option.value == filename.split('.')[0]: + option.click() + break + + +@when('the user clicks the Delete file format list button') +def ui_admin_click_delete_button(browser): + browser.find_by_css("#delete-format-button").click() + + +@then(parsers.parse('the success message for deleting the file format list {filename} is shown')) +def ui_admin_delete_file_format_success(browser, filename): + assert browser.is_text_present(f"File format list '{filename}' deleted successfully.")