Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,11 @@ jobs:
with:
flutter-version: '3.7.3'
channel: 'stable'

- name: Setup node (ㅠ﹏ㅠ)
uses: actions/setup-node@v3
with:
node-version: 18

- name: Setup Tools ᕙ|” ◉ ◡ ◉ ”|ᕗ
run: |
sudo apt-get update -y
sudo apt-get install -y ninja-build libgtk-3-dev libolm3 libmpv-dev mpv

cd $PROJECT_PATH/integration_test/subprocess
npm ci
npm install -g ts-node
sudo apt-get install -y ninja-build libgtk-3-dev libolm3 libmpv-dev mpv ffmpeg

- name: Start Synapse [◯ ‸ ◯]
run: |
Expand Down Expand Up @@ -67,4 +58,16 @@ jobs:
cd $PROJECT_PATH
export DISPLAY=:99
sudo Xvfb -ac :99 -screen 0 1920x1080x24 > /dev/null 2>&1 &
ffmpeg -f x11grab -video_size 1920x1080 -framerate 15 -i :99 -vcodec libx264 -preset ultrafast -qp 0 -nostdin -loglevel quiet -pix_fmt yuv444p video.mkv &
scripts/integration-test.sh
INTEGRATION_TEST_EXIT_CODE=$?
sleep 1
kill $(pgrep ffmpeg)
exit $INTEGRATION_TEST_EXIT_CODE

- name: Upload Artifact
if: always()
uses: actions/upload-artifact@v3
with:
name: result.mkv
path: commet/video.mkv
9 changes: 6 additions & 3 deletions commet/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,26 @@
"request": "launch",
"type": "dart",
"toolArgs": [
"--dart-define", "PLATFORM=desktop"
"--dart-define", "PLATFORM=desktop",
"--dart-define", "BUILD_MODE=debug"
],
},
{
"name": "commet (debug mobile)",
"request": "launch",
"type": "dart",
"toolArgs": [
"--dart-define", "PLATFORM=mobile"
"--dart-define", "PLATFORM=mobile",
"--dart-define", "BUILD_MODE=debug"
],
},
{
"name": "commet (debug android)",
"request": "launch",
"type": "dart",
"toolArgs": [
"--dart-define", "PLATFORM=android"
"--dart-define", "PLATFORM=android",
"--dart-define", "BUILD_MODE=debug"
],
},
{
Expand Down
30 changes: 30 additions & 0 deletions commet/integration_test/extensions/common_flows.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:commet/main.dart';
import 'package:hive/hive.dart';
import 'package:matrix/encryption/utils/key_verification.dart';
import 'package:matrix/matrix.dart';
import 'package:path_provider/path_provider.dart';

import 'wait_for.dart';
Expand Down Expand Up @@ -64,4 +66,32 @@ extension CommonFlows on WidgetTester {
await waitFor(() => app.clientManager.isLoggedIn(), timeout: const Duration(seconds: 5), skipPumpAndSettle: true);
expect(app.clientManager.isLoggedIn(), equals(true));
}

Future<Client> createTestClient() async {
var hs = const String.fromEnvironment('HOMESERVER', defaultValue: "localhost");

var username = const String.fromEnvironment('USER1_NAME', defaultValue: "alice");

var password = const String.fromEnvironment('USER1_PW', defaultValue: "AliceInWonderland");

var otherClient = Client(
"Commet Integration Tester",
verificationMethods: {KeyVerificationMethod.emoji, KeyVerificationMethod.numbers},
nativeImplementations: MatrixClient.nativeImplementations,
logLevel: Level.verbose,
databaseBuilder: (client) async {
print(await AppConfig.getDatabasePath());
final db = HiveCollectionsDatabase(client.clientName, await AppConfig.getDatabasePath());
await db.open();
return db;
},
);

await otherClient.checkHomeserver(Uri.http(hs));

await otherClient.login(LoginType.mLoginPassword,
identifier: AuthenticationUserIdentifier(user: username), password: password);

return otherClient;
}
}
23 changes: 17 additions & 6 deletions commet/integration_test/matrix/key_verification_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:convert';
import 'dart:io';

import 'package:commet/client/matrix/matrix_client.dart';
import 'package:commet/config/app_config.dart';
import 'package:commet/generated/l10n.dart';
import 'package:commet/ui/pages/matrix/verification/matrix_verification_page.dart';
import 'package:flutter/material.dart';
Expand All @@ -21,8 +22,6 @@ void main() {
var username = const String.fromEnvironment('USER1_NAME', defaultValue: "alice");
var password = const String.fromEnvironment('USER1_PW', defaultValue: "AliceInWonderland");

// Adding a bunch of delays to not trigger M_LIMIT_EXCEEDED: Too Many Requests
// Also helps avoid some errors with lock files when cleaning user data;
await tester.clearUserData();

var app = App();
Expand All @@ -31,9 +30,16 @@ void main() {

var matrixClient = (app.clientManager.getClients()[0] as MatrixClient);

var proc = await IntegrationTestSubprocess.verifyMeWithEmoji(matrixClient.getMatrixClient().deviceID!);
var otherClient = await tester.createTestClient();

await Future.delayed(const Duration(seconds: 1));
var client = matrixClient.getMatrixClient();

var devices = await otherClient.getDevices();
var device = devices!.firstWhere((element) => element.deviceId == client.deviceID);
expect(device, isNotNull);

var verification = otherClient.userDeviceKeys[otherClient.userID]!.deviceKeys[device.deviceId]!.startVerification();
verification.onUpdate = () {};

await tester.waitFor(() => find.byType(MatrixVerificationPage).evaluate().isNotEmpty);

Expand All @@ -51,14 +57,19 @@ void main() {

await tester.tap(button);

await verification.acceptSas();

await tester
.waitFor(() => find.widgetWithText(ElevatedButton, T.current.sasVerificationDone).evaluate().isNotEmpty);

await tester.pumpAndSettle();

var client = matrixClient.getMatrixClient();
expect(verification.isDone, equals(true));
expect(verification.state, equals(KeyVerificationState.done));

proc.kill();
await tester.clean();

expect(client.userDeviceKeys[client.userID]!.deviceKeys[otherClient.deviceID!], isNotNull);
expect(otherClient.userDeviceKeys[otherClient.userID]!.deviceKeys[client.deviceID!], isNotNull);
});
}
130 changes: 0 additions & 130 deletions commet/integration_test/subprocess/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion commet/integration_test/subprocess/.npmrc

This file was deleted.

20 changes: 0 additions & 20 deletions commet/integration_test/subprocess/README.md

This file was deleted.

Loading