added frontend

This commit is contained in:
verboomp
2026-01-21 16:08:09 +01:00
parent d2e6f5164a
commit b3de3eec8c
74 changed files with 4938 additions and 26 deletions

View File

@@ -0,0 +1,12 @@
import 'package:http/http.dart' as http;
import 'package:fotodocumentation/utils/http_client_utils.dart';
class TestHttpCLientUtilsImpl extends HttpClientUtils {
http.Client testClient;
TestHttpCLientUtilsImpl(this.testClient);
@override
http.Client get client => testClient;
}

View File

@@ -0,0 +1,67 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:http/http.dart' as http;
import 'package:mockito/annotations.dart';
import 'package:fotodocumentation/l10n/app_localizations.dart';
import 'package:fotodocumentation/pages/ui_utils/dialog/snackbar_utils.dart';
import 'package:fotodocumentation/pages/ui_utils/header_utils.dart';
import 'package:fotodocumentation/utils/login_credentials.dart';
import 'package:fotodocumentation/utils/password_utils.dart';
import 'package:fotodocumentation/utils/jwt_token_storage.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:fotodocumentation/utils/global_router.dart';
import 'test_utils.mocks.dart';
void setScreenSize(WidgetTester tester, int width, int height) {
final dpi = tester.view.devicePixelRatio;
tester.view.physicalSize = Size(width * dpi, height * dpi);
}
MockLoginCredentials getDefaultLoginCredentials() {
var mockLoginCredentials = MockLoginCredentials();
return mockLoginCredentials;
}
Future<void> pumpApp(WidgetTester tester, Widget widget) async {
await tester.pumpWidget(MaterialApp(
title: 'App',
localizationsDelegates: [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [
Locale('de'),
],
home: Scaffold(body: widget)));
await tester.pump();
}
Future<void> pumpAppConfig(WidgetTester tester, String initialLocation) async {
await tester.pumpWidget(MaterialApp.router(
title: 'App',
localizationsDelegates: [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [
Locale('de'),
],
routerConfig: GlobalRouter.createRouter(initialLocation)));
await tester.pump();
}
// dart run build_runner build
@GenerateMocks([
LoginCredentials,
HeaderUtils,
PasswordUtils,
SnackbarUtils,
JwtTokenStorage,
http.Client
])
void main() {}

View File

@@ -0,0 +1,542 @@
// Mocks generated by Mockito 5.4.6 from annotations
// in fotodocumentation/test/testing/test_utils.dart.
// Do not manually edit this file.
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i11;
import 'dart:convert' as _i12;
import 'dart:typed_data' as _i13;
import 'dart:ui' as _i6;
import 'package:flutter/material.dart' as _i2;
import 'package:fotodocumentation/pages/ui_utils/dialog/snackbar_utils.dart'
as _i9;
import 'package:fotodocumentation/pages/ui_utils/header_utils.dart' as _i7;
import 'package:fotodocumentation/utils/jwt_token_storage.dart' as _i10;
import 'package:fotodocumentation/utils/login_credentials.dart' as _i4;
import 'package:fotodocumentation/utils/password_utils.dart' as _i8;
import 'package:http/http.dart' as _i3;
import 'package:mockito/mockito.dart' as _i1;
import 'package:mockito/src/dummies.dart' as _i5;
// ignore_for_file: type=lint
// ignore_for_file: avoid_redundant_argument_values
// ignore_for_file: avoid_setters_without_getters
// ignore_for_file: comment_references
// ignore_for_file: deprecated_member_use
// ignore_for_file: deprecated_member_use_from_same_package
// ignore_for_file: implementation_imports
// ignore_for_file: invalid_use_of_visible_for_testing_member
// ignore_for_file: must_be_immutable
// ignore_for_file: prefer_const_constructors
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class
// ignore_for_file: invalid_use_of_internal_member
class _FakeWidget_0 extends _i1.SmartFake implements _i2.Widget {
_FakeWidget_0(
Object parent,
Invocation parentInvocation,
) : super(
parent,
parentInvocation,
);
@override
String toString({_i2.DiagnosticLevel? minLevel = _i2.DiagnosticLevel.info}) =>
super.toString();
}
class _FakeResponse_1 extends _i1.SmartFake implements _i3.Response {
_FakeResponse_1(
Object parent,
Invocation parentInvocation,
) : super(
parent,
parentInvocation,
);
}
class _FakeStreamedResponse_2 extends _i1.SmartFake
implements _i3.StreamedResponse {
_FakeStreamedResponse_2(
Object parent,
Invocation parentInvocation,
) : super(
parent,
parentInvocation,
);
}
/// A class which mocks [LoginCredentials].
///
/// See the documentation for Mockito's code generation for more information.
class MockLoginCredentials extends _i1.Mock implements _i4.LoginCredentials {
MockLoginCredentials() {
_i1.throwOnMissingStub(this);
}
@override
String get fullname => (super.noSuchMethod(
Invocation.getter(#fullname),
returnValue: _i5.dummyValue<String>(
this,
Invocation.getter(#fullname),
),
) as String);
@override
bool get hasListeners => (super.noSuchMethod(
Invocation.getter(#hasListeners),
returnValue: false,
) as bool);
@override
void logout() => super.noSuchMethod(
Invocation.method(
#logout,
[],
),
returnValueForMissingStub: null,
);
@override
void addListener(_i6.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#addListener,
[listener],
),
returnValueForMissingStub: null,
);
@override
void removeListener(_i6.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#removeListener,
[listener],
),
returnValueForMissingStub: null,
);
@override
void dispose() => super.noSuchMethod(
Invocation.method(
#dispose,
[],
),
returnValueForMissingStub: null,
);
@override
void notifyListeners() => super.noSuchMethod(
Invocation.method(
#notifyListeners,
[],
),
returnValueForMissingStub: null,
);
}
/// A class which mocks [HeaderUtils].
///
/// See the documentation for Mockito's code generation for more information.
class MockHeaderUtils extends _i1.Mock implements _i7.HeaderUtils {
MockHeaderUtils() {
_i1.throwOnMissingStub(this);
}
@override
_i2.Widget titleWidget(String? text) => (super.noSuchMethod(
Invocation.method(
#titleWidget,
[text],
),
returnValue: _FakeWidget_0(
this,
Invocation.method(
#titleWidget,
[text],
),
),
) as _i2.Widget);
}
/// A class which mocks [PasswordUtils].
///
/// See the documentation for Mockito's code generation for more information.
class MockPasswordUtils extends _i1.Mock implements _i8.PasswordUtils {
MockPasswordUtils() {
_i1.throwOnMissingStub(this);
}
@override
String create() => (super.noSuchMethod(
Invocation.method(
#create,
[],
),
returnValue: _i5.dummyValue<String>(
this,
Invocation.method(
#create,
[],
),
),
) as String);
}
/// A class which mocks [SnackbarUtils].
///
/// See the documentation for Mockito's code generation for more information.
class MockSnackbarUtils extends _i1.Mock implements _i9.SnackbarUtils {
MockSnackbarUtils() {
_i1.throwOnMissingStub(this);
}
@override
void showSnackbar(
_i2.BuildContext? context,
String? msg,
bool? warning,
) =>
super.noSuchMethod(
Invocation.method(
#showSnackbar,
[
context,
msg,
warning,
],
),
returnValueForMissingStub: null,
);
@override
void showSnackbarPopup(
_i2.BuildContext? context,
String? msg,
bool? warning,
) =>
super.noSuchMethod(
Invocation.method(
#showSnackbarPopup,
[
context,
msg,
warning,
],
),
returnValueForMissingStub: null,
);
}
/// A class which mocks [JwtTokenStorage].
///
/// See the documentation for Mockito's code generation for more information.
class MockJwtTokenStorage extends _i1.Mock implements _i10.JwtTokenStorage {
MockJwtTokenStorage() {
_i1.throwOnMissingStub(this);
}
@override
_i11.Future<void> saveTokens(
String? accessToken,
String? refreshToken,
) =>
(super.noSuchMethod(
Invocation.method(
#saveTokens,
[
accessToken,
refreshToken,
],
),
returnValue: _i11.Future<void>.value(),
returnValueForMissingStub: _i11.Future<void>.value(),
) as _i11.Future<void>);
@override
_i11.Future<String?> getAccessToken() => (super.noSuchMethod(
Invocation.method(
#getAccessToken,
[],
),
returnValue: _i11.Future<String?>.value(),
) as _i11.Future<String?>);
@override
_i11.Future<String?> getRefreshToken() => (super.noSuchMethod(
Invocation.method(
#getRefreshToken,
[],
),
returnValue: _i11.Future<String?>.value(),
) as _i11.Future<String?>);
@override
_i11.Future<void> clearTokens() => (super.noSuchMethod(
Invocation.method(
#clearTokens,
[],
),
returnValue: _i11.Future<void>.value(),
returnValueForMissingStub: _i11.Future<void>.value(),
) as _i11.Future<void>);
@override
_i11.Future<bool> hasTokens() => (super.noSuchMethod(
Invocation.method(
#hasTokens,
[],
),
returnValue: _i11.Future<bool>.value(false),
) as _i11.Future<bool>);
@override
_i11.Future<void> updateAccessToken(String? accessToken) =>
(super.noSuchMethod(
Invocation.method(
#updateAccessToken,
[accessToken],
),
returnValue: _i11.Future<void>.value(),
returnValueForMissingStub: _i11.Future<void>.value(),
) as _i11.Future<void>);
}
/// A class which mocks [Client].
///
/// See the documentation for Mockito's code generation for more information.
class MockClient extends _i1.Mock implements _i3.Client {
MockClient() {
_i1.throwOnMissingStub(this);
}
@override
_i11.Future<_i3.Response> head(
Uri? url, {
Map<String, String>? headers,
}) =>
(super.noSuchMethod(
Invocation.method(
#head,
[url],
{#headers: headers},
),
returnValue: _i11.Future<_i3.Response>.value(_FakeResponse_1(
this,
Invocation.method(
#head,
[url],
{#headers: headers},
),
)),
) as _i11.Future<_i3.Response>);
@override
_i11.Future<_i3.Response> get(
Uri? url, {
Map<String, String>? headers,
}) =>
(super.noSuchMethod(
Invocation.method(
#get,
[url],
{#headers: headers},
),
returnValue: _i11.Future<_i3.Response>.value(_FakeResponse_1(
this,
Invocation.method(
#get,
[url],
{#headers: headers},
),
)),
) as _i11.Future<_i3.Response>);
@override
_i11.Future<_i3.Response> post(
Uri? url, {
Map<String, String>? headers,
Object? body,
_i12.Encoding? encoding,
}) =>
(super.noSuchMethod(
Invocation.method(
#post,
[url],
{
#headers: headers,
#body: body,
#encoding: encoding,
},
),
returnValue: _i11.Future<_i3.Response>.value(_FakeResponse_1(
this,
Invocation.method(
#post,
[url],
{
#headers: headers,
#body: body,
#encoding: encoding,
},
),
)),
) as _i11.Future<_i3.Response>);
@override
_i11.Future<_i3.Response> put(
Uri? url, {
Map<String, String>? headers,
Object? body,
_i12.Encoding? encoding,
}) =>
(super.noSuchMethod(
Invocation.method(
#put,
[url],
{
#headers: headers,
#body: body,
#encoding: encoding,
},
),
returnValue: _i11.Future<_i3.Response>.value(_FakeResponse_1(
this,
Invocation.method(
#put,
[url],
{
#headers: headers,
#body: body,
#encoding: encoding,
},
),
)),
) as _i11.Future<_i3.Response>);
@override
_i11.Future<_i3.Response> patch(
Uri? url, {
Map<String, String>? headers,
Object? body,
_i12.Encoding? encoding,
}) =>
(super.noSuchMethod(
Invocation.method(
#patch,
[url],
{
#headers: headers,
#body: body,
#encoding: encoding,
},
),
returnValue: _i11.Future<_i3.Response>.value(_FakeResponse_1(
this,
Invocation.method(
#patch,
[url],
{
#headers: headers,
#body: body,
#encoding: encoding,
},
),
)),
) as _i11.Future<_i3.Response>);
@override
_i11.Future<_i3.Response> delete(
Uri? url, {
Map<String, String>? headers,
Object? body,
_i12.Encoding? encoding,
}) =>
(super.noSuchMethod(
Invocation.method(
#delete,
[url],
{
#headers: headers,
#body: body,
#encoding: encoding,
},
),
returnValue: _i11.Future<_i3.Response>.value(_FakeResponse_1(
this,
Invocation.method(
#delete,
[url],
{
#headers: headers,
#body: body,
#encoding: encoding,
},
),
)),
) as _i11.Future<_i3.Response>);
@override
_i11.Future<String> read(
Uri? url, {
Map<String, String>? headers,
}) =>
(super.noSuchMethod(
Invocation.method(
#read,
[url],
{#headers: headers},
),
returnValue: _i11.Future<String>.value(_i5.dummyValue<String>(
this,
Invocation.method(
#read,
[url],
{#headers: headers},
),
)),
) as _i11.Future<String>);
@override
_i11.Future<_i13.Uint8List> readBytes(
Uri? url, {
Map<String, String>? headers,
}) =>
(super.noSuchMethod(
Invocation.method(
#readBytes,
[url],
{#headers: headers},
),
returnValue: _i11.Future<_i13.Uint8List>.value(_i13.Uint8List(0)),
) as _i11.Future<_i13.Uint8List>);
@override
_i11.Future<_i3.StreamedResponse> send(_i3.BaseRequest? request) =>
(super.noSuchMethod(
Invocation.method(
#send,
[request],
),
returnValue:
_i11.Future<_i3.StreamedResponse>.value(_FakeStreamedResponse_2(
this,
Invocation.method(
#send,
[request],
),
)),
) as _i11.Future<_i3.StreamedResponse>);
@override
void close() => super.noSuchMethod(
Invocation.method(
#close,
[],
),
returnValueForMissingStub: null,
);
}