def test_base_environment_integration_model_serializer_save_updates_existing_if_soft_deleted(  # type: ignore[no-untyped-def]  # noqa: E501
    environment,
):
    """
    To avoid creating a model only for testing, we use the WebhookConfigurationSerializer, which subclasses
    BaseEnvironmentIntegrationModelSerializer.
    """

    # Given
    old_url = "https://old.webhook.url/hook"
    new_url = "https://new.webhook.url/hook"

    serializer = WebhookConfigurationSerializer(data={"url": new_url})

    # create an existing webhookconfiguration object that has been soft deleted
    WebhookConfiguration.objects.create(
        environment=environment, url=old_url, deleted_at=timezone.now()
    )

    serializer.is_valid(raise_exception=True)

    # When
    serializer.save(environment=environment)

    # Then
    updated_webhook_config = WebhookConfiguration.objects.filter(
        environment=environment
    ).first()
    assert updated_webhook_config is not None
    assert updated_webhook_config.url == new_url
    assert updated_webhook_config.deleted_at is None

    To avoid creating a model only for testing, we use the WebhookConfigurationSerializer, which subclasses
    BaseEnvironmentIntegrationModelSerializer.
    
api/tests/unit/integrations/common/test_unit_integrations_common_serializers.py