Skip to content

Conversation

@Rup-Narayan-Rajbanshi
Copy link
Contributor

@Rup-Narayan-Rajbanshi Rup-Narayan-Rajbanshi commented Sep 16, 2025

Changes

  • Add test for results
  • Add test for project: completeness
  • Update test for project
    • Create actual usergroup, organization and tutorial

Depends on

This PR doesn't introduce any:

  • temporary files, auto-generated files or secret keys
  • n+1 queries
  • flake8 issues
  • print
  • typos
  • unwanted comments

This PR contains valid:

  • tests
  • permission checks (tests here too)
  • translations

@Rup-Narayan-Rajbanshi Rup-Narayan-Rajbanshi changed the title chore(results): Add test for push result to firebase Add test for push result to firebase Sep 17, 2025
@codecov
Copy link

codecov bot commented Sep 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.24%. Comparing base (8d70f60) to head (8ff0643).
⚠️ Report is 9 commits behind head on develop.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #168      +/-   ##
===========================================
+ Coverage    80.48%   81.24%   +0.75%     
===========================================
  Files          196      196              
  Lines        10667    10747      +80     
  Branches       951      949       -2     
===========================================
+ Hits          8585     8731     +146     
+ Misses        1761     1683      -78     
- Partials       321      333      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Rup-Narayan-Rajbanshi Rup-Narayan-Rajbanshi force-pushed the feature/e2e-result-firebase branch 2 times, most recently from a634f80 to 6d8aaae Compare September 17, 2025 12:42
@Rup-Narayan-Rajbanshi Rup-Narayan-Rajbanshi marked this pull request as ready for review September 17, 2025 12:56
@Rup-Narayan-Rajbanshi Rup-Narayan-Rajbanshi changed the title Add test for push result to firebase E2E test for Results Sep 17, 2025
@Rup-Narayan-Rajbanshi Rup-Narayan-Rajbanshi force-pushed the feature/e2e-result-firebase branch 2 times, most recently from 8c0ae79 to 3ae7541 Compare September 18, 2025 12:57
)

# Test push tasks results to firebase
contributor_user_groups = ContributorUserGroupFactory.create_batch(2, **self.user_resource_kwargs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's create this from the assets as we already have the mutation for the contributor_user_groups.

  "create_contributor_user_group_data_list": [
      {
          "clientId": "01K49J0QPCZM2JCNC9AEE6HT8Y",,
          "name": "User Group 01",
          "description": "A user group for contributor user 01",
      },
      {
          "clientId": "01K49J0QPCZM2JCNC9AEE6HT8R",,
          "name": "User Group 01",
          "description": "A user group for contributor user 01",
      }
  ],

# Replace userGroups
group_value[new_key]["userGroups"] = user_groups_input

ref_results = Config.FIREBASE_HELPER.ref(Config.FirebaseKeys.results_projects())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ref_results = Config.FIREBASE_HELPER.ref(Config.FirebaseKeys.results_projects())
ref_results = Config.FIREBASE_HELPER.ref(f"/v2/results/{project_id}/")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@susilnem Why?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For e2e tests, you can directly specific the URLs
It helps to identify breaking changes.

"app_version": mapping_session.app_version,
"start_time": mapping_session.start_time.strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + "Z",
"end_time": mapping_session.end_time.strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + "Z",
"results_count": MappingSessionResult.objects.count(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add other checks too!

Suggested change
"results_count": MappingSessionResult.objects.count(),
"mapping_session_count": MappingSession.objects.count(),
"results_count": MappingSessionResult.objects.count(),
"user_groups_count": MappingSessionUserGroup.objects.count(),

MappingSessionResultTemp.objects.count(),
] != [0, 0, 0, 0, 0]

mapping_session = MappingSession.objects.first()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a todo we need to find another way to check this!


expected_pulled_results_data = test_data["expected_pulled_results_data"]
expected_pulled_results_data["project_firebase_id"] = next(iter(fb_results_data))
assert pull_firebase_data == expected_pulled_results_data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert pull_firebase_data == expected_pulled_results_data
assert pull_firebase_data == expected_pulled_results_data, "Difference found for pulled results data."


user_groups_input = {str(ug.firebase_id): True for ug in contributor_user_groups}

for group_key, group_value in input_data[project_fb_id].items(): # noqa: B007
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for group_key, group_value in input_data[project_fb_id].items(): # noqa: B007
for _, group_value in input_data[project_fb_id].items():

assert mapping_session.end_time is not None

pull_firebase_data = {
"project_firebase_id": mapping_session.project_task_group.project.firebase_id,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"project_firebase_id": mapping_session.project_task_group.project.firebase_id,

}

expected_pulled_results_data = test_data["expected_pulled_results_data"]
expected_pulled_results_data["project_firebase_id"] = next(iter(fb_results_data))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expected_pulled_results_data["project_firebase_id"] = next(iter(fb_results_data))

MappingSessionUserGroup.objects.count(),
MappingSessionUserGroupTemp.objects.count(),
MappingSessionResultTemp.objects.count(),
] == [0, 0, 0, 0, 0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
] == [0, 0, 0, 0, 0]
] == [0, 0, 0, 0, 0], "Mapping session data should be empty before pull from firebase"

MappingSessionUserGroup.objects.count(),
MappingSessionUserGroupTemp.objects.count(),
MappingSessionResultTemp.objects.count(),
] != [0, 0, 0, 0, 0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
] != [0, 0, 0, 0, 0]
] != [0, 0, 0, 0, 0], "Mapping session data should not be empty after pull from firebase"

@Rup-Narayan-Rajbanshi Rup-Narayan-Rajbanshi force-pushed the feature/e2e-result-firebase branch 8 times, most recently from cd05e8f to 36e4124 Compare September 19, 2025 11:29
@Rup-Narayan-Rajbanshi Rup-Narayan-Rajbanshi changed the title E2E test for Results E2E test for Tutorial, Results Sep 19, 2025
@Rup-Narayan-Rajbanshi Rup-Narayan-Rajbanshi changed the title E2E test for Tutorial, Results E2E BASE: Tutorial, Results Sep 19, 2025
)

# Test push tasks results to firebase
# Creating ContributorUserGroup: Without authentication
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this without authentication?

@tnagorra
Copy link
Collaborator

@Rup-Narayan-Rajbanshi Please add related PRs

@tnagorra tnagorra changed the title E2E BASE: Tutorial, Results E2E BASE: Results, Usergroups, Organizations, Tutorial ... Sep 25, 2025
@tnagorra tnagorra changed the title E2E BASE: Results, Usergroups, Organizations, Tutorial ... E2E BASE: Test for Results, Completeness Project and others Sep 25, 2025
@Rup-Narayan-Rajbanshi Rup-Narayan-Rajbanshi force-pushed the feature/e2e-result-firebase branch 3 times, most recently from f0adf69 to 14c3727 Compare September 25, 2025 12:07
@tnagorra tnagorra force-pushed the feature/e2e-result-firebase branch from 14c3727 to 8ff0643 Compare September 30, 2025 09:12
@tnagorra
Copy link
Collaborator

I have fixed the issues in this PR.

@tnagorra tnagorra merged commit 27d0c37 into develop Sep 30, 2025
6 checks passed
@tnagorra tnagorra deleted the feature/e2e-result-firebase branch September 30, 2025 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants