diff --git a/openbis_ng_ui/src/js/components/AppController.js b/openbis_ng_ui/src/js/components/AppController.js index b6627c8a5758fcaf5d1e1509588f90799ecd0aa6..0c9546bf9356569e8bce50292672bf703b2c4c5b 100644 --- a/openbis_ng_ui/src/js/components/AppController.js +++ b/openbis_ng_ui/src/js/components/AppController.js @@ -473,7 +473,7 @@ export class AppController { } } - async getSetting(settingId) { + getSetting(settingId) { const { settings } = this.context.getState() return settings[settingId] } @@ -486,7 +486,7 @@ export class AppController { [settingId]: settingObject } - this.context.setState({ settings: newSettings }) + await this.context.setState({ settings: newSettings }) await this._saveSettings(settingId, settingObject) } diff --git a/openbis_ng_ui/srcTest/js/common/fixture.js b/openbis_ng_ui/srcTest/js/common/fixture.js index 7d198067bc40b6db83db8236afbdcff9512cf8c1..795d9341de03326c7a57cf9dd9de748e151fe650 100644 --- a/openbis_ng_ui/srcTest/js/common/fixture.js +++ b/openbis_ng_ui/srcTest/js/common/fixture.js @@ -1,4 +1,5 @@ import openbis from '@srcTest/js/services/openbis.js' +import ids from '@src/js/common/consts/ids.js' const TEST_USER = 'test-user' const TEST_PASSWORD = 'test-password' @@ -7,10 +8,21 @@ const TEST_SESSION_TOKEN = 'test-session-token' const SYSTEM_USER_DTO = new openbis.Person() SYSTEM_USER_DTO.setUserId('system') +const WEB_APP_SETTINGS_DTO = new openbis.WebAppSettings() +WEB_APP_SETTINGS_DTO.setSettings({ + 'test-name': new openbis.WebAppSetting( + 'test-name', + '{ "test-key" : "test-value" }' + ) +}) + const TEST_USER_DTO = new openbis.Person() TEST_USER_DTO.setUserId('test-user') TEST_USER_DTO.setFirstName('test-first-name') TEST_USER_DTO.setLastName('test-last-name') +TEST_USER_DTO.setWebAppSettings({ + [ids.WEB_APP_ID]: WEB_APP_SETTINGS_DTO +}) const ANOTHER_USER_DTO = new openbis.Person() ANOTHER_USER_DTO.setUserId('another-user') diff --git a/openbis_ng_ui/srcTest/js/components/AppController.test.js b/openbis_ng_ui/srcTest/js/components/AppController.test.js index f910b9b8ee2bf27ddad7fe03e56f30a4b3516f44..5373aa3a0cc5b122b5ce9c8fbfbd1c8866094bad 100644 --- a/openbis_ng_ui/srcTest/js/components/AppController.test.js +++ b/openbis_ng_ui/srcTest/js/components/AppController.test.js @@ -17,6 +17,15 @@ beforeEach(() => { describe(SUITE, () => { test('login successful', async () => { openbis.login.mockReturnValue(fixture.TEST_SESSION_TOKEN) + openbis.getServerInformation.mockReturnValue({ + test: 'abc' + }) + openbis.getSessionInformation.mockReturnValue({ + userName: fixture.TEST_USER_DTO.getUserId() + }) + openbis.getPersons.mockReturnValue({ + [new openbis.Me()]: fixture.TEST_USER_DTO + }) await controller.login(fixture.TEST_USER, fixture.TEST_PASSWORD) @@ -24,6 +33,10 @@ describe(SUITE, () => { sessionToken: fixture.TEST_SESSION_TOKEN, userName: fixture.TEST_USER }) + expect(controller.getServerInformation('test')).toEqual('abc') + expect(await controller.getSetting('test-name')).toEqual({ + 'test-key': 'test-value' + }) expect(controller.getCurrentPage()).toEqual(pages.TYPES) }) diff --git a/openbis_ng_ui/srcTest/js/services/openbis/api.js b/openbis_ng_ui/srcTest/js/services/openbis/api.js index 232ae5543ec708d9a853c6450f9bf01f991be38b..dda65c413a056ae37f181ce60c0ad9ce07b6243f 100644 --- a/openbis_ng_ui/srcTest/js/services/openbis/api.js +++ b/openbis_ng_ui/srcTest/js/services/openbis/api.js @@ -18,7 +18,9 @@ const getMaterialTypes = jest.fn() const getPersons = jest.fn() const getPropertyTypes = jest.fn() const getSampleTypes = jest.fn() +const getServerInformation = jest.fn() const getServerPublicInformation = jest.fn() +const getSessionInformation = jest.fn() const getVocabularies = jest.fn() const getPlugins = jest.fn() const getQueries = jest.fn() @@ -186,7 +188,9 @@ export default { getPersons, getPropertyTypes, getSampleTypes, + getServerInformation, getServerPublicInformation, + getSessionInformation, getVocabularies, getPlugins, getQueries, diff --git a/openbis_ng_ui/srcTest/js/services/openbis/dto.js b/openbis_ng_ui/srcTest/js/services/openbis/dto.js index 94a1fc558f811bb6e2d1f85503fefc1a3ca92b0d..889ec315920abacdbb92bc567344fed57bde58b3 100644 --- a/openbis_ng_ui/srcTest/js/services/openbis/dto.js +++ b/openbis_ng_ui/srcTest/js/services/openbis/dto.js @@ -171,6 +171,8 @@ import VocabularyTermSearchCriteria from 'as/dto/vocabulary/search/VocabularyTer import VocabularyTermUpdate from 'as/dto/vocabulary/update/VocabularyTermUpdate' import VocabularyUpdate from 'as/dto/vocabulary/update/VocabularyUpdate' import WebAppSettingCreation from 'as/dto/webapp/create/WebAppSettingCreation' +import WebAppSettings from 'as/dto/webapp/WebAppSettings' +import WebAppSetting from 'as/dto/webapp/WebAppSetting' const dto = { AuthorizationGroup, AuthorizationGroupCreation, @@ -344,7 +346,9 @@ const dto = { VocabularyTermSearchCriteria, VocabularyTermUpdate, VocabularyUpdate, - WebAppSettingCreation + WebAppSettingCreation, + WebAppSettings, + WebAppSetting } export default dto