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

refactor: repository for about us screen. #2472

Closed
NiranjanNlc opened this issue Jan 5, 2024 · 12 comments
Closed

refactor: repository for about us screen. #2472

NiranjanNlc opened this issue Jan 5, 2024 · 12 comments
Assignees
Labels

Comments

@NiranjanNlc
Copy link
Contributor

Summary:
Test class for AboutUsView modal test is not present .

Steps to reproduce:

  1. Open the project in androd studio .
  2. Navigate to test directory [unitTest]
  3. Open viewmodals

Expected behaviour:
AboutUSViewModal should be tested .

Observed behaviour:

Like any other viewmodal test , the viewmodal of AboutUs should also be present . AboutUs ViewModal is not decoupled enough such that it can be tested .

Device and Android version:
Andriod Studio HedgeHog

Screenshots:
image

@NiranjanNlc
Copy link
Contributor Author

I should be working on it .
Thanks

@PratyushSingh07
Copy link
Collaborator

hey @NiranjanNlc actually the entire unit test classes are obsolete and if you run them you would see all of them failing. This is because we have updated our viewmodels. I have already opened #2305 that covers all of the updated viewmodels and repositories. Also I had planned to write the remaining test cases once #2425 gets merged.
Now if you write unit test for the about us viewmodel then I think you wont be able to test it because you may have to change all of the other test classes as well.

@NiranjanNlc
Copy link
Contributor Author

Noted.
Will it be okay if refactor AboutUsViewModal such that it exist also in repostory level .
I found that context is being used in viewmodal scenario , which seems to violating MVVM architecture .

@PratyushSingh07
Copy link
Collaborator

I think the use of context in about us viewmodel is debatable as AboutUsViewModel is indirectly accessing the application context via a static method in the MifosSelfServiceApp class. I do agree that viewmodel shouldn't have any android framework dependencies but the current implementation in my opinion is a pragmatic approach.
Also I dont think we need to create a repository for this viewmodel since it isn't interacting with any data source. Now you may feel that the use of viewmodel in this case is a overkill , hence I would like you to redirect to #2257 wherein the purpose of viewmodel was discussed and justified by the mentor

@NiranjanNlc
Copy link
Contributor Author

Quoting the mentor in the link you mentioned

Maybe in the future, requirements changes and we want the list to be dynamic and managed by the backend. So it is always a good practice to take scalability and consistency in mind. And also helps to follow the Unidirectional Data Flow architecture in your compose implementation. I hope it makes sense to you.

I think we need to create the repository , so that we can use context over there to get aboutus item and which also ensure viewmodal do not have any android framework dependencies .

What your say @PratyushSingh07

@PratyushSingh07
Copy link
Collaborator

Then Why not use the context from the fragment

@NiranjanNlc
Copy link
Contributor Author

Then Why not use the context from the fragment

Using context in the fragment only to retrieve whole lot of aboutusItems make no use of viewmodal
I think if we are using viewmodal then we can extend it till the repository too so that it will be more scaleable and manageable in near future

@NiranjanNlc
Copy link
Contributor Author

hey @PratyushSingh07 ,
shall we close ths issuse or we can wok on it by renaming the issuse title ?
what your say ?

@PratyushSingh07
Copy link
Collaborator

Rename and then you can work on it.

@NiranjanNlc NiranjanNlc changed the title Missing Test Class for AboutUsViewModel refactor AboutUsViewModel upto repository level to add test Jan 8, 2024
@PratyushSingh07
Copy link
Collaborator

Change the title to refactor: repository for about us screen.

Also what do you mean by adding tests? I did say that you may have to change all of the test files, right? Are you sure that writing tests for about us repository and it's viewmodels won't force you to change other test files as well (reason that we discussed above) ?

@NiranjanNlc NiranjanNlc changed the title refactor AboutUsViewModel upto repository level to add test refactor: repository for about us screen. Jan 8, 2024
@NiranjanNlc
Copy link
Contributor Author

done @PratyushSingh07

@PratyushSingh07
Copy link
Collaborator

The PR linked to this issue was closed hence I will be closing this issue

@PratyushSingh07 PratyushSingh07 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants