package test

import (
	"testing"

	"github.com/pingcap/dbaas/billing2/utils/tests"
	"github.com/stretchr/testify/suite"
)

type NovuSuite struct {
	tests.BillingTestSuite
}

func TestNovuSuite(t *testing.T) {

	suite.Run(t, new(NovuSuite))
}

//func (suite *NovuSuite) TestSubscribersGetNotification() {
//	assert := suite.Assert()
//	var resp novuhandler.Sub
//	path := fmt.Sprintf("/v1/subscribers/%s/notifications/feed", "120040_130494")
//	err := novuhandler.GetClient().Get(path, nil, &resp)
//	assert.Nil(err, resp)
//}

//func (suite *NovuSuite) TestGetSubscribers() {
//	assert := suite.Assert()
//	var resp novuhandler.SubscriberList
//
//	input := map[string]string{"page": "0", "limit": "100"}
//
//	err := novuhandler.GetClient().Get("/v1/subscribers", input, &resp)
//	assert.Nil(err, resp)
//}

//func (suite *NovuSuite) TestGetSubscriber() {
//
//	_, exist := novuhandler.Get().GetSubscriber("120040:13049")
//	if !exist {
//		fmt.Println("2222")
//
//	}
//}

//
//func (suite *NovuSuite) TestDeleteSubscriber() {
//	res := Res{}
//	config.Get().Set(config.NovuAPIHost, "api-novu.dev.tidbcloud.com")
//	config.Get().Set(config.NovuAPIKey, "7c17e9230579c1ae62824cffa9182f09")
//	err := novuhandler.GetClient().Request("DELETE", "/v1/subscribers/120040:130494-1", nil, nil, &res)
//	if err != nil {
//		fmt.Println(err)
//	}
//}

//func (suite *NovuSuite) TestCreateSubscribers() {
//	assert := suite.Assert()
//
//	id := "unittest_" + uuid.NewString()
//	result, checkResult := novuhandler.Get().GetSubscriber(id)
//	assert.False(checkResult, result)
//
//	inputs := []map[string]string{{novuhandler.CreateSubscriberSubscriberId: id}}
//
//	err := novuhandler.Get().CreateSubscribers(inputs)
//	assert.Nil(err)
//
//	result, checkResult = novuhandler.Get().GetSubscriber(id)
//	assert.False(checkResult, result)
//}

//	func (suite *NovuSuite) TestCQuerySubscribersAndTriggerEvent() {
//		assert := suite.Assert()
//
//		id := "utest_" + strconv.FormatInt(timeutils.GetNow().Unix(), 10)
//		result, checkResult := novuhandler.Get().GetSubscriber(id)
//		assert.False(checkResult, result)
//
//		input := []map[string]string{{novuhandler.CreateSubscriberSubscriberId: id}}
//
//		err := novuhandler.Get().CreateSubscribers(input)
//		assert.Nil(err)
//
//		result, checkResult = novuhandler.Get().GetSubscriber(id)
//		assert.False(checkResult, result)
//
//		var outPut = novuhandler.EventResponse{}
//		var inPut = novuhandler.EventRequest{}
//		inPut.Events = append(inPut.Events, novuhandler.Event{
//			Name: "test-wangxiaowu-11111-222222-XjTwbfbPv",
//			To: novuhandler.EventTo{
//				SubscriberId: id,
//			},
//			Payload: map[string]interface{}{"param": "ssss", "__source": "test-workflow"},
//		})
//
//		err = novuhandler.GetClient().Request("POST", "/v1/events/trigger/bulk", nil, inPut, &outPut)
//		//pp.Print(outPut)
//		assert.Nil(err, outPut)
//		time.Sleep(10 * time.Second)
//		var resp novuhandler.Sub
//		path := fmt.Sprintf("/v1/subscribers/%s/notifications/feed", id)
//		//api.novu.co/v1/subscribers/{subscriberId}/notifications/feed
//		err = novuhandler.GetClient().Get(path, nil, &resp)
//		assert.Nil(err, resp)
////	}
//func (suite *NovuSuite) TestGetEnv() {
//	assert := suite.Assert()
//	var resp novuhandler.Env
//
//	err := novuhandler.GetClient().Get("/v1/environments", nil, &resp)
//	assert.Nil(err, resp)
//
//}
//
//type Group struct {
//	Data struct {
//		Id             string `json:"_id"`
//		Name           string `json:"name"`
//		EnvironmentId  string `json:"_environmentId"`
//		OrganizationId string `json:"_organizationId"`
//		ParentId       string `json:"_parentId"`
//	} `json:"data"`
//}
//type GroupInput struct {
//	Name string `json:"name"`
//}
//
//type GroupOutPut struct {
//	Data []struct {
//		Id             string `json:"_id"`
//		Name           string `json:"name"`
//		EnvironmentId  string `json:"_environmentId"`
//		OrganizationId string `json:"_organizationId"`
//		ParentId       string `json:"_parentId"`
//	} `json:"data"`
//}
//
//func (suite *NovuSuite) TestCreateWorkflowGroup() {
//	assert := suite.Assert()
//
//	//groupNameList := []string{"informational", "actionable", "alert",
//	//	"feedback", "personalized", "promotional", "billing"}
//	//
//	//for _, groupName := range groupNameList {
//	//
//	//	var resp GroupInput
//	//	input := GroupInput{Name: groupName}
//	//
//	//	err := novuhandler.GetClient().Request("POST", "/v1/notification-groups", nil, input, &resp)
//	//	assert.Nil(err, resp)
//	//}
//	id, err := novuhandler.Get().GetNotificationGroupIDByName("alert")
//	assert.Nil(err, id)
//	name, err := novuhandler.Get().GetNotificationGroupNameByID(id)
//	assert.Nil(err, id)
//	assert.Equal("alert", name)
//
//}

//
//func (suite *NovuSuite) TestGetInAppNotifications() {
//	res, _ := novuhandler.Get().GetSubscriberInAppNotifications(forms.NotificationRequest{
//		TenantID: 1369847559691517271,
//		UserID:   1560754,
//		Page:     0,
//		PageSize: 10,
//	})
//	pp.Print(res)
//	res1, _ := novuhandler.Get().GetSubscriberInAppNotificationByID(forms.NotificationRequest{
//		TenantID:       1369847559691517271,
//		UserID:         1560754,
//		NotificationID: "6617a118885e9a67b708727d",
//	})
//	pp.Print(res1)
//
//}

//	func (suite *NovuSuite) TestCreateWorkflowGroup111() {
//		res, _ := novuhandler.Get().GetWorkflow("660591c3061c9af39e6e5650")
//		pp.Print(res)
//
// }
//type TestGetCounts struct {
//	Data struct {
//		Count int `json:"count"`
//	} `json:"data"`
//}
//
//func (suite *NovuSuite) TestGetCounts() {
//	assert := suite.Assert()
//
//	//https://api.novu.co/v1/subscribers/{subscriberId}/notifications/unseen
//	res, err := novuhandler.Get().GetNotificationsCount("120040_130494", "")
//	pp.Print(res)
//	assert.Nil(err, res)
//
//}

//func (suite *NovuSuite) TestDeleteSubscriber() {
//	assert := suite.Assert()
//
//	//https://api.novu.co/v1/subscribers/{subscriberId}/notifications/unseen
//	res, err := novuhandler.Get().DeleteSubscriber("1111:11111111111111111111111111111111")
//	pp.Print(res)
//	assert.Nil(err, res)
//
//}
