Skip to content

Commit

Permalink
tests: Fix flaky test
Browse files Browse the repository at this point in the history
Don't set a pk ^
  • Loading branch information
tonial committed Jul 11, 2024
1 parent 5db1395 commit 878b05b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tests/gps/__snapshots__/test_views.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
<div>


<a aria-label="Ne plus suivre Jane DOE" class="btn btn-warning btn-block w-100 w-md-auto btn-ico" data-bs-body="Vous pourrez toujours suivre ce bénéficiaire de nouveau plus tard." data-bs-confirm-class="btn-danger" data-bs-confirm-text="Ne plus suivre" data-bs-confirm-url="/gps/groups/34/leave" data-bs-target="#confirm_modal" data-bs-title="Êtes-vous sûr de ne plus vouloir suivre Jane DOE ?" data-bs-toggle="modal" href="/users/details/7614fc4b-aef9-4694-ab17-12324300180a">
<a aria-label="Ne plus suivre Jane DOE" class="btn btn-warning btn-block w-100 w-md-auto btn-ico" data-bs-body="Vous pourrez toujours suivre ce bénéficiaire de nouveau plus tard." data-bs-confirm-class="btn-danger" data-bs-confirm-text="Ne plus suivre" data-bs-confirm-url="/gps/groups/[PK of Group]/leave" data-bs-target="#confirm_modal" data-bs-title="Êtes-vous sûr de ne plus vouloir suivre Jane DOE ?" data-bs-toggle="modal" href="/users/details/7614fc4b-aef9-4694-ab17-12324300180a">
<i aria-hidden="true" class="ri-user-unfollow-line"></i>
<span>Ne plus suivre</span>

Expand All @@ -248,7 +248,7 @@



<a aria-label="Devenir référent de Jane DOE" class="btn btn-outline-success btn-block w-100 w-md-auto btn-ico" data-bs-body="Vous pourrez toujours ne plus être référent de ce bénéficiaire plus tard." data-bs-confirm-class="btn-success" data-bs-confirm-text="Devenir référent" data-bs-confirm-url="/gps/groups/34/toggle_referent" data-bs-target="#confirm_modal" data-bs-title="Êtes-vous sûr de vouloir devenir référent de Jane DOE ?" data-bs-toggle="modal" href="/users/details/7614fc4b-aef9-4694-ab17-12324300180a">
<a aria-label="Devenir référent de Jane DOE" class="btn btn-outline-success btn-block w-100 w-md-auto btn-ico" data-bs-body="Vous pourrez toujours ne plus être référent de ce bénéficiaire plus tard." data-bs-confirm-class="btn-success" data-bs-confirm-text="Devenir référent" data-bs-confirm-url="/gps/groups/[PK of Group]/toggle_referent" data-bs-target="#confirm_modal" data-bs-title="Êtes-vous sûr de vouloir devenir référent de Jane DOE ?" data-bs-toggle="modal" href="/users/details/7614fc4b-aef9-4694-ab17-12324300180a">

<i aria-hidden="true" class="ri-map-pin-user-line font-weight-normal me-1"></i>
<span>Devenir référent</span>
Expand Down
10 changes: 8 additions & 2 deletions tests/gps/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,17 @@ def test_my_groups(snapshot, client):

# Nominal case
# Groups created latelly should come first.
group = FollowUpGroupFactory(pk=34, memberships=1, for_snapshot=True)
group = FollowUpGroupFactory(memberships=1, for_snapshot=True)
FollowUpGroup.objects.follow_beneficiary(beneficiary=group.beneficiary, user=user)

response = client.get(reverse("gps:my_groups"))
groups = parse_response_to_soup(response, selector="#follow-up-groups-section").select(".membership-card")
groups = parse_response_to_soup(
response,
selector="#follow-up-groups-section",
replace_in_attr=[
("data-bs-confirm-url", f"/gps/groups/{group.pk}", "/gps/groups/[PK of Group]"),
],
).select(".membership-card")
assert len(groups) == 2
assert str(groups[0]) == snapshot(name="test_my_groups__group_card")

Expand Down

0 comments on commit 878b05b

Please sign in to comment.