From cb54c2c46efc6e04244b07fbba6974b0e59cb746 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 16 Jun 2026 17:52:17 +0200 Subject: [PATCH] test(member-live): build date-filter property bounds without a reject-filter The bound-pair generator filtered out ~1/4 of generated values, so unlucky seeds hit StreamData's FilterTooNarrowError under full property runs. Construct an at-least-one-bound-set pair directly instead, preserving the exact domain with no rejection. --- .../member_live/date_filter_property_test.exs | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/test/mv_web/live/member_live/date_filter_property_test.exs b/test/mv_web/live/member_live/date_filter_property_test.exs index fcce2a3..8844f91 100644 --- a/test/mv_web/live/member_live/date_filter_property_test.exs +++ b/test/mv_web/live/member_live/date_filter_property_test.exs @@ -20,11 +20,12 @@ defmodule MvWeb.MemberLive.Index.DateFilterPropertyTest do # Generators ----------------------------------------------------------- + defp date_gen do + map(integer(-3650..3650), &Date.add(~D[2000-01-01], &1)) + end + defp optional_date_gen do - one_of([ - constant(nil), - map(integer(-3650..3650), &Date.add(~D[2000-01-01], &1)) - ]) + one_of([constant(nil), date_gen()]) end defp exit_date_mode_gen do @@ -57,19 +58,25 @@ defmodule MvWeb.MemberLive.Index.DateFilterPropertyTest do # Property ------------------------------------------------------------- + # Generates a {from, to} pair with at least one bound set. Built by construction + # (pick which bounds are set, then generate the required dates) rather than by + # filtering out the both-nil case, so StreamData never rejects values and cannot + # raise FilterTooNarrowError on unlucky seeds. defp bound_pair_with_at_least_one_set_gen do gen all( - from <- optional_date_gen(), - to <- optional_date_gen(), - from != nil or to != nil + which <- member_of([:from_only, :to_only, :both]), + date_a <- date_gen(), + date_b <- date_gen() ) do - {from, to} + case which do + :from_only -> {date_a, nil} + :to_only -> {nil, date_a} + :both -> {date_a, date_b} + end end end - defp value_date_gen do - map(integer(-3650..3650), &Date.add(~D[2000-01-01], &1)) - end + defp value_date_gen, do: date_gen() # Property -------------------------------------------------------------