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

Views: Create tests for organization_feed.dart #1236

Open
palisadoes opened this issue Feb 28, 2022 · 20 comments · Fixed by #1478
Open

Views: Create tests for organization_feed.dart #1236

palisadoes opened this issue Feb 28, 2022 · 20 comments · Fixed by #1478
Labels
good first issue Good for newcomers no-issue-activity No issue activity test Testing application

Comments

@palisadoes
Copy link
Contributor

palisadoes commented Feb 28, 2022

The Talawa code base needs to be 100% reliable. This means we need to have 100% test code coverage.

Tests need to be written for file lib/views/after_auth_screens/feed/organization_feed.dart

  • When complete, all methods, classes and/or functions in the file will need to be tested.
  • These tests must be placed in a single file with the name test/views/after_auth_screens/feed/organization_feed_test.dart. You may need to create the appropriate directory structure to do this.

IMPORTANT:

Please refer to the parent issue on how to implement these tests correctly:

PR Acceptance Criteria

  • When complete this file must show 100% coverage when merged into the code base. This will be clearly visible when you submit your PR.
  • The current code coverage for the file can be found here. If the file isn't found in this directory, or there is a 404 error, then tests have not been created.
  • The PR will show a report for the code coverage for the file you have added. You can use that as a guide.
  • You can verify your own code coverage by creating an account at Codecov.io
  • No functionality must be removed to achieve this goal
@palisadoes palisadoes added the bug Something isn't working label Feb 28, 2022
@github-actions github-actions bot added parent The issue is generating more sub-issues test Testing application unapproved Unapproved, needs to be triaged labels Feb 28, 2022
@palisadoes palisadoes added points 01 good first issue Good for newcomers and removed bug Something isn't working parent The issue is generating more sub-issues labels Mar 1, 2022
@harshitraisahab
Copy link

i wolud like to solve this issue please assign to me

@palisadoes palisadoes removed the unapproved Unapproved, needs to be triaged label Dec 22, 2022
@noman2002 noman2002 added the unapproved Unapproved, needs to be triaged label Jan 31, 2023
@noman2002
Copy link
Member

Unassigned due to inactivity.

@Ayush0Chaudhary
Copy link
Contributor

@noman2002 @palisadoes @TheHazeEffect please assign this issue to me!

@palisadoes palisadoes removed the unapproved Unapproved, needs to be triaged label Feb 6, 2023
@Ayush0Chaudhary
Copy link
Contributor

I am facing a issue solving this issue.

void initialise() {
// For caching/initalizing the current organization after the stream subsciption has canceled and the stream is updated
_currentOrgName = _userConfig.currentOrg.name!;
// ------
// Attaching the stream subscription to rebuild the widgets automatically
_currentOrganizationStreamSubscription =
_userConfig.currentOrgInfoStream.listen(
(updatedOrganization) =>
setCurrentOrganizationName(updatedOrganization.name!),
);
_postsSubscription =
_postService.postStream.listen((newPosts) => buildNewPosts(newPosts));
_updatePostSubscription =
_postService.updatedPostStream.listen((post) => updatedPost(post));
}

the above code uses a stream and set value of _post variable

But all the test written return null, I was not able to find a test where actual post list was returned

@noman2002 @palisadoes can you help me with this

I have achieved 90% coverage but small part require the actual post to test

model.posts.isNotEmpty
? PostListWidget(
key: homeModel?.keySHPost,
posts: model.posts,
function: model.navigateToIndividualPage,

@Ayush0Chaudhary
Copy link
Contributor

testWidgets("Testing if tapping on calendar works", (tester) async {
await mockNetworkImages(() async {
locator.unregister<EventService>();
final StreamController<Event> _streamController = StreamController();
final Stream<Event> _stream =
_streamController.stream.asBroadcastStream();
final service = MockEventService();
when(service.eventStream).thenAnswer((invocation) => _stream);
locator.registerSingleton<EventService>(service);
final homeModel = locator<MainScreenViewModel>();
await tester.pumpWidget(createExploreEventsScreen(homeModel));
await tester.pumpAndSettle();
expect(
find.text("Looks like there aren't any events."), findsOneWidget);
});
});

one posiible solution is this but it return a null value

@palisadoes
Copy link
Contributor Author

@noman2002 @TheHazeEffect Do you have any thoughts on how to resolve this?

@Ayush0Chaudhary
Copy link
Contributor

IntelliJ Snippet

@palisadoes @noman2002 @TheHazeEffect I implemented this and 11 is getting printed but same thing is not happening in its viewmodel
Their is a problem with the scope of Mock
Can you help me with this??

@Ayush0Chaudhary
Copy link
Contributor

@literalEval can you suggest something??

@literalEval
Copy link
Member

@Ayush0Chaudhary I believe your reference of the view model is different then the one that the widget is using, I mean both are different instances.

I was having the same issue while writing tests for a widget and I worked it around by referencing the view model used by the widget directly.
Something like

late VM _vm;
....
....
BaseView<VM> (
  onModelReady: (model) {
    _vm = model;
  }
)

This way you can be sure that you are referencing the exact same view model.

@Ayush0Chaudhary
Copy link
Contributor

@literalEval You can try on this issue.

@literalEval
Copy link
Member

Sure. I will take this issue once I am done with the issues I am already assigned with.

palisadoes pushed a commit that referenced this issue Feb 13, 2023
* draft

* draft2

* draft

* draft

* draft 2

* Fixes #1236 Create tests for organization_feed.dart

* rmv unused imports

* testing issue

* Improve Coverage

* Update create_event_view_model.dart

* Update organization_feed_view_model.dart

* Update organization_feed_test.dart

* Update organization_feed_test.dart
@noman2002 noman2002 added the unapproved Unapproved, needs to be triaged label Feb 14, 2023
@Cioppolo14
Copy link
Contributor

This is reopened because test coverage for this file is not acceptable.

Copy link

github-actions bot commented Jan 5, 2024

This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.

@github-actions github-actions bot added the no-issue-activity No issue activity label Jan 5, 2024
@Cyclotron17
Copy link

Can you please assign this issue to me.

@Cioppolo14 Cioppolo14 removed no-issue-activity No issue activity unapproved Unapproved, needs to be triaged labels Jan 12, 2024
Copy link

This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.

@github-actions github-actions bot added the no-issue-activity No issue activity label Jan 23, 2024
@Cioppolo14
Copy link
Contributor

Unassigning due to inactivity.

@Cioppolo14 Cioppolo14 removed the no-issue-activity No issue activity label Jan 23, 2024
Copy link

github-actions bot commented Feb 3, 2024

This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.

@github-actions github-actions bot added the no-issue-activity No issue activity label Feb 3, 2024
@github-actions github-actions bot removed the no-issue-activity No issue activity label Feb 4, 2024
Copy link

This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.

@github-actions github-actions bot added the no-issue-activity No issue activity label Feb 15, 2024
Copy link

This issue did not get any activity in the past 180 days and thus has been closed. Please check if the newest release or develop branch has it fixed. Please, create a new issue if the issue is not fixed.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 13, 2024
@palisadoes palisadoes reopened this Aug 13, 2024
@github-actions github-actions bot removed the no-issue-activity No issue activity label Aug 14, 2024
Copy link

This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers no-issue-activity No issue activity test Testing application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants