diff --git a/e2e/client/specs/users_spec.ts b/e2e/client/specs/users_spec.ts index dfc2d5cc80..b38e87e9f1 100644 --- a/e2e/client/specs/users_spec.ts +++ b/e2e/client/specs/users_spec.ts @@ -47,6 +47,10 @@ describe('users', () => { element(by.css('.modal__dialog .btn--primary')).click(); browser.sleep(2000); // wait for reload + // close "missing categories" vocabulary warning + // most likely it appears because refreshing the page causes test data to disappear + element(by.css('.p-dialog-header-icons')).click(); + const header = element(by.css('[ng-hide="currentRoute.topTemplateUrl"]')); browser.wait(ECE.presenceOf(header), 1000); diff --git a/scripts/index.ts b/scripts/index.ts index 87e230437e..6b88ba7c7d 100644 --- a/scripts/index.ts +++ b/scripts/index.ts @@ -24,6 +24,8 @@ import {setupTansa} from 'apps/tansa'; import {i18n} from 'core/utils'; import {configurableAlgorithms} from 'core/ui/configurable-algorithms'; import {merge} from 'lodash'; +import {maybeDisplayInvalidInstanceConfigurationMessage} from 'validate-instance-configuration'; +import ng from 'core/services/ng'; let body = angular.element('body'); @@ -197,6 +199,7 @@ export function startApp( document.write('Invalid date format specified in config.view.dateFormat'); return; } + /** * @ngdoc module * @name superdesk-client @@ -210,6 +213,12 @@ export function startApp( 'superdesk.register_extensions', ].concat(appConfig.apps || []), {strictDi: true}); + setTimeout(() => { // required to avoid protractor timing out and failing tests + if (ng.get('session').sessionId != null) { // user logged in + maybeDisplayInvalidInstanceConfigurationMessage(); + } + }); + window['superdeskIsReady'] = true; body.attr('data-theme', 'dark-ui'); diff --git a/scripts/validate-instance-configuration.tsx b/scripts/validate-instance-configuration.tsx new file mode 100644 index 0000000000..8a0a2b53b9 --- /dev/null +++ b/scripts/validate-instance-configuration.tsx @@ -0,0 +1,45 @@ +import React from 'react'; +import {Modal} from 'superdesk-ui-framework/react'; +import ng from 'core/services/ng'; +import {gettext} from 'core/utils'; +import {showModal} from 'core/services/modalService'; + +const modalHeader = ( + + {gettext('Instance configuration is missing!')} + +); + +export function maybeDisplayInvalidInstanceConfigurationMessage() { + const issues: Array = []; + + ng.get('vocabularies').getAllActiveVocabularies().then((vocabularies) => { + const categoriesMissing = vocabularies.find(({_id}) => _id === 'categories') != null; + + if (categoriesMissing) { + issues.push( + ( + <> +

{gettext('Vocabulary with ID "categories" is required.')}

+

{gettext('Add it via Settings > Metadata')}

+ + ), + ); + } + + if (issues.length > 0) { + showModal(({closeModal}) => ( + + {issues[0]} + + )); + } + }); +}