Skip to content

Commit

Permalink
Fixes #1618 Bug: Non Removable Activity Loader (#1628)
Browse files Browse the repository at this point in the history
* Fixes #1618 Bug: Non Removable Activity Loader

* removed linting errors
  • Loading branch information
Ayush0Chaudhary authored Mar 7, 2023
1 parent c36752e commit 6211a88
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class SetUrlViewModel extends BaseModel {
} else {
// navigationService
// .showSnackBar("URL doesn't exist/no connection please check");

navigationService.pop();
navigationService.showTalawaErrorSnackBar(
"URL doesn't exist/no connection please check",
MessageType.error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:hive/hive.dart';
import 'package:mockito/mockito.dart';
import 'package:qr_code_scanner/qr_code_scanner.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:talawa/constants/custom_theme.dart';
import 'package:talawa/enums/enums.dart';
import 'package:talawa/locator.dart';
import 'package:talawa/router.dart';
import 'package:talawa/services/navigation_service.dart';
import 'package:talawa/services/size_config.dart';
import 'package:talawa/utils/app_localization.dart';
import 'package:talawa/utils/validators.dart';
import 'package:talawa/view_model/lang_view_model.dart';
import 'package:talawa/view_model/pre_auth_view_models/set_url_view_model.dart';
import 'package:talawa/views/base_view.dart';
import 'package:talawa/widgets/custom_progress_dialog.dart';

import '../../helpers/test_helpers.dart';
Expand All @@ -31,6 +38,47 @@ class TestWidget extends StatelessWidget {
}
}

class SetUrlMock extends StatelessWidget {
const SetUrlMock({required this.formKey, Key? key}) : super(key: key);

final GlobalKey<FormState> formKey;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Form(
key: formKey,
child: Container(),
),
navigatorKey: navigationService.navigatorKey,
);
}
}

Widget forTest({ThemeMode themeMode = ThemeMode.dark}) => BaseView<AppLanguage>(
onModelReady: (model) => model.initialize(),
builder: (context, model, child) {
final model1 = SetUrlViewModel();
return MaterialApp(
locale: const Locale('en'),
localizationsDelegates: [
const AppLocalizationsDelegate(isTest: true),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
key: const Key('Root'),
themeMode: themeMode,
theme: TalawaTheme.darkTheme,
home: FloatingActionButton(
onPressed: () async {
await model1.initialise();
},
),
navigatorKey: locator<NavigationService>().navigatorKey,
onGenerateRoute: generateRoute,
);
},
);

Future<void> main() async {
SizeConfig().test();

Expand Down Expand Up @@ -80,6 +128,21 @@ Future<void> main() async {
File('test/fixtures/core/url.hive').delete();
File('test/fixtures/core/url.lock').delete();
});
testWidgets('Check if initialize is working fine ', (tester) async {
final model = SetUrlViewModel();

await tester.pumpWidget(SetUrlMock(formKey: model.formKey));

model.initialise();
});
testWidgets('Check if initialize is working fine when we give url',
(tester) async {
final model = SetUrlViewModel();

await tester.pumpWidget(SetUrlMock(formKey: model.formKey));

model.initialise(inviteUrl: "http://www.youtube.com");
});

testWidgets(
'Check if checkURLandNavigate() is working fine when urlPresent is false',
Expand Down

0 comments on commit 6211a88

Please sign in to comment.