Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Adapters: copy the 'type' passed in the adapter config to fully support adapter schemas #6697

Merged
merged 13 commits into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ const mockSchemas = {
description: 'Route',
default: 'mockRoute',
},
type: {
type: 'string',
title: 'Type',
description: 'Fully qualified type for the adapter',
default: 'Adapter.Full.Type.Mock',
},
},
},
},
Expand All @@ -47,6 +53,7 @@ const mockSchemas = {
subtitle: 'Connect to Fake Chat Client',
helpLink: 'https://example.com/',
order: ['route', 'exampleName'],
hidden: ['type'],
},
},
},
Expand Down Expand Up @@ -129,20 +136,29 @@ describe('ExternalAdapterSettings', () => {
name: 'Adapter.Mock',
route: 'mockRoute',
enabled: true,
type: 'Adapter.Full.Type.Mock',
},
],
},
'Adapter.Mock': { exampleName: 'test text 12345', route: 'mockRoute', $kind: 'Adapter.Mock' },
'Adapter.Mock': {
exampleName: 'test text 12345',
route: 'mockRoute',
$kind: 'Adapter.Mock',
type: 'Adapter.Full.Type.Mock',
},
});
});

it('disables an adapter', async () => {
const initStateWithAdapter = {
runtimeSettings: { adapters: [{ name: 'Adapter.Mock', enabled: true, route: 'mock' }] },
runtimeSettings: {
adapters: [{ name: 'Adapter.Mock', enabled: true, route: 'mock', type: 'Adapter.Full.Type.Mock' }],
},
'Adapter.Mock': {
exampleName: 'example',
route: 'mock',
$kind: 'Adapter.Mock',
type: 'Adapter.Full.Type.Mock',
},
};

Expand All @@ -161,17 +177,22 @@ describe('ExternalAdapterSettings', () => {
expect(setSettingsMock).toHaveBeenLastCalledWith(
PROJECT_ID,
expect.objectContaining({
runtimeSettings: { adapters: [{ name: 'Adapter.Mock', enabled: false, route: 'mock' }] },
runtimeSettings: {
adapters: [{ name: 'Adapter.Mock', enabled: false, route: 'mock', type: 'Adapter.Full.Type.Mock' }],
},
})
);
});

it('enables an adapter', async () => {
const initStateWithAdapter = {
runtimeSettings: { adapters: [{ name: 'Adapter.Mock', enabled: false, route: 'mock' }] },
runtimeSettings: {
adapters: [{ name: 'Adapter.Mock', enabled: false, route: 'mock', type: 'Adapter.Full.Type.Mock' }],
},
'Adapter.Mock': {
exampleName: 'example',
route: 'mock',
type: 'Adapter.Full.Type.Mock',
},
};

Expand All @@ -190,7 +211,9 @@ describe('ExternalAdapterSettings', () => {
expect(setSettingsMock).toHaveBeenLastCalledWith(
PROJECT_ID,
expect.objectContaining({
runtimeSettings: { adapters: [{ name: 'Adapter.Mock', enabled: true, route: 'mock' }] },
runtimeSettings: {
adapters: [{ name: 'Adapter.Mock', enabled: true, route: 'mock', type: 'Adapter.Full.Type.Mock' }],
},
})
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const AdapterModal = (props: Props) => {
...currentSettings.runtimeSettings,
adapters: [
...currentAdapters.filter((a) => a.name != adapterKey),
{ name: adapterKey, enabled: true, route: value.route },
{ name: adapterKey, enabled: true, route: value.route, type: value.type ?? adapterKey },
],
},
});
Expand Down