Merge branch 'master' into mobile-sidebar
Signed-off-by: Philipp Hugenroth <philipph@spotify.com>
This commit is contained in:
+10
-8
@@ -14,22 +14,24 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { renderWithEffects, wrapInTestApp } from '@backstage/test-utils';
|
||||
import {
|
||||
renderWithEffects,
|
||||
TestApiRegistry,
|
||||
wrapInTestApp,
|
||||
} from '@backstage/test-utils';
|
||||
import { fireEvent } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import { UserSettingsAuthProviders } from './UserSettingsAuthProviders';
|
||||
|
||||
import {
|
||||
ApiProvider,
|
||||
ApiRegistry,
|
||||
ConfigReader,
|
||||
} from '@backstage/core-app-api';
|
||||
import { ApiProvider, ConfigReader } from '@backstage/core-app-api';
|
||||
import { configApiRef, googleAuthApiRef } from '@backstage/core-plugin-api';
|
||||
|
||||
const mockSignInHandler = jest.fn().mockReturnValue('');
|
||||
const mockGoogleAuth = {
|
||||
sessionState$: () => ({
|
||||
[Symbol.observable]: jest.fn(),
|
||||
subscribe: () => ({
|
||||
closed: false,
|
||||
unsubscribe: () => null,
|
||||
}),
|
||||
}),
|
||||
@@ -47,10 +49,10 @@ const createConfig = () =>
|
||||
|
||||
const config = createConfig();
|
||||
|
||||
const apiRegistry = ApiRegistry.from([
|
||||
const apiRegistry = TestApiRegistry.from(
|
||||
[configApiRef, config],
|
||||
[googleAuthApiRef, mockGoogleAuth],
|
||||
]);
|
||||
);
|
||||
|
||||
describe('<UserSettingsAuthProviders />', () => {
|
||||
it('displays a provider and calls its sign-in handler on click', async () => {
|
||||
|
||||
@@ -15,16 +15,16 @@
|
||||
*/
|
||||
|
||||
import { AppTheme, appThemeApiRef } from '@backstage/core-plugin-api';
|
||||
import { renderWithEffects, wrapInTestApp } from '@backstage/test-utils';
|
||||
import {
|
||||
renderWithEffects,
|
||||
TestApiRegistry,
|
||||
wrapInTestApp,
|
||||
} from '@backstage/test-utils';
|
||||
import { lightTheme } from '@backstage/theme';
|
||||
import { fireEvent } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import { UserSettingsThemeToggle } from './UserSettingsThemeToggle';
|
||||
import {
|
||||
ApiProvider,
|
||||
ApiRegistry,
|
||||
AppThemeSelector,
|
||||
} from '@backstage/core-app-api';
|
||||
import { ApiProvider, AppThemeSelector } from '@backstage/core-app-api';
|
||||
|
||||
const mockTheme: AppTheme = {
|
||||
id: 'light-theme',
|
||||
@@ -33,8 +33,9 @@ const mockTheme: AppTheme = {
|
||||
theme: lightTheme,
|
||||
};
|
||||
|
||||
const apiRegistry = ApiRegistry.from([
|
||||
[appThemeApiRef, AppThemeSelector.createWithStorage([mockTheme])],
|
||||
const apiRegistry = TestApiRegistry.from([
|
||||
appThemeApiRef,
|
||||
AppThemeSelector.createWithStorage([mockTheme]),
|
||||
]);
|
||||
|
||||
describe('<UserSettingsThemeToggle />', () => {
|
||||
|
||||
@@ -131,7 +131,7 @@ export const UserSettingsThemeToggle = () => {
|
||||
value={theme.id}
|
||||
>
|
||||
<>
|
||||
{theme.variant}
|
||||
{theme.title}
|
||||
<ThemeIcon
|
||||
id={theme.id}
|
||||
icon={themeIcon}
|
||||
|
||||
@@ -18,14 +18,14 @@ import React from 'react';
|
||||
import SettingsIcon from '@material-ui/icons/Settings';
|
||||
import { settingsRouteRef } from '../plugin';
|
||||
import { SidebarItem } from '@backstage/core-components';
|
||||
import { IconComponent } from '@backstage/core-plugin-api';
|
||||
import { useRouteRef, IconComponent } from '@backstage/core-plugin-api';
|
||||
|
||||
type SettingsProps = {
|
||||
icon?: IconComponent;
|
||||
};
|
||||
|
||||
export const Settings = (props: SettingsProps) => {
|
||||
const routePath = useRouteRef(settingsRouteRef);
|
||||
const Icon = props.icon ? props.icon : SettingsIcon;
|
||||
|
||||
return <SidebarItem text="Settings" to={settingsRouteRef.path} icon={Icon} />;
|
||||
return <SidebarItem text="Settings" to={routePath()} icon={Icon} />;
|
||||
};
|
||||
|
||||
@@ -21,8 +21,7 @@ import {
|
||||
} from '@backstage/core-plugin-api';
|
||||
|
||||
export const settingsRouteRef = createRouteRef({
|
||||
path: '/settings',
|
||||
title: 'Settings',
|
||||
id: 'user-settings',
|
||||
});
|
||||
|
||||
export const userSettingsPlugin = createPlugin({
|
||||
|
||||
Reference in New Issue
Block a user