test: add document sync test on appflowy cloud (#4163)

* test: add document sync test on appflowy cloud

* chore: add runner

* test: Stream has already been listened to.

* fix: using singleton subscription

* fix: using singleton subscription
This commit is contained in:
Nathan.fooo
2023-12-21 08:12:40 +08:00
committed by GitHub
parent f5a9f2bf4d
commit 6ecc3c9076
29 changed files with 560 additions and 381 deletions

View File

@ -70,23 +70,16 @@ Future<AuthenticatorType> getAuthenticatorType() async {
/// AppFlowy Cloud or Supabase configuration is valid.
/// Returns `false` otherwise.
bool get isAuthEnabled {
// Only enable supabase in release and develop mode.
if (integrationMode().isRelease ||
integrationMode().isDevelop ||
integrationMode().isIntegrationTest) {
final env = getIt<AppFlowyCloudSharedEnv>();
if (env.authenticatorType == AuthenticatorType.supabase) {
return env.supabaseConfig.isValid;
}
if (env.authenticatorType == AuthenticatorType.appflowyCloud) {
return env.appflowyCloudConfig.isValid;
}
return false;
} else {
return false;
final env = getIt<AppFlowyCloudSharedEnv>();
if (env.authenticatorType == AuthenticatorType.supabase) {
return env.supabaseConfig.isValid;
}
if (env.authenticatorType == AuthenticatorType.appflowyCloud) {
return env.appflowyCloudConfig.isValid;
}
return false;
}
/// Checks if Supabase is enabled.
@ -99,34 +92,12 @@ bool get isAuthEnabled {
/// if the application is in release or develop mode and the current cloud type
/// is `CloudType.supabase`. Otherwise, it returns `false`.
bool get isSupabaseEnabled {
// Only enable supabase in release and develop mode.
if (integrationMode().isRelease ||
integrationMode().isDevelop ||
integrationMode().isIntegrationTest) {
return currentCloudType() == AuthenticatorType.supabase;
} else {
return false;
}
return currentCloudType() == AuthenticatorType.supabase;
}
/// Determines if AppFlowy Cloud is enabled.
///
/// This getter assesses if AppFlowy Cloud should be enabled based on the
/// current integration mode and cloud type setting.
///
/// Returns:
/// A boolean value indicating whether AppFlowy Cloud is enabled. It returns
/// `true` if the application is in release or develop mode and the current
/// cloud type is `CloudType.appflowyCloud`. Otherwise, it returns `false`.
bool get isAppFlowyCloudEnabled {
// Only enable appflowy cloud in release and develop mode.
if (integrationMode().isRelease ||
integrationMode().isDevelop ||
integrationMode().isIntegrationTest) {
return currentCloudType() == AuthenticatorType.appflowyCloud;
} else {
return false;
}
return currentCloudType() == AuthenticatorType.appflowyCloud;
}
enum AuthenticatorType {

View File

@ -1,4 +1,6 @@
// lib/env/env.dart
// ignore_for_file: prefer_const_declarations
import 'package:envied/envied.dart';
part 'cloud_env_test.g.dart';
@ -9,21 +11,21 @@ part 'cloud_env_test.g.dart';
abstract class TestEnv {
/// AppFlowy Cloud Configuration
@EnviedField(
obfuscate: true,
obfuscate: false,
varName: 'APPFLOWY_CLOUD_URL',
defaultValue: '',
defaultValue: 'http://localhost',
)
static final String afCloudUrl = _TestEnv.afCloudUrl;
// Supabase Configuration:
@EnviedField(
obfuscate: true,
obfuscate: false,
varName: 'SUPABASE_URL',
defaultValue: '',
)
static final String supabaseUrl = _TestEnv.supabaseUrl;
@EnviedField(
obfuscate: true,
obfuscate: false,
varName: 'SUPABASE_ANON_KEY',
defaultValue: '',
)