0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-20 21:32:31 -05:00

refactor(test): replace facebook connector with mock social connector (#1714)

* refactor(test): replace facebook connector with mock social connector in connector set-up flow test

* refactor(test): replace facebook connector with mock social connector in SIE tests
This commit is contained in:
IceHe.Life 2022-08-02 09:44:35 +08:00 committed by GitHub
parent 1e568e02c9
commit 7579abaea4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 23 deletions

View file

@ -1,10 +1,3 @@
export const facebookConnectorId = 'facebook-universal';
export const facebookConnectorTarget = 'facebook';
export const facebookConnectorConfig = {
clientId: 'application_foo',
clientSecret: 'secret_bar',
};
export const aliyunSmsConnectorId = 'aliyun-short-message-service';
export const aliyunSmsConnectorConfig = {
accessKeyId: 'access-key-id-value',
@ -146,3 +139,10 @@ export const mockEmailConnectorConfig = {
},
],
};
export const mockSocialConnectorId = 'mock-social-connector';
export const mockSocialConnectorTarget = 'mock-social';
export const mockSocialConnectorConfig = {
clientId: 'client_id_value',
clientSecret: 'client_secret_value',
};

View file

@ -6,12 +6,12 @@ import {
aliyunEmailConnectorId,
aliyunSmsConnectorConfig,
aliyunSmsConnectorId,
facebookConnectorConfig,
facebookConnectorId,
mockEmailConnectorConfig,
mockEmailConnectorId,
mockSmsConnectorConfig,
mockSmsConnectorId,
mockSocialConnectorConfig,
mockSocialConnectorId,
} from '@/__mocks__/connectors-mock';
import {
disableConnector,
@ -34,9 +34,9 @@ test('connector set-up flow', async () => {
*/
await Promise.all(
[
{ id: facebookConnectorId, config: facebookConnectorConfig },
{ id: aliyunSmsConnectorId, config: aliyunSmsConnectorConfig },
{ id: aliyunEmailConnectorId, config: aliyunEmailConnectorConfig },
{ id: mockSocialConnectorId, config: mockSocialConnectorConfig },
].map(async ({ id, config }) => {
const updatedConnector = await updateConnectorConfig(id, config);
expect(updatedConnector.config).toEqual(config);
@ -55,12 +55,12 @@ test('connector set-up flow', async () => {
* We will test updating to the invalid connector config, that is the case not covered above.
*/
await expect(
updateConnectorConfig(facebookConnectorId, aliyunSmsConnectorConfig)
updateConnectorConfig(mockSocialConnectorId, aliyunSmsConnectorConfig)
).rejects.toThrow(HTTPError);
// To confirm the failed updating request above did not modify the original config,
// we check: the Facebook connector config should stay the same.
const facebookConnector = await getConnector(facebookConnectorId);
expect(facebookConnector.config).toEqual(facebookConnectorConfig);
// we check: the mock connector config should stay the same.
const mockSocialConnector = await getConnector(mockSocialConnectorId);
expect(mockSocialConnector.config).toEqual(mockSocialConnectorConfig);
/*
* Change to another SMS/Email connector
@ -103,8 +103,8 @@ test('connector set-up flow', async () => {
expect(await listConnectors()).toEqual(
expect.arrayContaining([
expect.objectContaining({
id: facebookConnectorId,
config: facebookConnectorConfig,
id: mockSocialConnectorId,
config: mockSocialConnectorConfig,
enabled: true,
}),
expect.objectContaining({

View file

@ -1,13 +1,13 @@
import { BrandingStyle, SignInMethodState } from '@logto/schemas';
import {
facebookConnectorId,
facebookConnectorConfig,
mockSocialConnectorConfig,
mockSocialConnectorId,
mockSocialConnectorTarget,
twilioSmsConnectorConfig,
twilioSmsConnectorId,
sendgridEmailConnectorConfig,
sendgridEmailConnectorId,
facebookConnectorTarget,
} from '@/__mocks__/connectors-mock';
import { getSignInExperience, updateSignInExperience } from '@/api';
import { updateConnectorConfig, enableConnector, disableConnector } from '@/api/connector';
@ -45,8 +45,8 @@ describe('admin console sign-in experience', () => {
it('should be able to setup sign in methods after connectors are enabled', async () => {
// Setup connectors for tests
await Promise.all([
updateConnectorConfig(facebookConnectorId, facebookConnectorConfig).then(async () =>
enableConnector(facebookConnectorId)
updateConnectorConfig(mockSocialConnectorId, mockSocialConnectorConfig).then(async () =>
enableConnector(mockSocialConnectorId)
),
updateConnectorConfig(twilioSmsConnectorId, twilioSmsConnectorConfig).then(async () =>
enableConnector(twilioSmsConnectorId)
@ -65,7 +65,7 @@ describe('admin console sign-in experience', () => {
};
const updatedSignInExperience = await updateSignInExperience({
socialSignInConnectorTargets: [facebookConnectorTarget],
socialSignInConnectorTargets: [mockSocialConnectorTarget],
signInMethods: newSignInMethods,
});
@ -73,7 +73,7 @@ describe('admin console sign-in experience', () => {
// Reset connectors
await Promise.all([
disableConnector(facebookConnectorId),
disableConnector(mockSocialConnectorId),
disableConnector(twilioSmsConnectorId),
disableConnector(sendgridEmailConnectorId),
]);