def test_get_all_feature_states_post_v2_versioning_migration(
    environment: Environment,
    feature: Feature,
    feature_state: FeatureState,
    segment: Segment,
    segment_featurestate: FeatureState,
    edge_identity_model: EdgeIdentity,
    mocker: MockerFixture,
    django_assert_num_queries: DjangoAssertNumQueries,
) -> None:
    """
    Specific test to reproduce an issue seen after migrating our staging environment to
    v2 versioning.
    """

    # Given
    # Multiple versions (old style versioning) of a given environment feature state and segment override
    # to simulate the fact that we will be left with feature states that do NOT have a feature version
    # (because only the latest versions get migrated to v2 versioning).
    feature_state.clone(env=environment, live_from=timezone.now(), version=2)
    v2_segment_override = segment_featurestate.clone(
        env=environment, live_from=timezone.now(), version=2
    )

    enable_v2_versioning(environment.id)

    edge_identity_dynamo_wrapper_mock = mocker.patch(
        "edge_api.identities.models.EdgeIdentity.dynamo_wrapper",
    )
    edge_identity_dynamo_wrapper_mock.get_segment_ids.return_value = [segment.id]

    # When
    with django_assert_num_queries(4):
        feature_states, identity_override_feature_names = (
            edge_identity_model.get_all_feature_states()
        )

    # Then
    assert len(feature_states) == 1
    assert feature_states[0] == v2_segment_override

    Specific test to reproduce an issue seen after migrating our staging environment to
    v2 versioning.
    
api/tests/unit/edge_api/identities/test_edge_identity_models.py