0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

refactor(test): refactor connector ui tests (#4688)

This commit is contained in:
Xiao Yijun 2023-10-18 14:08:59 +08:00 committed by GitHub
parent d24aaedf5b
commit c9886f2860
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 367 deletions

View file

@ -60,73 +60,6 @@ const sendGrid: PasswordlessConnectorCase = {
},
};
const aliyunDirectMail: PasswordlessConnectorCase = {
factoryId: 'aliyun-direct-mail',
isEmailConnector: true,
name: 'Aliyun Direct Mail',
initialFormData: {
'formConfig.accessKeyId': 'access-key-id',
'formConfig.accessKeySecret': 'access-key-config',
'formConfig.accountName': 'account-name',
'formConfig.fromAlias': 'from-alias',
},
updateFormData: {
'formConfig.accessKeyId': 'new-access-key-id',
'formConfig.accessKeySecret': 'new-access-key-config',
'formConfig.accountName': 'new-account-name',
'formConfig.fromAlias': 'new-from-alias',
},
errorFormData: {
'formConfig.accessKeyId': '',
'formConfig.accessKeySecret': '',
'formConfig.accountName': '',
},
};
const mailgun: PasswordlessConnectorCase = {
factoryId: 'mailgun-email',
isEmailConnector: true,
name: 'Mailgun',
initialFormData: {
'formConfig.endpoint': 'https://fake.mailgun.net',
'formConfig.domain': 'mailgun-domain.com',
'formConfig.apiKey': 'api-key',
'formConfig.from': 'from',
},
updateFormData: {
'formConfig.endpoint': 'https://new-fake.mailgun.net',
'formConfig.domain': 'new-mailgun-domain.com',
'formConfig.apiKey': 'new-api-key',
'formConfig.from': 'new-from',
},
errorFormData: {
'formConfig.domain': '',
'formConfig.apiKey': '',
'formConfig.from': '',
},
};
const smpt: PasswordlessConnectorCase = {
factoryId: 'simple-mail-transfer-protocol',
isEmailConnector: true,
name: 'SMTP',
initialFormData: {
'formConfig.host': 'host',
'formConfig.port': '25',
'formConfig.fromEmail': 'from',
},
updateFormData: {
'formConfig.host': 'new-host',
'formConfig.port': '26',
'formConfig.fromEmail': 'new-from',
},
errorFormData: {
'formConfig.host': '',
'formConfig.port': '',
'formConfig.fromEmail': '',
},
};
const twilio: PasswordlessConnectorCase = {
factoryId: 'twilio-short-message-service',
isEmailConnector: false,
@ -148,55 +81,6 @@ const twilio: PasswordlessConnectorCase = {
},
};
const aliyunShortMessage: PasswordlessConnectorCase = {
factoryId: 'aliyun-short-message-service',
isEmailConnector: false,
name: 'Aliyun Short Message Service',
initialFormData: {
'formConfig.accessKeyId': 'access-key-id',
'formConfig.accessKeySecret': 'access-key-config',
'formConfig.signName': 'sign-name',
},
updateFormData: {
'formConfig.accessKeyId': 'new-access-key-id',
'formConfig.accessKeySecret': 'new-access-key-config',
'formConfig.signName': 'new-sign-name',
},
errorFormData: {
'formConfig.accessKeyId': '',
'formConfig.accessKeySecret': '',
'formConfig.signName': '',
},
};
// Tencent-short-message-service
const tencentShortMessage: PasswordlessConnectorCase = {
factoryId: 'tencent-short-message-service',
isEmailConnector: false,
name: 'Tencent Short Message Service',
initialFormData: {
'formConfig.accessKeyId': 'access-key-id',
'formConfig.accessKeySecret': 'access-key-config',
'formConfig.signName': 'sign-name',
'formConfig.sdkAppId': 'sdk-app-id',
'formConfig.region': 'region',
},
updateFormData: {
'formConfig.accessKeyId': 'new-access-key-id',
'formConfig.accessKeySecret': 'new-access-key-config',
'formConfig.signName': 'new-sign-name',
'formConfig.sdkAppId': 'new-sdk-app-id',
'formConfig.region': 'new-region',
},
errorFormData: {
'formConfig.accessKeyId': '',
'formConfig.accessKeySecret': '',
'formConfig.signName': '',
'formConfig.sdkAppId': '',
'formConfig.region': '',
},
};
// Smsaero-short-message-service
const smsaeroShortMessage: PasswordlessConnectorCase = {
factoryId: 'smsaero-short-message-service',
@ -223,12 +107,7 @@ export const passwordlessConnectorTestCases = [
// Email
awsSesMail,
sendGrid,
aliyunDirectMail,
mailgun,
smpt,
// SMS
twilio,
aliyunShortMessage,
tencentShortMessage,
smsaeroShortMessage,
];

View file

@ -1,4 +1,3 @@
/* eslint-disable max-lines */
export type SocialConnectorCase = {
groupFactoryId?: string;
factoryId: string;
@ -29,137 +28,6 @@ const google: SocialConnectorCase = {
},
};
const apple: SocialConnectorCase = {
factoryId: 'apple-universal',
name: 'Apple',
initialFormData: {
'formConfig.clientId': 'client-id',
},
updateFormData: {
'formConfig.clientId': 'new-client-id',
},
errorFormData: {
'formConfig.clientId': '',
},
};
const facebook: SocialConnectorCase = {
factoryId: 'facebook-universal',
name: 'Facebook',
initialFormData: {
'formConfig.clientId': 'client-id',
'formConfig.clientSecret': 'client-secret',
'formConfig.scope': 'scope',
},
updateFormData: {
'formConfig.clientId': 'new-client-id',
'formConfig.clientSecret': 'new-client-secret',
'formConfig.scope': 'new-scope',
},
errorFormData: {
'formConfig.clientId': '',
'formConfig.clientSecret': '',
'formConfig.scope': '',
},
};
const github: SocialConnectorCase = {
factoryId: 'github-universal',
name: 'GitHub',
initialFormData: {
'formConfig.clientId': 'client-id',
'formConfig.clientSecret': 'client-secret',
'formConfig.scope': 'scope',
},
updateFormData: {
'formConfig.clientId': 'new-client-id',
'formConfig.clientSecret': 'new-client-secret',
'formConfig.scope': 'new-scope',
},
errorFormData: {
'formConfig.clientId': '',
'formConfig.clientSecret': '',
'formConfig.scope': '',
},
};
const discord: SocialConnectorCase = {
factoryId: 'discord-universal',
name: 'Discord',
initialFormData: {
'formConfig.clientId': 'client-id',
'formConfig.clientSecret': 'client-secret',
'formConfig.scope': 'scope',
},
updateFormData: {
'formConfig.clientId': 'new-client-id',
'formConfig.clientSecret': 'new-client-secret',
'formConfig.scope': 'new-scope',
},
errorFormData: {
'formConfig.clientId': '',
'formConfig.clientSecret': '',
'formConfig.scope': '',
},
};
const kakao: SocialConnectorCase = {
factoryId: 'kakao-universal',
name: 'Kakao',
initialFormData: {
'formConfig.clientId': 'client-id',
'formConfig.clientSecret': 'client-secret',
},
updateFormData: {
'formConfig.clientId': 'new-client-id',
'formConfig.clientSecret': 'new-client-secret',
},
errorFormData: {
'formConfig.clientId': '',
'formConfig.clientSecret': '',
},
};
const naver: SocialConnectorCase = {
factoryId: 'naver-universal',
name: 'Naver',
initialFormData: {
'formConfig.clientId': 'client-id',
'formConfig.clientSecret': 'client-secret',
},
updateFormData: {
'formConfig.clientId': 'new-client-id',
'formConfig.clientSecret': 'new-client-secret',
},
errorFormData: {
'formConfig.clientId': '',
'formConfig.clientSecret': '',
},
};
const microsoft: SocialConnectorCase = {
factoryId: 'azuread-universal',
name: 'Microsoft',
initialFormData: {
'formConfig.clientId': 'client-id',
'formConfig.clientSecret': 'client-secret',
'formConfig.cloudInstance': 'cloud-instance',
'formConfig.tenantId': 'tenant-id',
},
updateFormData: {
'formConfig.clientId': 'new-client-id',
'formConfig.clientSecret': 'new-client-secret',
'formConfig.cloudInstance': 'new-cloud-instance',
'formConfig.tenantId': 'new-tenant-id',
},
errorFormData: {
'formConfig.clientId': '',
'formConfig.clientSecret': '',
'formConfig.cloudInstance': '',
'formConfig.tenantId': '',
},
};
const feishu: SocialConnectorCase = {
factoryId: 'feishu-web',
name: 'Feishu',
@ -219,107 +87,6 @@ const wechatWeb: SocialConnectorCase = {
},
};
const alipayNative: SocialConnectorCase = {
groupFactoryId: 'alipay-native',
factoryId: 'alipay-native',
name: 'Alipay',
initialFormData: {
'formConfig.appId': 'app-id',
'formConfig.privateKey': 'private-key',
},
updateFormData: {
'formConfig.appId': 'new-app-id',
'formConfig.privateKey': 'new-private-key',
},
errorFormData: {
'formConfig.appId': '',
'formConfig.privateKey': '',
},
};
const alipayWeb: SocialConnectorCase = {
groupFactoryId: 'alipay-native',
factoryId: 'alipay-web',
name: 'Alipay',
initialFormData: {
'formConfig.appId': 'app-id',
'formConfig.privateKey': 'private-key',
'formConfig.scope': 'scope',
},
updateFormData: {
'formConfig.appId': 'new-app-id',
'formConfig.privateKey': 'new-private-key',
'formConfig.scope': 'new-scope',
},
errorFormData: {
'formConfig.appId': '',
'formConfig.privateKey': '',
'formConfig.scope': '',
},
};
const oauth2: SocialConnectorCase = {
factoryId: 'oauth2',
name: 'OAuth 2.0',
initialFormData: {
'formConfig.authorizationEndpoint': 'authorization-endpoint',
'formConfig.tokenEndpoint': 'token-endpoint',
'formConfig.userInfoEndpoint': 'user-info-endpoint',
'formConfig.clientId': 'client-id',
'formConfig.clientSecret': 'client-secret-id',
'formConfig.scope': 'scope',
},
updateFormData: {
'formConfig.authorizationEndpoint': 'new-authorization-endpoint',
'formConfig.tokenEndpoint': 'new-token-endpoint',
'formConfig.userInfoEndpoint': 'new-user-info-endpoint',
'formConfig.clientId': 'new-client-id',
'formConfig.clientSecret': 'new-client-secret-id',
'formConfig.scope': 'new-scope',
},
errorFormData: {
'formConfig.authorizationEndpoint': '',
'formConfig.tokenEndpoint': '',
'formConfig.userInfoEndpoint': '',
'formConfig.clientId': '',
'formConfig.clientSecret': '',
'formConfig.scope': '',
},
standardBasicFormData: {
name: 'OAuth 2.0',
target: 'oauth2',
},
};
const oidc: SocialConnectorCase = {
factoryId: 'oidc',
name: 'OIDC',
initialFormData: {
'formConfig.authorizationEndpoint': 'authorization-endpoint',
'formConfig.tokenEndpoint': 'token-endpoint',
'formConfig.clientId': 'client-id',
'formConfig.clientSecret': 'client-secret-id',
'formConfig.scope': 'scope',
},
updateFormData: {
'formConfig.authorizationEndpoint': 'new-authorization-endpoint',
'formConfig.tokenEndpoint': 'new-token-endpoint',
'formConfig.clientId': 'new-client-id',
'formConfig.clientSecret': 'new-client-secret-id',
'formConfig.scope': 'new-scope',
},
errorFormData: {
'formConfig.authorizationEndpoint': '',
'formConfig.tokenEndpoint': '',
'formConfig.clientId': '',
'formConfig.clientSecret': '',
},
standardBasicFormData: {
name: 'OIDC',
target: 'oidc',
},
};
const saml: SocialConnectorCase = {
factoryId: 'saml',
name: 'SAML',
@ -350,21 +117,14 @@ const saml: SocialConnectorCase = {
},
};
export const socialConnectorTestCases = [
// Universal
google,
apple,
facebook,
github,
discord,
kakao,
naver,
microsoft,
// Web
feishu,
// Group - Native
wechatNative,
// Group - Web
wechatWeb,
alipayNative,
alipayWeb,
oauth2,
oidc,
// Standard
saml,
];
/* eslint-enable max-lines */

View file

@ -32,7 +32,7 @@ type WaitToasterOptions = {
export const waitForToast = async (page: Page, { text, type = 'success' }: WaitToasterOptions) => {
const toast = await expect(page).toMatchElement(
`div[class*=toast][class*=${type}]:has(div[class$=message])`,
{ text }
{ text, timeout: 5000 }
);
// Remove immediately to prevent waiting for the toast to disappear and matching the same toast again