From 2fab1f1b7af9ae78aef90e7e066cdeb5076da946 Mon Sep 17 00:00:00 2001 From: pkupczyk <piotr.kupczyk@id.ethz.ch> Date: Fri, 23 Dec 2022 10:54:34 +0100 Subject: [PATCH] SSDM-13273 : Admin UI - remember the sizes of side panels between reloads - fix tests --- openbis_ng_ui/src/js/components/AppController.js | 4 ++-- openbis_ng_ui/srcTest/js/common/fixture.js | 12 ++++++++++++ .../srcTest/js/components/AppController.test.js | 13 +++++++++++++ openbis_ng_ui/srcTest/js/services/openbis/api.js | 4 ++++ openbis_ng_ui/srcTest/js/services/openbis/dto.js | 6 +++++- 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/openbis_ng_ui/src/js/components/AppController.js b/openbis_ng_ui/src/js/components/AppController.js index b6627c8a575..0c9546bf935 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 7d198067bc4..795d9341de0 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 f910b9b8ee2..5373aa3a0cc 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 232ae5543ec..dda65c413a0 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 94a1fc558f8..889ec315920 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 -- GitLab