mirror of
https://github.com/logto-io/logto.git
synced 2025-01-27 21:39:16 -05:00
test: integration test for setting up a social connector (#1628)
test: integration tests for setting up a social connector
This commit is contained in:
parent
49d6ee1c76
commit
e54c7f74f2
2 changed files with 53 additions and 4 deletions
|
@ -3,3 +3,22 @@ import { ConnectorDto } from '@logto/schemas';
|
|||
import { authedAdminApi } from '@/api';
|
||||
|
||||
export const listConnectors = async () => authedAdminApi.get('connectors').json<ConnectorDto[]>();
|
||||
|
||||
export const getConnector = async (connectorId: string) =>
|
||||
authedAdminApi.get(`connectors/${connectorId}`).json<ConnectorDto>();
|
||||
|
||||
export const updateConnectorConfig = async (connectorId: string, config: Record<string, unknown>) =>
|
||||
authedAdminApi
|
||||
.patch({
|
||||
url: `connectors/${connectorId}`,
|
||||
json: { config },
|
||||
})
|
||||
.json<ConnectorDto>();
|
||||
|
||||
export const enableConnector = async (connectorId: string) =>
|
||||
authedAdminApi
|
||||
.patch({
|
||||
url: `connectors/${connectorId}/enabled`,
|
||||
json: { enabled: true },
|
||||
})
|
||||
.json<ConnectorDto>();
|
||||
|
|
|
@ -1,13 +1,43 @@
|
|||
import { listConnectors } from '@/connector-api';
|
||||
import {
|
||||
enableConnector,
|
||||
getConnector,
|
||||
listConnectors,
|
||||
updateConnectorConfig,
|
||||
} from '@/connector-api';
|
||||
|
||||
const facebookConnectorId = 'facebook-universal';
|
||||
const facebookConnectorConfig = {
|
||||
clientId: 'application_foo',
|
||||
clientSecret: 'secret_bar',
|
||||
};
|
||||
|
||||
test('connector flow', async () => {
|
||||
// List connectors after initializing a new Logto instance
|
||||
const connectorDtos = await listConnectors();
|
||||
const allConnectors = await listConnectors();
|
||||
|
||||
// There should be no connectors, or all connectors should be disabled.
|
||||
for (const connectorDto of connectorDtos) {
|
||||
for (const connectorDto of allConnectors) {
|
||||
expect(connectorDto.enabled).toBeFalsy();
|
||||
}
|
||||
|
||||
// Next up: set up a social connector
|
||||
// Set up a social connector
|
||||
const updatedFacebookConnector = await updateConnectorConfig(
|
||||
facebookConnectorId,
|
||||
facebookConnectorConfig
|
||||
);
|
||||
expect(updatedFacebookConnector.config).toEqual(facebookConnectorConfig);
|
||||
const enabledFacebookConnector = await enableConnector(facebookConnectorId);
|
||||
expect(enabledFacebookConnector.enabled).toBeTruthy();
|
||||
|
||||
// The result of getting a connector should be same as the result of updating a connector above.
|
||||
const facebookConnector = await getConnector(facebookConnectorId);
|
||||
expect(facebookConnector.enabled).toBeTruthy();
|
||||
expect(facebookConnector.config).toEqual(facebookConnectorConfig);
|
||||
|
||||
// Next up:
|
||||
// - set up an SMS connector and then change to another SMS connector
|
||||
// - set up an email connector and then change to another email connector
|
||||
// - validate wrong connector config
|
||||
// - send sms/email test message
|
||||
// - list all connectors after manually setting up connectors
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue