diff --git a/functional_tests/features/ikiwiki.feature b/functional_tests/features/ikiwiki.feature index 6fcce1996..a196097f5 100644 --- a/functional_tests/features/ikiwiki.feature +++ b/functional_tests/features/ikiwiki.feature @@ -15,7 +15,7 @@ # along with this program. If not, see . # -@apps @ikiwiki +@apps @ikiwiki @backups Feature: ikiwiki Wiki and Blog Manage wikis and blogs. @@ -32,4 +32,12 @@ Scenario: Disable wiki application Given the wiki application is enabled When I disable the wiki application Then the wiki site should not be available - \ No newline at end of file + +Scenario: Backup and restore wiki + Given the wiki application is enabled + When there is an ikiwiki wiki + And I create a backup of the ikiwiki app data + And I delete the ikiwiki wiki + And I export the ikiwiki app data backup + And I restore the ikiwiki app data backup + Then the ikiwiki wiki should be restored diff --git a/functional_tests/step_definitions/application.py b/functional_tests/step_definitions/application.py index 0f14a79e5..4adebcdf5 100644 --- a/functional_tests/step_definitions/application.py +++ b/functional_tests/step_definitions/application.py @@ -199,3 +199,18 @@ def set_mediawiki_admin_password(browser): @when(parsers.parse('I disable message archive management')) def set_mediawiki_admin_password(browser): application.disable_ejabberd_message_archive_management(browser) + + +@when('there is an ikiwiki wiki') +def ikiwiki_create_wiki_if_needed(browser): + application.ikiwiki_create_wiki_if_needed(browser) + + +@when('I delete the ikiwiki wiki') +def ikiwiki_delete_wiki(browser): + application.ikiwiki_delete_wiki(browser) + + +@then('the ikiwiki wiki should be restored') +def ikiwiki_should_exist(browser): + assert application.ikiwiki_wiki_exists(browser) diff --git a/functional_tests/support/application.py b/functional_tests/support/application.py index 46ceab4dd..e554f006e 100644 --- a/functional_tests/support/application.py +++ b/functional_tests/support/application.py @@ -267,3 +267,35 @@ def disable_ejabberd_message_archive_management(browser): interface.nav_to_module(browser, 'ejabberd') _change_status(browser, 'ejabberd', 'disabled', checkbox_id='id_MAM_enabled') + + +def ikiwiki_create_wiki_if_needed(browser): + """Create wiki if it does not exist.""" + interface.nav_to_module(browser, 'ikiwiki') + browser.find_link_by_href('/plinth/apps/ikiwiki/manage/').first.click() + wiki = browser.find_link_by_href('/ikiwiki/wiki') + if not wiki: + browser.find_link_by_href('/plinth/apps/ikiwiki/create/').first.click() + browser.find_by_id('id_ikiwiki-name').fill('wiki') + browser.find_by_id('id_ikiwiki-admin_name').fill( + config['DEFAULT']['username']) + browser.find_by_id('id_ikiwiki-admin_password').fill( + config['DEFAULT']['password']) + submit(browser) + + +def ikiwiki_delete_wiki(browser): + """Delete wiki.""" + interface.nav_to_module(browser, 'ikiwiki') + browser.find_link_by_href('/plinth/apps/ikiwiki/manage/').first.click() + browser.find_link_by_href( + '/plinth/apps/ikiwiki/wiki/delete/').first.click() + submit(browser) + + +def ikiwiki_wiki_exists(browser): + """Check whether the wiki exists.""" + interface.nav_to_module(browser, 'ikiwiki') + browser.find_link_by_href('/plinth/apps/ikiwiki/manage/').first.click() + wiki = browser.find_link_by_href('/ikiwiki/wiki') + return bool(wiki)