2023-12-21 08:12:40 +08:00
|
|
|
// ignore_for_file: unused_import
|
|
|
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
import 'package:appflowy/env/cloud_env.dart';
|
|
|
|
import 'package:appflowy/generated/locale_keys.g.dart';
|
|
|
|
import 'package:appflowy/startup/startup.dart';
|
|
|
|
import 'package:appflowy/user/application/auth/af_cloud_mock_auth_service.dart';
|
|
|
|
import 'package:appflowy/user/application/auth/auth_service.dart';
|
|
|
|
import 'package:appflowy/workspace/application/settings/prelude.dart';
|
2024-04-30 14:09:08 +02:00
|
|
|
import 'package:appflowy/workspace/presentation/settings/pages/settings_account_view.dart';
|
2023-12-21 08:12:40 +08:00
|
|
|
import 'package:appflowy/workspace/presentation/settings/widgets/setting_appflowy_cloud.dart';
|
2023-12-31 07:29:40 +08:00
|
|
|
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
2023-12-21 08:12:40 +08:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
import 'package:flowy_infra/uuid.dart';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:integration_test/integration_test.dart';
|
2024-04-30 14:09:08 +02:00
|
|
|
import 'package:path/path.dart' as p;
|
|
|
|
|
2024-03-05 17:20:27 +08:00
|
|
|
import '../shared/dir.dart';
|
|
|
|
import '../shared/mock/mock_file_picker.dart';
|
|
|
|
import '../shared/util.dart';
|
2023-12-21 08:12:40 +08:00
|
|
|
|
|
|
|
void main() {
|
|
|
|
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
final email = '${uuid()}@appflowy.io';
|
2023-12-27 11:42:39 +08:00
|
|
|
const inputContent = 'Hello world, this is a test document';
|
2023-12-21 08:12:40 +08:00
|
|
|
|
|
|
|
// The test will create a new document called Sample, and sync it to the server.
|
|
|
|
// Then the test will logout the user, and login with the same user. The data will
|
|
|
|
// be synced from the server.
|
|
|
|
group('appflowy cloud document', () {
|
|
|
|
testWidgets('sync local docuemnt to server', (tester) async {
|
|
|
|
await tester.initializeAppFlowy(
|
2024-01-12 14:34:59 +08:00
|
|
|
cloudType: AuthenticatorType.appflowyCloudSelfHost,
|
2023-12-21 08:12:40 +08:00
|
|
|
email: email,
|
|
|
|
);
|
|
|
|
await tester.tapGoogleLoginInButton();
|
2023-12-27 11:42:39 +08:00
|
|
|
await tester.expectToSeeHomePageWithGetStartedPage();
|
2023-12-21 08:12:40 +08:00
|
|
|
|
|
|
|
// create a new document called Sample
|
2024-01-25 16:37:36 +01:00
|
|
|
await tester.createNewPage();
|
2023-12-21 08:12:40 +08:00
|
|
|
|
|
|
|
// focus on the editor
|
|
|
|
await tester.editor.tapLineOfEditorAt(0);
|
2023-12-27 11:42:39 +08:00
|
|
|
await tester.ime.insertText(inputContent);
|
|
|
|
expect(find.text(inputContent, findRichText: true), findsOneWidget);
|
2023-12-21 08:12:40 +08:00
|
|
|
|
2023-12-27 11:42:39 +08:00
|
|
|
// 6 seconds for data sync
|
|
|
|
await tester.waitForSeconds(6);
|
2023-12-21 08:12:40 +08:00
|
|
|
|
|
|
|
await tester.openSettings();
|
2024-04-30 14:09:08 +02:00
|
|
|
await tester.openSettingsPage(SettingsPage.account);
|
2023-12-26 02:03:42 +08:00
|
|
|
await tester.logout();
|
2023-12-21 08:12:40 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
testWidgets('sync doc from server', (tester) async {
|
|
|
|
await tester.initializeAppFlowy(
|
2024-01-12 14:34:59 +08:00
|
|
|
cloudType: AuthenticatorType.appflowyCloudSelfHost,
|
2023-12-21 08:12:40 +08:00
|
|
|
email: email,
|
|
|
|
);
|
|
|
|
await tester.tapGoogleLoginInButton();
|
2023-12-26 02:03:42 +08:00
|
|
|
await tester.expectToSeeHomePage();
|
2023-12-21 08:12:40 +08:00
|
|
|
|
2023-12-27 11:42:39 +08:00
|
|
|
// the latest document will be opened, so the content must be the inputContent
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text(inputContent, findRichText: true), findsOneWidget);
|
2023-12-21 08:12:40 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|