package e2e_test

import (
	"context"
	"fmt"
	"testing"

	"github.com/stretchr/testify/assert"
	"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models"
	"penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/client"
	"penahub.gitlab.yandexcloud.net/pena-services/customer/tests/helpers"
)

func TestGetRecentTariffs(t *testing.T) {
	jwtUtil := helpers.InitializeJWT()

	t.Run("Get Recent Tariffs", func(t *testing.T) {
		ctx, cancel := context.WithCancel(context.Background())
		defer cancel()

		userID := "64e5d9830fcca0596d82c0c7"

		token, tokenErr := jwtUtil.Create(userID)
		assert.NoError(t, tokenErr)

		responseGetRecentTariffs, errGetRecentTariffs := client.Get[[]models.TariffID, models.ResponseErrorHTTP](ctx, &client.RequestSettings{
			URL:     "http://localhost:8082/recent",
			Headers: map[string]string{"Authorization": fmt.Sprintf("Bearer %s", token)},
		})
		assert.NoError(t, errGetRecentTariffs)
		assert.Nil(t, responseGetRecentTariffs.Error)
		fmt.Println(responseGetRecentTariffs.Body)
		assert.NotNil(t, responseGetRecentTariffs.Body)
	})
}
