From f325797541f3c5090c9ebdf868db7f3282869488 Mon Sep 17 00:00:00 2001 From: Aleksei Potsetsuev Date: Tue, 9 Apr 2024 17:48:43 +0800 Subject: [PATCH] fix: deprecated settings tests --- .../expectDeprecatedSettingMessage.ts | 4 ++-- .../src/createSettingsAliasResolver.test.ts | 11 +++++++++-- .../core-settings/src/createSettingsAliasResolver.ts | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/webapp/packages/core-settings/src/__custom_mocks__/expectDeprecatedSettingMessage.ts b/webapp/packages/core-settings/src/__custom_mocks__/expectDeprecatedSettingMessage.ts index 0ae2cf2a0b..d9e937d7bd 100644 --- a/webapp/packages/core-settings/src/__custom_mocks__/expectDeprecatedSettingMessage.ts +++ b/webapp/packages/core-settings/src/__custom_mocks__/expectDeprecatedSettingMessage.ts @@ -7,7 +7,7 @@ */ import { addKnownWarn, consoleSpy } from '@cloudbeaver/tests-runner'; -const DEPRECATED_SETTING_MESSAGE_REGEX = /You are using deprecated settings.*/; +const DEPRECATED_SETTING_MESSAGE_REGEX = /You have deprecated settings:*/; beforeAll(async () => { addKnownWarn(DEPRECATED_SETTING_MESSAGE_REGEX); @@ -15,7 +15,7 @@ beforeAll(async () => { export function expectDeprecatedSettingMessage(deprecated?: string, key?: string) { if (deprecated && key) { - expect(consoleSpy.warn).toHaveBeenCalledWith(expect.stringMatching(`You are using deprecated settings: "${deprecated}". Use "${key}" instead.`)); + expect(consoleSpy.warn).toHaveBeenCalledWith(expect.stringMatching(`You have deprecated settings: "${deprecated}". Use "${key}" instead.`)); } else { expect(consoleSpy.warn).toHaveBeenCalledWith(expect.stringMatching(DEPRECATED_SETTING_MESSAGE_REGEX)); } diff --git a/webapp/packages/core-settings/src/createSettingsAliasResolver.test.ts b/webapp/packages/core-settings/src/createSettingsAliasResolver.test.ts index ff9a4d21c7..746996751d 100644 --- a/webapp/packages/core-settings/src/createSettingsAliasResolver.test.ts +++ b/webapp/packages/core-settings/src/createSettingsAliasResolver.test.ts @@ -9,7 +9,7 @@ import '@testing-library/jest-dom'; import { SyncExecutor } from '@cloudbeaver/core-executor'; -import { expectDeprecatedSettingMessage } from './__custom_mocks__/expectDeprecatedSettingMessage'; +import { expectDeprecatedSettingMessage, expectNoDeprecatedSettingMessage } from './__custom_mocks__/expectDeprecatedSettingMessage'; import { createSettingsAliasResolver } from './createSettingsAliasResolver'; import type { ISettingsSource } from './ISettingsSource'; @@ -52,9 +52,16 @@ function createResolver(settings: Record) { }); } -test('Deprecated setting extracted', async () => { +test('Deprecated setting ignored', async () => { const resolver = createResolver(newSettings); + expect(resolver.has('value')).toBe(false); + expectNoDeprecatedSettingMessage(); +}); + +test('Deprecated setting extracted', async () => { + const resolver = createResolver(deprecatedSettings); + expect(resolver.has('value')).toBe(true); expect(resolver.getValue('value')).toBe('deprecatedValue'); expectDeprecatedSettingMessage('deprecated', 'value'); diff --git a/webapp/packages/core-settings/src/createSettingsAliasResolver.ts b/webapp/packages/core-settings/src/createSettingsAliasResolver.ts index fcd10580ac..a032f6703f 100644 --- a/webapp/packages/core-settings/src/createSettingsAliasResolver.ts +++ b/webapp/packages/core-settings/src/createSettingsAliasResolver.ts @@ -69,7 +69,7 @@ export function createSettingsAliasResolver