diff --git a/plinth/modules/ejabberd/tests/test_functional.py b/plinth/modules/ejabberd/tests/test_functional.py index 1d816435c..f073716ee 100644 --- a/plinth/modules/ejabberd/tests/test_functional.py +++ b/plinth/modules/ejabberd/tests/test_functional.py @@ -54,6 +54,7 @@ class TestEjabberdApp(functional.BaseAppTests): def test_backup_restore(self, session_browser): """Test backup and restore of app data.""" functional.app_enable(session_browser, 'ejabberd') + functional.app_enable(session_browser, 'jsxc') _jsxc_add_contact(session_browser) functional.backup_create(session_browser, 'ejabberd', 'test_ejabberd') diff --git a/plinth/modules/jsxc/__init__.py b/plinth/modules/jsxc/__init__.py index 45024989d..a5c4d10d1 100644 --- a/plinth/modules/jsxc/__init__.py +++ b/plinth/modules/jsxc/__init__.py @@ -1,7 +1,5 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -""" -FreedomBox app to configure XMPP web client/jsxc. -""" +"""FreedomBox app to configure XMPP web client/jsxc.""" import logging @@ -32,8 +30,6 @@ class JSXCApp(app_module.App): _version = 1 - can_be_disabled = False - def __init__(self): """Create components for the app.""" super().__init__() @@ -50,6 +46,9 @@ class JSXCApp(app_module.App): parent_url_name='apps') self.add(menu_item) + enable_state = app_module.EnableState('enable-state-jsxc') + self.add(enable_state) + shortcut = frontpage.Shortcut('shortcut-jsxc', name=info.name, short_description=info.short_description, icon=info.icon_filename, diff --git a/plinth/modules/jsxc/tests/test_functional.py b/plinth/modules/jsxc/tests/test_functional.py index 53492cad0..f6f9bda40 100644 --- a/plinth/modules/jsxc/tests/test_functional.py +++ b/plinth/modules/jsxc/tests/test_functional.py @@ -1,7 +1,5 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -""" -Functional, browser based tests for jsxc app. -""" +"""Functional, browser based tests for jsxc app.""" import pytest @@ -10,21 +8,5 @@ from plinth.tests import functional pytestmark = [pytest.mark.apps, pytest.mark.jsxc] -@pytest.fixture(scope='module', autouse=True) -def fixture_background(session_browser): - """Login.""" - functional.login(session_browser) - - -def test_install(session_browser): - """Test installing the app.""" - functional.install(session_browser, 'jsxc') - assert functional.is_available(session_browser, 'jsxc') - - -@pytest.mark.backups -def test_backup(session_browser): - """Test backing up and restoring.""" - functional.backup_create(session_browser, 'jsxc', 'test_jsxc') - functional.backup_restore(session_browser, 'jsxc', 'test_jsxc') - assert functional.is_available(session_browser, 'jsxc') +class TestJSXCApp(functional.BaseAppTests): + app_name = 'jsxc' diff --git a/plinth/modules/jsxc/views.py b/plinth/modules/jsxc/views.py index 547ce1f61..c3e583211 100644 --- a/plinth/modules/jsxc/views.py +++ b/plinth/modules/jsxc/views.py @@ -1,17 +1,26 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -""" -Views for the JSXC module -""" +"""Views for the JSXC module.""" +from django.http import Http404 from django.views.generic import TemplateView +import plinth.app as app_module from plinth.modules import config class JsxcView(TemplateView): """A simple page to embed Javascript XMPP Client library.""" + template_name = 'jsxc_launch.html' + def dispatch(self, request, *args, **kwargs): + """Don't serve the view when app is disabled.""" + app = app_module.App.get('jsxc') + if not app.is_enabled(): + raise Http404 + + return super().dispatch(request, *args, **kwargs) + def get_context_data(self, *args, **kwargs): """Add domain information to view context.""" context = super().get_context_data(*args, **kwargs) diff --git a/plinth/tests/functional/__init__.py b/plinth/tests/functional/__init__.py index e588e1dfe..930cc74f1 100644 --- a/plinth/tests/functional/__init__.py +++ b/plinth/tests/functional/__init__.py @@ -157,7 +157,7 @@ def is_available(browser, site_name): browser.visit(url_to_visit) time.sleep(3) browser.reload() - if '404' in browser.title: + if '404' in browser.title or 'Page not found' in browser.title: return False # The site might have a default path after the sitename,