Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leonidastri committed Oct 10, 2024
1 parent 20f8d92 commit b0f5577
Show file tree
Hide file tree
Showing 4 changed files with 247 additions and 101 deletions.
227 changes: 126 additions & 101 deletions tests/features/ui/ui_admin.feature
Original file line number Diff line number Diff line change
@@ -1,114 +1,139 @@
@ui
Feature: Admin UI

Scenario Outline: Admin user views the admin page
# Scenario Outline: Admin user views the admin page
# Given user <user> is logged in
# When module "admin" is shown
# Then the text Administration is shown
# And the Administration option is available in the menu dropdown
# And the Maintenance Banner feature is visible
# And the Portal Theme feature is visible
# And the Publication Terms feature is visible
# # Example 1: technicaladmin is an admin user as the role: rodsadmin
# # Example 2: functionaladminpriv is an admin user in the group: priv-admin

# Examples:
# | user |
# | technicaladmin |
# | functionaladminpriv |


# Scenario Outline: Non-admin user views the admin page
# Given user <user> is logged in
# When module "admin" is shown
# Then the text Access forbidden is shown
# And the Administration option is not available in the menu dropdown

# Examples:
# | user |
# | researcher |


# Scenario Outline: Admin user sets up a default banner message
# Given user <user> is logged in
# When module "admin" is shown
# And the user inputs banner message <message>
# And the user <action> the checkbox to mark the banner as important
# And the user clicks the Set Banner button
# And the user navigates to the home page
# Then the banner displays the message <message>
# And the banner background color is <color>
# # Example 1: Set an unimportant banner message
# # Example 2: Set an important banner message

# Examples:
# | user | message | action | color |
# | functionaladminpriv | Test banner message | unchecks | text-bg-primary |
# | functionaladminpriv | Test banner message | checks | text-bg-danger |


# Scenario Outline: Admin user removes an existing banner message
# Given user <user> is logged in
# And the banner displays the message <message>
# When module "admin" is shown
# And the user clicks the Remove Banner button
# And the user navigates to the home page
# Then the banner does not exist

# Examples:
# | user | message |
# | functionaladminpriv | Test banner message |


# Scenario Outline: Admin user sets a new portal theme
# Given user <user> is logged in
# When module "admin" is shown
# And the user changes the portal theme to <theme>
# And the user clicks the Set Theme button
# And the user navigates to the home page
# Then the new theme displays <host name>

# Examples:
# | user | theme | host name |
# | functionaladminpriv | uu_fsw | Social Science |
# | functionaladminpriv | uu_geo | Geo |
# | functionaladminpriv | uu | Yoda |


# Scenario Outline: Admin user previews publication terms
# Given user <user> is logged in
# When module "admin" is shown
# And the user adds text <text> to publication terms
# And the user clicks the Preview Terms button
# Then the added text <text> is shown in the preview window

# Examples:
# | user | text |
# | functionaladminpriv | TemporaryTerms |


# Scenario Outline: Admin user updates publication terms
# Given user <user> is logged in
# When module "admin" is shown
# And the user adds text <text> to publication terms
# And the user clicks the Set Terms button
# And the user reloads the page
# Then the text <text> is displayed in the publication terms textarea

# Examples:
# | user | text |
# | functionaladminpriv | TemporaryTerms |


# Scenario Outline: Admin user removes the text from publication terms
# Given user <user> is logged in
# When module "admin" is shown
# And the text <text> is displayed in the publication terms textarea
# And the user removes the <text> from publication terms
# And the user clicks the Set Terms button
# And the user reloads the page
# Then the text <text> is not displayed in the publication terms textarea

# Examples:
# | user | text |
# | functionaladminpriv | TemporaryTerms |


Scenario Outline: Admin user uploads new file format
Given user <user> is logged in
When module "admin" is shown
Then the text Administration is shown
And the Administration option is available in the menu dropdown
And the Maintenance Banner feature is visible
And the Portal Theme feature is visible
And the Publication Terms feature is visible
# Example 1: technicaladmin is an admin user as the role: rodsadmin
# Example 2: functionaladminpriv is an admin user in the group: priv-admin

Examples:
| user |
| technicaladmin |
| functionaladminpriv |


Scenario Outline: Non-admin user views the admin page
Given user <user> is logged in
When module "admin" is shown
Then the text Access forbidden is shown
And the Administration option is not available in the menu dropdown

Examples:
| user |
| researcher |


Scenario Outline: Admin user sets up a default banner message
Given user <user> is logged in
When module "admin" is shown
And the user inputs banner message <message>
And the user <action> the checkbox to mark the banner as important
And the user clicks the Set Banner button
And the user navigates to the home page
Then the banner displays the message <message>
And the banner background color is <color>
# Example 1: Set an unimportant banner message
# Example 2: Set an important banner message

Examples:
| user | message | action | color |
| functionaladminpriv | Test banner message | unchecks | text-bg-primary |
| functionaladminpriv | Test banner message | checks | text-bg-danger |


Scenario Outline: Admin user removes an existing banner message
Given user <user> is logged in
And the banner displays the message <message>
When module "admin" is shown
And the user clicks the Remove Banner button
And the user navigates to the home page
Then the banner does not exist

Examples:
| user | message |
| functionaladminpriv | Test banner message |


Scenario Outline: Admin user sets a new portal theme
Given user <user> is logged in
When module "admin" is shown
And the user changes the portal theme to <theme>
And the user clicks the Set Theme button
And the user navigates to the home page
Then the new theme displays <host name>

Examples:
| user | theme | host name |
| functionaladminpriv | uu_fsw | Social Science |
| functionaladminpriv | uu_geo | Geo |
| functionaladminpriv | uu | Yoda |


Scenario Outline: Admin user previews publication terms
Given user <user> is logged in
When module "admin" is shown
And the user adds text <text> to publication terms
And the user clicks the Preview Terms button
Then the added text <text> is shown in the preview window

Examples:
| user | text |
| functionaladminpriv | TemporaryTerms |


Scenario Outline: Admin user updates publication terms
Given user <user> is logged in
When module "admin" is shown
And the user adds text <text> to publication terms
And the user clicks the Set Terms button
And the user reloads the page
Then the text <text> is displayed in the publication terms textarea
And the user clicks the Upload file format list <filename>
Then the success message of uploading a file format list <filename> is shown

Examples:
| user | text |
| functionaladminpriv | TemporaryTerms |
| user | filename |
| functionaladminpriv | 4TU.json |
| functionaladminpriv | DANS.json |


Scenario Outline: Admin user removes the text from publication terms
Scenario Outline: Admin user deletes file format
Given user <user> is logged in
When module "admin" is shown
And the text <text> is displayed in the publication terms textarea
And the user removes the <text> from publication terms
And the user clicks the Set Terms button
And the user reloads the page
Then the text <text> is not displayed in the publication terms textarea
And the user selects the file format list <filename> to delete
And the user clicks the Delete file format list button
Then the success message for deleting the file format list <filename> is shown

Examples:
| user | text |
| functionaladminpriv | TemporaryTerms |
| user | filename |
| functionaladminpriv | 4TU.json |
| functionaladminpriv | DANS.json |
35 changes: 35 additions & 0 deletions tests/files/file_formats/4TU.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
49 changes: 49 additions & 0 deletions tests/files/file_formats/DANS.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
37 changes: 37 additions & 0 deletions tests/step_defs/ui/test_ui_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
__copyright__ = "Copyright (c) 2024, Utrecht University"
__license__ = "GPLv3, see LICENSE"

import os
import time

from pytest_bdd import (
Expand Down Expand Up @@ -182,3 +183,39 @@ 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.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.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.")

0 comments on commit b0f5577

Please sign in to comment.