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

Bug-Fix SignUp #2477

Merged
merged 4 commits into from
Apr 16, 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
4 changes: 3 additions & 1 deletion lib/utils/queries.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Queries {
/// * `lastName`: user's data.
/// * `email`: user's data.
/// * `password`: user's data.
/// * `selectedOrganization`: ID of the selected organization.
///
/// **returns**:
/// * `String`: Return the mutation in string type to be passed to graphql client.
Expand All @@ -18,10 +19,11 @@ class Queries {
String lastName,
String email,
String password,
String? selectedOrganization,
) {
return """
mutation{
signUp(data: {firstName: "$firstName", lastName: "$lastName", email: "$email", password: "$password"})
signUp(data: {firstName: "$firstName", lastName: "$lastName", email: "$email", password: "$password", selectedOrganization: "$selectedOrganization"})
{
appUserProfile{
adminFor{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class SignupDetailsViewModel extends BaseModel {
Encryptor.encryptString(
password.text,
),
selectedOrganization.id,
),
);
navigationService.pop();
Expand Down
9 changes: 7 additions & 2 deletions test/utils_tests/queries_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ void main() {
var mutation = false;
expect(mutation, false);

final fnData = Queries()
.registerUser('Ayush', 'Chaudhary', '[email protected]', 'password');
final fnData = Queries().registerUser(
'Ayush',
'Chaudhary',
'[email protected]',
'password',
'orgId123',
);
if (fnData.contains('Ayush')) {
mutation = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SignUpMock extends StatelessWidget {
}

OrgInfo get org => OrgInfo(
id: '3',
id: '',
name: 'test org 3',
userRegistrationRequired: userRegistrationRequired,
creatorInfo: User(firstName: 'test', lastName: '1'),
Expand Down Expand Up @@ -84,13 +84,13 @@ void main() {
source: QueryResultSource.network,
data: data,
options: QueryOptions(
document: gql(queries.registerUser('', '', '', '')),
document: gql(queries.registerUser('', '', '', '', '')),
),
);
when(graphqlConfig.getToken()).thenAnswer((_) async => true);
when(
databaseFunctions.gqlNonAuthMutation(
queries.registerUser('', '', '', ''),
queries.registerUser('', '', '', '', ''),
),
).thenAnswer((_) async => result);
when(databaseFunctions.gqlAuthMutation(queries.joinOrgById(org.id!)))
Expand All @@ -116,7 +116,7 @@ void main() {
verify(databaseFunctions.gqlAuthMutation(queries.joinOrgById(org.id!)));
verify(
databaseFunctions.gqlNonAuthMutation(
queries.registerUser('', '', '', ''),
queries.registerUser('', '', '', '', ''),
),
);
verify(
Expand All @@ -143,12 +143,12 @@ void main() {
locator.registerSingleton<UserConfig>(MockUserConfig());

final model = SignupDetailsViewModel();

model.selectedOrganization = OrgInfo(id: "");
await tester.pumpWidget(SignUpMock(formKey: model.formKey));

when(
databaseFunctions.gqlNonAuthMutation(
queries.registerUser('', '', '', ''),
queries.registerUser('', '', '', '', ''),
),
).thenAnswer((_) async => null);

Expand Down Expand Up @@ -194,13 +194,13 @@ void main() {
source: QueryResultSource.network,
data: data,
options: QueryOptions(
document: gql(queries.registerUser('', '', '', '')),
document: gql(queries.registerUser('', '', '', '', '')),
),
);
when(graphqlConfig.getToken()).thenAnswer((_) async => false);
when(
databaseFunctions.gqlNonAuthMutation(
queries.registerUser('', '', '', ''),
queries.registerUser('', '', '', '', ''),
),
).thenAnswer((_) async => result);

Expand Down Expand Up @@ -301,13 +301,13 @@ void main() {
source: QueryResultSource.network,
data: data,
options: QueryOptions(
document: gql(queries.registerUser('', '', '', '')),
document: gql(queries.registerUser('', '', '', '', '')),
),
);
when(graphqlConfig.getToken()).thenAnswer((_) async => true);
when(
databaseFunctions.gqlNonAuthMutation(
queries.registerUser('', '', '', ''),
queries.registerUser('', '', '', '', ''),
),
).thenAnswer((_) async => result);
when(
Expand Down Expand Up @@ -340,7 +340,7 @@ void main() {
);
verify(
databaseFunctions.gqlNonAuthMutation(
queries.registerUser('', '', '', ''),
queries.registerUser('', '', '', '', ''),
),
);
verify(
Expand All @@ -364,7 +364,7 @@ void main() {
when(graphqlConfig.getToken()).thenAnswer((_) async => true);
when(
databaseFunctions.gqlNonAuthMutation(
queries.registerUser('', '', '', ''),
queries.registerUser('', '', '', '', ''),
),
).thenThrow(Exception());

Expand All @@ -374,7 +374,7 @@ void main() {

verify(
databaseFunctions.gqlNonAuthMutation(
queries.registerUser('', '', '', ''),
queries.registerUser('', '', '', '', ''),
),
);
verifyNever(
Expand Down Expand Up @@ -416,13 +416,15 @@ void main() {
source: QueryResultSource.network,
data: data,
options: QueryOptions(
document: gql(queries.registerUser('', '', '', '')),
document: gql(
queries.registerUser('', '', '', '', ''),
),
),
);
when(graphqlConfig.getToken()).thenAnswer((_) async => true);
when(
databaseFunctions.gqlNonAuthMutation(
queries.registerUser('', '', '', ''),
queries.registerUser('', '', '', '', ''),
),
).thenAnswer((_) async => result);
when(databaseFunctions.gqlAuthMutation(queries.joinOrgById(org.id!)))
Expand All @@ -435,7 +437,7 @@ void main() {
verify(databaseFunctions.gqlAuthMutation(queries.joinOrgById(org.id!)));
verify(
databaseFunctions.gqlNonAuthMutation(
queries.registerUser('', '', '', ''),
queries.registerUser('', '', '', '', ''),
),
);
verifyNever(
Expand Down Expand Up @@ -478,13 +480,15 @@ void main() {
source: QueryResultSource.network,
data: data,
options: QueryOptions(
document: gql(queries.registerUser('', '', '', '')),
document: gql(
queries.registerUser('', '', '', '', ''),
),
),
);
when(graphqlConfig.getToken()).thenAnswer((_) async => true);
when(
databaseFunctions.gqlNonAuthMutation(
queries.registerUser('', '', '', ''),
queries.registerUser('', '', '', '', ''),
),
).thenAnswer((_) async => result);
when(
Expand All @@ -503,7 +507,7 @@ void main() {
);
verify(
databaseFunctions.gqlNonAuthMutation(
queries.registerUser('', '', '', ''),
queries.registerUser('', '', '', '', ''),
),
);
verifyNever(
Expand Down
Loading