mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
* feat: integrate supabase auth service * chore: ignore the sercet * feat: separate and inject the auth service * chore: integrate auth service into sign in/up page * feat: integrate github and google sign in * chore: update user trait * feat: box any params in UserCloudService trait * feat: add flowy-server crate * refactor: user trait * docs: doc ThirdPartyAuthPB * feat: server provider * feat: pass the uuid to rust side * feat: pass supabase config to rust side * feat: integrate env file * feat: implement login as guest * feat: impl postgrest * test: use env * chore: upper case key * feat: optimize the file storage * fix: don't call set auth when user login in local * docs: add docs * feat: create/update/get user using postgrest * feat: optimize the login as guest * feat: create user workspace * feat: create user default workspace * feat: redesign the setting path location page * feat: use uuid as view id * feat: send auth info to rust backend * fix: sign up * fix: skip to wrong page after login * fix: integrate test error * fix: indent command error * feat: add discord login in type * fix: flutter analyze * ci: fix rust tests * ci: fix tauri build * ci: fix tauri build --------- Co-authored-by: nathan <nathan@appflowy.io>
115 lines
3.0 KiB
Dart
115 lines
3.0 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:appflowy/core/config/kv_keys.dart';
|
|
import 'package:appflowy/main.dart' as app;
|
|
import 'package:appflowy/startup/tasks/prelude.dart';
|
|
import 'package:flutter/gestures.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:path_provider/path_provider.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
class TestFolder {
|
|
/// Location / Path
|
|
|
|
/// Set a given AppFlowy data storage location under test environment.
|
|
///
|
|
/// To pass null means clear the location.
|
|
///
|
|
/// The file_picker is a system component and can't be tapped, so using logic instead of tapping.
|
|
///
|
|
static Future<void> setTestLocation(String? name) async {
|
|
final location = await testLocation(name);
|
|
SharedPreferences.setMockInitialValues({
|
|
KVKeys.pathLocation: location.path,
|
|
});
|
|
return;
|
|
}
|
|
|
|
/// Clean the location.
|
|
static Future<void> cleanTestLocation(String? name) async {
|
|
final dir = await testLocation(name);
|
|
await dir.delete(recursive: true);
|
|
return;
|
|
}
|
|
|
|
/// Get current using location.
|
|
static Future<String> currentLocation() async {
|
|
final prefs = await SharedPreferences.getInstance();
|
|
return prefs.getString(KVKeys.pathLocation)!;
|
|
}
|
|
|
|
/// Get default location under development environment.
|
|
static Future<String> defaultDevelopmentLocation() async {
|
|
final dir = await appFlowyDocumentDirectory();
|
|
return dir.path;
|
|
}
|
|
|
|
/// Get default location under test environment.
|
|
static Future<Directory> testLocation(String? name) async {
|
|
final dir = await getApplicationDocumentsDirectory();
|
|
var path = '${dir.path}/flowy_test';
|
|
if (name != null) {
|
|
path += '/$name';
|
|
}
|
|
return Directory(path).create(recursive: true);
|
|
}
|
|
}
|
|
|
|
extension AppFlowyTestBase on WidgetTester {
|
|
Future<void> initializeAppFlowy() async {
|
|
const MethodChannel('hotkey_manager')
|
|
.setMockMethodCallHandler((MethodCall methodCall) async {
|
|
if (methodCall.method == 'unregisterAll') {
|
|
// do nothing
|
|
}
|
|
});
|
|
|
|
await app.main();
|
|
await wait(3000);
|
|
await pumpAndSettle(const Duration(seconds: 2));
|
|
return;
|
|
}
|
|
|
|
Future<void> tapButton(
|
|
Finder finder, {
|
|
int? pointer,
|
|
int buttons = kPrimaryButton,
|
|
bool warnIfMissed = true,
|
|
int milliseconds = 500,
|
|
}) async {
|
|
await tap(finder);
|
|
await pumpAndSettle(Duration(milliseconds: milliseconds));
|
|
return;
|
|
}
|
|
|
|
Future<void> tapButtonWithName(
|
|
String tr, {
|
|
int milliseconds = 500,
|
|
}) async {
|
|
final button = find.text(tr);
|
|
await tapButton(
|
|
button,
|
|
milliseconds: milliseconds,
|
|
);
|
|
return;
|
|
}
|
|
|
|
Future<void> tapButtonWithTooltip(
|
|
String tr, {
|
|
int milliseconds = 500,
|
|
}) async {
|
|
final button = find.byTooltip(tr);
|
|
await tapButton(
|
|
button,
|
|
milliseconds: milliseconds,
|
|
);
|
|
return;
|
|
}
|
|
|
|
Future<void> wait(int milliseconds) async {
|
|
await pumpAndSettle(Duration(milliseconds: milliseconds));
|
|
return;
|
|
}
|
|
}
|