diff --git a/plugins/user-settings/alpha-api-report.md b/plugins/user-settings/alpha-api-report.md index 925d387882..673763745f 100644 --- a/plugins/user-settings/alpha-api-report.md +++ b/plugins/user-settings/alpha-api-report.md @@ -6,21 +6,24 @@ import { TranslationRef } from '@backstage/core-plugin-api/alpha'; // @alpha (undocumented) -export const userSettingsTranslationRef: TranslationRef<{ - language: string; - change_the_language: string; - theme: string; - theme_light: string; - theme_dark: string; - theme_auto: string; - change_the_theme_mode: string; - select_theme_light: string; - select_theme_dark: string; - select_theme_auto: string; - select_theme_custom: string; - lng: string; - select_lng: string; -}>; +export const userSettingsTranslationRef: TranslationRef< + { + readonly language: 'Language'; + readonly change_the_language: 'Change the language'; + readonly theme: 'Theme'; + readonly theme_light: 'Light'; + readonly theme_dark: 'Dark'; + readonly theme_auto: 'Auto'; + readonly change_the_theme_mode: 'Change the theme mode'; + readonly select_theme_light: 'Select light'; + readonly select_theme_dark: 'Select dark'; + readonly select_theme_auto: 'Select Auto Theme'; + readonly select_theme_custom: 'Select {{custom}}'; + readonly lng: '{{language}}'; + readonly select_lng: 'Select language {{language}}'; + }, + 'user-settings' +>; // (No @packageDocumentation comment for this package) ``` diff --git a/plugins/user-settings/src/components/General/UserSettingsThemeToggle.test.tsx b/plugins/user-settings/src/components/General/UserSettingsThemeToggle.test.tsx index 48d16a9fde..0e07fa8c59 100644 --- a/plugins/user-settings/src/components/General/UserSettingsThemeToggle.test.tsx +++ b/plugins/user-settings/src/components/General/UserSettingsThemeToggle.test.tsx @@ -15,7 +15,6 @@ */ import { AppTheme, appThemeApiRef } from '@backstage/core-plugin-api'; -import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; import { renderWithEffects, TestApiRegistry, @@ -28,7 +27,6 @@ import { fireEvent } from '@testing-library/react'; import React from 'react'; import { UserSettingsThemeToggle } from './UserSettingsThemeToggle'; import { ApiProvider, AppThemeSelector } from '@backstage/core-app-api'; -import { userSettingsTranslationRef } from '../../translation'; const mockTheme: AppTheme = { id: 'light-theme', @@ -41,11 +39,6 @@ const mockTheme: AppTheme = { ), }; -jest.mock('@backstage/core-plugin-api/alpha', () => ({ - ...jest.requireActual('@backstage/core-plugin-api/alpha'), - useTranslationRef: jest.fn(), -})); - const apiRegistry = TestApiRegistry.from([ appThemeApiRef, AppThemeSelector.createWithStorage([mockTheme]), @@ -54,15 +47,6 @@ const apiRegistry = TestApiRegistry.from([ describe('', () => { it('toggles the theme select button', async () => { const themeApi = apiRegistry.get(appThemeApiRef); - // todo: general test provider - const messages: Record = - userSettingsTranslationRef.getDefaultMessages(); - - const useTranslationRefMock = jest - .fn() - .mockReturnValue((key: string) => messages[key]); - - (useTranslationRef as jest.Mock).mockImplementation(useTranslationRefMock); const rendered = await renderWithEffects( wrapInTestApp( diff --git a/plugins/user-settings/src/translation.ts b/plugins/user-settings/src/translation.ts index 920f499082..ffe4174d99 100644 --- a/plugins/user-settings/src/translation.ts +++ b/plugins/user-settings/src/translation.ts @@ -33,5 +33,5 @@ export const userSettingsTranslationRef = createTranslationRef({ select_theme_custom: 'Select {{custom}}', lng: '{{language}}', select_lng: 'Select language {{language}}', - }, + } as const, });