2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-07-01 19:30:44 +00:00

Format Code and Add Format Checks to CI (#643)

* Remove unused lib/generated/i18n.dart

* Use `fvm dart format .`

* Add contributing guidelines

* Enforce dart format

* Add `dart format off` directive to generated files
This commit is contained in:
Ben Hagen
2025-06-24 01:55:01 +02:00
committed by GitHub
parent e9db6532e4
commit 4444884afa
100 changed files with 5332 additions and 5592 deletions

View File

@ -1,4 +1,3 @@
import "package:flutter/services.dart";
import "package:flutter_test/flutter_test.dart";
import "package:inventree/api.dart";
@ -16,11 +15,13 @@ void setupTestEnv() {
CustomBinding();
// Mock the path provider
const MethodChannel channel = MethodChannel("plugins.flutter.io/path_provider");
const MethodChannel channel = MethodChannel(
"plugins.flutter.io/path_provider",
);
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(channel, (MethodCall methodCall) async {
return ".";
});
return ".";
});
}
// Accessors for default testing values
@ -29,40 +30,43 @@ const String testServerName = "Test Server";
const String testUsername = "testuser";
const String testPassword = "testpassword";
/*
* Request an API token for the given profile
*/
Future<bool> fetchProfileToken({
UserProfile? profile,
String username = testUsername,
String password = testPassword
String password = testPassword,
}) async {
profile ??= await UserProfileDBManager().getProfileByName(testServerName);
assert(profile != null);
final response = await InvenTreeAPI().fetchToken(profile!, username, password);
final response = await InvenTreeAPI().fetchToken(
profile!,
username,
password,
);
return response.successful();
}
/*
* Setup a valid profile, and return it
*/
Future<UserProfile> setupServerProfile({bool select = true, bool fetchToken = false}) async {
Future<UserProfile> setupServerProfile({
bool select = true,
bool fetchToken = false,
}) async {
// Setup a valid server profile
UserProfile? profile = await UserProfileDBManager().getProfileByName(testServerName);
UserProfile? profile = await UserProfileDBManager().getProfileByName(
testServerName,
);
if (profile == null) {
// Profile does not already exist - create it!
bool result = await UserProfileDBManager().addProfile(
UserProfile(
server: testServerAddress,
name: testServerName
)
UserProfile(server: testServerAddress, name: testServerName),
);
assert(result);
@ -84,15 +88,13 @@ Future<UserProfile> setupServerProfile({bool select = true, bool fetchToken = fa
return profile!;
}
/*
* Complete all steps necessary to login to the server
*/
Future<void> connectToTestServer() async {
// Setup profile, and fetch user token as necessary
final profile = await setupServerProfile(fetchToken: true);
// Connect to the server
assert(await InvenTreeAPI().connectToServer(profile));
}
}