Skip to content

Commit

Permalink
Revert "Add basic support for experimental theme switching (elastic#1…
Browse files Browse the repository at this point in the history
…99748)"

This reverts commit 5b77b7e.
  • Loading branch information
tsullivan committed Nov 21, 2024
1 parent 56c00b9 commit f0e3c1e
Show file tree
Hide file tree
Showing 80 changed files with 289 additions and 597 deletions.
35 changes: 0 additions & 35 deletions packages/core/base/core-base-common/BUILD.bazel

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const createSetupContractMock = () => {
setupContract.getPlugins.mockReturnValue([]);
setupContract.getTheme.mockReturnValue({
darkMode: false,
name: 'amsterdam',
version: 'v8',
stylesheetPaths: {
default: ['light-1.css'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export interface InjectedMetadataExternalUrlPolicy {
/** @internal */
export interface InjectedMetadataTheme {
darkMode: DarkModeValue;
name: string;
version: ThemeVersion;
stylesheetPaths: {
default: string[];
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,6 @@ const createPackageInfo = (parts: Partial<PackageInfo> = {}): PackageInfo => ({
...parts,
});

const getClientGetMockImplementation =
({ darkMode, name }: { darkMode?: boolean; name?: string } = {}) =>
(key: string) => {
switch (key) {
case 'theme:darkMode':
return Promise.resolve(darkMode ?? false);
case 'theme:name':
return Promise.resolve(name ?? 'amsterdam');
}
return Promise.resolve();
};

const createUiPlugins = (): UiPlugins => ({
public: new Map(),
internal: new Map(),
Expand All @@ -71,7 +59,6 @@ describe('bootstrapRenderer', () => {
getPluginsBundlePathsMock.mockReturnValue(new Map());
renderTemplateMock.mockReturnValue('__rendered__');
getJsDependencyPathsMock.mockReturnValue([]);
uiSettingsClient.get.mockImplementation(getClientGetMockImplementation());

renderer = bootstrapRendererFactory({
auth,
Expand Down Expand Up @@ -104,17 +91,13 @@ describe('bootstrapRenderer', () => {
uiSettingsClient,
});

expect(uiSettingsClient.get).toHaveBeenCalledTimes(2);
expect(uiSettingsClient.get).toHaveBeenCalledTimes(1);
expect(uiSettingsClient.get).toHaveBeenCalledWith('theme:darkMode');
expect(uiSettingsClient.get).toHaveBeenCalledWith('theme:name');
});

it('calls getThemeTag with the values from the UiSettingsClient (true/dark) when the UserSettingsService is not provided', async () => {
uiSettingsClient.get.mockImplementation(
getClientGetMockImplementation({
darkMode: true,
})
);
uiSettingsClient.get.mockResolvedValue(true);

const request = httpServerMock.createKibanaRequest();

await renderer({
Expand All @@ -124,13 +107,13 @@ describe('bootstrapRenderer', () => {

expect(getThemeTagMock).toHaveBeenCalledTimes(1);
expect(getThemeTagMock).toHaveBeenCalledWith({
name: 'v8',
themeVersion: 'v8',
darkMode: true,
});
});

it('calls getThemeTag with the values from the UiSettingsClient (false/light) when the UserSettingsService is not provided', async () => {
uiSettingsClient.get.mockImplementation(getClientGetMockImplementation({}));
uiSettingsClient.get.mockResolvedValue(false);

const request = httpServerMock.createKibanaRequest();

Expand All @@ -141,7 +124,7 @@ describe('bootstrapRenderer', () => {

expect(getThemeTagMock).toHaveBeenCalledTimes(1);
expect(getThemeTagMock).toHaveBeenCalledWith({
name: 'v8',
themeVersion: 'v8',
darkMode: false,
});
});
Expand All @@ -167,7 +150,7 @@ describe('bootstrapRenderer', () => {

expect(getThemeTagMock).toHaveBeenCalledTimes(1);
expect(getThemeTagMock).toHaveBeenCalledWith({
name: 'v8',
themeVersion: 'v8',
darkMode: true,
});
});
Expand All @@ -183,6 +166,7 @@ describe('bootstrapRenderer', () => {
userSettingsService,
});

uiSettingsClient.get.mockResolvedValue(true);
const request = httpServerMock.createKibanaRequest();

await renderer({
Expand All @@ -192,7 +176,7 @@ describe('bootstrapRenderer', () => {

expect(getThemeTagMock).toHaveBeenCalledTimes(1);
expect(getThemeTagMock).toHaveBeenCalledWith({
name: 'v8',
themeVersion: 'v8',
darkMode: false,
});
});
Expand All @@ -208,6 +192,7 @@ describe('bootstrapRenderer', () => {
userSettingsService,
});

uiSettingsClient.get.mockResolvedValue(false);
const request = httpServerMock.createKibanaRequest();

await renderer({
Expand All @@ -217,7 +202,7 @@ describe('bootstrapRenderer', () => {

expect(getThemeTagMock).toHaveBeenCalledTimes(1);
expect(getThemeTagMock).toHaveBeenCalledWith({
name: 'v8',
themeVersion: 'v8',
darkMode: false,
});
});
Expand All @@ -233,11 +218,7 @@ describe('bootstrapRenderer', () => {
userSettingsService,
});

uiSettingsClient.get.mockImplementation(
getClientGetMockImplementation({
darkMode: true,
})
);
uiSettingsClient.get.mockResolvedValue(true);
const request = httpServerMock.createKibanaRequest();

await renderer({
Expand All @@ -247,7 +228,7 @@ describe('bootstrapRenderer', () => {

expect(getThemeTagMock).toHaveBeenCalledTimes(1);
expect(getThemeTagMock).toHaveBeenCalledWith({
name: 'v8',
themeVersion: 'v8',
darkMode: true,
});
});
Expand All @@ -269,17 +250,12 @@ describe('bootstrapRenderer', () => {
uiSettingsClient,
});

expect(uiSettingsClient.get).toHaveBeenCalledTimes(2);
expect(uiSettingsClient.get).toHaveBeenCalledTimes(1);
expect(uiSettingsClient.get).toHaveBeenCalledWith('theme:darkMode');
expect(uiSettingsClient.get).toHaveBeenCalledWith('theme:name');
});

it('calls getThemeTag with the correct parameters', async () => {
uiSettingsClient.get.mockImplementation(
getClientGetMockImplementation({
darkMode: true,
})
);
uiSettingsClient.get.mockResolvedValue(true);

const request = httpServerMock.createKibanaRequest();

Expand All @@ -290,7 +266,7 @@ describe('bootstrapRenderer', () => {

expect(getThemeTagMock).toHaveBeenCalledTimes(1);
expect(getThemeTagMock).toHaveBeenCalledWith({
name: 'v8',
themeVersion: 'v8',
darkMode: true,
});
});
Expand All @@ -307,7 +283,7 @@ describe('bootstrapRenderer', () => {

expect(getThemeTagMock).toHaveBeenCalledTimes(1);
expect(getThemeTagMock).toHaveBeenCalledWith({
name: 'system',
themeVersion: 'v8',
darkMode: false,
});
});
Expand Down Expand Up @@ -342,7 +318,7 @@ describe('bootstrapRenderer', () => {

expect(getThemeTagMock).toHaveBeenCalledTimes(1);
expect(getThemeTagMock).toHaveBeenCalledWith({
name: 'v8',
themeVersion: 'v8',
darkMode: false,
});
});
Expand Down
Loading

0 comments on commit f0e3c1e

Please sign in to comment.