Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed registerForEvent mutation & update tests #2469

Merged
merged 1 commit into from
Apr 12, 2024
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
1 change: 0 additions & 1 deletion lib/services/event_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ class EventService {

final List eventsJson =
(result as QueryResult).data!["eventsByOrganizationConnection"] as List;
debugPrint('Events: $eventsJson');
eventsJson.forEach((eventJsonData) {
final Event event = Event.fromJson(eventJsonData as Map<String, dynamic>);
event.isRegistered = event.attendees?.any(
Expand Down
9 changes: 3 additions & 6 deletions lib/utils/event_queries.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,11 @@ class EventQueries {
String registerForEvent() {
return """
mutation registerForEvent(\$eventId: ID!) {
registerForEvent(id: \$eventId)
{
registerForEvent(id: \$eventId) {
_id
title
description
}
}
""";
}
""";
}

/// Creates a GraphQL mutation for deleting an event.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,20 @@ class EventInfoViewModel extends BaseModel {
await locator<EventService>().registerForAnEvent(event.id!);
if (registerResult != null) {
event.isRegistered = true;
final userConfig = locator<UserConfig>();
attendees.add(
Attendee(
id: UserConfig().currentUser.id,
firstName: UserConfig().currentUser.firstName,
lastName: UserConfig().currentUser.lastName,
image: UserConfig().currentUser.image,
id: userConfig.currentUser.id,
firstName: userConfig.currentUser.firstName,
lastName: userConfig.currentUser.lastName,
image: userConfig.currentUser.image,
),
);
}
print(registerResult);
fabTitle = getFabTitle();
navigationService.pop();
notifyListeners();
await locator<EventService>().getEvents();
}
}

Expand Down
3 changes: 0 additions & 3 deletions test/service_tests/event_service_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// ignore_for_file: talawa_api_doc

import 'package:flutter_test/flutter_test.dart';
import 'package:graphql_flutter/graphql_flutter.dart';
import 'package:mockito/mockito.dart';
Expand Down Expand Up @@ -91,7 +89,6 @@ void main() {
data: {
'register for an event': {
'_id': 'eventId',
'name': 'name',
},
},
source: QueryResultSource.network,
Expand Down
9 changes: 3 additions & 6 deletions test/utils/event_queries_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,11 @@ void main() {
test("Check if registerForEvent works correctly", () {
const data = """
mutation registerForEvent(\$eventId: ID!) {
registerForEvent(id: \$eventId)
{
registerForEvent(id: \$eventId) {
_id
title
description
}
}
""";
}
""";

final fnData = EventQueries().registerForEvent();
expect(fnData, data);
Expand Down
Loading