0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-23 20:33:16 -05:00
logto/packages/integration-tests/tests/connectors.test.ts
IceHe.life e54c7f74f2
test: integration test for setting up a social connector (#1628)
test: integration tests for setting up a social connector
2022-07-21 14:54:11 +08:00

43 lines
1.5 KiB
TypeScript

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 allConnectors = await listConnectors();
// There should be no connectors, or all connectors should be disabled.
for (const connectorDto of allConnectors) {
expect(connectorDto.enabled).toBeFalsy();
}
// 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
});