You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
2.2 KiB
55 lines
2.2 KiB
import 'package:eaimar/modules/login/models/login_methods.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
Set<LoginMethod> ios({bool guest = true}) =>
|
|
resolveLoginMethods(isIOS: true, envChannel: 'CHINA_XIAOMI', guestVisible: guest);
|
|
Set<LoginMethod> google({bool guest = true}) => resolveLoginMethods(
|
|
isIOS: false, envChannel: 'GLOBAL_GOOGLE', guestVisible: guest);
|
|
Set<LoginMethod> domestic(String ch, {bool guest = true}) =>
|
|
resolveLoginMethods(isIOS: false, envChannel: ch, guestVisible: guest);
|
|
|
|
test('苹果包:只有苹果登录 + 游客', () {
|
|
expect(ios(), {LoginMethod.apple, LoginMethod.guest});
|
|
});
|
|
|
|
test('苹果包不受 .env Channel 影响(iOS 不跑 build_channels.sh,值还是国内渠道)', () {
|
|
expect(
|
|
resolveLoginMethods(
|
|
isIOS: true, envChannel: 'GLOBAL_GOOGLE', guestVisible: false),
|
|
{LoginMethod.apple},
|
|
);
|
|
});
|
|
|
|
test('安卓国内包:只有微信登录 + 游客', () {
|
|
for (final ch in ['CHINA_XIAOMI', 'CHINA_HUAWEI', 'CHINA_HONOR', 'OFFICIAL']) {
|
|
expect(domestic(ch), {LoginMethod.wechat, LoginMethod.guest},
|
|
reason: 'channel=$ch');
|
|
}
|
|
});
|
|
|
|
test('谷歌包:只有邮箱(contact)登录 + 游客,没有微信也没有苹果', () {
|
|
expect(google(), {LoginMethod.contact, LoginMethod.guest});
|
|
});
|
|
|
|
test('Channel 认不出时按国内包处理(失败方向:宁可留微信,不要露出邮箱登录)', () {
|
|
expect(domestic(''), {LoginMethod.wechat, LoginMethod.guest});
|
|
expect(domestic('xiaomi'), {LoginMethod.wechat, LoginMethod.guest});
|
|
});
|
|
|
|
test('Channel 的大小写与空白不影响判定', () {
|
|
expect(domestic(' global_google ', guest: false), {LoginMethod.contact});
|
|
});
|
|
|
|
test('游客开关由服务端给,关掉时每个包各自只剩一个入口', () {
|
|
expect(ios(guest: false), {LoginMethod.apple});
|
|
expect(google(guest: false), {LoginMethod.contact});
|
|
expect(domestic('CHINA_VIVO', guest: false), {LoginMethod.wechat});
|
|
});
|
|
|
|
test('任何组合下都至少有一个登录入口,且三种包互不重叠', () {
|
|
for (final m in [ios(), google(), domestic('CHINA_OPPO')]) {
|
|
expect(m.where((e) => e != LoginMethod.guest).length, 1);
|
|
}
|
|
});
|
|
}
|
|
|